aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2011-05-08 05:31:39 +0200
committerSven Gothel <sgothel@jausoft.com>2011-05-08 05:31:39 +0200
commiteefa76604706bcaa55a1a324cb4eef78dd7a030c (patch)
tree7ed2e3cf5818ac9b6b4f1013027fd1325231f3bd /src/jogl/classes/jogamp/graph
parentd60bc9c4bc4a6f99bafa8c723b3d7f3bacc80950 (diff)
Graph/Font: use StringBuilder
Diffstat (limited to 'src/jogl/classes/jogamp/graph')
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java20
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java14
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java5
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java22
4 files changed, 42 insertions, 19 deletions
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() {