Revision: 2464
http://sourceforge.net/p/swingme/code/2464
Author: yuranet
Date: 2021-06-22 19:44:48 +0000 (Tue, 22 Jun 2021)
Log Message:
-----------
font are right way round now
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Graphics.java
Modified: iOSME/src/javax/microedition/lcdui/Graphics.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-22 18:54:03 UTC (rev 2463)
+++ iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-22 19:44:48 UTC (rev 2464)
@@ -218,11 +218,12 @@
anchor = javax.microedition.lcdui.Graphics.TOP | javax.microedition.lcdui.Graphics.LEFT;
}
+ // https://www.cocoanetics.com/2010/02/understanding-uifont/
if ((anchor & javax.microedition.lcdui.Graphics.TOP) != 0) {
- newy -= 0;
+ newy += font.font.ascender(); // is positive
}
else if ((anchor & javax.microedition.lcdui.Graphics.BOTTOM) != 0) {
- newy -= font.getHeight();
+ newy += font.font.descender(); // is negative
}
if ((anchor & javax.microedition.lcdui.Graphics.HCENTER) != 0) {
@@ -242,6 +243,7 @@
//CoreFoundation.CFRelease(attributedStringRef);
//CoreFoundation.CFRelease(stringRef);
+ // this does not require pissing about with TextMatrix, maybe i should use this
//UIKit.UIGraphicsPushContext(context);
//NSString string = NSString.stringWithString(str);
//string.drawAtPointWithAttributes(new CGPoint(tx + newx, ty + newy), font.getAsNSDictionary());
@@ -255,9 +257,12 @@
NSAttributedString attributedString = NSAttributedString.alloc().initWithStringAttributes(str, attributes);
CTLineRef line = CoreText.CTLineCreateWithAttributedString(ObjCRuntime.cast(attributedString, CFAttributedStringRef.class));
+ // https://blog.spacemanlabs.com/2011/08/quick-tip-drawing-core-text-right-side-up/
+ CoreGraphics.CGContextSetTextMatrix(context, CoreGraphics.CGAffineTransformMakeScale(1.0f, -1.0f));
CoreGraphics.CGContextSetTextPosition(context, tx + newx, ty + newy);
CoreText.CTLineDraw(line, context);
+ CoreGraphics.CGContextSetTextMatrix(context, CoreGraphics.CGAffineTransformIdentity());
CoreFoundation.CFRelease(line);
//}
//else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|