mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
deal with textAscent/Descent problems to fix text alignment
This commit is contained in:
@@ -265,6 +265,7 @@ public class PFont implements PConstants {
|
||||
descent = PApplet.round(lazyPaint.descent());
|
||||
}
|
||||
}
|
||||
PApplet.println("ascent/descent = " + ascent + " " + descent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2467,6 +2467,7 @@ public class PGraphics extends PImage implements PConstants {
|
||||
}
|
||||
*/
|
||||
textSize(which.size);
|
||||
PApplet.println("size should be " + which.size);
|
||||
|
||||
} else {
|
||||
throw new RuntimeException(ERROR_TEXTFONT_NULL_PFONT);
|
||||
@@ -2549,7 +2550,10 @@ public class PGraphics extends PImage implements PConstants {
|
||||
}
|
||||
|
||||
textSize = size;
|
||||
// PApplet.println("textSize textAscent -> " + textAscent());
|
||||
// PApplet.println("textSize textDescent -> " + textDescent());
|
||||
textLeading = (textAscent() + textDescent()) * 1.275f;
|
||||
// PApplet.println("textSize textLeading = " + textLeading);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1000,30 +1000,30 @@ public class PGraphicsAndroid2D extends PGraphics {
|
||||
//public void textAlign(int alignX, int alignY)
|
||||
|
||||
|
||||
public float textAscent() {
|
||||
if (textFont == null) {
|
||||
defaultFontOrDeath("textAscent");
|
||||
}
|
||||
// Font font = textFont.getFont();
|
||||
Typeface font = textFont.getTypeface();
|
||||
if (font == null) {
|
||||
return super.textAscent();
|
||||
}
|
||||
return fillPaint.ascent();
|
||||
}
|
||||
// public float textAscent() {
|
||||
// if (textFont == null) {
|
||||
// defaultFontOrDeath("textAscent");
|
||||
// }
|
||||
//// Font font = textFont.getFont();
|
||||
// Typeface font = textFont.getTypeface();
|
||||
// if (font == null) {
|
||||
// return super.textAscent();
|
||||
// }
|
||||
// return fillPaint.ascent();
|
||||
// }
|
||||
|
||||
|
||||
public float textDescent() {
|
||||
if (textFont == null) {
|
||||
defaultFontOrDeath("textDescent");
|
||||
}
|
||||
// Font font = textFont.getFont();
|
||||
Typeface font = textFont.getTypeface();
|
||||
if (font == null) {
|
||||
return super.textDescent();
|
||||
}
|
||||
return fillPaint.descent();
|
||||
}
|
||||
// public float textDescent() {
|
||||
// if (textFont == null) {
|
||||
// defaultFontOrDeath("textDescent");
|
||||
// }
|
||||
//// Font font = textFont.getFont();
|
||||
// Typeface font = textFont.getTypeface();
|
||||
// if (font == null) {
|
||||
// return super.textDescent();
|
||||
// }
|
||||
// return fillPaint.descent();
|
||||
// }
|
||||
|
||||
|
||||
public void textFont(PFont which) {
|
||||
@@ -1066,7 +1066,10 @@ public class PGraphicsAndroid2D extends PGraphics {
|
||||
// this has to happen second, because it calls textAscent()
|
||||
// (which requires the native font metrics to be set)
|
||||
textSize = size;
|
||||
// PApplet.println("P2D textSize textAscent -> " + textAscent());
|
||||
// PApplet.println("P2D textSize textDescent -> " + textDescent());
|
||||
textLeading = (textAscent() + textDescent()) * 1.275f;
|
||||
// PApplet.println("P2D textSize textLeading = " + textLeading);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+24
-15
@@ -18,9 +18,32 @@ o remove old AVDs because their APIs might be out of date
|
||||
o probably need to name AVDs based on their API spec
|
||||
o http://dev.processing.org/bugs/show_bug.cgi?id=1526
|
||||
o http://code.google.com/p/processing/issues/detail?id=249
|
||||
X text ascent/descent problem, text("blah\nblah") doesn't work properly
|
||||
X reverting to using the PGraphics version rather than P2D
|
||||
X because Paint.ascent() is returning negative values
|
||||
|
||||
P1 _ exceptions with StreamPump and adb devices on osx and linux
|
||||
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1545
|
||||
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1527
|
||||
P1 _ implement certificates (self-signed) for distribution
|
||||
P1 _ http://developer.android.com/guide/publishing/app-signing.html
|
||||
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1430
|
||||
P1 _ http://code.google.com/p/processing/issues/detail?id=222
|
||||
P1 _ properly handle setting whatever permissions are necessary
|
||||
|
||||
_ text leading is broken, text("blah\nblah") doesn't work properly
|
||||
P3 _ Errors show up that .java files are duplicates with the Android tools.
|
||||
P3 _ problem is with the packages and where the preproc is putting the file
|
||||
P3 _ example sketch added to bug report
|
||||
P3 _ http://dev.processing.org/bugs/show_bug.cgi?id=1472
|
||||
P3 _ http://code.google.com/p/processing/issues/detail?id=232
|
||||
|
||||
_ additional manifest gui necessary:
|
||||
_ icons are apparently important
|
||||
_ setting the default package
|
||||
_ some sort of warning re: messing with AndroidManifest.xml
|
||||
|
||||
_ also for the wiki:
|
||||
_ add information about permissions, since loadStrings() will break
|
||||
|
||||
_ don't let the keystore message show up in red
|
||||
_ Using keystore: /Users/fry/.android/debug.keystore
|
||||
@@ -198,15 +221,6 @@ _ signing tool
|
||||
_ selection of which avd (emulator), or plugged-in devices (if multiple)
|
||||
_ run the 'android' application (since finding its location is painful)
|
||||
|
||||
P1 _ exceptions with StreamPump and adb devices on osx and linux
|
||||
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1545
|
||||
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1527
|
||||
P1 _ implement certificates (self-signed) for distribution
|
||||
P1 _ http://developer.android.com/guide/publishing/app-signing.html
|
||||
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1430
|
||||
P1 _ http://code.google.com/p/processing/issues/detail?id=222
|
||||
P1 _ properly handle setting whatever permissions are necessary
|
||||
|
||||
P2 _ need to prevent hitting 'run' twice (threaded, so would work)
|
||||
P2 _ currently things just keep restarting the build, bad state
|
||||
P2 _ http://dev.processing.org/bugs/show_bug.cgi?id=1387
|
||||
@@ -237,11 +251,6 @@ P3 _ perhaps the first time an application is installed, remove it?
|
||||
P3 _ http://dev.processing.org/bugs/show_bug.cgi?id=1481
|
||||
P3 _ library support also needs android manifest changes
|
||||
P3 _ http://dev.processing.org/bugs/show_bug.cgi?id=1439
|
||||
P3 _ Errors show up that .java files are duplicates with the Android tools.
|
||||
P3 _ problem is with the packages and where the preproc is putting the file
|
||||
P3 _ example sketch added to bug report
|
||||
P3 _ http://dev.processing.org/bugs/show_bug.cgi?id=1472
|
||||
P3 _ http://code.google.com/p/processing/issues/detail?id=232
|
||||
|
||||
P4 _ don't require android tools to be installed already
|
||||
P4 _ or implement automatic download/install of android tools
|
||||
|
||||
Reference in New Issue
Block a user