aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/net/java/dev/typecast/ot/OTFont.java23
-rw-r--r--src/net/java/dev/typecast/ot/OTGlyph.java (renamed from src/net/java/dev/typecast/ot/Glyph.java)23
2 files changed, 32 insertions, 14 deletions
diff --git a/src/net/java/dev/typecast/ot/OTFont.java b/src/net/java/dev/typecast/ot/OTFont.java
index d23228483..e58fc3794 100644
--- a/src/net/java/dev/typecast/ot/OTFont.java
+++ b/src/net/java/dev/typecast/ot/OTFont.java
@@ -54,7 +54,8 @@ import java.io.DataInputStream;
import java.io.IOException;
import net.java.dev.typecast.ot.table.DirectoryEntry;
-import net.java.dev.typecast.ot.table.TTCHeader;
+import net.java.dev.typecast.ot.table.GlyfDescript;
+import net.java.dev.typecast.ot.table.HdmxTable;
import net.java.dev.typecast.ot.table.TableDirectory;
import net.java.dev.typecast.ot.table.Table;
import net.java.dev.typecast.ot.table.Os2Table;
@@ -73,7 +74,7 @@ import net.java.dev.typecast.ot.table.TableFactory;
/**
* The TrueType font.
* @version $Id: OTFont.java,v 1.6 2007-01-31 01:49:18 davidsch Exp $
- * @author <a href="mailto:[email protected]">David Schweinsberg</a>
+ * @author <a href="mailto:[email protected]">David Schweinsberg</a>, Sven Gothel
*/
public class OTFont {
@@ -85,6 +86,7 @@ public class OTFont {
private GlyfTable _glyf;
private HeadTable _head;
private HheaTable _hhea;
+ private HdmxTable _hdmx;
private HmtxTable _hmtx;
private LocaTable _loca;
private MaxpTable _maxp;
@@ -124,6 +126,10 @@ public class OTFont {
return _hhea;
}
+ public HdmxTable getHdmxTable() {
+ return _hdmx;
+ }
+
public HmtxTable getHmtxTable() {
return _hmtx;
}
@@ -160,15 +166,17 @@ public class OTFont {
return _maxp.getNumGlyphs();
}
- public Glyph getGlyph(int i) {
- return (_glyf.getDescription(i) != null)
- ? new Glyph(
- _glyf.getDescription(i),
+ public OTGlyph getGlyph(int i) {
+
+ final GlyfDescript _glyfDescr = _glyf.getDescription(i);
+ return (null != _glyfDescr)
+ ? new OTGlyph(
+ _glyfDescr,
_hmtx.getLeftSideBearing(i),
_hmtx.getAdvanceWidth(i))
: null;
}
-
+
public TableDirectory getTableDirectory() {
return _tableDirectory;
}
@@ -245,6 +253,7 @@ public class OTFont {
// Get references to commonly used tables (these happen to be all the
// required tables)
_cmap = (CmapTable) getTable(Table.cmap);
+ _hdmx = (HdmxTable) getTable(Table.hdmx);
_hmtx = (HmtxTable) getTable(Table.hmtx);
_name = (NameTable) getTable(Table.name);
_os2 = (Os2Table) getTable(Table.OS_2);
diff --git a/src/net/java/dev/typecast/ot/Glyph.java b/src/net/java/dev/typecast/ot/OTGlyph.java
index a59d62684..958dd2280 100644
--- a/src/net/java/dev/typecast/ot/Glyph.java
+++ b/src/net/java/dev/typecast/ot/OTGlyph.java
@@ -50,6 +50,8 @@
package net.java.dev.typecast.ot;
+import com.jogamp.graph.geom.AABBox;
+
import net.java.dev.typecast.ot.table.GlyphDescription;
import net.java.dev.typecast.ot.table.GlyfDescript;
import net.java.dev.typecast.ot.table.Charstring;
@@ -60,13 +62,14 @@ import net.java.dev.typecast.t2.T2Interpreter;
/**
* An individual glyph within a font.
* @version $Id: Glyph.java,v 1.3 2007-02-21 12:23:54 davidsch Exp $
- * @author <a href="mailto:[email protected]">David Schweinsberg</a>
+ * @author <a href="mailto:[email protected]">David Schweinsberg</a>, Sven Gothel
*/
-public class Glyph {
+public class OTGlyph {
protected short _leftSideBearing;
protected int _advanceWidth;
private Point[] _points;
+ AABBox _bbox;
/**
* Construct a Glyph from a TrueType outline described by
@@ -75,7 +78,7 @@ public class Glyph {
* @param lsb The Left Side Bearing.
* @param advance The advance width.
*/
- public Glyph(GlyphDescription gd, short lsb, int advance) {
+ public OTGlyph(GlyphDescription gd, short lsb, int advance) {
_leftSideBearing = lsb;
_advanceWidth = advance;
describe(gd);
@@ -87,7 +90,7 @@ public class Glyph {
* @param lsb The Left Side Bearing.
* @param advance The advance width.
*/
- public Glyph(Charstring cs, short lsb, int advance) {
+ public OTGlyph(Charstring cs, short lsb, int advance) {
_leftSideBearing = lsb;
_advanceWidth = advance;
if (cs instanceof CharstringType2) {
@@ -98,6 +101,10 @@ public class Glyph {
}
}
+ public AABBox getBBox() {
+ return _bbox;
+ }
+
public int getAdvanceWidth() {
return _advanceWidth;
}
@@ -139,7 +146,7 @@ public class Glyph {
*/
private void describe(GlyphDescription gd) {
int endPtIndex = 0;
- _points = new Point[gd.getPointCount() + 2];
+ _points = new Point[gd.getPointCount() /* + 2 */ ];
for (int i = 0; i < gd.getPointCount(); i++) {
boolean endPt = gd.getEndPtOfContours(endPtIndex) == i;
if (endPt) {
@@ -153,7 +160,9 @@ public class Glyph {
}
// Append the origin and advanceWidth points (n & n+1)
- _points[gd.getPointCount()] = new Point(0, 0, true, true);
- _points[gd.getPointCount()+1] = new Point(_advanceWidth, 0, true, true);
+ // _points[gd.getPointCount()] = new Point(0, 0, true, true);
+ // _points[gd.getPointCount()+1] = new Point(_advanceWidth, 0, true, true);
+
+ _bbox = new AABBox(gd.getXMinimum(), gd.getYMinimum(), 0, gd.getXMaximum(), gd.getYMaximum(), 0);
}
}