aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp
diff options
context:
space:
mode:
authorGlenn Burkhardt <[email protected]>2023-06-04 15:50:56 -0400
committerGlenn Burkhardt <[email protected]>2023-06-04 15:50:56 -0400
commit25fd535a11803c74a4fb63c627bee6f771d83480 (patch)
treea7c7d988b2e5b737a3587363c28aa8575233a1dc /src/jogl/classes/com/jogamp
parent3e11b872b1c365b529132b86b0fc401ff595d5ea (diff)
Use DPI scaling to scale drawn fonts.
Diffstat (limited to 'src/jogl/classes/com/jogamp')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
index 0fc36a249..06671c0c7 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java
@@ -42,6 +42,8 @@ package com.jogamp.opengl.util.awt;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.util.InterruptSource;
import com.jogamp.common.util.PropertyAccess;
+import com.jogamp.nativewindow.NativeSurface;
+import com.jogamp.nativewindow.ScalableSurface;
import com.jogamp.opengl.util.*;
import com.jogamp.opengl.util.packrect.*;
import com.jogamp.opengl.util.texture.*;
@@ -291,7 +293,18 @@ public class TextRenderer {
public TextRenderer(final Font font, final boolean antialiased,
final boolean useFractionalMetrics, RenderDelegate renderDelegate,
final boolean mipmap) {
- this.font = font;
+
+ NativeSurface surface = GLContext.getCurrent().getGLDrawable().getNativeSurface();
+ if (surface instanceof ScalableSurface) {
+ // DPI scaling for surface
+ float[] surfaceScale = new float[2];
+ ((ScalableSurface) surface).getCurrentSurfaceScale(surfaceScale);
+ float newSize = font.getSize() * surfaceScale[0];
+ this.font = font.deriveFont(newSize);
+ } else {
+ this.font = font;
+ }
+
this.antialiased = antialiased;
this.useFractionalMetrics = useFractionalMetrics;
this.mipmap = mipmap;