From 46ac4899e2321ebdd71f4da9f8204ccab6eaad41 Mon Sep 17 00:00:00 2001 From: AShiningRay Date: Thu, 20 Feb 2025 16:10:22 -0300 Subject: [PATCH] Font: Graphics: Rework font sizing, and always smooth them. Thins makes fonts much more readable at lower screen resolutions. Related to #59. --- src/javax/microedition/lcdui/Font.java | 8 ++++---- src/org/recompile/mobile/PlatformGraphics.java | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/javax/microedition/lcdui/Font.java b/src/javax/microedition/lcdui/Font.java index 1a9022a0..13f6639a 100644 --- a/src/javax/microedition/lcdui/Font.java +++ b/src/javax/microedition/lcdui/Font.java @@ -39,10 +39,10 @@ public final class Font private static final int[] fontSizes = { - 9, 10, 12, // < 128 minimum px dimension - 10, 12, 14, // < 176 minimum px dimension - 12, 14, 16, // < 220 minimum px dimension - 14, 16, 20, // >= 220 minimum px dimension + 10, 12, 14, // < 128 minimum px dimension + 12, 14, 15, // < 176 minimum px dimension + 14, 16, 18, // < 220 minimum px dimension + 16, 18, 20, // >= 220 minimum px dimension }; private static int screenType = -4; diff --git a/src/org/recompile/mobile/PlatformGraphics.java b/src/org/recompile/mobile/PlatformGraphics.java index 3517dbcd..e6d177ba 100644 --- a/src/org/recompile/mobile/PlatformGraphics.java +++ b/src/org/recompile/mobile/PlatformGraphics.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.awt.image.ConvolveOp; import java.awt.image.DataBufferInt; @@ -90,6 +91,7 @@ public PlatformGraphics(PlatformImage image) setStrokeStyle(SOLID); gc.setBackground(new Color(0, 0, 0, 0)); gc.setFont(font.platformFont.awtFont); + gc.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); } public void reset() //Internal use method, resets the Graphics object to its inital values @@ -406,7 +408,7 @@ public void drawString(String str, int x, int y, int anchor) int ascent = gc.getFontMetrics().getAscent(); int height = gc.getFontMetrics().getHeight(); - y += ascent; + y += ascent - 1; if((anchor & Graphics.VCENTER)>0) { y = y+height/2; } if((anchor & Graphics.BOTTOM)>0) { y = y-height; }