aboutsummaryrefslogtreecommitdiffstats
path: root/src/demos/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/com')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
index 9a143a29d..2035c39cc 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
@@ -99,7 +99,8 @@ import com.jogamp.opengl.util.Animator;
public class FontView01 {
private static final float GlyphGridWidth = 3/4f; // FBO AA: 3/4f = 0.75f dropped fine grid lines @ 0.2f thickness; 0.70f OK
private static final float GlyphGridBorderThickness = 0.02f; // thickness 0.2f dropping
- private static final Vec4f GlyphGridBorderColor = new Vec4f(0.2f, 0.2f, 0.2f, 1);
+ private static final Vec4f GlyphGridBorderColorConvex = new Vec4f(0.2f, 0.2f, 0.7f, 1);
+ private static final Vec4f GlyphGridBorderColorComplex = new Vec4f(0.2f, 0.2f, 0.2f, 1);
// static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.MSAA_RENDERING_BIT, Region.DEFAULT_AA_QUALITY, 4);
// static CommandlineOptions options = new CommandlineOptions(1280, 720, Region.VBAA_RENDERING_BIT);
@@ -420,6 +421,7 @@ public class FontView01 {
}
printScreenOnGLThread(scene, window.getChosenGLCapabilities(), font, gridDim.contourChars.get(0));
// stay open ..
+ OutlineShape.printPerf(System.err);
}
static void printScreenOnGLThread(final Scene scene, final GLCapabilitiesImmutable caps, final Font font, final int codepoint) {
@@ -435,6 +437,7 @@ public class FontView01 {
final int rows;
final int rowsPerPage;
final int elemCount;
+ int convexGlyphCount;
int maxNameLen;
public GridDim(final Font font, final int columns, final int rowsPerPage, final int xReserved) {
@@ -453,11 +456,15 @@ public class FontView01 {
private int scanContourGlyphs(final Font font) {
final long t0 = Clock.currentNanos();
contourChars.clear();
+ convexGlyphCount = 0;
maxNameLen = 1;
final int[] max = { max_glyph_count };
font.forAllGlyphs((final Glyph fg) -> {
if( !fg.isNonContour() && max[0]-- > 0 ) {
contourChars.add( fg.getCodepoint() );
+ if( null != fg.getShape() && fg.getShape().isConvex() ) {
+ ++convexGlyphCount;
+ }
maxNameLen = Math.max(maxNameLen, fg.getName().length());
}
});
@@ -468,7 +475,7 @@ public class FontView01 {
return contourChars.size();
}
@Override
- public String toString() { return "GridDim[contours "+glyphCount+", "+columns+"x"+rows+"="+(columns*rows)+">="+elemCount+", rows/pg "+rowsPerPage+"]"; }
+ public String toString() { return "GridDim[contours "+glyphCount+", convex "+convexGlyphCount+" ("+((float)convexGlyphCount/(float)glyphCount)*100+"%), "+columns+"x"+rows+"="+(columns*rows)+">="+elemCount+", rows/pg "+rowsPerPage+"]"; }
}
static Group getGlyphShapeHolder(final Shape shape0) {
@@ -498,6 +505,7 @@ public class FontView01 {
for(int idx = 0; idx < gridDim.glyphCount; ++idx) {
final char codepoint = gridDim.contourChars.get(idx);
final Font.Glyph fg = font.getGlyph(codepoint);
+ final boolean isConvex = null != fg.getShape() ? fg.getShape().isConvex() : true;
final GlyphShape g = new GlyphShape(options.renderModes, fg, 0, 0);
g.setColor(0.1f, 0.1f, 0.1f, 1).setName("GlyphShape");
@@ -511,7 +519,8 @@ public class FontView01 {
final AABBox gbox = fg.getBounds(tmpBox); // g.getBounds(glp);
final boolean addUnderline = showUnderline && gbox.getMinY() < 0f;
final Group c1 = new Group( new BoxLayout( 1f, 1f, addUnderline ? Alignment.None : Alignment.Center) );
- c1.setBorder(GlyphGridBorderThickness).setBorderColor(GlyphGridBorderColor).setInteractive(true).setDragAndResizable(false).setName("GlyphHolder2");
+ c1.setBorder(GlyphGridBorderThickness).setBorderColor(isConvex ? GlyphGridBorderColorConvex : GlyphGridBorderColorComplex)
+ .setInteractive(true).setDragAndResizable(false).setName("GlyphHolder2");
if( addUnderline ) {
final Shape underline = new Rectangle(options.renderModes, 1f, gbox.getMinY(), 0.01f).setInteractive(false).setColor(0f, 0f, 1f, 0.25f);
c1.addShape(underline);
@@ -565,11 +574,12 @@ public class FontView01 {
static String getGlyphInfo(final Font.Glyph g) {
final OutlineShape os = g.getShape();
+ final boolean isConvex = null != os ? os.isConvex() : true;
final int osVertices = null != os ? os.getVertexCount() : 0;
final String name_s = null != g.getName() ? g.getName() : "";
final AABBox bounds = g.getBounds();
final String box_s = String.format("Box %+.3f/%+.3f%n %+.3f/%+.3f", bounds.getLow().x(), bounds.getLow().y(), bounds.getHigh().x(), bounds.getHigh().y());
- return String.format((Locale)null, "%s%nHeight: %1.3f%nLine Height: %1.3f%n%nSymbol: %04x, id %04x%nName: '%s'%nDim %1.3f x %1.3f%n%s%nAdvance %1.3f%nLS Bearings: %1.3f%nVertices: %03d",
+ return String.format((Locale)null, "%s%nHeight: %1.3f%nLine Height: %1.3f%n%nSymbol: %04x, id %04x%nName: '%s'%nDim %1.3f x %1.3f%n%s%nAdvance %1.3f%nLS Bearings: %1.3f%nVertices: %03d%n%s",
g.getFont().getFullFamilyName(),
g.getFont().getMetrics().getAscent() - g.getFont().getMetrics().getDescent(), // font hhea table
g.getFont().getLineHeight(), // font hhea table
@@ -577,6 +587,6 @@ public class FontView01 {
bounds.getWidth(), bounds.getHeight(), box_s,
g.getAdvanceWidth(),
g.getLeftSideBearings(),
- osVertices);
+ osVertices, isConvex?"Convex":"Non-Convex");
}
}