diff options
Diffstat (limited to 'src')
5 files changed, 54 insertions, 21 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index a942c7a58..6503f2779 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -82,7 +82,14 @@ public interface Font { public String getName(int nameIndex); - public StringBuffer getAllNames(StringBuffer buffer, String separator); + public StringBuilder getName(StringBuilder string, int nameIndex); + + /** Shall return the family and subfamily name, separated a dash. + * <p>{@link #getName(StringBuilder, int)} w/ {@link #NAME_FAMILY} and {@link #NAME_SUBFAMILY}</p> + * <p>Example: "{@code Ubuntu-Regular}"</p> */ + public StringBuilder getFullFamilyName(StringBuilder buffer); + + public StringBuilder getAllNames(StringBuilder string, String separator); public Metrics getMetrics(); public Glyph getGlyph(char symbol); @@ -92,5 +99,8 @@ public interface Font { public float getStringHeight(CharSequence string, float pixelSize); public AABBox getStringBounds(CharSequence string, float pixelSize); - public boolean isPrintableChar( char c ); + public boolean isPrintableChar( char c ); + + /** Shall return {@link #getFullFamilyName()} */ + public String toString(); }
\ 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 2e5774622..b5ec011c9 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -39,6 +39,7 @@ import jogamp.graph.geom.plane.AffineTransform; import jogamp.graph.geom.plane.Path2D; import com.jogamp.common.util.IntObjectHashMap; +import com.jogamp.graph.font.Font; import com.jogamp.graph.font.FontFactory; import com.jogamp.graph.geom.AABBox; @@ -139,13 +140,21 @@ class TypecastFont implements FontInt { } char2Glyph = new IntObjectHashMap(cmapentries + cmapentries/4); } - + + public StringBuilder getName(StringBuilder sb, int nameIndex) { + return font.getName(nameIndex, sb); + } public String getName(int nameIndex) { - return font.getName(nameIndex); + return getName(null, nameIndex).toString(); } - public StringBuffer getAllNames(StringBuffer buffer, String separator) { - return font.getAllNames(buffer, separator); + public StringBuilder getAllNames(StringBuilder sb, String separator) { + return font.getAllNames(sb, separator); } + public StringBuilder getFullFamilyName(StringBuilder sb) { + sb = getName(sb, Font.NAME_FAMILY).append("-"); + getName(sb, Font.NAME_SUBFAMILY); + return sb; + } public Metrics getMetrics() { if (metrics == null) { @@ -274,4 +283,7 @@ class TypecastFont implements FontInt { return FontFactory.isPrintableChar(c); } + public String toString() { + return getFullFamilyName(null).toString(); + } } 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 6e7e76bc7..8c14b7302 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java @@ -101,16 +101,20 @@ public class OTFont { public OTFont(OTFontCollection fc) { _fc = fc; } - public String getName(int nameIndex) { - return _name.getRecordsRecordString(nameIndex); + public StringBuilder getName(int nameIndex, StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + return _name.getRecordsRecordString(sb, nameIndex); } - public StringBuffer getAllNames(StringBuffer sb, String separator) { + + public StringBuilder getAllNames(StringBuilder sb, String separator) { if(null != _name) { if(null == sb) { - sb = new StringBuffer(); + sb = new StringBuilder(); } for(int i=0; i<_name.getNumberOfNameRecords(); i++) { - sb.append(_name.getRecord(i).getRecordString()).append(separator); + _name.getRecord(i).getRecordString(sb).append(separator); } } return sb; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java index 04168ff77..cd13e9b4a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java @@ -92,8 +92,9 @@ public class NameRecord { return _platformId; } - public String getRecordString() { - return _record; + public StringBuilder getRecordString(StringBuilder sb) { + sb.append(_record); + return sb; } protected void loadString(DataInput di) throws IOException { 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 cfaa7a2bc..6daf2ad60 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 @@ -106,22 +106,28 @@ public class NameTable implements Table { return null; } - public String getRecordsRecordString(int i) { + public StringBuilder getRecordsRecordString(StringBuilder sb, int i) { if(_numberOfNameRecords > i) { - return _records[i].getRecordString(); + _records[i].getRecordString(sb); + } else { + sb.append(Table.notAvailable); } - return Table.notAvailable; + return sb; } - public String getRecordString(short nameId) { - + public StringBuilder getNamedRecordString(StringBuilder sb, short nameId) { // Search for the first instance of this name ID - for (int i = 0; i < _numberOfNameRecords; i++) { + boolean done = false; + for (int i = 0; !done && i < _numberOfNameRecords; i++) { if (_records[i].getNameId() == nameId) { - return _records[i].getRecordString(); + _records[i].getRecordString(sb); + done = true; } } - return ""; + if(!done) { + sb.append(Table.notAvailable); + } + return sb; } public int getType() { |