diff options
Diffstat (limited to 'src')
107 files changed, 729 insertions, 792 deletions
diff --git a/src/main/java/net/java/dev/typecast/cff/CffStandardStrings.java b/src/main/java/net/java/dev/typecast/cff/CffStandardStrings.java index 4da6167..adb77b4 100644 --- a/src/main/java/net/java/dev/typecast/cff/CffStandardStrings.java +++ b/src/main/java/net/java/dev/typecast/cff/CffStandardStrings.java @@ -23,7 +23,7 @@ package net.java.dev.typecast.cff; * CFF specification. * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class CffStandardStrings { +class CffStandardStrings { public static final String[] standardStrings = { ".notdef", diff --git a/src/main/java/net/java/dev/typecast/cff/CharsetFormat1.java b/src/main/java/net/java/dev/typecast/cff/CharsetFormat1.java index 9b5e93a..5b418b0 100644 --- a/src/main/java/net/java/dev/typecast/cff/CharsetFormat1.java +++ b/src/main/java/net/java/dev/typecast/cff/CharsetFormat1.java @@ -53,8 +53,7 @@ public class CharsetFormat1 extends Charset { int count = 1; for (CharsetRange range : _charsetRanges) { if (gid <= range.getLeft() + count) { - int sid = gid - count + range.getFirst(); - return sid; + return gid - count + range.getFirst(); } count += range.getLeft() + 1; } diff --git a/src/main/java/net/java/dev/typecast/cff/CharsetFormat2.java b/src/main/java/net/java/dev/typecast/cff/CharsetFormat2.java index 69fadf9..b1badc0 100644 --- a/src/main/java/net/java/dev/typecast/cff/CharsetFormat2.java +++ b/src/main/java/net/java/dev/typecast/cff/CharsetFormat2.java @@ -53,8 +53,7 @@ public class CharsetFormat2 extends Charset { int count = 1; for (CharsetRange range : _charsetRanges) { if (gid <= range.getLeft() + count) { - int sid = gid - count + range.getFirst(); - return sid; + return gid - count + range.getFirst(); } count += range.getLeft() + 1; } diff --git a/src/main/java/net/java/dev/typecast/cff/CharsetRange.java b/src/main/java/net/java/dev/typecast/cff/CharsetRange.java index b3d0888..db553dd 100644 --- a/src/main/java/net/java/dev/typecast/cff/CharsetRange.java +++ b/src/main/java/net/java/dev/typecast/cff/CharsetRange.java @@ -21,7 +21,7 @@ package net.java.dev.typecast.cff; * * @author dschweinsberg */ -public class CharsetRange { +class CharsetRange { private int _first; private int _left; @@ -33,7 +33,7 @@ public class CharsetRange { return _first; } - protected final void setFirst(int first) { + final void setFirst(int first) { _first = first; } @@ -41,7 +41,7 @@ public class CharsetRange { return _left; } - protected final void setLeft(int left) { + final void setLeft(int left) { _left = left; } diff --git a/src/main/java/net/java/dev/typecast/cff/CharsetRange1.java b/src/main/java/net/java/dev/typecast/cff/CharsetRange1.java index dc33430..f0334bf 100644 --- a/src/main/java/net/java/dev/typecast/cff/CharsetRange1.java +++ b/src/main/java/net/java/dev/typecast/cff/CharsetRange1.java @@ -24,9 +24,9 @@ import java.io.IOException; * * @author dschweinsberg */ -public class CharsetRange1 extends CharsetRange { +class CharsetRange1 extends CharsetRange { - protected CharsetRange1(DataInput di) throws IOException { + CharsetRange1(DataInput di) throws IOException { setFirst(di.readUnsignedShort()); setLeft(di.readUnsignedByte()); } diff --git a/src/main/java/net/java/dev/typecast/cff/CharsetRange2.java b/src/main/java/net/java/dev/typecast/cff/CharsetRange2.java index 9e14c44..a76f9e5 100644 --- a/src/main/java/net/java/dev/typecast/cff/CharsetRange2.java +++ b/src/main/java/net/java/dev/typecast/cff/CharsetRange2.java @@ -24,9 +24,9 @@ import java.io.IOException; * * @author dschweinsberg */ -public class CharsetRange2 extends CharsetRange { +class CharsetRange2 extends CharsetRange { - protected CharsetRange2(DataInput di) throws IOException { + CharsetRange2(DataInput di) throws IOException { setFirst(di.readUnsignedShort()); setLeft(di.readUnsignedShort()); } diff --git a/src/main/java/net/java/dev/typecast/cff/CharstringType2.java b/src/main/java/net/java/dev/typecast/cff/CharstringType2.java index bd97a97..ee31c6f 100644 --- a/src/main/java/net/java/dev/typecast/cff/CharstringType2.java +++ b/src/main/java/net/java/dev/typecast/cff/CharstringType2.java @@ -205,7 +205,7 @@ public class CharstringType2 extends Charstring { int b2 = _data[ip + 2]; int b3 = _data[ip + 3]; int b4 = _data[ip + 4]; - return new Float((b1 << 8 | b2) + ((b3 << 8 | b4) / 65536.0)); + return (float) ((b1 << 8 | b2) + ((b3 << 8 | b4) / 65536.0)); } else { return null; } diff --git a/src/main/java/net/java/dev/typecast/cff/Dict.java b/src/main/java/net/java/dev/typecast/cff/Dict.java index 5c500d8..231a106 100644 --- a/src/main/java/net/java/dev/typecast/cff/Dict.java +++ b/src/main/java/net/java/dev/typecast/cff/Dict.java @@ -21,7 +21,6 @@ import java.io.DataInput; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; /** @@ -57,7 +56,7 @@ public class Dict { return _entries.get(key); } - private boolean addKeyAndValueEntry() { + private void addKeyAndValueEntry() { ArrayList<Object> operands = new ArrayList<>(); Object operand = null; while (isOperandAtIndex()) { @@ -74,7 +73,6 @@ public class Dict { } else { _entries.put(operator, operands); } - return true; } private boolean isOperandAtIndex() { @@ -153,9 +151,7 @@ public class Dict { @Override public String toString() { StringBuilder sb = new StringBuilder(); - Iterator<Integer> keys = _entries.keySet().iterator(); - while (keys.hasNext()) { - Integer key = keys.next(); + for (Integer key : _entries.keySet()) { if ((key & 0xc00) == 0xc00) { sb.append("12 ").append(key & 0xff).append(": "); } else { diff --git a/src/main/java/net/java/dev/typecast/cff/NameIndex.java b/src/main/java/net/java/dev/typecast/cff/NameIndex.java index fa8bdab..cadd9f3 100644 --- a/src/main/java/net/java/dev/typecast/cff/NameIndex.java +++ b/src/main/java/net/java/dev/typecast/cff/NameIndex.java @@ -28,8 +28,8 @@ public class NameIndex extends Index { super(di); } - public String getName(int index) { - String name = null; + private String getName(int index) { + String name; int offset = getOffset(index) - 1; int len = getOffset(index + 1) - offset - 1; // Ensure the name hasn't been deleted diff --git a/src/main/java/net/java/dev/typecast/cff/T2Interpreter.java b/src/main/java/net/java/dev/typecast/cff/T2Interpreter.java index 79bf51e..29b726f 100644 --- a/src/main/java/net/java/dev/typecast/cff/T2Interpreter.java +++ b/src/main/java/net/java/dev/typecast/cff/T2Interpreter.java @@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory; */ public class T2Interpreter { - private class SubrPair { + private static class SubrPair { final CharstringType2 cs; final int ip; SubrPair(CharstringType2 cs, int ip) { @@ -43,7 +43,7 @@ public class T2Interpreter { private static final int SUBR_STACK_LIMIT = 10; private static final int TRANSIENT_ARRAY_ELEMENT_COUNT = 32; - static final Logger logger = LoggerFactory.getLogger(T2Interpreter.class); + private static final Logger logger = LoggerFactory.getLogger(T2Interpreter.class); private final Number[] _argStack = new Number[ARGUMENT_STACK_LIMIT]; private int _argStackIndex = 0; @@ -251,8 +251,7 @@ public class T2Interpreter { int xb = xa + dxb[i]; int yb = ya + dyb[i]; int xc = xb + dxc[i]; - int yc = yb; - curveTo(xa, ya, xb, yb, xc, yc); + curveTo(xa, ya, xb, yb, xc, yb); } clearArg(); } @@ -298,16 +297,14 @@ public class T2Interpreter { int ya = lastPoint.y; int xb = xa + dxb[i]; int yb = ya + dyb[i]; - int xc = xb; int yc = yb + dyc[i]; - int xd = xc; int yd = yc + dyd[i]; - int xe = xd + dxe[i]; + int xe = xb + dxe[i]; int ye = yd + dye[i]; int xf = xe + dxf[i]; int yf = ye + (i == count - 1 ? dyf : 0); - curveTo(xa, ya, xb, yb, xc, yc); - curveTo(xd, yd, xe, ye, xf, yf); + curveTo(xa, ya, xb, yb, xb, yc); + curveTo(xb, yd, xe, ye, xf, yf); } } else { int count = getArgCount() / 8; @@ -354,15 +351,13 @@ public class T2Interpreter { int xb = xa + dxb[i]; int yb = ya + dyb[i]; int xc = xb + dxc[i]; - int yc = yb; int xd = xc + dxd[i]; - int yd = yc; int xe = xd + dxe[i]; - int ye = yd + dye[i]; + int ye = yb + dye[i]; int xf = xe + (i == count - 1 ? dxf : 0); int yf = ye + dyf[i]; - curveTo(xa, ya, xb, yb, xc, yc); - curveTo(xd, yd, xe, ye, xf, yf); + curveTo(xa, ya, xb, yb, xc, yb); + curveTo(xd, yb, xe, ye, xf, yf); } } clearArg(); @@ -484,15 +479,13 @@ public class T2Interpreter { int xb = xa + dxb[i]; int yb = ya + dyb[i]; int xc = xb + dxc[i]; - int yc = yb; int xd = xc + dxd[i]; - int yd = yc; int xe = xd + dxe[i]; - int ye = yd + dye[i]; + int ye = yb + dye[i]; int xf = xe + (i == count - 1 ? dxf : 0); int yf = ye + dyf[i]; - curveTo(xa, ya, xb, yb, xc, yc); - curveTo(xd, yd, xe, ye, xf, yf); + curveTo(xa, ya, xb, yb, xc, yb); + curveTo(xd, yb, xe, ye, xf, yf); } } else { int count = getArgCount() / 8; @@ -538,16 +531,14 @@ public class T2Interpreter { int ya = lastPoint.y; int xb = xa + dxb[i]; int yb = ya + dyb[i]; - int xc = xb; int yc = yb + dyc[i]; - int xd = xc; int yd = yc + dyd[i]; - int xe = xd + dxe[i]; + int xe = xb + dxe[i]; int ye = yd + dye[i]; int xf = xe + dxf[i]; int yf = ye + (i == count - 1 ? dyf : 0); - curveTo(xa, ya, xb, yb, xc, yc); - curveTo(xd, yd, xe, ye, xf, yf); + curveTo(xa, ya, xb, yb, xb, yc); + curveTo(xb, yd, xe, ye, xf, yf); } } clearArg(); @@ -581,9 +572,8 @@ public class T2Interpreter { int ya = lastPoint.y + dya[i]; int xb = xa + dxb[i]; int yb = ya + dyb[i]; - int xc = xb; int yc = yb + dyc[i]; - curveTo(xa, ya, xb, yb, xc, yc); + curveTo(xa, ya, xb, yb, xb, yc); } clearArg(); diff --git a/src/main/java/net/java/dev/typecast/cff/T2Mnemonic.java b/src/main/java/net/java/dev/typecast/cff/T2Mnemonic.java index 55e3507..ab84437 100644 --- a/src/main/java/net/java/dev/typecast/cff/T2Mnemonic.java +++ b/src/main/java/net/java/dev/typecast/cff/T2Mnemonic.java @@ -22,7 +22,7 @@ package net.java.dev.typecast.cff; * The Mnemonic representations of the Type 2 charstring instruction set. * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class T2Mnemonic { +class T2Mnemonic { /** * One byte operators diff --git a/src/main/java/net/java/dev/typecast/exchange/Exporter.java b/src/main/java/net/java/dev/typecast/exchange/Exporter.java index 98ef724..111ceac 100644 --- a/src/main/java/net/java/dev/typecast/exchange/Exporter.java +++ b/src/main/java/net/java/dev/typecast/exchange/Exporter.java @@ -26,7 +26,7 @@ import net.java.dev.typecast.ot.table.TableException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public abstract class Exporter { +abstract class Exporter { public abstract void export(OutputStream os) throws TableException; } diff --git a/src/main/java/net/java/dev/typecast/exchange/Messages.java b/src/main/java/net/java/dev/typecast/exchange/Messages.java index 8338bc4..4e955c1 100644 --- a/src/main/java/net/java/dev/typecast/exchange/Messages.java +++ b/src/main/java/net/java/dev/typecast/exchange/Messages.java @@ -20,7 +20,7 @@ package net.java.dev.typecast.exchange; import java.util.Locale; import java.util.MissingResourceException; -import org.apache.batik.i18n.Localizable; + import org.apache.batik.i18n.LocalizableSupport; /** @@ -28,7 +28,7 @@ import org.apache.batik.i18n.LocalizableSupport; * * @author <a href="mailto:[email protected]">Vincent Hardy</a> */ -public class Messages { +class Messages { /** * This class does not need to be instantiated. @@ -38,13 +38,13 @@ public class Messages { /** * The error messages bundle class name. */ - protected final static String RESOURCES = + private final static String RESOURCES = "net.java.dev.typecast.exchange.Messages"; /** * The localizable support for the error messages. */ - protected static LocalizableSupport localizableSupport = + private static final LocalizableSupport localizableSupport = new LocalizableSupport(RESOURCES); /** diff --git a/src/main/java/net/java/dev/typecast/exchange/SVGExporter.java b/src/main/java/net/java/dev/typecast/exchange/SVGExporter.java index d24d92e..1a8fbc3 100644 --- a/src/main/java/net/java/dev/typecast/exchange/SVGExporter.java +++ b/src/main/java/net/java/dev/typecast/exchange/SVGExporter.java @@ -48,10 +48,10 @@ public class SVGExporter extends Exporter implements XMLConstants, SVGConstants, ScriptTags, FeatureTags { - static final String EOL; + private static final String EOL; - static final String PROPERTY_LINE_SEPARATOR = "line.separator"; - static final String PROPERTY_LINE_SEPARATOR_DEFAULT = "\n"; + private static final String PROPERTY_LINE_SEPARATOR = "line.separator"; + private static final String PROPERTY_LINE_SEPARATOR_DEFAULT = "\n"; static { String temp; @@ -88,7 +88,7 @@ public class SVGExporter private static final String CONFIG_SVG_TEST_CARD_END = "SVGFont.config.svg.test.card.end"; - protected static String encodeEntities(String s) { + private static String encodeEntities(String s) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { switch (s.charAt(i)) { @@ -115,7 +115,7 @@ public class SVGExporter return sb.toString(); } - protected static String getContourAsSVGPathData(Glyph glyph, int startIndex, int count) { + private static String getContourAsSVGPathData(Glyph glyph, int startIndex, int count) { // If this is a single point on it's own, we can't do anything with it if (glyph.getPoint(startIndex).endOfContour) { @@ -196,7 +196,7 @@ public class SVGExporter return sb.toString(); } - protected static String getSVGFontFaceElement(OTFont font) { + private static String getSVGFontFaceElement(OTFont font) { StringBuilder sb = new StringBuilder(); String fontFamily = font.getNameTable().getRecordString(ID.nameFontFamilyName); short unitsPerEm = font.getHeadTable().getUnitsPerEm(); @@ -265,7 +265,7 @@ public class SVGExporter * @param forceAscii Force the use of the ASCII character map * @throws net.java.dev.typecast.ot.table.TableException */ - protected static void writeFontAsSVGFragment(PrintStream ps, TTFont font, String id, int first, int last, boolean forceAscii) + private static void writeFontAsSVGFragment(PrintStream ps, TTFont font, String id, int first, int last, boolean forceAscii) throws TableException { int horiz_advance_x = font.getOS2Table().getAvgCharWidth(); @@ -289,7 +289,7 @@ public class SVGExporter ps.print(getSVGFontFaceElement(font)); // Decide upon a cmap table to use for our character to glyph look-up - CmapFormat cmapFmt = null; + CmapFormat cmapFmt; if (forceAscii) { // We've been asked to use the ASCII/Macintosh cmap format @@ -380,7 +380,7 @@ public class SVGExporter ps.println(XML_CLOSE_TAG_END); } - protected static String getGlyphAsSVG( + private static String getGlyphAsSVG( OTFont font, Glyph glyph, int glyphIndex, @@ -441,7 +441,7 @@ public class SVGExporter return sb.toString(); } - protected static String getGlyphAsSVG( + private static String getGlyphAsSVG( TTFont font, Glyph glyph, int glyphIndex, @@ -525,7 +525,7 @@ public class SVGExporter return sb.toString(); } - protected static String getKerningPairAsSVG(KerningPair kp, PostTable post) { + private static String getKerningPairAsSVG(KerningPair kp, PostTable post) { StringBuilder sb = new StringBuilder(); sb.append(XML_OPEN_TAG_START).append(SVG_HKERN_TAG).append(XML_SPACE); sb.append(SVG_G1_ATTRIBUTE).append(XML_EQUAL_QUOT); @@ -543,25 +543,25 @@ public class SVGExporter return sb.toString(); } - protected static void writeSvgBegin(PrintStream ps) { + private static void writeSvgBegin(PrintStream ps) { ps.println(Messages.formatMessage(CONFIG_SVG_BEGIN, new Object[]{SVG_PUBLIC_ID, SVG_SYSTEM_ID})); } - protected static void writeSvgDefsBegin(PrintStream ps) { + private static void writeSvgDefsBegin(PrintStream ps) { ps.println(XML_OPEN_TAG_START + SVG_DEFS_TAG + XML_OPEN_TAG_END_CHILDREN); } - protected static void writeSvgDefsEnd(PrintStream ps) { + private static void writeSvgDefsEnd(PrintStream ps) { ps.println(XML_CLOSE_TAG_START + SVG_DEFS_TAG + XML_CLOSE_TAG_END); } - protected static void writeSvgEnd(PrintStream ps) { + private static void writeSvgEnd(PrintStream ps) { ps.println(XML_CLOSE_TAG_START + SVG_SVG_TAG + XML_CLOSE_TAG_END); } - protected static void writeSvgTestCard(PrintStream ps, String fontFamily) { + private static void writeSvgTestCard(PrintStream ps, String fontFamily) { ps.println(Messages.formatMessage(CONFIG_SVG_TEST_CARD_START, null)); ps.println(fontFamily); ps.println(Messages.formatMessage(CONFIG_SVG_TEST_CARD_END, null)); @@ -612,7 +612,6 @@ public class SVGExporter private static void chopUpStringBuffer(StringBuilder sb) { if (sb.length() < 256) { - return; } else { // Being rather simplistic about it, for now we'll insert a newline after // 240 chars diff --git a/src/main/java/net/java/dev/typecast/ot/Disassembler.java b/src/main/java/net/java/dev/typecast/ot/Disassembler.java index c2ab7f2..2733167 100644 --- a/src/main/java/net/java/dev/typecast/ot/Disassembler.java +++ b/src/main/java/net/java/dev/typecast/ot/Disassembler.java @@ -21,7 +21,7 @@ public class Disassembler { * @param ip The current instruction pointer * @return The new instruction pointer */ - public static int advanceIP(short[] instructions, int ip) { + private static int advanceIP(short[] instructions, int ip) { // The high word specifies font, cvt, or glyph program int i = ip & 0xffff; @@ -45,7 +45,7 @@ public class Disassembler { return ip; } - public static short getPushCount(short[] instructions, int ip) { + private static short getPushCount(short[] instructions, int ip) { short instr = instructions[ip & 0xffff]; if ((Mnemonic.NPUSHB == instr) || (Mnemonic.NPUSHW == instr)) { return instructions[(ip & 0xffff) + 1]; @@ -55,7 +55,7 @@ public class Disassembler { return 0; } - public static int[] getPushData(short[] instructions, int ip) { + private static int[] getPushData(short[] instructions, int ip) { int count = getPushCount(instructions, ip); int[] data = new int[count]; int i = ip & 0xffff; @@ -81,7 +81,7 @@ public class Disassembler { } public static String disassemble(short[] instructions, int leadingSpaces) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int ip = 0; while (ip < instructions.length) { for (int i = 0; i < leadingSpaces; i++) { @@ -91,12 +91,12 @@ public class Disassembler { sb.append(Mnemonic.getMnemonic(instructions[ip])); if (getPushCount(instructions, ip) > 0) { int[] data = getPushData(instructions, ip); - for(int j = 0; j < data.length; j++) { + for (int datum : data) { if ((instructions[ip] == Mnemonic.PUSHW) || - (instructions[ip] == Mnemonic.NPUSHW)) { - sb.append(" ").append((short) data[j]); + (instructions[ip] == Mnemonic.NPUSHW)) { + sb.append(" ").append((short) datum); } else { - sb.append(" ").append(data[j]); + sb.append(" ").append(datum); } } } diff --git a/src/main/java/net/java/dev/typecast/ot/OTFont.java b/src/main/java/net/java/dev/typecast/ot/OTFont.java index 3751828..eb8bbb2 100644 --- a/src/main/java/net/java/dev/typecast/ot/OTFont.java +++ b/src/main/java/net/java/dev/typecast/ot/OTFont.java @@ -118,7 +118,7 @@ public abstract class OTFont { return _hmtx; } - public MaxpTable getMaxpTable() { + MaxpTable getMaxpTable() { return _maxp; } diff --git a/src/main/java/net/java/dev/typecast/ot/OTFontCollection.java b/src/main/java/net/java/dev/typecast/ot/OTFontCollection.java index 6f7d7de..a78f6bc 100644 --- a/src/main/java/net/java/dev/typecast/ot/OTFontCollection.java +++ b/src/main/java/net/java/dev/typecast/ot/OTFontCollection.java @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class OTFontCollection { +class OTFontCollection { private TTCHeader _ttcHeader; private OTFont[] _fonts; diff --git a/src/main/java/net/java/dev/typecast/ot/Point.java b/src/main/java/net/java/dev/typecast/ot/Point.java index de847ad..3530ba4 100644 --- a/src/main/java/net/java/dev/typecast/ot/Point.java +++ b/src/main/java/net/java/dev/typecast/ot/Point.java @@ -13,10 +13,10 @@ package net.java.dev.typecast.ot; */ public class Point { - public int x = 0; - public int y = 0; - public boolean onCurve = true; - public boolean endOfContour = false; + public int x; + public int y; + public boolean onCurve; + public boolean endOfContour; public boolean touched = false; public Point(int x, int y, boolean onCurve, boolean endOfContour) { diff --git a/src/main/java/net/java/dev/typecast/ot/T2Glyph.java b/src/main/java/net/java/dev/typecast/ot/T2Glyph.java index 2b33f3e..9e7afa8 100644 --- a/src/main/java/net/java/dev/typecast/ot/T2Glyph.java +++ b/src/main/java/net/java/dev/typecast/ot/T2Glyph.java @@ -27,8 +27,8 @@ import net.java.dev.typecast.cff.T2Interpreter; * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ public class T2Glyph extends Glyph { - protected short _leftSideBearing; - protected int _advanceWidth; + private final short _leftSideBearing; + private final int _advanceWidth; private final Point[] _points; private final Integer[] _hstems; private final Integer[] _vstems; diff --git a/src/main/java/net/java/dev/typecast/ot/TTGlyph.java b/src/main/java/net/java/dev/typecast/ot/TTGlyph.java index 0752b0b..4ec844a 100644 --- a/src/main/java/net/java/dev/typecast/ot/TTGlyph.java +++ b/src/main/java/net/java/dev/typecast/ot/TTGlyph.java @@ -26,8 +26,8 @@ import net.java.dev.typecast.ot.table.GlyphDescription; */ public class TTGlyph extends Glyph { - protected short _leftSideBearing; - protected int _advanceWidth; + private short _leftSideBearing; + private int _advanceWidth; private Point[] _points; /** diff --git a/src/main/java/net/java/dev/typecast/ot/mac/ResourceData.java b/src/main/java/net/java/dev/typecast/ot/mac/ResourceData.java index 526df2d..b5bdb10 100644 --- a/src/main/java/net/java/dev/typecast/ot/mac/ResourceData.java +++ b/src/main/java/net/java/dev/typecast/ot/mac/ResourceData.java @@ -25,7 +25,7 @@ import java.io.IOException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class ResourceData { +class ResourceData { private byte[] data; diff --git a/src/main/java/net/java/dev/typecast/ot/mac/ResourceFile.java b/src/main/java/net/java/dev/typecast/ot/mac/ResourceFile.java index 1158f2d..58aa63e 100644 --- a/src/main/java/net/java/dev/typecast/ot/mac/ResourceFile.java +++ b/src/main/java/net/java/dev/typecast/ot/mac/ResourceFile.java @@ -26,13 +26,13 @@ import java.io.RandomAccessFile; * TODO: incorporate this into the test suite. * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class ResourceFile { +class ResourceFile { private ResourceHeader header; private ResourceMap map; /** Creates new Resource */ - public ResourceFile(RandomAccessFile raf) throws IOException { + private ResourceFile(RandomAccessFile raf) throws IOException { // Read header at the beginning of the file raf.seek(0); @@ -43,7 +43,7 @@ public class ResourceFile { map = new ResourceMap(raf); } - public ResourceMap getResourceMap() { + private ResourceMap getResourceMap() { return map; } diff --git a/src/main/java/net/java/dev/typecast/ot/mac/ResourceMap.java b/src/main/java/net/java/dev/typecast/ot/mac/ResourceMap.java index 37579f8..1a30368 100644 --- a/src/main/java/net/java/dev/typecast/ot/mac/ResourceMap.java +++ b/src/main/java/net/java/dev/typecast/ot/mac/ResourceMap.java @@ -27,7 +27,7 @@ import java.io.IOException; */ public class ResourceMap { - private byte[] headerCopy = new byte[16]; + private final byte[] headerCopy = new byte[16]; private int nextResourceMap; private int fileReferenceNumber; private int attributes; @@ -61,10 +61,10 @@ public class ResourceMap { } public ResourceType getResourceType(String typeName) { - for (int i = 0; i < types.length; i++) { - String s = types[i].getTypeAsString(); - if (types[i].getTypeAsString().equals(typeName)) { - return types[i]; + for (ResourceType type : types) { + String s = type.getTypeAsString(); + if (type.getTypeAsString().equals(typeName)) { + return type; } } return null; diff --git a/src/main/java/net/java/dev/typecast/ot/mac/ResourceReference.java b/src/main/java/net/java/dev/typecast/ot/mac/ResourceReference.java index 39667fa..ea3a551 100644 --- a/src/main/java/net/java/dev/typecast/ot/mac/ResourceReference.java +++ b/src/main/java/net/java/dev/typecast/ot/mac/ResourceReference.java @@ -35,7 +35,7 @@ public class ResourceReference { private String name; /** Creates new ResourceReference */ - protected ResourceReference(DataInput di) throws IOException { + ResourceReference(DataInput di) throws IOException { id = di.readUnsignedShort(); nameOffset = di.readShort(); attributes = (short) di.readUnsignedByte(); @@ -43,7 +43,7 @@ public class ResourceReference { handle = di.readInt(); } - protected void readName(DataInput di) throws IOException { + void readName(DataInput di) throws IOException { if (nameOffset > -1) { int len = di.readUnsignedByte(); byte[] buf = new byte[len]; diff --git a/src/main/java/net/java/dev/typecast/ot/mac/ResourceType.java b/src/main/java/net/java/dev/typecast/ot/mac/ResourceType.java index f43ad2f..a4bc0d1 100644 --- a/src/main/java/net/java/dev/typecast/ot/mac/ResourceType.java +++ b/src/main/java/net/java/dev/typecast/ot/mac/ResourceType.java @@ -33,20 +33,20 @@ public class ResourceType { private ResourceReference[] references; /** Creates new ResourceType */ - protected ResourceType(DataInput di) throws IOException { + ResourceType(DataInput di) throws IOException { type = di.readInt(); count = di.readUnsignedShort() + 1; offset = di.readUnsignedShort(); references = new ResourceReference[count]; } - protected void readRefs(DataInput di) throws IOException { + void readRefs(DataInput di) throws IOException { for (int i = 0; i < count; i++) { references[i] = new ResourceReference(di); } } - protected void readNames(DataInput di) throws IOException { + void readNames(DataInput di) throws IOException { for (int i = 0; i < count; i++) { references[i].readName(di); } @@ -57,12 +57,10 @@ public class ResourceType { } public String getTypeAsString() { - return new StringBuffer() - .append((char)((type>>24)&0xff)) - .append((char)((type>>16)&0xff)) - .append((char)((type>>8)&0xff)) - .append((char)((type)&0xff)) - .toString(); + return String.valueOf((char) ((type >> 24) & 0xff)) + + (char) ((type >> 16) & 0xff) + + (char) ((type >> 8) & 0xff) + + (char) ((type) & 0xff); } public int getCount() { diff --git a/src/main/java/net/java/dev/typecast/ot/table/BaseTable.java b/src/main/java/net/java/dev/typecast/ot/table/BaseTable.java index a4f3e89..f092698 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/BaseTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/BaseTable.java @@ -22,7 +22,6 @@ import java.io.ByteArrayInputStream; import java.io.DataInput; import java.io.DataInputStream; import java.io.IOException; -import net.java.dev.typecast.ot.Fixed; /** * Baseline Table @@ -30,18 +29,18 @@ import net.java.dev.typecast.ot.Fixed; */ public class BaseTable implements Table { - private abstract class BaseCoord { + private abstract static class BaseCoord { public abstract int getBaseCoordFormat(); public abstract short getCoordinate(); } - private class BaseCoordFormat1 extends BaseCoord { + private static class BaseCoordFormat1 extends BaseCoord { private short _coordinate; - protected BaseCoordFormat1(DataInput di) throws IOException { + BaseCoordFormat1(DataInput di) throws IOException { _coordinate = di.readShort(); } @@ -55,13 +54,13 @@ public class BaseTable implements Table { } - private class BaseCoordFormat2 extends BaseCoord { + private static class BaseCoordFormat2 extends BaseCoord { private short _coordinate; private int _referenceGlyph; private int _baseCoordPoint; - protected BaseCoordFormat2(DataInput di) throws IOException { + BaseCoordFormat2(DataInput di) throws IOException { _coordinate = di.readShort(); _referenceGlyph = di.readUnsignedShort(); _baseCoordPoint = di.readUnsignedShort(); @@ -77,12 +76,12 @@ public class BaseTable implements Table { } - private class BaseCoordFormat3 extends BaseCoord { + private static class BaseCoordFormat3 extends BaseCoord { private short _coordinate; private int _deviceTableOffset; - protected BaseCoordFormat3(DataInput di) throws IOException { + BaseCoordFormat3(DataInput di) throws IOException { _coordinate = di.readShort(); _deviceTableOffset = di.readUnsignedShort(); } @@ -97,13 +96,13 @@ public class BaseTable implements Table { } - private class FeatMinMaxRecord { + private static class FeatMinMaxRecord { private int _tag; private int _minCoordOffset; private int _maxCoordOffset; - protected FeatMinMaxRecord(DataInput di) throws IOException { + FeatMinMaxRecord(DataInput di) throws IOException { _tag = di.readInt(); _minCoordOffset = di.readUnsignedShort(); _maxCoordOffset = di.readUnsignedShort(); @@ -117,7 +116,7 @@ public class BaseTable implements Table { private int _featMinMaxCount; private FeatMinMaxRecord[] _featMinMaxRecord; - protected MinMax(int minMaxOffset) throws IOException { + MinMax(int minMaxOffset) throws IOException { DataInput di = getDataInputForOffset(minMaxOffset); _minCoordOffset = di.readUnsignedShort(); _maxCoordOffset = di.readUnsignedShort(); @@ -136,7 +135,7 @@ public class BaseTable implements Table { private int[] _baseCoordOffset; private BaseCoord[] _baseCoords; - protected BaseValues(int baseValuesOffset) throws IOException { + BaseValues(int baseValuesOffset) throws IOException { DataInput di = getDataInputForOffset(baseValuesOffset); _defaultIndex = di.readUnsignedShort(); _baseCoordCount = di.readUnsignedShort(); @@ -162,12 +161,12 @@ public class BaseTable implements Table { } } - private class BaseLangSysRecord { + private static class BaseLangSysRecord { private int _baseLangSysTag; private int _minMaxOffset; - protected BaseLangSysRecord(DataInput di) throws IOException { + BaseLangSysRecord(DataInput di) throws IOException { _baseLangSysTag = di.readInt(); _minMaxOffset = di.readUnsignedShort(); } @@ -176,14 +175,14 @@ public class BaseTable implements Table { return _baseLangSysTag; } - public int getMinMaxOffset() { + int getMinMaxOffset() { return _minMaxOffset; } } private class BaseScript { - private int _thisOffset; + private final int _thisOffset; private int _baseValuesOffset; private int _defaultMinMaxOffset; private int _baseLangSysCount; @@ -191,7 +190,7 @@ public class BaseTable implements Table { private BaseValues _baseValues; private MinMax[] _minMax; - protected BaseScript(int baseScriptOffset) throws IOException { + BaseScript(int baseScriptOffset) throws IOException { _thisOffset = baseScriptOffset; DataInput di = getDataInputForOffset(baseScriptOffset); _baseValuesOffset = di.readUnsignedShort(); @@ -210,7 +209,7 @@ public class BaseTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer() + StringBuilder sb = new StringBuilder() .append("\nBaseScript BaseScriptT").append(Integer.toHexString(_thisOffset)) .append("\nBaseValuesT").append(Integer.toHexString(_thisOffset + _baseValuesOffset)) .append("\nMinMaxT").append(Integer.toHexString(_thisOffset + _defaultMinMaxOffset)) @@ -230,33 +229,33 @@ public class BaseTable implements Table { } } - private class BaseScriptRecord { + private static class BaseScriptRecord { private int _baseScriptTag; private int _baseScriptOffset; - protected BaseScriptRecord(DataInput di) throws IOException { + BaseScriptRecord(DataInput di) throws IOException { _baseScriptTag = di.readInt(); _baseScriptOffset = di.readUnsignedShort(); } - public int getBaseScriptTag() { + int getBaseScriptTag() { return _baseScriptTag; } - public int getBaseScriptOffset() { + int getBaseScriptOffset() { return _baseScriptOffset; } } private class BaseScriptList { - private int _thisOffset; + private final int _thisOffset; private int _baseScriptCount; private BaseScriptRecord[] _baseScriptRecord; private BaseScript[] _baseScripts; - protected BaseScriptList(int baseScriptListOffset) throws IOException { + BaseScriptList(int baseScriptListOffset) throws IOException { _thisOffset = baseScriptListOffset; DataInput di = getDataInputForOffset(baseScriptListOffset); _baseScriptCount = di.readUnsignedShort(); @@ -272,7 +271,7 @@ public class BaseTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer() + StringBuilder sb = new StringBuilder() .append("\nBaseScriptList BaseScriptListT").append(Integer.toHexString(_thisOffset)) .append("\n").append(Integer.toHexString(_baseScriptCount)); for (int i = 0; i < _baseScriptCount; ++i) { @@ -289,11 +288,11 @@ public class BaseTable implements Table { private class BaseTagList { - private int _thisOffset; + private final int _thisOffset; private int _baseTagCount; private int[] _baselineTag; - protected BaseTagList(int baseTagListOffset) throws IOException { + BaseTagList(int baseTagListOffset) throws IOException { _thisOffset = baseTagListOffset; DataInput di = getDataInputForOffset(baseTagListOffset); _baseTagCount = di.readUnsignedShort(); @@ -304,7 +303,7 @@ public class BaseTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer() + StringBuilder sb = new StringBuilder() .append("\nBaseTagList BaseTagListT").append(Integer.toHexString(_thisOffset)) .append("\n").append(Integer.toHexString(_baseTagCount)); for (int i = 0; i < _baseTagCount; ++i) { @@ -316,13 +315,13 @@ public class BaseTable implements Table { private class Axis { - private int _thisOffset; + private final int _thisOffset; private int _baseTagListOffset; private int _baseScriptListOffset; private BaseTagList _baseTagList; private BaseScriptList _baseScriptList; - protected Axis(int axisOffset) throws IOException { + Axis(int axisOffset) throws IOException { _thisOffset = axisOffset; DataInput di = getDataInputForOffset(axisOffset); _baseTagListOffset = di.readUnsignedShort(); @@ -337,13 +336,11 @@ public class BaseTable implements Table { } public String toString() { - return new StringBuffer() - .append("\nAxis AxisT").append(Integer.toHexString(_thisOffset)) - .append("\nBaseTagListT").append(Integer.toHexString(_thisOffset + _baseTagListOffset)) - .append("\nBaseScriptListT").append(Integer.toHexString(_thisOffset + _baseScriptListOffset)) - .append("\n").append(_baseTagList) - .append("\n").append(_baseScriptList) - .toString(); + return "\nAxis AxisT" + Integer.toHexString(_thisOffset) + + "\nBaseTagListT" + Integer.toHexString(_thisOffset + _baseTagListOffset) + + "\nBaseScriptListT" + Integer.toHexString(_thisOffset + _baseScriptListOffset) + + "\n" + _baseTagList + + "\n" + _baseScriptList; } } @@ -390,7 +387,7 @@ public class BaseTable implements Table { // return String.format("%1$8x", value); // } - static protected String tagAsString(int tag) { + private static String tagAsString(int tag) { char[] c = new char[4]; c[0] = (char)((tag >> 24) & 0xff); c[1] = (char)((tag >> 16) & 0xff); @@ -400,7 +397,7 @@ public class BaseTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer() + StringBuilder sb = new StringBuilder() .append("; 'BASE' Table - Baseline\n;-------------------------------------\n\n") .append("BASEHeader BASEHeaderT").append(Integer.toHexString(0)) .append("\n").append(Integer.toHexString(_version)) diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat.java b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat.java index 5a2cef6..546924b 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat.java @@ -27,12 +27,12 @@ import java.io.IOException; */ public abstract class CmapFormat { - public class Range { + public static class Range { private final int _startCode; private final int _endCode; - protected Range(int startCode, int endCode) { + Range(int startCode, int endCode) { _startCode = startCode; _endCode = endCode; } @@ -46,7 +46,7 @@ public abstract class CmapFormat { } } - protected static CmapFormat create(int format, DataInput di) + static CmapFormat create(int format, DataInput di) throws IOException { switch(format) { case 0: @@ -64,11 +64,11 @@ public abstract class CmapFormat { } } - public abstract int getFormat(); + protected abstract int getFormat(); public abstract int getLength(); - public abstract int getLanguage(); + protected abstract int getLanguage(); public abstract int getRangeCount(); @@ -79,12 +79,11 @@ public abstract class CmapFormat { @Override public String toString() { - return new StringBuilder() - .append("format: ") - .append(getFormat()) - .append(", length: ") - .append(getLength()) - .append(", language: ") - .append(getLanguage()).toString(); + return "format: " + + getFormat() + + ", length: " + + getLength() + + ", language: " + + getLanguage(); } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat0.java b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat0.java index 329a650..01b15d8 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat0.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat0.java @@ -33,7 +33,7 @@ public class CmapFormat0 extends CmapFormat { private final int _language; private final int[] _glyphIdArray = new int[256]; - protected CmapFormat0(DataInput di) throws IOException { + CmapFormat0(DataInput di) throws IOException { _length = di.readUnsignedShort(); _language = di.readUnsignedShort(); for (int i = 0; i < 256; i++) { diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat12.java b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat12.java index daf6306..39efaa0 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat12.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat12.java @@ -33,7 +33,7 @@ public class CmapFormat12 extends CmapFormat { private final int[] _endCharCode; private final int[] _startGlyphId; - protected CmapFormat12(DataInput di) throws IOException { + CmapFormat12(DataInput di) throws IOException { di.readUnsignedShort(); // reserved _length = di.readInt(); _language = di.readInt(); @@ -96,9 +96,8 @@ public class CmapFormat12 extends CmapFormat { @Override public String toString() { - return new StringBuilder() - .append(super.toString()) - .append(", nGroups: ") - .append(_nGroups).toString(); + return super.toString() + + ", nGroups: " + + _nGroups; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat2.java b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat2.java index cff572e..2820ca6 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat2.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat2.java @@ -28,7 +28,7 @@ import java.io.IOException; */ public class CmapFormat2 extends CmapFormat { - private class SubHeader { + private static class SubHeader { int _firstCode; int _entryCount; short _idDelta; @@ -42,7 +42,7 @@ public class CmapFormat2 extends CmapFormat { private final SubHeader[] _subHeaders; private final int[] _glyphIndexArray; - protected CmapFormat2(DataInput di) throws IOException { + CmapFormat2(DataInput di) throws IOException { _length = di.readUnsignedShort(); _language = di.readUnsignedShort(); @@ -128,7 +128,7 @@ public class CmapFormat2 extends CmapFormat { return new Range( highByte | _subHeaders[index]._firstCode, highByte | (_subHeaders[index]._firstCode + - _subHeaders[index]._entryCount - 1)); + _subHeaders[index]._entryCount - 1)); } @Override diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat4.java b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat4.java index 034e6f3..ed405b0 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat4.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat4.java @@ -21,6 +21,7 @@ package net.java.dev.typecast.ot.table; import java.io.DataInput; import java.io.IOException; +import java.util.Arrays; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> @@ -40,7 +41,7 @@ public class CmapFormat4 extends CmapFormat { private final int[] _glyphIdArray; private final int _segCount; - protected CmapFormat4(DataInput di) throws IOException { + CmapFormat4(DataInput di) throws IOException { _length = di.readUnsignedShort(); _language = di.readUnsignedShort(); _segCountX2 = di.readUnsignedShort(); // +2 (8) @@ -132,23 +133,22 @@ public class CmapFormat4 extends CmapFormat { @Override public String toString() { - return new StringBuilder() - .append(super.toString()) - .append(", segCountX2: ") - .append(_segCountX2) - .append(", searchRange: ") - .append(_searchRange) - .append(", entrySelector: ") - .append(_entrySelector) - .append(", rangeShift: ") - .append(_rangeShift) - .append(", endCode: ") - .append(_endCode) - .append(", startCode: ") - .append(_endCode) - .append(", idDelta: ") - .append(_idDelta) - .append(", idRangeOffset: ") - .append(_idRangeOffset).toString(); + return super.toString() + + ", segCountX2: " + + _segCountX2 + + ", searchRange: " + + _searchRange + + ", entrySelector: " + + _entrySelector + + ", rangeShift: " + + _rangeShift + + ", endCode: " + + Arrays.toString(_endCode) + + ", startCode: " + + Arrays.toString(_endCode) + + ", idDelta: " + + Arrays.toString(_idDelta) + + ", idRangeOffset: " + + Arrays.toString(_idRangeOffset); } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat6.java b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat6.java index af93e0a..71057c0 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapFormat6.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapFormat6.java @@ -33,7 +33,7 @@ public class CmapFormat6 extends CmapFormat { private final int _entryCount; private final int[] _glyphIdArray; - protected CmapFormat6(DataInput di) throws IOException { + CmapFormat6(DataInput di) throws IOException { _length = di.readUnsignedShort(); _language = di.readUnsignedShort(); _firstCode = di.readUnsignedShort(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapFormatUnknown.java b/src/main/java/net/java/dev/typecast/ot/table/CmapFormatUnknown.java index fe1fef3..bef549d 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapFormatUnknown.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapFormatUnknown.java @@ -36,7 +36,7 @@ public class CmapFormatUnknown extends CmapFormat { * @param format * @param di * @throws java.io.IOException */ - protected CmapFormatUnknown(int format, DataInput di) throws IOException { + CmapFormatUnknown(int format, DataInput di) throws IOException { _format = format; if (_format < 8) { _length = di.readUnsignedShort(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapIndexEntry.java b/src/main/java/net/java/dev/typecast/ot/table/CmapIndexEntry.java index 7982568..746cf59 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapIndexEntry.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapIndexEntry.java @@ -63,7 +63,7 @@ public class CmapIndexEntry implements Comparable<CmapIndexEntry> { private int _offset; private CmapFormat _format; - protected CmapIndexEntry(DataInput di) throws IOException { + CmapIndexEntry(DataInput di) throws IOException { _platformId = di.readUnsignedShort(); _encodingId = di.readUnsignedShort(); _offset = di.readInt(); @@ -91,27 +91,20 @@ public class CmapIndexEntry implements Comparable<CmapIndexEntry> { @Override public String toString() { - return new StringBuffer() - .append("platform id: ") - .append(_platformId) - .append(" (") - .append(ID.getPlatformName((short) _platformId)) - .append("), encoding id: ") - .append(_encodingId) - .append(" (") - .append(ID.getEncodingName((short) _platformId, (short) _encodingId)) - .append("), offset: ") - .append(_offset).toString(); + return "platform id: " + + _platformId + + " (" + + ID.getPlatformName((short) _platformId) + + "), encoding id: " + + _encodingId + + " (" + + ID.getEncodingName((short) _platformId, (short) _encodingId) + + "), offset: " + + _offset; } @Override public int compareTo(CmapIndexEntry entry) { - if (getOffset() < entry.getOffset()) { - return -1; - } else if (getOffset() > entry.getOffset()) { - return 1; - } else { - return 0; - } + return Integer.compare(getOffset(), entry.getOffset()); } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/CmapTable.java b/src/main/java/net/java/dev/typecast/ot/table/CmapTable.java index 4d4faeb..fe0597f 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CmapTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CmapTable.java @@ -129,7 +129,7 @@ public class CmapTable implements Table { @Override public String toString() { - StringBuffer sb = new StringBuffer().append("cmap\n"); + StringBuilder sb = new StringBuilder().append("cmap\n"); // Get each of the index entries for (int i = 0; i < _numTables; i++) { diff --git a/src/main/java/net/java/dev/typecast/ot/table/ColrTable.java b/src/main/java/net/java/dev/typecast/ot/table/ColrTable.java index ef26e43..54ef89a 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/ColrTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/ColrTable.java @@ -21,48 +21,48 @@ import java.io.IOException; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class ColrTable implements Table { +class ColrTable implements Table { - public class BaseGlyphRecord { + static class BaseGlyphRecord { private final int _gid; private final int _firstLayerIndex; private final int _numLayers; - protected BaseGlyphRecord(DataInput di) throws IOException { + BaseGlyphRecord(DataInput di) throws IOException { _gid = di.readUnsignedShort(); _firstLayerIndex = di.readUnsignedShort(); _numLayers = di.readUnsignedShort(); } - public int getGid() { + int getGid() { return _gid; } - public int getFirstLayerIndex() { + int getFirstLayerIndex() { return _firstLayerIndex; } - public int getNumLayers() { + int getNumLayers() { return _numLayers; } } - public class LayerRecord { + static class LayerRecord { private final int _gid; private final int _paletteIndex; - protected LayerRecord(DataInput di) throws IOException { + LayerRecord(DataInput di) throws IOException { _gid = di.readUnsignedShort(); _paletteIndex = di.readUnsignedShort(); } - public int getGid() { + int getGid() { return _gid; } - public int getPaletteIndex() { + int getPaletteIndex() { return _paletteIndex; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/Coverage.java b/src/main/java/net/java/dev/typecast/ot/table/Coverage.java index 684139f..a477ed6 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Coverage.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Coverage.java @@ -70,7 +70,7 @@ public abstract class Coverage { public abstract int[] getGlyphIds(); - protected static Coverage read(DataInput di) throws IOException { + static Coverage read(DataInput di) throws IOException { Coverage c = null; int format = di.readUnsignedShort(); if (format == 1) { diff --git a/src/main/java/net/java/dev/typecast/ot/table/CoverageFormat1.java b/src/main/java/net/java/dev/typecast/ot/table/CoverageFormat1.java index 238ce9e..8cec8a5 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CoverageFormat1.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CoverageFormat1.java @@ -63,7 +63,7 @@ public class CoverageFormat1 extends Coverage { private final int[] _glyphIds; /** Creates new CoverageFormat1 */ - protected CoverageFormat1(DataInput di) throws IOException { + CoverageFormat1(DataInput di) throws IOException { _glyphCount = di.readUnsignedShort(); _glyphIds = new int[_glyphCount]; for (int i = 0; i < _glyphCount; i++) { diff --git a/src/main/java/net/java/dev/typecast/ot/table/CoverageFormat2.java b/src/main/java/net/java/dev/typecast/ot/table/CoverageFormat2.java index 234ec74..97a716a 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CoverageFormat2.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CoverageFormat2.java @@ -65,7 +65,7 @@ public class CoverageFormat2 extends Coverage { private final RangeRecord[] _rangeRecords; /** Creates new CoverageFormat2 */ - protected CoverageFormat2(DataInput di) throws IOException { + CoverageFormat2(DataInput di) throws IOException { _rangeCount = di.readUnsignedShort(); _rangeRecords = new RangeRecord[_rangeCount]; for (int i = 0; i < _rangeCount; i++) { diff --git a/src/main/java/net/java/dev/typecast/ot/table/CpalTable.java b/src/main/java/net/java/dev/typecast/ot/table/CpalTable.java index 9153274..e71e5fa 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CpalTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CpalTable.java @@ -21,35 +21,35 @@ import java.io.IOException; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class CpalTable implements Table { +class CpalTable implements Table { - public class ColorRecord { + static class ColorRecord { private final short _blue; private final short _green; private final short _red; private final short _alpha; - protected ColorRecord(DataInput di) throws IOException { + ColorRecord(DataInput di) throws IOException { _blue = (short) di.readUnsignedByte(); _green = (short) di.readUnsignedByte(); _red = (short) di.readUnsignedByte(); _alpha = (short) di.readUnsignedByte(); } - public short getBlue() { + short getBlue() { return _blue; } - public short getGreen() { + short getGreen() { return _green; } - public short getRed() { + short getRed() { return _red; } - public short getAlpha() { + short getAlpha() { return _alpha; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/CvtTable.java b/src/main/java/net/java/dev/typecast/ot/table/CvtTable.java index 32f4c47..a205617 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/CvtTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/CvtTable.java @@ -8,16 +8,15 @@ package net.java.dev.typecast.ot.table; -import java.io.ByteArrayInputStream; import java.io.DataInput; import java.io.IOException; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class CvtTable implements Table { +class CvtTable implements Table { - private short[] values; + private final short[] values; protected CvtTable(DataInput di, int length) throws IOException { int len = length / 2; @@ -32,7 +31,7 @@ public class CvtTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'cvt ' Table - Control Value Table\n----------------------------------\n"); sb.append("Size = ").append(0).append(" bytes, ").append(values.length).append(" entries\n"); sb.append(" Values\n ------\n"); diff --git a/src/main/java/net/java/dev/typecast/ot/table/Device.java b/src/main/java/net/java/dev/typecast/ot/table/Device.java index dd44eae..cf84459 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Device.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Device.java @@ -15,7 +15,7 @@ import java.io.RandomAccessFile; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class Device extends Object { +class Device { private int startSize; private int endSize; diff --git a/src/main/java/net/java/dev/typecast/ot/table/DsigEntry.java b/src/main/java/net/java/dev/typecast/ot/table/DsigEntry.java index 35246e5..e2ea30f 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/DsigEntry.java +++ b/src/main/java/net/java/dev/typecast/ot/table/DsigEntry.java @@ -15,14 +15,14 @@ import java.io.DataInput; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class DsigEntry { +class DsigEntry { private int format; private int length; private int offset; /** Creates new DsigEntry */ - protected DsigEntry(DataInput di) throws IOException { + DsigEntry(DataInput di) throws IOException { format = di.readInt(); length = di.readInt(); offset = di.readInt(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/DsigTable.java b/src/main/java/net/java/dev/typecast/ot/table/DsigTable.java index 9175d7a..853332b 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/DsigTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/DsigTable.java @@ -15,7 +15,7 @@ import java.io.DataInput; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class DsigTable implements Table { +class DsigTable implements Table { private int version; private int numSigs; @@ -39,7 +39,7 @@ public class DsigTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer().append("DSIG\n"); + StringBuilder sb = new StringBuilder().append("DSIG\n"); for (int i = 0; i < numSigs; i++) { sb.append(sigBlocks[i].toString()); } diff --git a/src/main/java/net/java/dev/typecast/ot/table/Feature.java b/src/main/java/net/java/dev/typecast/ot/table/Feature.java index d454455..5e4162e 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Feature.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Feature.java @@ -64,7 +64,7 @@ public class Feature { private int[] _lookupListIndex; /** Creates new Feature */ - protected Feature(DataInput di) throws IOException { + Feature(DataInput di) throws IOException { _featureParams = di.readUnsignedShort(); _lookupCount = di.readUnsignedShort(); _lookupListIndex = new int[_lookupCount]; diff --git a/src/main/java/net/java/dev/typecast/ot/table/FeatureRecord.java b/src/main/java/net/java/dev/typecast/ot/table/FeatureRecord.java index ba7eb26..b3d329d 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/FeatureRecord.java +++ b/src/main/java/net/java/dev/typecast/ot/table/FeatureRecord.java @@ -63,7 +63,7 @@ public class FeatureRecord { private int _offset; /** Creates new FeatureRecord */ - protected FeatureRecord(DataInput di) throws IOException { + FeatureRecord(DataInput di) throws IOException { _tag = di.readInt(); _offset = di.readUnsignedShort(); } @@ -77,11 +77,9 @@ public class FeatureRecord { } public String getTagAsString() { - return new StringBuffer() - .append((char)((_tag>>24)&0xff)) - .append((char)((_tag>>16)&0xff)) - .append((char)((_tag>>8)&0xff)) - .append((char)((_tag)&0xff)) - .toString(); + return String.valueOf((char) ((_tag >> 24) & 0xff)) + + (char) ((_tag >> 16) & 0xff) + + (char) ((_tag >> 8) & 0xff) + + (char) ((_tag) & 0xff); } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/FeatureTags.java b/src/main/java/net/java/dev/typecast/ot/table/FeatureTags.java index 2062645..7bec8b9 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/FeatureTags.java +++ b/src/main/java/net/java/dev/typecast/ot/table/FeatureTags.java @@ -56,7 +56,7 @@ package net.java.dev.typecast.ot.table; * @author <a href="mailto:[email protected]">Vincent Hardy</a> */ public interface FeatureTags { - public static final String FEATURE_TAG_INIT = "init"; - public static final String FEATURE_TAG_MEDI = "medi"; - public static final String FEATURE_TAG_FINA = "fina"; + String FEATURE_TAG_INIT = "init"; + String FEATURE_TAG_MEDI = "medi"; + String FEATURE_TAG_FINA = "fina"; } diff --git a/src/main/java/net/java/dev/typecast/ot/table/FpgmTable.java b/src/main/java/net/java/dev/typecast/ot/table/FpgmTable.java index 9542668..e5bf788 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/FpgmTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/FpgmTable.java @@ -15,7 +15,7 @@ import net.java.dev.typecast.ot.Disassembler; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class FpgmTable extends Program implements Table { +class FpgmTable extends Program implements Table { protected FpgmTable(DataInput di, int length) throws IOException { readInstructions(di, length); diff --git a/src/main/java/net/java/dev/typecast/ot/table/GaspRange.java b/src/main/java/net/java/dev/typecast/ot/table/GaspRange.java index d85b337..d28a703 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GaspRange.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GaspRange.java @@ -15,22 +15,22 @@ import java.io.IOException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class GaspRange { +class GaspRange { - public static final int GASP_GRIDFIT = 1; - public static final int GASP_DOGRAY = 2; + private static final int GASP_GRIDFIT = 1; + private static final int GASP_DOGRAY = 2; private int rangeMaxPPEM; private int rangeGaspBehavior; /** Creates new GaspRange */ - protected GaspRange(DataInput di) throws IOException { + GaspRange(DataInput di) throws IOException { rangeMaxPPEM = di.readUnsignedShort(); rangeGaspBehavior = di.readUnsignedShort(); } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(" rangeMaxPPEM: ").append(rangeMaxPPEM) .append("\n rangeGaspBehavior: 0x").append(rangeGaspBehavior); if ((rangeGaspBehavior & GASP_GRIDFIT) != 0) { diff --git a/src/main/java/net/java/dev/typecast/ot/table/GaspTable.java b/src/main/java/net/java/dev/typecast/ot/table/GaspTable.java index d34367d..9dbf642 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GaspTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GaspTable.java @@ -32,7 +32,7 @@ public class GaspTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'gasp' Table - Grid-fitting And Scan-conversion Procedure\n---------------------------------------------------------"); sb.append("\n 'gasp' version: ").append(version); sb.append("\n numRanges: ").append(numRanges); diff --git a/src/main/java/net/java/dev/typecast/ot/table/GdefTable.java b/src/main/java/net/java/dev/typecast/ot/table/GdefTable.java index 0b3a65b..9e243f6 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GdefTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GdefTable.java @@ -7,7 +7,7 @@ import java.io.IOException; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class GdefTable implements Table { +class GdefTable implements Table { protected GdefTable(DataInput di) throws IOException { } diff --git a/src/main/java/net/java/dev/typecast/ot/table/GlyfCompositeComp.java b/src/main/java/net/java/dev/typecast/ot/table/GlyfCompositeComp.java index b6cc120..7792b05 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GlyfCompositeComp.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GlyfCompositeComp.java @@ -58,18 +58,18 @@ import java.io.IOException; */ public class GlyfCompositeComp { - public static final short ARG_1_AND_2_ARE_WORDS = 0x0001; - public static final short ARGS_ARE_XY_VALUES = 0x0002; + private static final short ARG_1_AND_2_ARE_WORDS = 0x0001; + private static final short ARGS_ARE_XY_VALUES = 0x0002; public static final short ROUND_XY_TO_GRID = 0x0004; - public static final short WE_HAVE_A_SCALE = 0x0008; + private static final short WE_HAVE_A_SCALE = 0x0008; public static final short MORE_COMPONENTS = 0x0020; - public static final short WE_HAVE_AN_X_AND_Y_SCALE = 0x0040; - public static final short WE_HAVE_A_TWO_BY_TWO = 0x0080; + private static final short WE_HAVE_AN_X_AND_Y_SCALE = 0x0040; + private static final short WE_HAVE_A_TWO_BY_TWO = 0x0080; public static final short WE_HAVE_INSTRUCTIONS = 0x0100; public static final short USE_MY_METRICS = 0x0200; - private int _firstIndex; - private int _firstContour; + private final int _firstIndex; + private final int _firstContour; private short _argument1; private short _argument2; private int _flags; @@ -83,7 +83,7 @@ public class GlyfCompositeComp { private int _point1 = 0; private int _point2 = 0; - protected GlyfCompositeComp(int firstIndex, int firstContour, DataInput di) + GlyfCompositeComp(int firstIndex, int firstContour, DataInput di) throws IOException { _firstIndex = firstIndex; _firstContour = firstContour; @@ -95,8 +95,8 @@ public class GlyfCompositeComp { _argument1 = di.readShort(); _argument2 = di.readShort(); } else { - _argument1 = (short) di.readByte(); - _argument2 = (short) di.readByte(); + _argument1 = di.readByte(); + _argument2 = di.readByte(); } // Assign the arguments according to the flags diff --git a/src/main/java/net/java/dev/typecast/ot/table/GlyfCompositeDescript.java b/src/main/java/net/java/dev/typecast/ot/table/GlyfCompositeDescript.java index d5a73db..05f3b77 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GlyfCompositeDescript.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GlyfCompositeDescript.java @@ -64,8 +64,8 @@ import java.util.ArrayList; */ public class GlyfCompositeDescript extends GlyfDescript { - private ArrayList<GlyfCompositeComp> _components = - new ArrayList<GlyfCompositeComp>(); + private final ArrayList<GlyfCompositeComp> _components = + new ArrayList<>(); public GlyfCompositeDescript( GlyfTable parentTable, @@ -77,24 +77,18 @@ public class GlyfCompositeDescript extends GlyfDescript { GlyfCompositeComp comp; int firstIndex = 0; int firstContour = 0; - try { - do { - _components.add(comp = new GlyfCompositeComp(firstIndex, firstContour, di)); - GlyfDescript desc = parentTable.getDescription(comp.getGlyphIndex()); - if (desc != null) { - firstIndex += desc.getPointCount(); - firstContour += desc.getContourCount(); - } - } while ((comp.getFlags() & GlyfCompositeComp.MORE_COMPONENTS) != 0); - - // Are there hinting intructions to read? - if ((comp.getFlags() & GlyfCompositeComp.WE_HAVE_INSTRUCTIONS) != 0) { - readInstructions(di, di.readShort()); + do { + _components.add(comp = new GlyfCompositeComp(firstIndex, firstContour, di)); + GlyfDescript desc = parentTable.getDescription(comp.getGlyphIndex()); + if (desc != null) { + firstIndex += desc.getPointCount(); + firstContour += desc.getContourCount(); } - } catch (IOException e) { - throw e; -// } catch (Exception e) { -// int foo = 0; + } while ((comp.getFlags() & GlyfCompositeComp.MORE_COMPONENTS) != 0); + + // Are there hinting intructions to read? + if ((comp.getFlags() & GlyfCompositeComp.WE_HAVE_INSTRUCTIONS) != 0) { + readInstructions(di, di.readShort()); } } @@ -175,10 +169,10 @@ public class GlyfCompositeDescript extends GlyfDescript { return _components.get(i); } - protected GlyfCompositeComp getCompositeComp(int i) { + private GlyfCompositeComp getCompositeComp(int i) { GlyfCompositeComp c; - for (int n = 0; n < _components.size(); n++) { - c = _components.get(n); + for (GlyfCompositeComp component : _components) { + c = component; GlyphDescription gd = _parentTable.getDescription(c.getGlyphIndex()); if (c.getFirstIndex() <= i && i < (c.getFirstIndex() + gd.getPointCount())) { return c; @@ -187,10 +181,10 @@ public class GlyfCompositeDescript extends GlyfDescript { return null; } - protected GlyfCompositeComp getCompositeCompEndPt(int i) { + private GlyfCompositeComp getCompositeCompEndPt(int i) { GlyfCompositeComp c; - for (int j = 0; j < _components.size(); j++) { - c = _components.get(j); + for (GlyfCompositeComp component : _components) { + c = component; GlyphDescription gd = _parentTable.getDescription(c.getGlyphIndex()); if (c.getFirstContour() <= i && i < (c.getFirstContour() + gd.getContourCount())) { return c; diff --git a/src/main/java/net/java/dev/typecast/ot/table/GlyfDescript.java b/src/main/java/net/java/dev/typecast/ot/table/GlyfDescript.java index 1d2669e..ce6080c 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GlyfDescript.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GlyfDescript.java @@ -60,21 +60,21 @@ public abstract class GlyfDescript extends Program implements GlyphDescription { // flags public static final byte onCurve = 0x01; - public static final byte xShortVector = 0x02; - public static final byte yShortVector = 0x04; - public static final byte repeat = 0x08; - public static final byte xDual = 0x10; - public static final byte yDual = 0x20; + static final byte xShortVector = 0x02; + static final byte yShortVector = 0x04; + static final byte repeat = 0x08; + static final byte xDual = 0x10; + static final byte yDual = 0x20; - protected GlyfTable _parentTable; + final GlyfTable _parentTable; private int _glyphIndex; - private int _numberOfContours; + private final int _numberOfContours; private short _xMin; private short _yMin; private short _xMax; private short _yMax; - protected GlyfDescript( + GlyfDescript( GlyfTable parentTable, int glyphIndex, short numberOfContours, @@ -87,7 +87,7 @@ public abstract class GlyfDescript extends Program implements GlyphDescription { _yMax = di.readShort(); } - public int getNumberOfContours() { + int getNumberOfContours() { return _numberOfContours; } @@ -112,12 +112,10 @@ public abstract class GlyfDescript extends Program implements GlyphDescription { } public String toString() { - return new StringBuffer() - .append(" numberOfContours: ").append(_numberOfContours) - .append("\n xMin: ").append(_xMin) - .append("\n yMin: ").append(_yMin) - .append("\n xMax: ").append(_xMax) - .append("\n yMax: ").append(_yMax) - .toString(); + return " numberOfContours: " + _numberOfContours + + "\n xMin: " + _xMin + + "\n yMin: " + _yMin + + "\n xMax: " + _xMax + + "\n yMax: " + _yMax; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/GlyfSimpleDescript.java b/src/main/java/net/java/dev/typecast/ot/table/GlyfSimpleDescript.java index 0e82135..192ff33 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GlyfSimpleDescript.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GlyfSimpleDescript.java @@ -184,7 +184,7 @@ public class GlyfSimpleDescript extends GlyfDescript { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("\n\n EndPoints\n ---------"); for (int i = 0; i < _endPtsOfContours.length; i++) { diff --git a/src/main/java/net/java/dev/typecast/ot/table/GlyfTable.java b/src/main/java/net/java/dev/typecast/ot/table/GlyfTable.java index 266bd47..791dfa0 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GlyfTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GlyfTable.java @@ -60,7 +60,7 @@ import java.io.IOException; */ public class GlyfTable implements Table { - private GlyfDescript[] _descript; + private final GlyfDescript[] _descript; public GlyfTable( DataInput di, diff --git a/src/main/java/net/java/dev/typecast/ot/table/GlyphDescription.java b/src/main/java/net/java/dev/typecast/ot/table/GlyphDescription.java index 3939192..371ce63 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GlyphDescription.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GlyphDescription.java @@ -56,29 +56,29 @@ package net.java.dev.typecast.ot.table; */ public interface GlyphDescription { - public int getGlyphIndex(); + int getGlyphIndex(); - public int getEndPtOfContours(int i); + int getEndPtOfContours(int i); - public byte getFlags(int i); + byte getFlags(int i); - public short getXCoordinate(int i); + short getXCoordinate(int i); - public short getYCoordinate(int i); + short getYCoordinate(int i); - public short getXMaximum(); + short getXMaximum(); - public short getXMinimum(); + short getXMinimum(); - public short getYMaximum(); + short getYMaximum(); - public short getYMinimum(); + short getYMinimum(); - public boolean isComposite(); + boolean isComposite(); - public int getPointCount(); + int getPointCount(); - public int getContourCount(); + int getContourCount(); // public int getComponentIndex(int c); // public int getComponentCount(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/GposTable.java b/src/main/java/net/java/dev/typecast/ot/table/GposTable.java index 1399480..b49b0a0 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/GposTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/GposTable.java @@ -25,7 +25,7 @@ import java.io.IOException; * TODO: To be implemented * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class GposTable implements Table { +class GposTable implements Table { protected GposTable(DataInput di) throws IOException { diff --git a/src/main/java/net/java/dev/typecast/ot/table/HdmxTable.java b/src/main/java/net/java/dev/typecast/ot/table/HdmxTable.java index 25e11a8..72e8bbf 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/HdmxTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/HdmxTable.java @@ -28,13 +28,13 @@ import java.io.IOException; */ public class HdmxTable implements Table { - public class DeviceRecord { + static class DeviceRecord { private short _pixelSize; private short _maxWidth; private short[] _widths; - protected DeviceRecord(int numGlyphs, DataInput di) throws IOException { + DeviceRecord(int numGlyphs, DataInput di) throws IOException { _pixelSize = di.readByte(); _maxWidth = di.readByte(); _widths = new short[numGlyphs]; @@ -43,15 +43,15 @@ public class HdmxTable implements Table { } } - public short getPixelSize() { + short getPixelSize() { return _pixelSize; } - public short getMaxWidth() { + short getMaxWidth() { return _maxWidth; } - public short[] getWidths() { + short[] getWidths() { return _widths; } } @@ -78,7 +78,7 @@ public class HdmxTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'hdmx' Table - Horizontal Device Metrics\n----------------------------------------\n"); sb.append("Size = ").append(_length).append(" bytes\n") .append("\t'hdmx' version: ").append(_version).append("\n") diff --git a/src/main/java/net/java/dev/typecast/ot/table/HeadTable.java b/src/main/java/net/java/dev/typecast/ot/table/HeadTable.java index f2eddf1..7527ce6 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/HeadTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/HeadTable.java @@ -167,26 +167,24 @@ public class HeadTable implements Table { } public String toString() { - return new StringBuffer() - .append("'head' Table - Font Header\n--------------------------") - .append("\n 'head' version: ").append(Fixed.floatValue(_versionNumber)) - .append("\n fontRevision: ").append(Fixed.roundedFloatValue(_fontRevision, 8)) - .append("\n checkSumAdjustment: 0x").append(Integer.toHexString(_checkSumAdjustment).toUpperCase()) - .append("\n magicNumber: 0x").append(Integer.toHexString(_magicNumber).toUpperCase()) - .append("\n flags: 0x").append(Integer.toHexString(_flags).toUpperCase()) - .append("\n unitsPerEm: ").append(_unitsPerEm) - .append("\n created: ").append(_created) - .append("\n modified: ").append(_modified) - .append("\n xMin: ").append(_xMin) - .append("\n yMin: ").append(_yMin) - .append("\n xMax: ").append(_xMax) - .append("\n yMax: ").append(_yMax) - .append("\n macStyle bits: ").append(Integer.toHexString(_macStyle).toUpperCase()) - .append("\n lowestRecPPEM: ").append(_lowestRecPPEM) - .append("\n fontDirectionHint: ").append(_fontDirectionHint) - .append("\n indexToLocFormat: ").append(_indexToLocFormat) - .append("\n glyphDataFormat: ").append(_glyphDataFormat) - .toString(); + return "'head' Table - Font Header\n--------------------------" + + "\n 'head' version: " + Fixed.floatValue(_versionNumber) + + "\n fontRevision: " + Fixed.roundedFloatValue(_fontRevision, 8) + + "\n checkSumAdjustment: 0x" + Integer.toHexString(_checkSumAdjustment).toUpperCase() + + "\n magicNumber: 0x" + Integer.toHexString(_magicNumber).toUpperCase() + + "\n flags: 0x" + Integer.toHexString(_flags).toUpperCase() + + "\n unitsPerEm: " + _unitsPerEm + + "\n created: " + _created + + "\n modified: " + _modified + + "\n xMin: " + _xMin + + "\n yMin: " + _yMin + + "\n xMax: " + _xMax + + "\n yMax: " + _yMax + + "\n macStyle bits: " + Integer.toHexString(_macStyle).toUpperCase() + + "\n lowestRecPPEM: " + _lowestRecPPEM + + "\n fontDirectionHint: " + _fontDirectionHint + + "\n indexToLocFormat: " + _indexToLocFormat + + "\n glyphDataFormat: " + _glyphDataFormat; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/HheaTable.java b/src/main/java/net/java/dev/typecast/ot/table/HheaTable.java index 25f50ec..946353e 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/HheaTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/HheaTable.java @@ -93,26 +93,24 @@ public class HheaTable implements Table { } public String toString() { - return new StringBuffer() - .append("'hhea' Table - Horizontal Header\n--------------------------------") - .append("\n 'hhea' version: ").append(Fixed.floatValue(version)) - .append("\n yAscender: ").append(ascender) - .append("\n yDescender: ").append(descender) - .append("\n yLineGap: ").append(lineGap) - .append("\n advanceWidthMax: ").append(advanceWidthMax) - .append("\n minLeftSideBearing: ").append(minLeftSideBearing) - .append("\n minRightSideBearing: ").append(minRightSideBearing) - .append("\n xMaxExtent: ").append(xMaxExtent) - .append("\n horizCaretSlopeNum: ").append(caretSlopeRise) - .append("\n horizCaretSlopeDenom: ").append(caretSlopeRun) - .append("\n reserved0: 0") - .append("\n reserved1: 0") - .append("\n reserved2: 0") - .append("\n reserved3: 0") - .append("\n reserved4: 0") - .append("\n metricDataFormat: ").append(metricDataFormat) - .append("\n numOf_LongHorMetrics: ").append(numberOfHMetrics) - .toString(); + return "'hhea' Table - Horizontal Header\n--------------------------------" + + "\n 'hhea' version: " + Fixed.floatValue(version) + + "\n yAscender: " + ascender + + "\n yDescender: " + descender + + "\n yLineGap: " + lineGap + + "\n advanceWidthMax: " + advanceWidthMax + + "\n minLeftSideBearing: " + minLeftSideBearing + + "\n minRightSideBearing: " + minRightSideBearing + + "\n xMaxExtent: " + xMaxExtent + + "\n horizCaretSlopeNum: " + caretSlopeRise + + "\n horizCaretSlopeDenom: " + caretSlopeRun + + "\n reserved0: 0" + + "\n reserved1: 0" + + "\n reserved2: 0" + + "\n reserved3: 0" + + "\n reserved4: 0" + + "\n metricDataFormat: " + metricDataFormat + + "\n numOf_LongHorMetrics: " + numberOfHMetrics; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/HmtxTable.java b/src/main/java/net/java/dev/typecast/ot/table/HmtxTable.java index 8e2bdd4..bb50656 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/HmtxTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/HmtxTable.java @@ -58,8 +58,8 @@ import java.io.IOException; */ public class HmtxTable implements Table { - private int[] _hMetrics = null; - private short[] _leftSideBearing = null; + private int[] _hMetrics; + private short[] _leftSideBearing; private int _length; public HmtxTable( @@ -106,7 +106,7 @@ public class HmtxTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'hmtx' Table - Horizontal Metrics\n---------------------------------\n"); sb.append("Size = ").append(_length).append(" bytes, ") .append(_hMetrics.length).append(" entries\n"); diff --git a/src/main/java/net/java/dev/typecast/ot/table/ID.java b/src/main/java/net/java/dev/typecast/ot/table/ID.java index 1fdac60..e51f2fb 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/ID.java +++ b/src/main/java/net/java/dev/typecast/ot/table/ID.java @@ -31,164 +31,164 @@ public abstract class ID { public static final short platformMicrosoft = 3; // Unicode Encoding IDs - public static final short encodingUnicode10Semantics = 0; - public static final short encodingUnicode11Semantics = 1; - public static final short encodingISO10646Semantics = 2; - public static final short encodingUnicode20SemanticsBMPOnly = 3; - public static final short encodingUnicode20Semantics = 4; - public static final short encodingUnicodeVariationSequences = 5; - public static final short encodingFullUnicodeCoverage = 6; + private static final short encodingUnicode10Semantics = 0; + private static final short encodingUnicode11Semantics = 1; + private static final short encodingISO10646Semantics = 2; + private static final short encodingUnicode20SemanticsBMPOnly = 3; + private static final short encodingUnicode20Semantics = 4; + private static final short encodingUnicodeVariationSequences = 5; + private static final short encodingFullUnicodeCoverage = 6; // Microsoft Encoding IDs // public static final short encodingUndefined = 0; // public static final short encodingUGL = 1; public static final short encodingSymbol = 0; public static final short encodingUnicode = 1; - public static final short encodingShiftJIS = 2; - public static final short encodingPRC = 3; - public static final short encodingBig5 = 4; - public static final short encodingWansung = 5; - public static final short encodingJohab = 6; - public static final short encodingUCS4 = 10; + private static final short encodingShiftJIS = 2; + private static final short encodingPRC = 3; + private static final short encodingBig5 = 4; + private static final short encodingWansung = 5; + private static final short encodingJohab = 6; + private static final short encodingUCS4 = 10; // Macintosh Encoding IDs public static final short encodingRoman = 0; - public static final short encodingJapanese = 1; - public static final short encodingChinese = 2; - public static final short encodingKorean = 3; - public static final short encodingArabic = 4; - public static final short encodingHebrew = 5; - public static final short encodingGreek = 6; - public static final short encodingRussian = 7; - public static final short encodingRSymbol = 8; - public static final short encodingDevanagari = 9; - public static final short encodingGurmukhi = 10; - public static final short encodingGujarati = 11; - public static final short encodingOriya = 12; - public static final short encodingBengali = 13; - public static final short encodingTamil = 14; - public static final short encodingTelugu = 15; - public static final short encodingKannada = 16; - public static final short encodingMalayalam = 17; - public static final short encodingSinhalese = 18; - public static final short encodingBurmese = 19; - public static final short encodingKhmer = 20; - public static final short encodingThai = 21; - public static final short encodingLaotian = 22; - public static final short encodingGeorgian = 23; - public static final short encodingArmenian = 24; - public static final short encodingMaldivian = 25; - public static final short encodingTibetan = 26; - public static final short encodingMongolian = 27; - public static final short encodingGeez = 28; - public static final short encodingSlavic = 29; - public static final short encodingVietnamese = 30; - public static final short encodingSindhi = 31; - public static final short encodingUninterp = 32; + private static final short encodingJapanese = 1; + private static final short encodingChinese = 2; + private static final short encodingKorean = 3; + private static final short encodingArabic = 4; + private static final short encodingHebrew = 5; + private static final short encodingGreek = 6; + private static final short encodingRussian = 7; + private static final short encodingRSymbol = 8; + private static final short encodingDevanagari = 9; + private static final short encodingGurmukhi = 10; + private static final short encodingGujarati = 11; + private static final short encodingOriya = 12; + private static final short encodingBengali = 13; + private static final short encodingTamil = 14; + private static final short encodingTelugu = 15; + private static final short encodingKannada = 16; + private static final short encodingMalayalam = 17; + private static final short encodingSinhalese = 18; + private static final short encodingBurmese = 19; + private static final short encodingKhmer = 20; + private static final short encodingThai = 21; + private static final short encodingLaotian = 22; + private static final short encodingGeorgian = 23; + private static final short encodingArmenian = 24; + private static final short encodingMaldivian = 25; + private static final short encodingTibetan = 26; + private static final short encodingMongolian = 27; + private static final short encodingGeez = 28; + private static final short encodingSlavic = 29; + private static final short encodingVietnamese = 30; + private static final short encodingSindhi = 31; + private static final short encodingUninterp = 32; // ISO Encoding IDs - public static final short encodingASCII = 0; - public static final short encodingISO10646 = 1; - public static final short encodingISO8859_1 = 2; + private static final short encodingASCII = 0; + private static final short encodingISO10646 = 1; + private static final short encodingISO8859_1 = 2; // Microsoft Language IDs - public static final short languageSQI = 0x041c; - public static final short languageEUQ = 0x042d; - public static final short languageBEL = 0x0423; - public static final short languageBGR = 0x0402; - public static final short languageCAT = 0x0403; - public static final short languageSHL = 0x041a; - public static final short languageCSY = 0x0405; - public static final short languageDAN = 0x0406; - public static final short languageNLD = 0x0413; - public static final short languageNLB = 0x0813; - public static final short languageENU = 0x0409; - public static final short languageENG = 0x0809; - public static final short languageENA = 0x0c09; - public static final short languageENC = 0x1009; - public static final short languageENZ = 0x1409; - public static final short languageENI = 0x1809; - public static final short languageETI = 0x0425; - public static final short languageFIN = 0x040b; - public static final short languageFRA = 0x040c; - public static final short languageFRB = 0x080c; - public static final short languageFRC = 0x0c0c; - public static final short languageFRS = 0x100c; - public static final short languageFRL = 0x140c; - public static final short languageDEU = 0x0407; - public static final short languageDES = 0x0807; - public static final short languageDEA = 0x0c07; - public static final short languageDEL = 0x1007; - public static final short languageDEC = 0x1407; - public static final short languageELL = 0x0408; - public static final short languageHUN = 0x040e; - public static final short languageISL = 0x040f; - public static final short languageITA = 0x0410; - public static final short languageITS = 0x0810; - public static final short languageLVI = 0x0426; - public static final short languageLTH = 0x0427; - public static final short languageNOR = 0x0414; - public static final short languageNON = 0x0814; - public static final short languagePLK = 0x0415; - public static final short languagePTB = 0x0416; - public static final short languagePTG = 0x0816; - public static final short languageROM = 0x0418; - public static final short languageRUS = 0x0419; - public static final short languageSKY = 0x041b; - public static final short languageSLV = 0x0424; - public static final short languageESP = 0x040a; - public static final short languageESM = 0x080a; - public static final short languageESN = 0x0c0a; - public static final short languageSVE = 0x041d; - public static final short languageTRK = 0x041f; - public static final short languageUKR = 0x0422; + private static final short languageSQI = 0x041c; + private static final short languageEUQ = 0x042d; + private static final short languageBEL = 0x0423; + private static final short languageBGR = 0x0402; + private static final short languageCAT = 0x0403; + private static final short languageSHL = 0x041a; + private static final short languageCSY = 0x0405; + private static final short languageDAN = 0x0406; + private static final short languageNLD = 0x0413; + private static final short languageNLB = 0x0813; + private static final short languageENU = 0x0409; + private static final short languageENG = 0x0809; + private static final short languageENA = 0x0c09; + private static final short languageENC = 0x1009; + private static final short languageENZ = 0x1409; + private static final short languageENI = 0x1809; + private static final short languageETI = 0x0425; + private static final short languageFIN = 0x040b; + private static final short languageFRA = 0x040c; + private static final short languageFRB = 0x080c; + private static final short languageFRC = 0x0c0c; + private static final short languageFRS = 0x100c; + private static final short languageFRL = 0x140c; + private static final short languageDEU = 0x0407; + private static final short languageDES = 0x0807; + private static final short languageDEA = 0x0c07; + private static final short languageDEL = 0x1007; + private static final short languageDEC = 0x1407; + private static final short languageELL = 0x0408; + private static final short languageHUN = 0x040e; + private static final short languageISL = 0x040f; + private static final short languageITA = 0x0410; + private static final short languageITS = 0x0810; + private static final short languageLVI = 0x0426; + private static final short languageLTH = 0x0427; + private static final short languageNOR = 0x0414; + private static final short languageNON = 0x0814; + private static final short languagePLK = 0x0415; + private static final short languagePTB = 0x0416; + private static final short languagePTG = 0x0816; + private static final short languageROM = 0x0418; + private static final short languageRUS = 0x0419; + private static final short languageSKY = 0x041b; + private static final short languageSLV = 0x0424; + private static final short languageESP = 0x040a; + private static final short languageESM = 0x080a; + private static final short languageESN = 0x0c0a; + private static final short languageSVE = 0x041d; + private static final short languageTRK = 0x041f; + private static final short languageUKR = 0x0422; // Macintosh Language IDs - public static final short languageEnglish = 0; - public static final short languageFrench = 1; - public static final short languageGerman = 2; - public static final short languageItalian = 3; - public static final short languageDutch = 4; - public static final short languageSwedish = 5; - public static final short languageSpanish = 6; - public static final short languageDanish = 7; - public static final short languagePortuguese = 8; - public static final short languageNorwegian = 9; - public static final short languageHebrew = 10; - public static final short languageJapanese = 11; - public static final short languageArabic = 12; - public static final short languageFinnish = 13; - public static final short languageGreek = 14; - public static final short languageIcelandic = 15; - public static final short languageMaltese = 16; - public static final short languageTurkish = 17; - public static final short languageYugoslavian = 18; - public static final short languageChinese = 19; - public static final short languageUrdu = 20; - public static final short languageHindi = 21; - public static final short languageThai = 22; + private static final short languageEnglish = 0; + private static final short languageFrench = 1; + private static final short languageGerman = 2; + private static final short languageItalian = 3; + private static final short languageDutch = 4; + private static final short languageSwedish = 5; + private static final short languageSpanish = 6; + private static final short languageDanish = 7; + private static final short languagePortuguese = 8; + private static final short languageNorwegian = 9; + private static final short languageHebrew = 10; + private static final short languageJapanese = 11; + private static final short languageArabic = 12; + private static final short languageFinnish = 13; + private static final short languageGreek = 14; + private static final short languageIcelandic = 15; + private static final short languageMaltese = 16; + private static final short languageTurkish = 17; + private static final short languageYugoslavian = 18; + private static final short languageChinese = 19; + private static final short languageUrdu = 20; + private static final short languageHindi = 21; + private static final short languageThai = 22; // Name IDs - public static final short nameCopyrightNotice = 0; + private static final short nameCopyrightNotice = 0; public static final short nameFontFamilyName = 1; - public static final short nameFontSubfamilyName = 2; - public static final short nameUniqueFontIdentifier = 3; - public static final short nameFullFontName = 4; - public static final short nameVersionString = 5; - public static final short namePostscriptName = 6; - public static final short nameTrademark = 7; - public static final short nameManufacturerName = 8; - public static final short nameDesigner = 9; - public static final short nameDescription = 10; - public static final short nameURLVendor = 11; - public static final short nameURLDesigner = 12; - public static final short nameLicenseDescription = 13; - public static final short nameLicenseInfoURL = 14; - public static final short namePreferredFamily = 16; - public static final short namePreferredSubfamily = 17; - public static final short nameCompatibleFull = 18; - public static final short nameSampleText = 19; - public static final short namePostScriptCIDFindfontName = 20; + private static final short nameFontSubfamilyName = 2; + private static final short nameUniqueFontIdentifier = 3; + private static final short nameFullFontName = 4; + private static final short nameVersionString = 5; + private static final short namePostscriptName = 6; + private static final short nameTrademark = 7; + private static final short nameManufacturerName = 8; + private static final short nameDesigner = 9; + private static final short nameDescription = 10; + private static final short nameURLVendor = 11; + private static final short nameURLDesigner = 12; + private static final short nameLicenseDescription = 13; + private static final short nameLicenseInfoURL = 14; + private static final short namePreferredFamily = 16; + private static final short namePreferredSubfamily = 17; + private static final short nameCompatibleFull = 18; + private static final short nameSampleText = 19; + private static final short namePostScriptCIDFindfontName = 20; public static String getPlatformName(short platformId) { switch (platformId) { diff --git a/src/main/java/net/java/dev/typecast/ot/table/KernSubtable.java b/src/main/java/net/java/dev/typecast/ot/table/KernSubtable.java index 9b31dbc..a14356b 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/KernSubtable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/KernSubtable.java @@ -18,7 +18,7 @@ import java.io.IOException; public abstract class KernSubtable { /** Creates new KernSubtable */ - protected KernSubtable() { + KernSubtable() { } public abstract int getKerningPairCount(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/KernSubtableFormat0.java b/src/main/java/net/java/dev/typecast/ot/table/KernSubtableFormat0.java index 9cad4a5..a60975b 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/KernSubtableFormat0.java +++ b/src/main/java/net/java/dev/typecast/ot/table/KernSubtableFormat0.java @@ -24,7 +24,7 @@ public class KernSubtableFormat0 extends KernSubtable { private KerningPair[] kerningPairs; /** Creates new KernSubtableFormat0 */ - protected KernSubtableFormat0(DataInput di) throws IOException { + KernSubtableFormat0(DataInput di) throws IOException { nPairs = di.readUnsignedShort(); searchRange = di.readUnsignedShort(); entrySelector = di.readUnsignedShort(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/KernSubtableFormat2.java b/src/main/java/net/java/dev/typecast/ot/table/KernSubtableFormat2.java index 95dbea1..ab4809c 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/KernSubtableFormat2.java +++ b/src/main/java/net/java/dev/typecast/ot/table/KernSubtableFormat2.java @@ -23,7 +23,7 @@ public class KernSubtableFormat2 extends KernSubtable { private int array; /** Creates new KernSubtableFormat2 */ - protected KernSubtableFormat2(DataInput di) throws IOException { + KernSubtableFormat2(DataInput di) throws IOException { rowWidth = di.readUnsignedShort(); leftClassTable = di.readUnsignedShort(); rightClassTable = di.readUnsignedShort(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/KerningPair.java b/src/main/java/net/java/dev/typecast/ot/table/KerningPair.java index 366343a..f059df7 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/KerningPair.java +++ b/src/main/java/net/java/dev/typecast/ot/table/KerningPair.java @@ -22,7 +22,7 @@ public class KerningPair { private short value; /** Creates new KerningPair */ - protected KerningPair(DataInput di) throws IOException { + KerningPair(DataInput di) throws IOException { left = di.readUnsignedShort(); right = di.readUnsignedShort(); value = di.readShort(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/LangSys.java b/src/main/java/net/java/dev/typecast/ot/table/LangSys.java index 2cb1ef6..d06781e 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/LangSys.java +++ b/src/main/java/net/java/dev/typecast/ot/table/LangSys.java @@ -65,7 +65,7 @@ public class LangSys { private int[] _featureIndex; /** Creates new LangSys */ - protected LangSys(DataInput di) throws IOException { + LangSys(DataInput di) throws IOException { _lookupOrder = di.readUnsignedShort(); _reqFeatureIndex = di.readUnsignedShort(); _featureCount = di.readUnsignedShort(); @@ -91,7 +91,7 @@ public class LangSys { return _featureIndex[i]; } - protected boolean isFeatureIndexed(int n) { + boolean isFeatureIndexed(int n) { for (int i = 0; i < _featureCount; i++) { if (_featureIndex[i] == n) { return true; diff --git a/src/main/java/net/java/dev/typecast/ot/table/LangSysRecord.java b/src/main/java/net/java/dev/typecast/ot/table/LangSysRecord.java index a105c3d..aef42ef 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/LangSysRecord.java +++ b/src/main/java/net/java/dev/typecast/ot/table/LangSysRecord.java @@ -77,11 +77,9 @@ public class LangSysRecord { } public String getTagAsString() { - return new StringBuffer() - .append((char)((_tag>>24)&0xff)) - .append((char)((_tag>>16)&0xff)) - .append((char)((_tag>>8)&0xff)) - .append((char)((_tag)&0xff)) - .toString(); + return String.valueOf((char) ((_tag >> 24) & 0xff)) + + (char) ((_tag >> 16) & 0xff) + + (char) ((_tag >> 8) & 0xff) + + (char) ((_tag) & 0xff); } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/Ligature.java b/src/main/java/net/java/dev/typecast/ot/table/Ligature.java index 2dd3783..6f9b6d2 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Ligature.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Ligature.java @@ -57,7 +57,7 @@ import java.io.IOException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class Ligature { +class Ligature { private int _ligGlyph; private int _compCount; diff --git a/src/main/java/net/java/dev/typecast/ot/table/LigatureSet.java b/src/main/java/net/java/dev/typecast/ot/table/LigatureSet.java index 4eab7bd..2b416bd 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/LigatureSet.java +++ b/src/main/java/net/java/dev/typecast/ot/table/LigatureSet.java @@ -57,7 +57,7 @@ import java.io.IOException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class LigatureSet { +class LigatureSet { private int _ligatureCount; private int[] _ligatureOffsets; diff --git a/src/main/java/net/java/dev/typecast/ot/table/LigatureSubstFormat1.java b/src/main/java/net/java/dev/typecast/ot/table/LigatureSubstFormat1.java index 4ba4f66..863e4b6 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/LigatureSubstFormat1.java +++ b/src/main/java/net/java/dev/typecast/ot/table/LigatureSubstFormat1.java @@ -66,7 +66,7 @@ public class LigatureSubstFormat1 extends LigatureSubst { private LigatureSet[] _ligatureSets; /** Creates new LigatureSubstFormat1 */ - protected LigatureSubstFormat1( + LigatureSubstFormat1( DataInputStream dis, int offset) throws IOException { _coverageOffset = dis.readUnsignedShort(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/LocaTable.java b/src/main/java/net/java/dev/typecast/ot/table/LocaTable.java index 158afff..84ddee0 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/LocaTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/LocaTable.java @@ -18,11 +18,11 @@ import org.slf4j.LoggerFactory; */ public class LocaTable implements Table { - private int[] _offsets = null; - private short _factor = 0; + private int[] _offsets; + private short _factor; private int _length; - static final Logger logger = LoggerFactory.getLogger(LocaTable.class); + private static final Logger logger = LoggerFactory.getLogger(LocaTable.class); public LocaTable( DataInput di, diff --git a/src/main/java/net/java/dev/typecast/ot/table/LookupSubtableFactory.java b/src/main/java/net/java/dev/typecast/ot/table/LookupSubtableFactory.java index fcaa642..026d3eb 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/LookupSubtableFactory.java +++ b/src/main/java/net/java/dev/typecast/ot/table/LookupSubtableFactory.java @@ -57,7 +57,7 @@ import java.io.IOException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public interface LookupSubtableFactory { - public LookupSubtable read(int type, DataInputStream dis, int offset) +interface LookupSubtableFactory { + LookupSubtable read(int type, DataInputStream dis, int offset) throws IOException; } diff --git a/src/main/java/net/java/dev/typecast/ot/table/LtshTable.java b/src/main/java/net/java/dev/typecast/ot/table/LtshTable.java index abf75fe..c09a10d 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/LtshTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/LtshTable.java @@ -15,7 +15,7 @@ import java.io.IOException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class LtshTable implements Table { +class LtshTable implements Table { private int version; private int numGlyphs; @@ -32,7 +32,7 @@ public class LtshTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'LTSH' Table - Linear Threshold Table\n-------------------------------------") .append("\n 'LTSH' Version: ").append(version) .append("\n Number of Glyphs: ").append(numGlyphs) diff --git a/src/main/java/net/java/dev/typecast/ot/table/MaxpTable.java b/src/main/java/net/java/dev/typecast/ot/table/MaxpTable.java index 2a71a54..f23cf4d 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/MaxpTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/MaxpTable.java @@ -118,7 +118,7 @@ public class MaxpTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'maxp' Table - Maximum Profile\n------------------------------") .append("\n 'maxp' version: ").append(Fixed.floatValue(versionNumber)) .append("\n numGlyphs: ").append(numGlyphs); diff --git a/src/main/java/net/java/dev/typecast/ot/table/NameRecord.java b/src/main/java/net/java/dev/typecast/ot/table/NameRecord.java index 65fb8f8..862380a 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/NameRecord.java +++ b/src/main/java/net/java/dev/typecast/ot/table/NameRecord.java @@ -66,7 +66,7 @@ public class NameRecord { private short _stringOffset; private String _record; - protected NameRecord(DataInput di) throws IOException { + NameRecord(DataInput di) throws IOException { _platformId = di.readShort(); _encodingId = di.readShort(); _languageId = di.readShort(); @@ -95,8 +95,8 @@ public class NameRecord { return _record; } - protected void loadString(DataInput di) throws IOException { - StringBuffer sb = new StringBuffer(); + void loadString(DataInput di) throws IOException { + StringBuilder sb = new StringBuilder(); di.skipBytes(_stringOffset); if (_platformId == ID.platformUnicode) { @@ -129,16 +129,14 @@ public class NameRecord { } public String toString() { - StringBuffer sb = new StringBuffer(); - - sb.append(" Platform ID: ").append(_platformId) - .append("\n Specific ID: ").append(_encodingId) - .append("\n Language ID: ").append(_languageId) - .append("\n Name ID: ").append(_nameId) - .append("\n Length: ").append(_stringLength) - .append("\n Offset: ").append(_stringOffset) - .append("\n\n").append(_record); - - return sb.toString(); + + String sb = " Platform ID: " + _platformId + + "\n Specific ID: " + _encodingId + + "\n Language ID: " + _languageId + + "\n Name ID: " + _nameId + + "\n Length: " + _stringLength + + "\n Offset: " + _stringOffset + + "\n\n" + _record; + return sb; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/Os2Table.java b/src/main/java/net/java/dev/typecast/ot/table/Os2Table.java index 6882994..8d3a8a1 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Os2Table.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Os2Table.java @@ -52,7 +52,6 @@ package net.java.dev.typecast.ot.table; import java.io.DataInput; import java.io.IOException; -import net.java.dev.typecast.ot.Fixed; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> @@ -292,51 +291,47 @@ public class Os2Table implements Table { } public String toString() { - return new StringBuffer() - .append("'OS/2' Table - OS/2 and Windows Metrics\n---------------------------------------") - .append("\n 'OS/2' version: ").append(_version) - .append("\n xAvgCharWidth: ").append(_xAvgCharWidth) - .append("\n usWeightClass: ").append(_usWeightClass) - .append("\n usWidthClass: ").append(_usWidthClass) - .append("\n fsType: 0x").append(Integer.toHexString(_fsType).toUpperCase()) - .append("\n ySubscriptXSize: ").append(_ySubscriptXSize) - .append("\n ySubscriptYSize: ").append(_ySubscriptYSize) - .append("\n ySubscriptXOffset: ").append(_ySubscriptXOffset) - .append("\n ySubscriptYOffset: ").append(_ySubscriptYOffset) - .append("\n ySuperscriptXSize: ").append(_ySuperscriptXSize) - .append("\n ySuperscriptYSize: ").append(_ySuperscriptYSize) - .append("\n ySuperscriptXOffset: ").append(_ySuperscriptXOffset) - .append("\n ySuperscriptYOffset: ").append(_ySuperscriptYOffset) - .append("\n yStrikeoutSize: ").append(_yStrikeoutSize) - .append("\n yStrikeoutPosition: ").append(_yStrikeoutPosition) - .append("\n sFamilyClass: ").append(_sFamilyClass>>8) - .append(" subclass = ").append(_sFamilyClass&0xff) - .append("\n PANOSE: ").append(_panose.toString()) - .append("\n Unicode Range 1( Bits 0 - 31 ): ").append(Integer.toHexString(_ulUnicodeRange1).toUpperCase()) - .append("\n Unicode Range 2( Bits 32- 63 ): ").append(Integer.toHexString(_ulUnicodeRange2).toUpperCase()) - .append("\n Unicode Range 3( Bits 64- 95 ): ").append(Integer.toHexString(_ulUnicodeRange3).toUpperCase()) - .append("\n Unicode Range 4( Bits 96-127 ): ").append(Integer.toHexString(_ulUnicodeRange4).toUpperCase()) - .append("\n achVendID: '").append(getVendorIDAsString()) - .append("'\n fsSelection: 0x").append(Integer.toHexString(_fsSelection).toUpperCase()) - .append("\n usFirstCharIndex: 0x").append(Integer.toHexString(_usFirstCharIndex).toUpperCase()) - .append("\n usLastCharIndex: 0x").append(Integer.toHexString(_usLastCharIndex).toUpperCase()) - .append("\n sTypoAscender: ").append(_sTypoAscender) - .append("\n sTypoDescender: ").append(_sTypoDescender) - .append("\n sTypoLineGap: ").append(_sTypoLineGap) - .append("\n usWinAscent: ").append(_usWinAscent) - .append("\n usWinDescent: ").append(_usWinDescent) - .append("\n CodePage Range 1( Bits 0 - 31 ): ").append(Integer.toHexString(_ulCodePageRange1).toUpperCase()) - .append("\n CodePage Range 2( Bits 32- 63 ): ").append(Integer.toHexString(_ulCodePageRange2).toUpperCase()) - .toString(); + return "'OS/2' Table - OS/2 and Windows Metrics\n---------------------------------------" + + "\n 'OS/2' version: " + _version + + "\n xAvgCharWidth: " + _xAvgCharWidth + + "\n usWeightClass: " + _usWeightClass + + "\n usWidthClass: " + _usWidthClass + + "\n fsType: 0x" + Integer.toHexString(_fsType).toUpperCase() + + "\n ySubscriptXSize: " + _ySubscriptXSize + + "\n ySubscriptYSize: " + _ySubscriptYSize + + "\n ySubscriptXOffset: " + _ySubscriptXOffset + + "\n ySubscriptYOffset: " + _ySubscriptYOffset + + "\n ySuperscriptXSize: " + _ySuperscriptXSize + + "\n ySuperscriptYSize: " + _ySuperscriptYSize + + "\n ySuperscriptXOffset: " + _ySuperscriptXOffset + + "\n ySuperscriptYOffset: " + _ySuperscriptYOffset + + "\n yStrikeoutSize: " + _yStrikeoutSize + + "\n yStrikeoutPosition: " + _yStrikeoutPosition + + "\n sFamilyClass: " + (_sFamilyClass >> 8) + + " subclass = " + (_sFamilyClass & 0xff) + + "\n PANOSE: " + _panose.toString() + + "\n Unicode Range 1( Bits 0 - 31 ): " + Integer.toHexString(_ulUnicodeRange1).toUpperCase() + + "\n Unicode Range 2( Bits 32- 63 ): " + Integer.toHexString(_ulUnicodeRange2).toUpperCase() + + "\n Unicode Range 3( Bits 64- 95 ): " + Integer.toHexString(_ulUnicodeRange3).toUpperCase() + + "\n Unicode Range 4( Bits 96-127 ): " + Integer.toHexString(_ulUnicodeRange4).toUpperCase() + + "\n achVendID: '" + getVendorIDAsString() + + "'\n fsSelection: 0x" + Integer.toHexString(_fsSelection).toUpperCase() + + "\n usFirstCharIndex: 0x" + Integer.toHexString(_usFirstCharIndex).toUpperCase() + + "\n usLastCharIndex: 0x" + Integer.toHexString(_usLastCharIndex).toUpperCase() + + "\n sTypoAscender: " + _sTypoAscender + + "\n sTypoDescender: " + _sTypoDescender + + "\n sTypoLineGap: " + _sTypoLineGap + + "\n usWinAscent: " + _usWinAscent + + "\n usWinDescent: " + _usWinDescent + + "\n CodePage Range 1( Bits 0 - 31 ): " + Integer.toHexString(_ulCodePageRange1).toUpperCase() + + "\n CodePage Range 2( Bits 32- 63 ): " + Integer.toHexString(_ulCodePageRange2).toUpperCase(); } private String getVendorIDAsString() { - return new StringBuffer() - .append((char)((_achVendorID>>24)&0xff)) - .append((char)((_achVendorID>>16)&0xff)) - .append((char)((_achVendorID>>8)&0xff)) - .append((char)((_achVendorID)&0xff)) - .toString(); + return String.valueOf((char) ((_achVendorID >> 24) & 0xff)) + + (char) ((_achVendorID >> 16) & 0xff) + + (char) ((_achVendorID >> 8) & 0xff) + + (char) ((_achVendorID) & 0xff); } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/Panose.java b/src/main/java/net/java/dev/typecast/ot/table/Panose.java index a6064e8..f9cd32d 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Panose.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Panose.java @@ -13,16 +13,16 @@ package net.java.dev.typecast.ot.table; */ public class Panose { - byte bFamilyType = 0; - byte bSerifStyle = 0; - byte bWeight = 0; - byte bProportion = 0; - byte bContrast = 0; - byte bStrokeVariation = 0; - byte bArmStyle = 0; - byte bLetterform = 0; - byte bMidline = 0; - byte bXHeight = 0; + private byte bFamilyType; + private byte bSerifStyle; + private byte bWeight; + private byte bProportion; + private byte bContrast; + private byte bStrokeVariation; + private byte bArmStyle; + private byte bLetterform; + private byte bMidline; + private byte bXHeight; /** Creates new Panose */ public Panose(byte[] panose) { @@ -79,17 +79,16 @@ public class Panose { } public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(String.valueOf(bFamilyType)).append(" ") - .append(String.valueOf(bSerifStyle)).append(" ") - .append(String.valueOf(bWeight)).append(" ") - .append(String.valueOf(bProportion)).append(" ") - .append(String.valueOf(bContrast)).append(" ") - .append(String.valueOf(bStrokeVariation)).append(" ") - .append(String.valueOf(bArmStyle)).append(" ") - .append(String.valueOf(bLetterform)).append(" ") - .append(String.valueOf(bMidline)).append(" ") - .append(String.valueOf(bXHeight)); - return sb.toString(); + String sb = String.valueOf(bFamilyType) + " " + + String.valueOf(bSerifStyle) + " " + + String.valueOf(bWeight) + " " + + String.valueOf(bProportion) + " " + + String.valueOf(bContrast) + " " + + String.valueOf(bStrokeVariation) + " " + + String.valueOf(bArmStyle) + " " + + String.valueOf(bLetterform) + " " + + String.valueOf(bMidline) + " " + + String.valueOf(bXHeight); + return sb; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/PcltTable.java b/src/main/java/net/java/dev/typecast/ot/table/PcltTable.java index 40e077c..04e76c9 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/PcltTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/PcltTable.java @@ -15,7 +15,7 @@ import java.io.IOException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class PcltTable implements Table { +class PcltTable implements Table { private int version; private long fontNumber; @@ -25,9 +25,9 @@ public class PcltTable implements Table { private int typeFamily; private int capHeight; private int symbolSet; - private char[] typeface = new char[16]; - private short[] characterComplement = new short[8]; - private char[] fileName = new char[6]; + private final char[] typeface = new char[16]; + private final short[] characterComplement = new short[8]; + private final char[] fileName = new char[6]; private short strokeWeight; private short widthType; private byte serifStyle; @@ -59,26 +59,24 @@ public class PcltTable implements Table { } public String toString() { - return new StringBuffer() - .append("'PCLT' Table - Printer Command Language Table\n---------------------------------------------") - .append("\n version: 0x").append(Integer.toHexString(version).toUpperCase()) - .append("\n fontNumber: ").append(fontNumber).append(" (0x").append(Long.toHexString(fontNumber).toUpperCase()) - .append(")\n pitch: ").append(pitch) - .append("\n xHeight: ").append(xHeight) - .append("\n style: 0x").append(style) - .append("\n typeFamily: 0x").append(typeFamily>>12) - .append(" ").append(typeFamily & 0xfff) - .append("\n capHeight: ").append(capHeight) - .append("\n symbolSet: ").append(symbolSet) - .append("\n typeFace: ").append(new String(typeface)) - .append("\n characterComplement 0x") - .append(Integer.toHexString(characterComplement[0]).toUpperCase()) - .append("\n fileName: ").append(new String(fileName)) - .append("\n strokeWeight: ").append(strokeWeight) - .append("\n widthType: ").append(widthType) - .append("\n serifStyle: ").append(serifStyle) - .append("\n reserved: ").append(reserved) - .toString(); + return "'PCLT' Table - Printer Command Language Table\n---------------------------------------------" + + "\n version: 0x" + Integer.toHexString(version).toUpperCase() + + "\n fontNumber: " + fontNumber + " (0x" + Long.toHexString(fontNumber).toUpperCase() + + ")\n pitch: " + pitch + + "\n xHeight: " + xHeight + + "\n style: 0x" + style + + "\n typeFamily: 0x" + (typeFamily >> 12) + + " " + (typeFamily & 0xfff) + + "\n capHeight: " + capHeight + + "\n symbolSet: " + symbolSet + + "\n typeFace: " + new String(typeface) + + "\n characterComplement 0x" + + Integer.toHexString(characterComplement[0]).toUpperCase() + + "\n fileName: " + new String(fileName) + + "\n strokeWeight: " + strokeWeight + + "\n widthType: " + widthType + + "\n serifStyle: " + serifStyle + + "\n reserved: " + reserved; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/PostTable.java b/src/main/java/net/java/dev/typecast/ot/table/PostTable.java index 7ef3e8f..2b013ee 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/PostTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/PostTable.java @@ -361,7 +361,7 @@ public class PostTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'post' Table - PostScript Metrics\n---------------------------------\n") .append("\n 'post' version: ").append(Fixed.floatValue(version)) .append("\n italicAngle: ").append(Fixed.floatValue(italicAngle)) diff --git a/src/main/java/net/java/dev/typecast/ot/table/PrepTable.java b/src/main/java/net/java/dev/typecast/ot/table/PrepTable.java index 2a47aed..1792c34 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/PrepTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/PrepTable.java @@ -15,7 +15,7 @@ import net.java.dev.typecast.ot.Disassembler; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class PrepTable extends Program implements Table { +class PrepTable extends Program implements Table { public PrepTable(DataInput di, int length) throws IOException { readInstructions(di, length); diff --git a/src/main/java/net/java/dev/typecast/ot/table/Program.java b/src/main/java/net/java/dev/typecast/ot/table/Program.java index 82549e1..901523f 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Program.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Program.java @@ -10,20 +10,19 @@ package net.java.dev.typecast.ot.table; import java.io.DataInput; import java.io.IOException; -import java.io.ByteArrayInputStream; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public abstract class Program { +abstract class Program { private short[] instructions; - public short[] getInstructions() { + short[] getInstructions() { return instructions; } - protected void readInstructions(DataInput di, int count) throws IOException { + void readInstructions(DataInput di, int count) throws IOException { instructions = new short[count]; for (int i = 0; i < count; i++) { instructions[i] = (short) di.readUnsignedByte(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/RangeRecord.java b/src/main/java/net/java/dev/typecast/ot/table/RangeRecord.java index 5073b9c..40a48ae 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/RangeRecord.java +++ b/src/main/java/net/java/dev/typecast/ot/table/RangeRecord.java @@ -58,7 +58,7 @@ import java.io.IOException; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class RangeRecord { +class RangeRecord { private final int _start; private final int _end; @@ -83,7 +83,7 @@ public class RangeRecord { return _startCoverageIndex; } - public boolean isInRange(int glyphId) { + private boolean isInRange(int glyphId) { return (_start <= glyphId && glyphId <= _end); } diff --git a/src/main/java/net/java/dev/typecast/ot/table/SbixTable.java b/src/main/java/net/java/dev/typecast/ot/table/SbixTable.java index 988ca22..65eed36 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/SbixTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/SbixTable.java @@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory; */ public class SbixTable implements Table { - public class GlyphDataRecord { + public static class GlyphDataRecord { private final short _originOffsetX; private final short _originOffsetY; private final int _graphicType; @@ -39,7 +39,7 @@ public class SbixTable implements Table { private static final int PNG = 0x706E6720; - protected GlyphDataRecord(DataInput di, int dataLength) throws IOException { + GlyphDataRecord(DataInput di, int dataLength) throws IOException { _originOffsetX = di.readShort(); _originOffsetY = di.readShort(); _graphicType = di.readInt(); @@ -68,13 +68,13 @@ public class SbixTable implements Table { } } - public class Strike { + public static class Strike { private final int _ppem; private final int _resolution; private final long[] _glyphDataOffset; private final GlyphDataRecord[] _glyphDataRecord; - protected Strike(ByteArrayInputStream bais, int numGlyphs) throws IOException { + Strike(ByteArrayInputStream bais, int numGlyphs) throws IOException { DataInput di = new DataInputStream(bais); _ppem = di.readUnsignedShort(); _resolution = di.readUnsignedShort(); @@ -112,9 +112,9 @@ public class SbixTable implements Table { private final int[] _strikeOffset; private final Strike[] _strikes; - static final Logger logger = LoggerFactory.getLogger(SbixTable.class); + private static final Logger logger = LoggerFactory.getLogger(SbixTable.class); - public SbixTable(DataInput di, int length, MaxpTable maxp) throws IOException { + private SbixTable(DataInput di, int length, MaxpTable maxp) throws IOException { // Load entire table into a buffer, and create another input stream byte[] buf = new byte[length]; diff --git a/src/main/java/net/java/dev/typecast/ot/table/Script.java b/src/main/java/net/java/dev/typecast/ot/table/Script.java index c8ed06c..26c404e 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Script.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Script.java @@ -66,7 +66,7 @@ public class Script { private LangSys[] _langSys; /** Creates new ScriptTable */ - protected Script(DataInputStream dis, int offset) throws IOException { + Script(DataInputStream dis, int offset) throws IOException { // Ensure we're in the right place dis.reset(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/ScriptList.java b/src/main/java/net/java/dev/typecast/ot/table/ScriptList.java index 4b3edd0..c447e85 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/ScriptList.java +++ b/src/main/java/net/java/dev/typecast/ot/table/ScriptList.java @@ -59,12 +59,12 @@ import java.io.IOException; */ public class ScriptList { - private int _scriptCount = 0; + private int _scriptCount; private ScriptRecord[] _scriptRecords; private Script[] _scripts; /** Creates new ScriptList */ - protected ScriptList(DataInputStream dis, int offset) throws IOException { + ScriptList(DataInputStream dis, int offset) throws IOException { // Ensure we're in the right place dis.reset(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/ScriptRecord.java b/src/main/java/net/java/dev/typecast/ot/table/ScriptRecord.java index 6d7c212..f7de900 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/ScriptRecord.java +++ b/src/main/java/net/java/dev/typecast/ot/table/ScriptRecord.java @@ -63,7 +63,7 @@ public class ScriptRecord { private int _offset; /** Creates new ScriptRecord */ - protected ScriptRecord(DataInput di) throws IOException { + ScriptRecord(DataInput di) throws IOException { _tag = di.readInt(); _offset = di.readUnsignedShort(); } @@ -77,11 +77,9 @@ public class ScriptRecord { } public String getTagAsString() { - return new StringBuffer() - .append((char)((_tag>>24)&0xff)) - .append((char)((_tag>>16)&0xff)) - .append((char)((_tag>>8)&0xff)) - .append((char)((_tag)&0xff)) - .toString(); + return String.valueOf((char) ((_tag >> 24) & 0xff)) + + (char) ((_tag >> 16) & 0xff) + + (char) ((_tag >> 8) & 0xff) + + (char) ((_tag) & 0xff); } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/ScriptTags.java b/src/main/java/net/java/dev/typecast/ot/table/ScriptTags.java index eaaa6c2..4d2107b 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/ScriptTags.java +++ b/src/main/java/net/java/dev/typecast/ot/table/ScriptTags.java @@ -56,5 +56,5 @@ package net.java.dev.typecast.ot.table; * @author <a href="mailto:[email protected]">Vincent Hardy</a> */ public interface ScriptTags { - public static final String SCRIPT_TAG_ARAB = "arab"; + String SCRIPT_TAG_ARAB = "arab"; } diff --git a/src/main/java/net/java/dev/typecast/ot/table/SignatureBlock.java b/src/main/java/net/java/dev/typecast/ot/table/SignatureBlock.java index 621a956..c0a23ef 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/SignatureBlock.java +++ b/src/main/java/net/java/dev/typecast/ot/table/SignatureBlock.java @@ -15,7 +15,7 @@ import java.io.DataInput; * * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class SignatureBlock { +class SignatureBlock { private int reserved1; private int reserved2; @@ -23,7 +23,7 @@ public class SignatureBlock { private byte[] signature; /** Creates new SignatureBlock */ - protected SignatureBlock(DataInput di) throws IOException { + SignatureBlock(DataInput di) throws IOException { reserved1 = di.readUnsignedShort(); reserved2 = di.readUnsignedShort(); signatureLen = di.readInt(); @@ -32,7 +32,7 @@ public class SignatureBlock { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < signatureLen; i += 16) { if (signatureLen - i >= 16) { sb.append(new String(signature, i, 16)).append("\n"); diff --git a/src/main/java/net/java/dev/typecast/ot/table/SingleSubstFormat1.java b/src/main/java/net/java/dev/typecast/ot/table/SingleSubstFormat1.java index 73af2d8..369d281 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/SingleSubstFormat1.java +++ b/src/main/java/net/java/dev/typecast/ot/table/SingleSubstFormat1.java @@ -64,7 +64,7 @@ public class SingleSubstFormat1 extends SingleSubst { private Coverage _coverage; /** Creates new SingleSubstFormat1 */ - protected SingleSubstFormat1(DataInputStream dis, int offset) throws IOException { + SingleSubstFormat1(DataInputStream dis, int offset) throws IOException { _coverageOffset = dis.readUnsignedShort(); _deltaGlyphID = dis.readShort(); dis.reset(); diff --git a/src/main/java/net/java/dev/typecast/ot/table/SingleSubstFormat2.java b/src/main/java/net/java/dev/typecast/ot/table/SingleSubstFormat2.java index 6608589..fba6a7b 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/SingleSubstFormat2.java +++ b/src/main/java/net/java/dev/typecast/ot/table/SingleSubstFormat2.java @@ -65,7 +65,7 @@ public class SingleSubstFormat2 extends SingleSubst { private final Coverage _coverage; /** Creates new SingleSubstFormat2 */ - protected SingleSubstFormat2(DataInputStream dis, int offset) throws IOException { + SingleSubstFormat2(DataInputStream dis, int offset) throws IOException { _coverageOffset = dis.readUnsignedShort(); _glyphCount = dis.readUnsignedShort(); _substitutes = new int[_glyphCount]; diff --git a/src/main/java/net/java/dev/typecast/ot/table/TTCHeader.java b/src/main/java/net/java/dev/typecast/ot/table/TTCHeader.java index 652968e..5f92a55 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/TTCHeader.java +++ b/src/main/java/net/java/dev/typecast/ot/table/TTCHeader.java @@ -17,7 +17,7 @@ import java.io.IOException; */ public class TTCHeader { - public static final int ttcf = 0x74746366; + private static final int ttcf = 0x74746366; private int ttcTag; private int version; diff --git a/src/main/java/net/java/dev/typecast/ot/table/Table.java b/src/main/java/net/java/dev/typecast/ot/table/Table.java index 6972795..f691752 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/Table.java +++ b/src/main/java/net/java/dev/typecast/ot/table/Table.java @@ -23,42 +23,42 @@ package net.java.dev.typecast.ot.table; public interface Table { // Table constants - public static final int BASE = 0x42415345; // Baseline data [OpenType] - public static final int CFF = 0x43464620; // PostScript font program (compact font format) [PostScript] - public static final int COLR = 0x434f4c52; // Color Table - public static final int CPAL = 0x4350414c; // Color Palette Table - public static final int DSIG = 0x44534947; // Digital signature - public static final int EBDT = 0x45424454; // Embedded bitmap data - public static final int EBLC = 0x45424c43; // Embedded bitmap location data - public static final int EBSC = 0x45425343; // Embedded bitmap scaling data - public static final int GDEF = 0x47444546; // Glyph definition data [OpenType] - public static final int GPOS = 0x47504f53; // Glyph positioning data [OpenType] - public static final int GSUB = 0x47535542; // Glyph substitution data [OpenType] - public static final int JSTF = 0x4a535446; // Justification data [OpenType] - public static final int LTSH = 0x4c545348; // Linear threshold table - public static final int MMFX = 0x4d4d4658; // Multiple master font metrics [PostScript] - public static final int MMSD = 0x4d4d5344; // Multiple master supplementary data [PostScript] - public static final int OS_2 = 0x4f532f32; // OS/2 and Windows specific metrics [r] - public static final int PCLT = 0x50434c54; // PCL5 - public static final int VDMX = 0x56444d58; // Vertical Device Metrics table - public static final int cmap = 0x636d6170; // character to glyph mapping [r] - public static final int cvt = 0x63767420; // Control Value Table - public static final int fpgm = 0x6670676d; // font program - public static final int fvar = 0x66766172; // Apple's font variations table [PostScript] - public static final int gasp = 0x67617370; // grid-fitting and scan conversion procedure (grayscale) - public static final int glyf = 0x676c7966; // glyph data [r] - public static final int hdmx = 0x68646d78; // horizontal device metrics - public static final int head = 0x68656164; // font header [r] - public static final int hhea = 0x68686561; // horizontal header [r] - public static final int hmtx = 0x686d7478; // horizontal metrics [r] - public static final int kern = 0x6b65726e; // kerning - public static final int loca = 0x6c6f6361; // index to location [r] - public static final int maxp = 0x6d617870; // maximum profile [r] - public static final int name = 0x6e616d65; // naming table [r] - public static final int prep = 0x70726570; // CVT Program - public static final int post = 0x706f7374; // PostScript information [r] - public static final int sbix = 0x73626978; // Extended Bitmaps - public static final int vhea = 0x76686561; // Vertical Metrics header - public static final int vmtx = 0x766d7478; // Vertical Metrics + int BASE = 0x42415345; // Baseline data [OpenType] + int CFF = 0x43464620; // PostScript font program (compact font format) [PostScript] + int COLR = 0x434f4c52; // Color Table + int CPAL = 0x4350414c; // Color Palette Table + int DSIG = 0x44534947; // Digital signature + int EBDT = 0x45424454; // Embedded bitmap data + int EBLC = 0x45424c43; // Embedded bitmap location data + int EBSC = 0x45425343; // Embedded bitmap scaling data + int GDEF = 0x47444546; // Glyph definition data [OpenType] + int GPOS = 0x47504f53; // Glyph positioning data [OpenType] + int GSUB = 0x47535542; // Glyph substitution data [OpenType] + int JSTF = 0x4a535446; // Justification data [OpenType] + int LTSH = 0x4c545348; // Linear threshold table + int MMFX = 0x4d4d4658; // Multiple master font metrics [PostScript] + int MMSD = 0x4d4d5344; // Multiple master supplementary data [PostScript] + int OS_2 = 0x4f532f32; // OS/2 and Windows specific metrics [r] + int PCLT = 0x50434c54; // PCL5 + int VDMX = 0x56444d58; // Vertical Device Metrics table + int cmap = 0x636d6170; // character to glyph mapping [r] + int cvt = 0x63767420; // Control Value Table + int fpgm = 0x6670676d; // font program + int fvar = 0x66766172; // Apple's font variations table [PostScript] + int gasp = 0x67617370; // grid-fitting and scan conversion procedure (grayscale) + int glyf = 0x676c7966; // glyph data [r] + int hdmx = 0x68646d78; // horizontal device metrics + int head = 0x68656164; // font header [r] + int hhea = 0x68686561; // horizontal header [r] + int hmtx = 0x686d7478; // horizontal metrics [r] + int kern = 0x6b65726e; // kerning + int loca = 0x6c6f6361; // index to location [r] + int maxp = 0x6d617870; // maximum profile [r] + int name = 0x6e616d65; // naming table [r] + int prep = 0x70726570; // CVT Program + int post = 0x706f7374; // PostScript information [r] + int sbix = 0x73626978; // Extended Bitmaps + int vhea = 0x76686561; // Vertical Metrics header + int vmtx = 0x766d7478; // Vertical Metrics } diff --git a/src/main/java/net/java/dev/typecast/ot/table/VdmxTable.java b/src/main/java/net/java/dev/typecast/ot/table/VdmxTable.java index c282423..2336645 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/VdmxTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/VdmxTable.java @@ -27,70 +27,70 @@ import java.io.IOException; */ public class VdmxTable implements Table { - private class Ratio { + private static class Ratio { private byte _bCharSet; private byte _xRatio; private byte _yStartRatio; private byte _yEndRatio; - protected Ratio(DataInput di) throws IOException { + Ratio(DataInput di) throws IOException { _bCharSet = di.readByte(); _xRatio = di.readByte(); _yStartRatio = di.readByte(); _yEndRatio = di.readByte(); } - public byte getBCharSet() { + byte getBCharSet() { return _bCharSet; } - public byte getXRatio() { + byte getXRatio() { return _xRatio; } - public byte getYStartRatio() { + byte getYStartRatio() { return _yStartRatio; } - public byte getYEndRatio() { + byte getYEndRatio() { return _yEndRatio; } } - private class VTableRecord { + private static class VTableRecord { private int _yPelHeight; private short _yMax; private short _yMin; - protected VTableRecord(DataInput di) throws IOException { + VTableRecord(DataInput di) throws IOException { _yPelHeight = di.readUnsignedShort(); _yMax = di.readShort(); _yMin = di.readShort(); } - public int getYPelHeight() { + int getYPelHeight() { return _yPelHeight; } - public short getYMax() { + short getYMax() { return _yMax; } - public short getYMin() { + short getYMin() { return _yMin; } } - private class Group { + private static class Group { private int _recs; private int _startsz; private int _endsz; private VTableRecord[] _entry; - protected Group(DataInput di) throws IOException { + Group(DataInput di) throws IOException { _recs = di.readUnsignedShort(); _startsz = di.readUnsignedByte(); _endsz = di.readUnsignedByte(); @@ -100,19 +100,19 @@ public class VdmxTable implements Table { } } - public int getRecs() { + int getRecs() { return _recs; } - public int getStartSZ() { + int getStartSZ() { return _startsz; } - public int getEndSZ() { + int getEndSZ() { return _endsz; } - public VTableRecord[] getEntry() { + VTableRecord[] getEntry() { return _entry; } } @@ -121,7 +121,7 @@ public class VdmxTable implements Table { private int _numRecs; private int _numRatios; private Ratio[] _ratRange; - private int _offset[]; + private int[] _offset; private Group[] _groups; /** Creates a new instance of VdmxTable */ @@ -144,7 +144,7 @@ public class VdmxTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'VDMX' Table - Precomputed Vertical Device Metrics\n") .append("--------------------------------------------------\n") .append(" Version: ").append(_version).append("\n") diff --git a/src/main/java/net/java/dev/typecast/ot/table/VheaTable.java b/src/main/java/net/java/dev/typecast/ot/table/VheaTable.java index dd69a3d..57a0169 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/VheaTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/VheaTable.java @@ -104,26 +104,24 @@ public class VheaTable implements Table { } public String toString() { - return new StringBuffer() - .append("'vhea' Table - Vertical Header\n------------------------------") - .append("\n 'vhea' version: ").append(Fixed.floatValue(_version)) - .append("\n xAscender: ").append(_ascent) - .append("\n xDescender: ").append(_descent) - .append("\n xLineGap: ").append(_lineGap) - .append("\n advanceHeightMax: ").append(_advanceHeightMax) - .append("\n minTopSideBearing: ").append(_minTopSideBearing) - .append("\n minBottomSideBearing: ").append(_minBottomSideBearing) - .append("\n yMaxExtent: ").append(_yMaxExtent) - .append("\n horizCaretSlopeNum: ").append(_caretSlopeRise) - .append("\n horizCaretSlopeDenom: ").append(_caretSlopeRun) - .append("\n reserved0: 0") - .append("\n reserved1: 0") - .append("\n reserved2: 0") - .append("\n reserved3: 0") - .append("\n reserved4: 0") - .append("\n metricDataFormat: ").append(_metricDataFormat) - .append("\n numOf_LongVerMetrics: ").append(_numberOfLongVerMetrics) - .toString(); + return "'vhea' Table - Vertical Header\n------------------------------" + + "\n 'vhea' version: " + Fixed.floatValue(_version) + + "\n xAscender: " + _ascent + + "\n xDescender: " + _descent + + "\n xLineGap: " + _lineGap + + "\n advanceHeightMax: " + _advanceHeightMax + + "\n minTopSideBearing: " + _minTopSideBearing + + "\n minBottomSideBearing: " + _minBottomSideBearing + + "\n yMaxExtent: " + _yMaxExtent + + "\n horizCaretSlopeNum: " + _caretSlopeRise + + "\n horizCaretSlopeDenom: " + _caretSlopeRun + + "\n reserved0: 0" + + "\n reserved1: 0" + + "\n reserved2: 0" + + "\n reserved3: 0" + + "\n reserved4: 0" + + "\n metricDataFormat: " + _metricDataFormat + + "\n numOf_LongVerMetrics: " + _numberOfLongVerMetrics; } } diff --git a/src/main/java/net/java/dev/typecast/ot/table/VmtxTable.java b/src/main/java/net/java/dev/typecast/ot/table/VmtxTable.java index 0309fe0..f7d4fc9 100644 --- a/src/main/java/net/java/dev/typecast/ot/table/VmtxTable.java +++ b/src/main/java/net/java/dev/typecast/ot/table/VmtxTable.java @@ -25,10 +25,10 @@ import java.io.IOException; * Vertical Metrics Table * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class VmtxTable implements Table { +class VmtxTable implements Table { - private int[] _vMetrics = null; - private short[] _topSideBearing = null; + private int[] _vMetrics; + private short[] _topSideBearing; protected VmtxTable( DataInput di, @@ -49,7 +49,7 @@ public class VmtxTable implements Table { } } - public int getAdvanceHeight(int i) { + private int getAdvanceHeight(int i) { if (_vMetrics == null) { return 0; } @@ -60,7 +60,7 @@ public class VmtxTable implements Table { } } - public short getTopSideBearing(int i) { + private short getTopSideBearing(int i) { if (_vMetrics == null) { return 0; } @@ -72,7 +72,7 @@ public class VmtxTable implements Table { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("'vmtx' Table - Vertical Metrics\n-------------------------------\n"); // sb.append("Size = ").append(_de.getLength()).append(" bytes, ") sb.append(_vMetrics.length).append(" entries\n"); diff --git a/src/main/java/net/java/dev/typecast/render/GlyphImageFactory.java b/src/main/java/net/java/dev/typecast/render/GlyphImageFactory.java index 580305b..42beec8 100644 --- a/src/main/java/net/java/dev/typecast/render/GlyphImageFactory.java +++ b/src/main/java/net/java/dev/typecast/render/GlyphImageFactory.java @@ -33,7 +33,7 @@ import net.java.dev.typecast.ot.Glyph; * A factory for generating bitmaps from glyph outlines. * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class GlyphImageFactory { +class GlyphImageFactory { /** * Build an {@link java.awt.Image Image} from a diff --git a/src/main/java/net/java/dev/typecast/render/GlyphPathFactory.java b/src/main/java/net/java/dev/typecast/render/GlyphPathFactory.java index 257ba7e..508af8b 100644 --- a/src/main/java/net/java/dev/typecast/render/GlyphPathFactory.java +++ b/src/main/java/net/java/dev/typecast/render/GlyphPathFactory.java @@ -31,7 +31,7 @@ import net.java.dev.typecast.ot.T2Glyph; * A factory for generating Graphics2D paths from glyph outlines. * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class GlyphPathFactory { +class GlyphPathFactory { /** * Build a {@link java.awt.geom.GeneralPath GeneralPath} from a @@ -71,7 +71,7 @@ public class GlyphPathFactory { int offset = 0; boolean connect = false; while (offset < count) { - Shape s = null; + Shape s; Point point_minus1 = glyph.getPoint((offset==0) ? startIndex+count-1 : startIndex+(offset-1)%count); Point point = glyph.getPoint(startIndex + offset%count); Point point_plus1 = glyph.getPoint(startIndex + (offset+1)%count); diff --git a/src/main/java/net/java/dev/typecast/tt/engine/GraphicsState.java b/src/main/java/net/java/dev/typecast/tt/engine/GraphicsState.java index 0a414f9..a083d12 100644 --- a/src/main/java/net/java/dev/typecast/tt/engine/GraphicsState.java +++ b/src/main/java/net/java/dev/typecast/tt/engine/GraphicsState.java @@ -29,14 +29,14 @@ class GraphicsState { public int delta_base = 9; public int delta_shift = 3; public int dual_projection_vectors; - public int[] freedom_vector = new int[2]; + public final int[] freedom_vector = new int[2]; public int zp0 = 1; public int zp1 = 1; public int zp2 = 1; public int instruction_control = 0; public int loop = 1; public int minimum_distance = 1; - public int[] projection_vector = new int[2]; + public final int[] projection_vector = new int[2]; public int round_state = 1; public int rp0 = 0; public int rp1 = 0; diff --git a/src/main/java/net/java/dev/typecast/tt/engine/Interpreter.java b/src/main/java/net/java/dev/typecast/tt/engine/Interpreter.java index 7397db4..1c3a68d 100644 --- a/src/main/java/net/java/dev/typecast/tt/engine/Interpreter.java +++ b/src/main/java/net/java/dev/typecast/tt/engine/Interpreter.java @@ -27,15 +27,15 @@ import net.java.dev.typecast.ot.Point; * or some other. * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class Interpreter { +class Interpreter { private Parser parser = null; - private GraphicsState gs = new GraphicsState(); - private Point[][] zone = new Point[2][]; - private int[] stack = null; - private int[] store = null; - private int[] cvt = new int[256]; - private int[] functionMap = null; + private final GraphicsState gs = new GraphicsState(); + private final Point[][] zone = new Point[2][]; + private int[] stack; + private int[] store; + private final int[] cvt = new int[256]; + private int[] functionMap; private int stackIndex = 0; private boolean inFuncDef = false; @@ -450,7 +450,8 @@ public class Interpreter { * JuMP Relative */ private int _jmpr(int instructionIndex) { - return instructionIndex += pop() - 1; + instructionIndex += pop() - 1; + return instructionIndex; } /** @@ -512,7 +513,7 @@ public class Interpreter { private void _max() { int n1 = pop(); int n2 = pop(); - push((n1 > n2) ? n1 : n2); + push(Math.max(n1, n2)); } private void _md(short param) { @@ -539,7 +540,7 @@ public class Interpreter { private void _min() { int n1 = pop(); int n2 = pop(); - push((n1 < n2) ? n1 : n2); + push(Math.min(n1, n2)); } /** @@ -631,8 +632,8 @@ public class Interpreter { * PUSH Words */ private void _push(int[] data) { - for (int j = 0; j < data.length; j++) { - push(data[j]); + for (int datum : data) { + push(datum); } } @@ -1183,7 +1184,7 @@ public class Interpreter { store[pop()] = pop(); } - public void execute(int ip) { + private void execute(int ip) { while (ip < ((ip & 0xffff0000) | parser.getISLength(ip >> 16))) { short opcode = parser.getOpcode(ip); if (inFuncDef) { diff --git a/src/main/java/net/java/dev/typecast/tt/engine/Parser.java b/src/main/java/net/java/dev/typecast/tt/engine/Parser.java index 9e10b33..38497d0 100644 --- a/src/main/java/net/java/dev/typecast/tt/engine/Parser.java +++ b/src/main/java/net/java/dev/typecast/tt/engine/Parser.java @@ -23,9 +23,9 @@ import net.java.dev.typecast.ot.Mnemonic; /** * @author <a href="mailto:[email protected]">David Schweinsberg</a> */ -public class Parser { +class Parser { - private short[][] instructions = new short[3][]; + private final short[][] instructions = new short[3][]; /** * Advance the instruction pointer to the next executable opcode. @@ -68,7 +68,7 @@ public class Parser { return instructions[ip >> 16][ip & 0xffff]; } - public short getPushCount(int ip) { + private short getPushCount(int ip) { short instr = instructions[ip >> 16][ip & 0xffff]; if ((Mnemonic.NPUSHB == instr) || (Mnemonic.NPUSHW == instr)) { return instructions[ip >> 16][(ip & 0xffff) + 1]; @@ -112,7 +112,7 @@ public class Parser { } public int handleIf(boolean test, int ip) { - if (test == false) { + if (!test) { // The TrueType spec says that we merely jump to the *next* ELSE or EIF // instruction in the instruction stream. So therefore no nesting! // Looking at actual code, IF-ELSE-EIF can be nested! @@ -146,14 +146,13 @@ public class Parser { } public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int ip = 0; while (ip < instructions[0].length) { sb.append(Mnemonic.getMnemonic(getOpcode(ip))); if (getPushCount(ip) > 0) { int[] data = getPushData(ip); - for(int j = 0; j < data.length; j++) - sb.append(" ").append(data[j]); + for (int datum : data) sb.append(" ").append(datum); } sb.append("\n"); ip = advanceIP(ip); @@ -164,8 +163,8 @@ public class Parser { sb.append(Mnemonic.getMnemonic(getOpcode(ip))); if(getPushCount(ip) > 0) { int[] data = getPushData(ip); - for (int j = 0; j < data.length; j++) { - sb.append(" ").append(data[j]); + for (int datum : data) { + sb.append(" ").append(datum); } } sb.append("\n"); @@ -177,8 +176,8 @@ public class Parser { sb.append(Mnemonic.getMnemonic(getOpcode(ip))); if (getPushCount(ip) > 0) { int[] data = getPushData(ip); - for (int j = 0; j < data.length; j++) { - sb.append(" ").append(data[j]); + for (int datum : data) { + sb.append(" ").append(datum); } } sb.append("\n"); diff --git a/src/main/java/org/apache/batik/i18n/LocaleGroup.java b/src/main/java/org/apache/batik/i18n/LocaleGroup.java index 94d3f8e..059a3b6 100644 --- a/src/main/java/org/apache/batik/i18n/LocaleGroup.java +++ b/src/main/java/org/apache/batik/i18n/LocaleGroup.java @@ -25,7 +25,7 @@ public class LocaleGroup { /** * The shared Locale. */ - protected Locale locale; + private Locale locale; /** * Sets the default locale for all the instances of ExtendedLocalizable diff --git a/src/main/java/org/apache/batik/i18n/Localizable.java b/src/main/java/org/apache/batik/i18n/Localizable.java index 4dd0321..aab3ad1 100644 --- a/src/main/java/org/apache/batik/i18n/Localizable.java +++ b/src/main/java/org/apache/batik/i18n/Localizable.java @@ -17,7 +17,7 @@ import java.util.MissingResourceException; * * @author <a href="mailto:[email protected]">Stephane Hillion</a> */ -public interface Localizable { +interface Localizable { /** * Provides a way to the user to specify a locale which override the * default one. If null is passed to this method, the used locale diff --git a/src/main/java/org/apache/batik/i18n/LocalizableSupport.java b/src/main/java/org/apache/batik/i18n/LocalizableSupport.java index f275f27..a9f139a 100644 --- a/src/main/java/org/apache/batik/i18n/LocalizableSupport.java +++ b/src/main/java/org/apache/batik/i18n/LocalizableSupport.java @@ -68,32 +68,32 @@ public class LocalizableSupport implements Localizable { /** * The locale group to which this object belongs. */ - protected LocaleGroup localeGroup = LocaleGroup.DEFAULT; + private LocaleGroup localeGroup = LocaleGroup.DEFAULT; /** * The resource bundle classname. */ - protected String bundleName; + private final String bundleName; /** * The classloader to use to create the resource bundle. */ - protected ClassLoader classLoader; + private final ClassLoader classLoader; /** * The current locale. */ - protected Locale locale; + private Locale locale; /** * The locale in use. */ - protected Locale usedLocale; + private Locale usedLocale; /** * The resources */ - protected ResourceBundle resourceBundle; + private ResourceBundle resourceBundle; /** * Same as LocalizableSupport(s, null). @@ -112,7 +112,7 @@ public class LocalizableSupport implements Localizable { * or null. * @see java.util.ResourceBundle */ - public LocalizableSupport(String s, ClassLoader cl) { + private LocalizableSupport(String s, ClassLoader cl) { bundleName = s; classLoader = cl; } @@ -181,7 +181,7 @@ public class LocalizableSupport implements Localizable { * Implements {@link * org.apache.batik.i18n.ExtendedLocalizable#getResourceBundle()}. */ - public ResourceBundle getResourceBundle() { + private ResourceBundle getResourceBundle() { Locale l; if (resourceBundle == null) { diff --git a/src/main/java/org/apache/batik/util/CSSConstants.java b/src/main/java/org/apache/batik/util/CSSConstants.java index 334d427..f7f832b 100644 --- a/src/main/java/org/apache/batik/util/CSSConstants.java +++ b/src/main/java/org/apache/batik/util/CSSConstants.java @@ -56,7 +56,7 @@ package org.apache.batik.util; * * @author <a href="mailto:[email protected]">Stephane Hillion</a> */ -public interface CSSConstants { +interface CSSConstants { // // The CSS mime-type string. diff --git a/src/main/resources/net/java/dev/typecast/exchange/Messages.properties b/src/main/resources/net/java/dev/typecast/exchange/Messages.properties index ef5e952..a1b09a9 100644 --- a/src/main/resources/net/java/dev/typecast/exchange/Messages.properties +++ b/src/main/resources/net/java/dev/typecast/exchange/Messages.properties @@ -16,7 +16,7 @@ SVGFont.config.svg.begin = \ <svg width="100%" height="100%"> SVGFont.config.svg.test.card.start = \ -<g style="font-family:' +<g style="font-family:' SVGFont.config.svg.test.card.end = '; font-size:18;fill:black"> \n\ <text x="20" y="60"> !"#$%&'()*+,-./0123456789:;<>?</text> \n\ |