aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2011-04-01 15:11:05 +0200
committerSven Gothel <sgothel@jausoft.com>2011-04-01 15:11:05 +0200
commitf47753b63c9530a6af36cb69135dee0421abfe6b (patch)
tree88f970a6c5af5c4fa3ef1b2a9fffe415def1bb3e /src/jogl/classes
parent259d018ed9511ccca0d8e792e443ce9f3d9f39ea (diff)
Font: +getName / +getAllNames / +isPrintableCharacter
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java3
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java13
-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.java24
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java2
5 files changed, 61 insertions, 3 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index a4ab527e2..a34e81ccd 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -71,6 +71,7 @@ public interface Font {
public String getName();
+ public String getAllNames(String separator);
public Metrics getMetrics();
public Glyph getGlyph(char symbol);
@@ -79,4 +80,6 @@ public interface Font {
public float getStringWidth(String string, float pixelSize);
public float getStringHeight(String string, float pixelSize);
public AABBox getStringBounds(CharSequence string, float pixelSize);
+
+ public boolean isPrintableChar( char c );
} \ No newline at end of file
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index 35c62a3d9..9829bb426 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -35,10 +35,12 @@ 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;
import com.jogamp.common.util.IntObjectHashMap;
+import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.geom.AABBox;
class TypecastFont implements FontInt {
@@ -140,7 +142,11 @@ class TypecastFont implements FontInt {
}
public String getName() {
- return fontset.getFileName();
+ return font.getName();
+ }
+
+ public String getAllNames(String separator) {
+ return font.getAllNames(separator);
}
public Metrics getMetrics() {
@@ -265,4 +271,9 @@ class TypecastFont implements FontInt {
final public int getNumGlyphs() {
return font.getNumGlyphs();
}
+
+ public boolean isPrintableChar( char c ) {
+ return FontFactory.isPrintableChar(c);
+ }
+
} \ No newline at end of file
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 3740dac6f..2ac7e97d9 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java
@@ -102,6 +102,28 @@ public class OTFont {
_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 getAllNames(String separator) {
+ if(null != _name) {
+ StringBuffer 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;
+ }
+
public Table getTable(int tableType) {
for (int i = 0; i < _tables.length; i++) {
if ((_tables[i] != null) && (_tables[i].getType() == 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 26cd067db..72fde956c 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
@@ -64,12 +64,21 @@ import java.io.IOException;
*/
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;
private short _stringStorageOffset;
private NameRecord[] _records;
-
+
protected NameTable(DirectoryEntry de, DataInput di) throws IOException {
_de = (DirectoryEntry) de.clone();
_formatSelector = di.readShort();
@@ -99,8 +108,19 @@ public class NameTable implements Table {
return _numberOfNameRecords;
}
+
public NameRecord getRecord(int i) {
- return _records[i];
+ if(_numberOfNameRecords > i) {
+ return _records[i];
+ }
+ return null;
+ }
+
+ public String getRecordsRecordString(int i) {
+ if(_numberOfNameRecords > i) {
+ return _records[i].getRecordString();
+ }
+ return Table.notAvailable;
}
public String getRecordString(short nameId) {
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java
index 87bb0de7a..624f47bef 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java
@@ -50,6 +50,8 @@ public interface Table {
public static final int vhea = 0x76686561; // Vertical Metrics header
public static final int vmtx = 0x766d7478; // Vertical Metrics
+ public static final String notAvailable = "n/a";
+
/**
* Get the table type, as a table directory value.
* @return The table type