diff options
author | Kenneth Russel <kbrussel@alum.mit.edu> | 2007-04-08 16:12:27 +0000 |
---|---|---|
committer | Kenneth Russel <kbrussel@alum.mit.edu> | 2007-04-08 16:12:27 +0000 |
commit | 61962236ac093574f267d55ea2a580861578a4b7 (patch) | |
tree | 533845b8c050735afb0842fac08afddad7d5371d /src/classes/com/sun/opengl/util | |
parent | d1c3191328fe9d1c15b1ac27cf0f0a05b176c300 (diff) |
More fully debugged tokenized rendering of strings and turned it on by
default. Can be disabled by specifying -Djogl.TextRenderer.nosplit.
Exposed getSpaceWidth() on request of emzic on javagaming.org forums.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1195 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/util')
-rwxr-xr-x | src/classes/com/sun/opengl/util/j2d/TextRenderer.java | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java index 468590b7d..ca4617abb 100755 --- a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java +++ b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java @@ -129,7 +129,7 @@ public class TextRenderer { // producing identical (or even vaguely similar) rendering results; // may ultimately yield more efficient use of the backing store, but // also seems to have performance issues due to rendering more quads - private boolean splitAtSpaces; + private boolean splitAtSpaces = !Debug.isPropertyDefined("jogl.TextRenderer.nosplit"); private int spaceWidth = -1; private List/*<String>*/ tokenizationResults = new ArrayList/*<String>*/(); @@ -545,7 +545,7 @@ public class TextRenderer { data.markUsed(); // Align the leftmost point of the baseline to the (x, y, z) coordinate requested - renderer.draw3DRect(x - scaleFactor * (data.origin().x + xOffset), + renderer.draw3DRect(x + xOffset - scaleFactor * data.origin().x, y - scaleFactor * ((rect.h() - data.origin().y)), z, rect.x(), @@ -569,6 +569,23 @@ public class TextRenderer { endRendering(true); } + /** Returns the width of the ASCII space character, in pixels, drawn + in this TextRenderer's font when no scaling or rotation has been + applied. This is the horizontal advance of the space character. + + @return the width of the space character in the TextRenderer's font + */ + public int getSpaceWidth() { + if (spaceWidth < 0) { + Graphics2D g = getGraphics2D(); + FontRenderContext frc = getFontRenderContext(); + GlyphVector gv = font.createGlyphVector(frc, " "); + GlyphMetrics metrics = gv.getGlyphMetrics(0); + spaceWidth = (int) metrics.getAdvanceX(); + } + return spaceWidth; + } + /** Ends a 3D render cycle with this {@link TextRenderer TextRenderer}. Restores several OpenGL state bits. Should be paired with {@link #begin3DRendering begin3DRendering}. @@ -702,17 +719,6 @@ public class TextRenderer { } } - private int getSpaceWidth() { - if (spaceWidth < 0) { - Graphics2D g = getGraphics2D(); - FontRenderContext frc = getFontRenderContext(); - GlyphVector gv = font.createGlyphVector(frc, " "); - Rectangle2D bbox = gv.getLogicalBounds(); - spaceWidth = (int) bbox.getWidth(); - } - return spaceWidth; - } - private void tokenize(String str) { // Avoid lots of little allocations per render tokenizationResults.clear(); |