aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-01 20:07:04 +0200
committerSven Gothel <[email protected]>2011-04-01 20:07:04 +0200
commit5857d93e2d41608b247ec18cb9129f3a6624d9ac (patch)
tree38b1ab9b489b9e249a9d2495aa528db1fbee3288 /src
parent85c3bcac2ef65aa7c6a5a4990f1e2559d691a361 (diff)
Font Names: Expose name indices allowing user to pick all names ..
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java8
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java15
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java10
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java22
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java11
6 files changed, 34 insertions, 42 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
index 2bb99d27c..79ae8c11e 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
@@ -55,13 +55,13 @@ public abstract class TextRenderer extends Renderer {
Path2D[] paths = new Path2D[str.length()];
((FontInt)font).getOutline(str, size, affineTransform, paths);
- GlyphString glyphString = new GlyphString(pointFactory, font.getName(), str);
+ GlyphString glyphString = new GlyphString(pointFactory, font.getName(Font.NAME_UNIQUNAME), str);
glyphString.createfromFontPath(paths, affineTransform);
glyphString.generateRegion(gl.getContext(), sharpness, st, renderType);
return glyphString;
}
-
+
public void flushCache() {
Iterator<GlyphString> iterator = stringCacheMap.values().iterator();
while(iterator.hasNext()){
@@ -84,12 +84,12 @@ public abstract class TextRenderer extends Renderer {
}
protected GlyphString getCachedGlyphString(Font font, String str, int fontSize) {
- final String key = font.getName() + "." + str.hashCode() + "." + fontSize;
+ final String key = font.getName(Font.NAME_UNIQUNAME) + "." + str.hashCode() + "." + fontSize;
return stringCacheMap.get(key);
}
protected void addCachedGlyphString(Font font, String str, int fontSize, GlyphString glyphString) {
- final String key = font.getName() + "." + str.hashCode() + "." + fontSize;
+ final String key = font.getName(Font.NAME_UNIQUNAME) + "." + str.hashCode() + "." + fontSize;
validateCache(1);
stringCacheMap.put(key, glyphString);
stringCacheArray.add(stringCacheArray.size(), key);
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index a34e81ccd..d8c30c61b 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -41,6 +41,17 @@ import com.jogamp.graph.geom.AABBox;
public interface Font {
+ /** font name indices for name table */
+ public static final int NAME_COPYRIGHT = 0;
+ public static final int NAME_FAMILY = 1;
+ public static final int NAME_SUBFAMILY = 2;
+ public static final int NAME_UNIQUNAME = 3;
+ public static final int NAME_FULLNAME = 4;
+ public static final int NAME_VERSION = 5;
+ public static final int NAME_MANUFACTURER = 8;
+ public static final int NAME_DESIGNER = 9;
+
+
/**
* Metrics for font
*
@@ -70,8 +81,8 @@ public interface Font {
}
- public String getName();
- public String getAllNames(String separator);
+ public String getName(int nameIndex);
+ public StringBuffer getAllNames(StringBuffer buffer, String separator);
public Metrics getMetrics();
public Glyph getGlyph(char symbol);
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index 9829bb426..f702b981f 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -35,7 +35,6 @@ import jogamp.graph.font.typecast.ot.table.CmapIndexEntry;
import jogamp.graph.font.typecast.ot.table.CmapTable;
import jogamp.graph.font.typecast.ot.table.HdmxTable;
import jogamp.graph.font.typecast.ot.table.ID;
-import jogamp.graph.font.typecast.ot.table.NameTable;
import jogamp.graph.geom.plane.AffineTransform;
import jogamp.graph.geom.plane.Path2D;
@@ -141,12 +140,11 @@ class TypecastFont implements FontInt {
char2Glyph = new IntObjectHashMap(cmapentries + cmapentries/4);
}
- public String getName() {
- return font.getName();
+ public String getName(int nameIndex) {
+ return font.getName(nameIndex);
}
-
- public String getAllNames(String separator) {
- return font.getAllNames(separator);
+ public StringBuffer getAllNames(StringBuffer buffer, String separator) {
+ return font.getAllNames(buffer, separator);
}
public Metrics getMetrics() {
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java
index 2ac7e97d9..17b5af594 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java
@@ -101,27 +101,19 @@ public class OTFont {
public OTFont(OTFontCollection fc) {
_fc = fc;
}
-
- public String getName() {
- if(null != _name) {
- StringBuffer sb = new StringBuffer();
- sb.append(_name.getRecordsRecordString(NameTable.RECORD_FAMILY)).append(" - ")
- .append(_name.getRecordsRecordString(NameTable.RECORD_SUBFAMILY)).append(" - ")
- .append(_name.getRecordsRecordString(NameTable.RECORD_MANUFACTURER)) ;
- return sb.toString();
- }
- return Table.notAvailable;
+ public String getName(int nameIndex) {
+ return _name.getRecordsRecordString(nameIndex);
}
-
- public String getAllNames(String separator) {
+ public StringBuffer getAllNames(StringBuffer sb, String separator) {
if(null != _name) {
- StringBuffer sb = new StringBuffer();
+ if(null == sb) {
+ sb = new StringBuffer();
+ }
for(int i=0; i<_name.getNumberOfNameRecords(); i++) {
sb.append(_name.getRecord(i).getRecordString()).append(separator);
}
- return sb.toString();
}
- return Table.notAvailable;
+ return sb;
}
public Table getTable(int tableType) {
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java
index 72fde956c..cfaa7a2bc 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java
@@ -63,16 +63,6 @@ import java.io.IOException;
* @author <a href="mailto:[email protected]">David Schweinsberg</a>
*/
public class NameTable implements Table {
-
- public static final int RECORD_COPYRIGHT = 0;
- public static final int RECORD_FAMILY = 1;
- public static final int RECORD_SUBFAMILY = 2;
- public static final int RECORD_UNIQUNAME = 3;
- public static final int RECORD_FULLNAME = 4;
- public static final int RECORD_VERSION = 5;
- public static final int RECORD_MANUFACTURER = 8;
- public static final int RECORD_DESIGNER = 9;
-
private DirectoryEntry _de;
private short _formatSelector;
private short _numberOfNameRecords;
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
index a8d822d88..bdfaab17b 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java
@@ -92,9 +92,9 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
public GPUTextRendererListenerBase01(Vertex.Factory<? extends Vertex> factory, int mode, boolean debug, boolean trace) {
super(TextRenderer.create(factory, mode), debug, trace);
this.font = FontFactory.get(fontSet).getDefault();
- System.err.println(font.getAllNames("\n"));
+ System.err.println(font.getAllNames(null, "\n"));
- this.fontName = font.getName();
+ this.fontName = font.getName(Font.NAME_FAMILY) + " - " + font.getName(Font.NAME_SUBFAMILY);
this.fontNameBox = font.getStringBounds(fontName, fontSizeFixed*2);
switchHeadBox();
}
@@ -179,7 +179,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
public void nextFontSet() {
fontSet = ( fontSet == FontFactory.UBUNTU ) ? FontFactory.JAVA : FontFactory.UBUNTU ;
font = FontFactory.get(fontSet).getDefault();
- this.fontName = font.getName();
+ this.fontName = font.getName(Font.NAME_FAMILY) + " - " + font.getName(Font.NAME_SUBFAMILY);
this.fontNameBox = font.getStringBounds(fontName, fontSizeFixed*3);
}
@@ -219,7 +219,8 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
}
public void printScreen(GLAutoDrawable drawable, String dir, String tech, boolean exportAlpha) throws GLException, IOException {
- printScreen(drawable, dir, tech, font.getName(), exportAlpha);
+ final String fn = font.getName(Font.NAME_FAMILY)+"-"+font.getName(Font.NAME_SUBFAMILY);
+ printScreen(drawable, dir, tech, fn.replace(' ', '_'), exportAlpha);
}
public class KeyAction implements KeyListener {
@@ -267,4 +268,4 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
}
public void keyReleased(KeyEvent arg0) {}
}
-} \ No newline at end of file
+}