diff options
author | David Schweinsberg <[email protected]> | 2015-12-30 14:50:42 -0800 |
---|---|---|
committer | David Schweinsberg <[email protected]> | 2015-12-30 14:50:42 -0800 |
commit | 886b65573a163f32d663b8cc8c475eefe5f3a6df (patch) | |
tree | 50c863fd74c90160a859d8a8082a696e66879830 | |
parent | 55ec21b4df51e80cbf71785a3cee30a8116d19f1 (diff) |
Split Glyph into TrueType and Type 2 Charstring implementations. Moved CffFont loading into constructor.
-rw-r--r-- | src/net/java/dev/typecast/app/editor/GlyphPanel.java | 13 | ||||
-rw-r--r-- | src/net/java/dev/typecast/cff/CffFont.java | 78 | ||||
-rw-r--r-- | src/net/java/dev/typecast/cff/CharstringType2.java | 8 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/Glyph.java | 174 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/OTFont.java | 3 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/T2Glyph.java | 72 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/TTGlyph.java | 108 | ||||
-rw-r--r-- | src/net/java/dev/typecast/ot/table/CffTable.java | 107 |
8 files changed, 312 insertions, 251 deletions
diff --git a/src/net/java/dev/typecast/app/editor/GlyphPanel.java b/src/net/java/dev/typecast/app/editor/GlyphPanel.java index 4271e75..64a7053 100644 --- a/src/net/java/dev/typecast/app/editor/GlyphPanel.java +++ b/src/net/java/dev/typecast/app/editor/GlyphPanel.java @@ -23,10 +23,11 @@ import java.awt.Color; import javax.swing.JPanel; import javax.swing.JScrollPane; import net.java.dev.typecast.app.framework.EditorView; +import net.java.dev.typecast.cff.CharstringType2; import net.java.dev.typecast.edit.GlyphEdit; -import net.java.dev.typecast.ot.Glyph; import net.java.dev.typecast.ot.OTFont; -import net.java.dev.typecast.cff.Charstring; +import net.java.dev.typecast.ot.T2Glyph; +import net.java.dev.typecast.ot.TTGlyph; import net.java.dev.typecast.ot.table.GlyphDescription; /** @@ -75,15 +76,15 @@ public class GlyphPanel extends JPanel implements EditorView { if (obj instanceof GlyphDescription) { _glyphEdit.setFont(font); GlyphDescription gd = (GlyphDescription) obj; - _glyphEdit.setGlyph(new Glyph( + _glyphEdit.setGlyph(new TTGlyph( gd, font.getHmtxTable().getLeftSideBearing(gd.getGlyphIndex()), font.getHmtxTable().getAdvanceWidth(gd.getGlyphIndex()))); } - else if (obj instanceof Charstring) { + else if (obj instanceof CharstringType2) { _glyphEdit.setFont(font); - Charstring cs = (Charstring) obj; - _glyphEdit.setGlyph(new Glyph( + CharstringType2 cs = (CharstringType2) obj; + _glyphEdit.setGlyph(new T2Glyph( cs, font.getHmtxTable().getLeftSideBearing(cs.getIndex()), font.getHmtxTable().getAdvanceWidth(cs.getIndex()), diff --git a/src/net/java/dev/typecast/cff/CffFont.java b/src/net/java/dev/typecast/cff/CffFont.java index 574ccdd..2c919bb 100644 --- a/src/net/java/dev/typecast/cff/CffFont.java +++ b/src/net/java/dev/typecast/cff/CffFont.java @@ -17,12 +17,19 @@ */ package net.java.dev.typecast.cff; +import java.io.DataInput; +import java.io.IOException; +import java.util.List; +import net.java.dev.typecast.ot.table.CffTable; + /** * * @author dschweinsberg */ public class CffFont { + private final CffTable _table; + private final Dict _topDict; private final Index _charStringsIndex; private final Dict _privateDict; private final Index _localSubrsIndex; @@ -30,16 +37,67 @@ public class CffFont { private final Charstring[] _charstrings; public CffFont( - Index charStringsIndex, - Dict privateDict, - Index localSubrsIndex, - Charset charset, - Charstring[] charstrings) { - _charStringsIndex = charStringsIndex; - _privateDict = privateDict; - _localSubrsIndex = localSubrsIndex; - _charset = charset; - _charstrings = charstrings; + CffTable table, + int index, + Dict topDict) throws IOException { + _table = table; + _topDict = topDict; + + // Charstrings INDEX + // We load this before Charsets because we may need to know the number + // of glyphs + Integer charStringsOffset = (Integer) _topDict.getValue(17); + DataInput di = _table.getDataInputForOffset(charStringsOffset); + _charStringsIndex = new Index(di); + int glyphCount = _charStringsIndex.getCount(); + + // Private DICT + List<Integer> privateSizeAndOffset = (List<Integer>) _topDict.getValue(18); + di = _table.getDataInputForOffset(privateSizeAndOffset.get(1)); + _privateDict = new Dict(di, privateSizeAndOffset.get(0)); + + // Local Subrs INDEX + Integer localSubrsOffset = (Integer) _privateDict.getValue(19); + if (localSubrsOffset != null) { + di = table.getDataInputForOffset(privateSizeAndOffset.get(1) + localSubrsOffset); + _localSubrsIndex = new Index(di); + } else { + _localSubrsIndex = null; + //throw new Exception(); + } + + // Charsets + Integer charsetOffset = (Integer) _topDict.getValue(15); + di = table.getDataInputForOffset(charsetOffset); + int format = di.readUnsignedByte(); + switch (format) { + case 0: + _charset = new CharsetFormat0(di, glyphCount); + break; + case 1: + _charset = new CharsetFormat1(di, glyphCount); + break; + case 2: + _charset = new CharsetFormat2(di, glyphCount); + break; + default: + _charset = null; + //throw new Exception(); + } + + // Create the charstrings + _charstrings = new Charstring[glyphCount]; + for (int i = 0; i < glyphCount; ++i) { + int offset = _charStringsIndex.getOffset(i) - 1; + int len = _charStringsIndex.getOffset(i + 1) - offset - 1; + _charstrings[i] = new CharstringType2( + this, + index, + table.getStringIndex().getString(_charset.getSID(i)), + _charStringsIndex.getData(), + offset, + len); + } } public Index getCharStringsIndex() { diff --git a/src/net/java/dev/typecast/cff/CharstringType2.java b/src/net/java/dev/typecast/cff/CharstringType2.java index b5da650..241044f 100644 --- a/src/net/java/dev/typecast/cff/CharstringType2.java +++ b/src/net/java/dev/typecast/cff/CharstringType2.java @@ -101,6 +101,7 @@ public class CharstringType2 extends Charstring { "-Reserved-" }; + private final CffFont _font; private final int _index; private final String _name; private final int[] _data; @@ -109,17 +110,20 @@ public class CharstringType2 extends Charstring { private int _ip; /** Creates a new instance of CharstringType2 + * @param font * @param index * @param name * @param data * @param offset * @param length */ public CharstringType2( + CffFont font, int index, String name, int[] data, int offset, int length) { + _font = font; _index = index; _name = name; _data = data; @@ -127,6 +131,10 @@ public class CharstringType2 extends Charstring { _length = length; } + public CffFont getFont() { + return _font; + } + @Override public int getIndex() { return _index; diff --git a/src/net/java/dev/typecast/ot/Glyph.java b/src/net/java/dev/typecast/ot/Glyph.java index 0a5d6d2..af3fb46 100644 --- a/src/net/java/dev/typecast/ot/Glyph.java +++ b/src/net/java/dev/typecast/ot/Glyph.java @@ -1,166 +1,34 @@ /* - - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "Batik" and "Apache Software Foundation" must not be - used to endorse or promote products derived from this software without - prior written permission. For written permission, please contact - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation. For more information on the - Apache Software Foundation, please see <http://www.apache.org/>. - -*/ + * Typecast - The Font Development Environment + * + * Copyright (c) 2004-2015 David Schweinsberg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package net.java.dev.typecast.ot; -import net.java.dev.typecast.ot.table.CffTable; -import net.java.dev.typecast.ot.table.GlyphDescription; -import net.java.dev.typecast.ot.table.GlyfDescript; -import net.java.dev.typecast.cff.Charstring; -import net.java.dev.typecast.cff.CharstringType2; -import net.java.dev.typecast.cff.Index; -import net.java.dev.typecast.cff.T2Interpreter; - /** * An individual glyph within a font. * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class Glyph { - - protected short _leftSideBearing; - protected int _advanceWidth; - private Point[] _points; - - /** - * Construct a Glyph from a TrueType outline described by - * a GlyphDescription. - * @param cs The Charstring describing the glyph. - * @param lsb The Left Side Bearing. - * @param advance The advance width. - */ - public Glyph(GlyphDescription gd, short lsb, int advance) { - _leftSideBearing = lsb; - _advanceWidth = advance; - describe(gd); - } - - /** - * Construct a Glyph from a PostScript outline described by a Charstring. - * @param cs The Charstring describing the glyph. - * @param lsb The Left Side Bearing. - * @param advance The advance width. - * @param localSubrIndex - * @param globalSubrIndex - */ - public Glyph( - Charstring cs, - short lsb, - int advance, - Index localSubrIndex, - Index globalSubrIndex) { - _leftSideBearing = lsb; - _advanceWidth = advance; - if (cs instanceof CharstringType2) { - T2Interpreter t2i = new T2Interpreter(localSubrIndex, globalSubrIndex); - _points = t2i.execute((CharstringType2) cs); - } else { - //throw unsupported charstring type - } - } - - public int getAdvanceWidth() { - return _advanceWidth; - } - - public short getLeftSideBearing() { - return _leftSideBearing; - } - - public Point getPoint(int i) { - return _points[i]; - } - - public int getPointCount() { - return _points.length; - } +public abstract class Glyph { - /** - * Resets the glyph to the TrueType table settings - */ - public void reset() { - } + public abstract int getAdvanceWidth(); - /** - * @param factor a 16.16 fixed value - */ - public void scale(int factor) { - for (int i = 0; i < _points.length; i++) { - //points[i].x = ( points[i].x * factor ) >> 6; - //points[i].y = ( points[i].y * factor ) >> 6; - _points[i].x = ((_points[i].x<<10) * factor) >> 26; - _points[i].y = ((_points[i].y<<10) * factor) >> 26; - } - _leftSideBearing = (short)(( _leftSideBearing * factor) >> 6); - _advanceWidth = (_advanceWidth * factor) >> 6; - } + public abstract short getLeftSideBearing(); - /** - * Set the points of a glyph from the GlyphDescription - */ - private void describe(GlyphDescription gd) { - int endPtIndex = 0; - _points = new Point[gd.getPointCount() + 2]; - for (int i = 0; i < gd.getPointCount(); i++) { - boolean endPt = gd.getEndPtOfContours(endPtIndex) == i; - if (endPt) { - endPtIndex++; - } - _points[i] = new Point( - gd.getXCoordinate(i), - gd.getYCoordinate(i), - (gd.getFlags(i) & GlyfDescript.onCurve) != 0, - endPt); - } + public abstract Point getPoint(int i); - // 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); - } + public abstract int getPointCount(); } diff --git a/src/net/java/dev/typecast/ot/OTFont.java b/src/net/java/dev/typecast/ot/OTFont.java index 90980be..012dd6a 100644 --- a/src/net/java/dev/typecast/ot/OTFont.java +++ b/src/net/java/dev/typecast/ot/OTFont.java @@ -163,9 +163,10 @@ public class OTFont { return _maxp.getNumGlyphs(); } + // TODO What happens with the following when dealing with PostScript? public Glyph getGlyph(int i) { return (_glyf.getDescription(i) != null) - ? new Glyph( + ? new TTGlyph( _glyf.getDescription(i), _hmtx.getLeftSideBearing(i), _hmtx.getAdvanceWidth(i)) diff --git a/src/net/java/dev/typecast/ot/T2Glyph.java b/src/net/java/dev/typecast/ot/T2Glyph.java new file mode 100644 index 0000000..264d0a3 --- /dev/null +++ b/src/net/java/dev/typecast/ot/T2Glyph.java @@ -0,0 +1,72 @@ +/* + * Typecast - The Font Development Environment + * + * Copyright (c) 2004-2015 David Schweinsberg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.java.dev.typecast.ot; + +import net.java.dev.typecast.cff.CharstringType2; +import net.java.dev.typecast.cff.Index; +import net.java.dev.typecast.cff.T2Interpreter; + +/** + * An individual Type 2 Charstring glyph within a font. + * @author <a href="mailto:[email protected]">David Schweinsberg</a> + */ +public class T2Glyph extends Glyph { + protected short _leftSideBearing; + protected int _advanceWidth; + private Point[] _points; + + /** + * Construct a Glyph from a PostScript outline described by a Charstring. + * @param cs The CharstringType2 describing the glyph. + * @param lsb The Left Side Bearing. + * @param advance The advance width. + * @param localSubrIndex + * @param globalSubrIndex + */ + public T2Glyph( + CharstringType2 cs, + short lsb, + int advance, + Index localSubrIndex, + Index globalSubrIndex) { + _leftSideBearing = lsb; + _advanceWidth = advance; + T2Interpreter t2i = new T2Interpreter(localSubrIndex, globalSubrIndex); + _points = t2i.execute((CharstringType2) cs); + } + + @Override + public int getAdvanceWidth() { + return _advanceWidth; + } + + @Override + public short getLeftSideBearing() { + return _leftSideBearing; + } + + @Override + public Point getPoint(int i) { + return _points[i]; + } + + @Override + public int getPointCount() { + return _points.length; + } +} diff --git a/src/net/java/dev/typecast/ot/TTGlyph.java b/src/net/java/dev/typecast/ot/TTGlyph.java new file mode 100644 index 0000000..24a8df6 --- /dev/null +++ b/src/net/java/dev/typecast/ot/TTGlyph.java @@ -0,0 +1,108 @@ +/* + * Typecast - The Font Development Environment + * + * Copyright (c) 2004-2015 David Schweinsberg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.java.dev.typecast.ot; + +import net.java.dev.typecast.ot.table.GlyfDescript; +import net.java.dev.typecast.ot.table.GlyphDescription; + +/** + * An individual TrueType glyph within a font. + * @author <a href="mailto:[email protected]">David Schweinsberg</a> + */ +public class TTGlyph extends Glyph { + + protected short _leftSideBearing; + protected int _advanceWidth; + private Point[] _points; + + /** + * Construct a Glyph from a TrueType outline described by + * a GlyphDescription. + * @param gd The glyph description of the glyph. + * @param lsb The Left Side Bearing. + * @param advance The advance width. + */ + public TTGlyph(GlyphDescription gd, short lsb, int advance) { + _leftSideBearing = lsb; + _advanceWidth = advance; + describe(gd); + } + + @Override + public int getAdvanceWidth() { + return _advanceWidth; + } + + @Override + public short getLeftSideBearing() { + return _leftSideBearing; + } + + @Override + public Point getPoint(int i) { + return _points[i]; + } + + @Override + public int getPointCount() { + return _points.length; + } + + /** + * Resets the glyph to the TrueType table settings + */ + public void reset() { + } + + /** + * @param factor a 16.16 fixed value + */ + public void scale(int factor) { + for (Point _point : _points) { + //points[i].x = ( points[i].x * factor ) >> 6; + //points[i].y = ( points[i].y * factor ) >> 6; + _point.x = ((_point.x << 10) * factor) >> 26; + _point.y = ((_point.y << 10) * factor) >> 26; + } + _leftSideBearing = (short)(( _leftSideBearing * factor) >> 6); + _advanceWidth = (_advanceWidth * factor) >> 6; + } + + /** + * Set the points of a glyph from the GlyphDescription + */ + private void describe(GlyphDescription gd) { + int endPtIndex = 0; + _points = new Point[gd.getPointCount() + 2]; + for (int i = 0; i < gd.getPointCount(); i++) { + boolean endPt = gd.getEndPtOfContours(endPtIndex) == i; + if (endPt) { + endPtIndex++; + } + _points[i] = new Point( + gd.getXCoordinate(i), + gd.getYCoordinate(i), + (gd.getFlags(i) & GlyfDescript.onCurve) != 0, + endPt); + } + + // 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); + } +} diff --git a/src/net/java/dev/typecast/ot/table/CffTable.java b/src/net/java/dev/typecast/ot/table/CffTable.java index 523eda6..a0d8436 100644 --- a/src/net/java/dev/typecast/ot/table/CffTable.java +++ b/src/net/java/dev/typecast/ot/table/CffTable.java @@ -22,15 +22,7 @@ import java.io.ByteArrayInputStream; import java.io.DataInput; import java.io.DataInputStream; import java.io.IOException; -import java.util.List; import net.java.dev.typecast.cff.CffFont; -import net.java.dev.typecast.cff.Charset; -import net.java.dev.typecast.cff.CharsetFormat0; -import net.java.dev.typecast.cff.CharsetFormat1; -import net.java.dev.typecast.cff.CharsetFormat2; -import net.java.dev.typecast.cff.Charstring; -import net.java.dev.typecast.cff.CharstringType2; -import net.java.dev.typecast.cff.Dict; import net.java.dev.typecast.cff.Index; import net.java.dev.typecast.cff.NameIndex; import net.java.dev.typecast.cff.StringIndex; @@ -42,18 +34,18 @@ import net.java.dev.typecast.cff.TopDictIndex; */ public class CffTable implements Table { - private DirectoryEntry _de; - private int _major; - private int _minor; - private int _hdrSize; - private int _offSize; - private NameIndex _nameIndex; - private TopDictIndex _topDictIndex; - private StringIndex _stringIndex; - private Index _globalSubrIndex; - private CffFont[] _fonts; - - private byte[] _buf; + private final DirectoryEntry _de; + private final int _major; + private final int _minor; + private final int _hdrSize; + private final int _offSize; + private final NameIndex _nameIndex; + private final TopDictIndex _topDictIndex; + private final StringIndex _stringIndex; + private final Index _globalSubrIndex; + private final CffFont[] _fonts; + + private final byte[] _buf; /** Creates a new instance of CffTable * @param de @@ -87,13 +79,14 @@ public class CffTable implements Table { _globalSubrIndex = new Index(di2); // TESTING - Charstring gscs = new CharstringType2( - 0, - "Global subrs", - _globalSubrIndex.getData(), - _globalSubrIndex.getOffset(0) - 1, - _globalSubrIndex.getDataLength()); - System.out.println(gscs.toString()); +// Charstring gscs = new CharstringType2( +// null, +// 0, +// "Global subrs", +// _globalSubrIndex.getData(), +// _globalSubrIndex.getOffset(0) - 1, +// _globalSubrIndex.getDataLength()); +// System.out.println(gscs.toString()); // Encodings go here -- but since this is an OpenType font will this // not always be a CIDFont? In which case there are no encodings @@ -102,63 +95,11 @@ public class CffTable implements Table { // Load each of the fonts _fonts = new CffFont[_topDictIndex.getCount()]; for (int i = 0; i < _topDictIndex.getCount(); ++i) { - - // Charstrings INDEX - // We load this before Charsets because we may need to know the number - // of glyphs - Integer charStringsOffset = (Integer) _topDictIndex.getTopDict(i).getValue(17); - di2 = getDataInputForOffset(charStringsOffset); - Index charStringsIndex = new Index(di2); - int glyphCount = charStringsIndex.getCount(); - - // Private DICT - List<Integer> privateSizeAndOffset = (List<Integer>) _topDictIndex.getTopDict(i).getValue(18); - di2 = getDataInputForOffset(privateSizeAndOffset.get(1)); - Dict privateDict = new Dict(di2, privateSizeAndOffset.get(0)); - - // Local Subrs INDEX - Index localSubrsIndex = null; - Integer localSubrsOffset = (Integer) privateDict.getValue(19); - if (localSubrsOffset != null) { - di2 = getDataInputForOffset(privateSizeAndOffset.get(1) + localSubrsOffset); - localSubrsIndex = new Index(di2); - } - - // Charsets - Charset charset = null; - Integer charsetOffset = (Integer) _topDictIndex.getTopDict(i).getValue(15); - di2 = getDataInputForOffset(charsetOffset); - int format = di2.readUnsignedByte(); - switch (format) { - case 0: - charset = new CharsetFormat0(di2, glyphCount); - break; - case 1: - charset = new CharsetFormat1(di2, glyphCount); - break; - case 2: - charset = new CharsetFormat2(di2, glyphCount); - break; - } - - // Create the charstrings - Charstring[] charstrings = new Charstring[glyphCount]; - for (int j = 0; j < glyphCount; ++j) { - int offset = charStringsIndex.getOffset(j) - 1; - int len = charStringsIndex.getOffset(j + 1) - offset - 1; - charstrings[j] = new CharstringType2( - i, - _stringIndex.getString(charset.getSID(j)), - charStringsIndex.getData(), - offset, - len); - } - - _fonts[i] = new CffFont(charStringsIndex, privateDict, localSubrsIndex, charset, charstrings); + _fonts[i] = new CffFont(this, i, _topDictIndex.getTopDict(i)); } } - private DataInput getDataInputForOffset(int offset) { + public final DataInput getDataInputForOffset(int offset) { return new DataInputStream(new ByteArrayInputStream( _buf, offset, _de.getLength() - offset)); @@ -167,6 +108,10 @@ public class CffTable implements Table { public NameIndex getNameIndex() { return _nameIndex; } + + public StringIndex getStringIndex() { + return _stringIndex; + } public Index getGlobalSubrIndex() { return _globalSubrIndex; |