aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/graph
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/jogamp/graph')
-rw-r--r--src/com/jogamp/graph/curve/text/HwTextRenderer.java29
-rw-r--r--src/com/jogamp/graph/font/Font.java44
-rw-r--r--src/com/jogamp/graph/font/FontFactory.java6
-rw-r--r--src/com/jogamp/graph/geom/AABBox.java7
4 files changed, 44 insertions, 42 deletions
diff --git a/src/com/jogamp/graph/curve/text/HwTextRenderer.java b/src/com/jogamp/graph/curve/text/HwTextRenderer.java
index b16d2e6fd..f30f42cc5 100644
--- a/src/com/jogamp/graph/curve/text/HwTextRenderer.java
+++ b/src/com/jogamp/graph/curve/text/HwTextRenderer.java
@@ -114,8 +114,8 @@ public class HwTextRenderer {
this.regionType = type;
}
- public Font createFont(Vertex.Factory<? extends Vertex> factory, String name, int size) {
- return fontFactory.createFont(factory, name, size);
+ public Font createFont(Vertex.Factory<? extends Vertex> factory, String name) {
+ return fontFactory.createFont(factory, name);
}
@@ -123,9 +123,8 @@ public class HwTextRenderer {
String[] families,
String style,
String variant,
- String weight,
- String size) {
- return fontFactory.createFont(factory, families, style, variant, weight, size);
+ String weight) {
+ return fontFactory.createFont(factory, families, style, variant, weight);
}
/**
@@ -312,11 +311,11 @@ public class HwTextRenderer {
return true;
}
- private GlyphString createString(GL2ES2 gl, Font font, String str) {
+ private GlyphString createString(GL2ES2 gl, Font font, int size, String str) {
AffineTransform affineTransform = new AffineTransform(pointFactory);
Path2D[] paths = new Path2D[str.length()];
- ((FontInt)font).getOutline(str, affineTransform, paths);
+ ((FontInt)font).getOutline(str, size, affineTransform, paths);
GlyphString glyphString = new GlyphString(pointFactory, font.getName(), str);
glyphString.createfromFontPath(paths, affineTransform);
@@ -337,25 +336,27 @@ public class HwTextRenderer {
* @param font font to be used
* @param str text to be rendered
* @param position the lower left corner of the string
- * @param size texture size for multipass render
+ * @param fontSize font size
+ * @param texSize texture size for multipass render
* @throws Exception if TextRenderer not initialized
*/
- public void renderString3D(GL2ES2 gl, Font font, String str, float[] position, int size) {
+ public void renderString3D(GL2ES2 gl, Font font, String str, float[] position, int fontSize, int texSize) {
if(!initialized){
throw new GLException("HWTextRenderer: not initialized!");
}
- String fontStrHash = getTextHashCode(font, str);
+ String fontStrHash = getTextHashCode(font, str, fontSize);
GlyphString glyphString = strings.get(fontStrHash);
if(null == glyphString) {
- glyphString = createString(gl, font, str);
+ glyphString = createString(gl, font, fontSize, str);
strings.put(fontStrHash, glyphString);
}
- glyphString.renderString3D(pmvMatrix, win_width, win_height, size);
+ glyphString.renderString3D(pmvMatrix, win_width, win_height, texSize);
}
- private String getTextHashCode(Font font, String str){
- return "" + str.hashCode() + font.getSize();
+ private String getTextHashCode(Font font, String str, int fontSize) {
+ // FIXME: use integer hash code
+ return font.getName() + "." + str.hashCode() + "." + fontSize;
}
/** Clears the cached string curves
diff --git a/src/com/jogamp/graph/font/Font.java b/src/com/jogamp/graph/font/Font.java
index 0abaad5b5..fbdf1f474 100644
--- a/src/com/jogamp/graph/font/Font.java
+++ b/src/com/jogamp/graph/font/Font.java
@@ -29,46 +29,44 @@ package com.jogamp.graph.font;
import com.jogamp.graph.geom.AABBox;
+/**
+ * Interface wrapper for font implementation.
+ *
+ * TrueType Font Specification:
+ * http://developer.apple.com/fonts/ttrefman/rm06/Chap6.html
+ */
+
public interface Font {
/**
- * Metrics for font based on pixel size !
- *
- * If no pixelSize is given, this font's static pixelSize is being used.
- *
- * value = Table.value * fontSize * 1.0f / HeadTable.UnitsPerEm
+ * Metrics for font
*/
public interface Metrics {
- public float getAscent();
- public float getDescent();
- public float getLineGap();
- public float getScale();
- public float getScaleForPixelSize(float pixelSize);
- public AABBox getBBox();
+ float getAscent(float pixelSize);
+ float getDescent(float pixelSize);
+ float getLineGap(float pixelSize);
+ float getScale(float pixelSize);
+ AABBox getBBox(float pixelSize);
}
/**
- * Glyph for font symbols based on pixel size !
- *
- * If no pixelSize is given, this font's static pixelSize is being used.
+ * Glyph for font
*/
public interface Glyph {
public Font getFont();
public char getSymbol();
- public AABBox getBBox();
- public float getAdvance();
- public float getAdvanceForPixelSize(float pixelSize, boolean useFrationalMetrics);
+ public AABBox getBBox(float pixelSize);
+ public float getAdvance(float pixelSize, boolean useFrationalMetrics);
}
public String getName();
- public float getSize();
+
public Metrics getMetrics();
public Glyph getGlyph(char symbol);
-
- public float getStringWidth(String string);
- public float getStringHeight(String string);
- public AABBox getStringBounds(CharSequence string);
-
public int getNumGlyphs();
+
+ public float getStringWidth(String string, float pixelSize);
+ public float getStringHeight(String string, float pixelSize);
+ public AABBox getStringBounds(CharSequence string, float pixelSize);
} \ No newline at end of file
diff --git a/src/com/jogamp/graph/font/FontFactory.java b/src/com/jogamp/graph/font/FontFactory.java
index a96dac1b8..b595413ba 100644
--- a/src/com/jogamp/graph/font/FontFactory.java
+++ b/src/com/jogamp/graph/font/FontFactory.java
@@ -35,10 +35,8 @@ public interface FontFactory {
String[] families,
String style,
String variant,
- String weight,
- String size);
+ String weight);
Font createFont(Vertex.Factory<? extends Vertex> factory,
- String name,
- int size);
+ String name);
} \ No newline at end of file
diff --git a/src/com/jogamp/graph/geom/AABBox.java b/src/com/jogamp/graph/geom/AABBox.java
index 9199e5253..2e99daa83 100644
--- a/src/com/jogamp/graph/geom/AABBox.java
+++ b/src/com/jogamp/graph/geom/AABBox.java
@@ -47,6 +47,11 @@ public class AABBox {
computeCenter();
}
+
+ public String toString() {
+ return "[ "+low[0]+"/"+low[1]+"/"+low[1]+" .. "+high[0]+"/"+high[0]+"/"+high[0]+", ctr "+
+ center[0]+"/"+center[1]+"/"+center[1]+" ]";
+ }
public AABBox(float[] low, float[] high)
@@ -56,7 +61,7 @@ public class AABBox {
computeCenter();
}
-
+
public float[] getHigh()
{
return high;