Revision: 2451
http://sourceforge.net/p/swingme/code/2451
Author: yuranet
Date: 2021-06-13 15:05:30 +0000 (Sun, 13 Jun 2021)
Log Message:
-----------
font more correct
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Font.java
Modified: iOSME/src/javax/microedition/lcdui/Font.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Font.java 2021-06-13 14:50:52 UTC (rev 2450)
+++ iOSME/src/javax/microedition/lcdui/Font.java 2021-06-13 15:05:30 UTC (rev 2451)
@@ -24,8 +24,7 @@
public static final int FONT_STATIC_TEXT = 0;
public static final int FONT_INPUT_TEXT = 1;
- private static final Font DEFAULT_FONT = new Font(Font.FACE_SYSTEM,
- Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
+ private static final Font DEFAULT_FONT = new Font(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
private static Font[] fontsBySpecifier = { DEFAULT_FONT, DEFAULT_FONT };
@@ -43,25 +42,58 @@
UIFont font;
- // NOTE: We support negative sizes, meaning literal font sizes.
+ /**
+ * NOTE: We support negative sizes, meaning literal font sizes.
+ */
private Font(int face, int style, int size) {
- if ((face != FACE_SYSTEM) && (face != FACE_MONOSPACE)
- && (face != FACE_PROPORTIONAL)) {
+ if ((face != FACE_SYSTEM) && (face != FACE_MONOSPACE) && (face != FACE_PROPORTIONAL)) {
throw new IllegalArgumentException();
}
- if (!(isPlain() || isBold() || isItalic() || isUnderlined())) {
- throw new IllegalArgumentException();
- }
if (size >= 0 && size != SIZE_SMALL && size != SIZE_MEDIUM && size != SIZE_LARGE) {
throw new IllegalArgumentException("size: "+size);
}
+ this.style = style;
+
+ if (!(isPlain() || isBold() || isItalic() || isUnderlined())) {
+ throw new IllegalArgumentException();
+ }
+
this.face = face;
- this.style = style;
this.size = size;
- // TODO get font based on other params too
- font = UIFont.systemFontOfSize(size);
+ double fontSize;
+ switch (size) {
+ case SIZE_SMALL:
+ fontSize = 12d;
+ break;
+ case SIZE_MEDIUM:
+ fontSize = 17d;
+ break;
+ case SIZE_LARGE:
+ fontSize = 22d;
+ break;
+ default:
+ fontSize = - size;
+ break;
+ }
+
+ double weight;
+ if (isBold()) {
+ weight = UIKit.UIFontWeightBold();
+ }
+ else {
+ weight = UIKit.UIFontWeightRegular();
+ }
+
+ if (face == FACE_MONOSPACE) {
+ font = UIFont.monospacedSystemFontOfSizeWeight(fontSize, weight);
+ }
+ else {
+ font = UIFont.systemFontOfSizeWeight(fontSize, weight);
+ }
+
+ // TODO add support for italic and underline
}
public static Font getDefaultFont() {
@@ -115,7 +147,7 @@
public int getHeight() {
if (height == -1) {
- return (int)font.xHeight();
+ return (int)font.lineHeight();
}
return height;
}
@@ -122,10 +154,8 @@
public int getBaselinePosition() {
if (baselinePosition == -1) {
- //baselinePosition = FontManager.getFont(this).getBaselinePosition();
- throw new RuntimeException("not implemented");
+ return - (int)font.ascender();
}
-
return baselinePosition;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|