Skip to content

Commit

Permalink
Font: Graphics: Rework font sizing, and always smooth them.
Browse files Browse the repository at this point in the history
Thins makes fonts much more readable at lower screen resolutions.

Related to #59.
  • Loading branch information
AShiningRay committed Feb 20, 2025
1 parent f9a31a1 commit 46ac489
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/javax/microedition/lcdui/Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/org/recompile/mobile/PlatformGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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; }
Expand Down

0 comments on commit 46ac489

Please sign in to comment.