aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-11-09 22:28:29 +0000
committerKenneth Russel <[email protected]>2007-11-09 22:28:29 +0000
commit2d62cbeca1e965654627b84c03e2422f31fa7c40 (patch)
tree30df6f4f1247ee69d6f70a44799eaef33be2f44d /src/classes
parentf80269640ee83e4207e38a30d6c93f7a4d93cffa (diff)
Fixed Issue 326: TextRenderer corruption with certain text
Fixed four issues: - Regression in new segmenting and punting code causing ArrayIndexOutOfBoundsException due to not resetting the glyph uploader during punt. - Issue in same code where length and total advance were not being reset properly. - Incorrect handling in glyph-by-glyph rendering when backing store was using NPOT texture and GL_ARB_texture_rectangle. - Failure to punt when glyph code was out of bounds. Checked in two regression tests for these issues. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1434 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes')
-rwxr-xr-xsrc/classes/com/sun/opengl/util/j2d/TextRenderer.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
index d11d928a9..dad518ea0 100755
--- a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
+++ b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
@@ -850,6 +850,10 @@ public class TextRenderer {
}
TextureRenderer renderer = getBackingStore();
+ // Handles case where NPOT texture is used for backing store
+ TextureCoords wholeImageTexCoords = renderer.getTexture().getImageTexCoords();
+ float xScale = wholeImageTexCoords.right();
+ float yScale = wholeImageTexCoords.bottom();
for (int i = 0; i < inGlyphs.length; i++) {
Rect rect = inGlyphs.textureSourceRect[i];
@@ -864,12 +868,12 @@ public class TextRenderer {
int width = rect.w();
int height = rect.h();
- float tx1 = (float) texturex / (float) renderer.getWidth();
- float ty1 = 1.0f -
- ((float) texturey / (float) renderer.getHeight());
- float tx2 = (float) (texturex + width) / (float) renderer.getWidth();
- float ty2 = 1.0f -
- ((float) (texturey + height) / (float) renderer.getHeight());
+ float tx1 = xScale * (float) texturex / (float) renderer.getWidth();
+ float ty1 = yScale * (1.0f -
+ ((float) texturey / (float) renderer.getHeight()));
+ float tx2 = xScale * (float) (texturex + width) / (float) renderer.getWidth();
+ float ty2 = yScale * (1.0f -
+ ((float) (texturey + height) / (float) renderer.getHeight()));
mPipelinedQuadRenderer.glTexCoord2f(tx1, ty1);
mPipelinedQuadRenderer.glVertex3f(x, y, z);
@@ -1571,6 +1575,11 @@ public class TextRenderer {
GlyphsList puntToRobust(CharSequence inString) {
glyphsOutput.nextState = DrawingState.robust;
glyphsOutput.remaining = inString;
+ // Reset the glyph uploader
+ glyphsToUpload.numberOfNewGlyphs = 0;
+ // Reset the glyph list
+ glyphsOutput.length = 0;
+ glyphsOutput.totalAdvance = 0;
return glyphsOutput;
}
@@ -1620,6 +1629,10 @@ public class TextRenderer {
GlyphVector gv = font.createGlyphVector(fontRenderContext,
singleUnicode); // need this to get single bitmaps
glyphID = gv.getGlyphCode(0);
+ // Have seen huge glyph codes (65536) coming out of some fonts in some Unicode situations
+ if (glyphID >= advances.length) {
+ return puntToRobust(inString);
+ }
advance = metrics.getAdvance();
advances[glyphID] = advance;