aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-05-15 17:48:15 +0200
committerSven Gothel <[email protected]>2012-05-15 17:48:15 +0200
commitab2eb9b73f7643fa579810abc5d2c422525b1362 (patch)
tree1b4cc013bed3f5a9b9c9c0d11fdb1588faf4f12b
parent1d58578ebc794f339a0a1a5e7fbc0fcbb704762c (diff)
graph/font: Add "public float getAdvanceWidth(int i, float pixelSize);"
Font::getAdvancedWidth(..) allows applications to query a glyphs width with a given pixel size, as it is being used for rendering.
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java1
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java5
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java2
3 files changed, 7 insertions, 1 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index c60d0cc2a..e2b3fe5d7 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -97,6 +97,7 @@ public interface Font {
public StringBuilder getAllNames(StringBuilder string, String separator);
+ public float getAdvanceWidth(int i, float pixelSize);
public Metrics getMetrics();
public Glyph getGlyph(char symbol);
public int getNumGlyphs();
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index 8806f537d..8e465de99 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -44,6 +44,7 @@ import com.jogamp.common.util.IntObjectHashMap;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
+import com.jogamp.graph.font.Font.Glyph;
import com.jogamp.graph.geom.AABBox;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Vertex.Factory;
@@ -162,6 +163,10 @@ class TypecastFont implements FontInt {
return sb;
}
+ public float getAdvanceWidth(int i, float pixelSize) {
+ return font.getHmtxTable().getAdvanceWidth(i) * metrics.getScale(pixelSize);
+ }
+
public Metrics getMetrics() {
if (metrics == null) {
metrics = new TypecastHMetrics(this);
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java
index 6baaf5afb..916c7b4d8 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java
@@ -77,7 +77,7 @@ public class TypecastRenderer {
advanceTotal = 0;
continue;
} else if (character == ' ') {
- advanceTotal += font.font.getHmtxTable().getAdvanceWidth(Glyph.ID_SPACE) * metrics.getScale(pixelSize);
+ advanceTotal += font.getAdvanceWidth(Glyph.ID_SPACE, pixelSize);
continue;
}
Glyph glyph = font.getGlyph(character);