You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2013/11/17 16:27:34 UTC
svn commit: r1542748 [1/5] - in /pdfbox/branches/1.8: ./
examples/src/main/java/org/apache/pdfbox/examples/fdf/
examples/src/main/java/org/apache/pdfbox/examples/signature/
fontbox/src/main/java/org/apache/fontbox/cff/
fontbox/src/main/java/org/apache/...
Author: lehmi
Date: Sun Nov 17 15:27:33 2013
New Revision: 1542748
URL: http://svn.apache.org/r1542748
Log:
merged the following changes from trunk into 1.8 branch:
PDFBOX-1342 r1536136
PDFBOX-1412 r1536173
PDFBOX-1633 r1540801
PDFBOX-1743 r1530740
PDFBOX-1744 r1536463
PDFBOX-1749 r1535953
PDFBOX-1753 r1535956
PDFBOX-1758 r1538371
PDFBOX-1764 r1538191
PDFBOX-1776 r1541625,r1542291
PDFBOX-1780 r1541987
Added:
pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java
- copied, changed from r1541625, pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/
- copied from r1541625, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/
Modified:
pdfbox/branches/1.8/ (props changed)
pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeComp.java
pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java
pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfSimpleDescript.java
pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java
pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java
pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/TTFDataStream.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType0.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/documentinterchange/logicalstructure/PDStructureTreeRoot.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/AxialShadingContext.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/shading/RadialShadingContext.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObject.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectForm.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateCreator.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDFTemplateStructure.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigBuilder.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSigProperties.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/digitalsignature/visible/PDVisibleSignDesigner.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/DateConverter.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/util/PDFMergerUtility.java
pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/util/TestDateUtil.java
pdfbox/branches/1.8/preflight/src/main/java/org/apache/pdfbox/preflight/process/FileSpecificationValidationProcess.java
Propchange: pdfbox/branches/1.8/
------------------------------------------------------------------------------
Merged /pdfbox/trunk:r1530740,1535953,1535956,1536136,1536173,1536463,1538191,1538371,1540801,1541625,1541987,1542291
Modified: pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java?rev=1542748&r1=1542747&r2=1542748&view=diff
==============================================================================
--- pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java (original)
+++ pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/fdf/PrintFields.java Sun Nov 17 15:27:33 2013
@@ -17,36 +17,35 @@
package org.apache.pdfbox.examples.fdf;
import java.io.IOException;
-
import java.util.Iterator;
import java.util.List;
-import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
-import org.apache.pdfbox.pdmodel.interactive.form.PDField;
-
import org.apache.pdfbox.exceptions.CryptographyException;
import org.apache.pdfbox.exceptions.InvalidPasswordException;
-
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
+import org.apache.pdfbox.pdmodel.common.COSObjectable;
+import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
+import org.apache.pdfbox.pdmodel.interactive.form.PDField;
+import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField;
/**
* This example will take a PDF document and print all the fields from the file.
- *
+ *
* @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.16 $
+ *
*/
public class PrintFields
{
/**
* This will print all the fields from the document.
- *
+ *
* @param pdfDocument The PDF to get the fields from.
- *
+ *
* @throws IOException If there is an error getting the fields.
*/
- public void printFields( PDDocument pdfDocument ) throws IOException
+ public void printFields(PDDocument pdfDocument) throws IOException
{
PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
@@ -55,51 +54,59 @@ public class PrintFields
System.out.println(new Integer(fields.size()).toString() + " top-level fields were found on the form");
- while( fieldsIter.hasNext())
+ while (fieldsIter.hasNext())
{
- PDField field = (PDField)fieldsIter.next();
- processField(field, "|--", field.getPartialName());
+ PDField field = (PDField) fieldsIter.next();
+ processField(field, "|--", field.getPartialName());
}
}
private void processField(PDField field, String sLevel, String sParent) throws IOException
{
- List kids = field.getKids();
- if(kids != null)
+ List<COSObjectable> kids = field.getKids();
+ if (kids != null)
{
- Iterator kidsIter = kids.iterator();
- if(!sParent.equals(field.getPartialName()))
+ Iterator<COSObjectable> kidsIter = kids.iterator();
+ if (!sParent.equals(field.getPartialName()))
{
- sParent = sParent + "." + field.getPartialName();
+ sParent = sParent + "." + field.getPartialName();
}
System.out.println(sLevel + sParent);
- //System.out.println(sParent + " is of type " + field.getClass().getName());
- while(kidsIter.hasNext())
+ // System.out.println(sParent + " is of type " + field.getClass().getName());
+ while (kidsIter.hasNext())
{
- Object pdfObj = kidsIter.next();
- if(pdfObj instanceof PDField)
- {
- PDField kid = (PDField)pdfObj;
- processField(kid, "| " + sLevel, sParent);
- }
- }
- }
- else
- {
- String outputString = sLevel + sParent + "." + field.getPartialName() + " = " + field.getValue() +
- ", type=" + field.getClass().getName();
-
- System.out.println(outputString);
- }
+ Object pdfObj = kidsIter.next();
+ if (pdfObj instanceof PDField)
+ {
+ PDField kid = (PDField) pdfObj;
+ processField(kid, "| " + sLevel, sParent);
+ }
+ }
+ }
+ else
+ {
+ String fieldValue = null;
+ if (field instanceof PDSignatureField)
+ {
+ // PDSignature doesn't have a value
+ fieldValue = "PDSignatureField";
+ }
+ else
+ {
+ fieldValue = field.getValue();
+ }
+ String outputString = sLevel + sParent + "." + field.getPartialName() + " = " + fieldValue + ", type="
+ + field.getClass().getName();
+ System.out.println(outputString);
+ }
}
/**
- * This will read a PDF file and print out the form elements.
- * <br />
+ * This will read a PDF file and print out the form elements. <br />
* see usage() for commandline
- *
+ *
* @param args command line arguments
- *
+ *
* @throws IOException If there is an error importing the FDF document.
* @throws CryptographyException If there is an error decrypting the document.
*/
@@ -108,42 +115,43 @@ public class PrintFields
PDDocument pdf = null;
try
{
- if( args.length != 1 )
+ if (args.length != 1)
{
usage();
}
else
{
- pdf = PDDocument.load( args[0] );
+ pdf = PDDocument.load(args[0]);
PrintFields exporter = new PrintFields();
- if( pdf.isEncrypted() )
+ if (pdf.isEncrypted())
{
try
{
- pdf.decrypt( "" );
+ pdf.decrypt("");
}
- catch( InvalidPasswordException e )
+ catch (InvalidPasswordException e)
{
- System.err.println( "Error: The document is encrypted." );
+ System.err.println("Error: The document is encrypted.");
usage();
}
}
- exporter.printFields( pdf );
+ exporter.printFields(pdf);
}
}
finally
{
- if( pdf != null )
+ if (pdf != null)
{
pdf.close();
}
}
}
+
/**
* This will print out a message telling how to use this example.
*/
private static void usage()
{
- System.err.println( "usage: org.apache.pdfbox.examples.fdf.PrintFields <pdf-file>" );
+ System.err.println("usage: org.apache.pdfbox.examples.fdf.PrintFields <pdf-file>");
}
}
Copied: pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java (from r1541625, pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java)
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java?p2=pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java&p1=pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java&r1=1541625&r2=1542748&rev=1542748&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java (original)
+++ pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java Sun Nov 17 15:27:33 2013
@@ -193,7 +193,6 @@ public class CreateVisibleSignature impl
* Here the user should use his favorite cryptographic library and implement a pkcs7 signature creation.
* </p>
*/
- @Override
public byte[] sign(InputStream content) throws SignatureException, IOException
{
CMSProcessableInputStream input = new CMSProcessableInputStream(content);
Modified: pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java?rev=1542748&r1=1542747&r2=1542748&view=diff
==============================================================================
--- pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java (original)
+++ pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/cff/CFFParser.java Sun Nov 17 15:27:33 2013
@@ -20,8 +20,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -43,6 +43,10 @@ import org.apache.fontbox.cff.encoding.C
public class CFFParser
{
+ private static final String TAG_OTTO = "OTTO";
+ private static final String TAG_TTCF = "ttcf";
+ private static final String TAG_TTFONLY = "\u0000\u0001\u0000\u0000";
+
private CFFDataInput input = null;
private Header header = null;
private IndexData nameIndex = null;
@@ -58,9 +62,10 @@ public class CFFParser
public List<CFFFont> parse(byte[] bytes) throws IOException
{
input = new CFFDataInput(bytes);
-
+
String firstTag = readTagName(input);
- if (firstTag.equals("OTTO"))
+ // try to determine which kind of font we have
+ if (TAG_OTTO.equals(firstTag))
{
// this is OpenType font containing CFF data
// so find CFF tag
@@ -68,35 +73,41 @@ public class CFFParser
short searchRange = input.readShort();
short entrySelector = input.readShort();
short rangeShift = input.readShort();
-
+
boolean cffFound = false;
- for (int q=0; q<numTables; q++)
+ for (int q = 0; q < numTables; q++)
{
String tagName = readTagName(input);
long checksum = readLong(input);
long offset = readLong(input);
long length = readLong(input);
- if (tagName.equals("CFF "))
+ if (tagName.equals("CFF "))
{
cffFound = true;
- byte[] bytes2 = new byte[(int)length];
- System.arraycopy(bytes, (int)offset, bytes2, 0, bytes2.length);
+ byte[] bytes2 = new byte[(int) length];
+ System.arraycopy(bytes, (int) offset, bytes2, 0, bytes2.length);
input = new CFFDataInput(bytes2);
break;
}
}
-
- if (!cffFound)
+ if (!cffFound)
{
throw new IOException("CFF tag not found in this OpenType font.");
}
-
- }
- else
+ }
+ else if (TAG_TTCF.equals(firstTag))
+ {
+ throw new IOException("True Type Collection fonts are not supported.");
+ }
+ else if (TAG_TTFONLY.equals(firstTag))
+ {
+ throw new IOException("OpenType fonts containing a true type font are not supported.");
+ }
+ else
{
input.setPosition(0);
}
-
+
header = readHeader(input);
nameIndex = readIndexData(input);
topDictIndex = readIndexData(input);
@@ -112,16 +123,16 @@ public class CFFParser
}
return fonts;
}
-
- private static String readTagName(CFFDataInput input) throws IOException
+
+ private static String readTagName(CFFDataInput input) throws IOException
{
- byte[] b=input.readBytes(4);
+ byte[] b = input.readBytes(4);
return new String(b);
}
- private static long readLong(CFFDataInput input) throws IOException
+ private static long readLong(CFFDataInput input) throws IOException
{
- return (input.readCard16()<<16) | input.readCard16();
+ return (input.readCard16() << 16) | input.readCard16();
}
private static Header readHeader(CFFDataInput input) throws IOException
@@ -134,8 +145,7 @@ public class CFFParser
return cffHeader;
}
- private static IndexData readIndexData(CFFDataInput input)
- throws IOException
+ private static IndexData readIndexData(CFFDataInput input) throws IOException
{
int count = input.readCard16();
IndexData index = new IndexData(count);
@@ -169,8 +179,7 @@ public class CFFParser
return dict;
}
- private static DictData.Entry readEntry(CFFDataInput input)
- throws IOException
+ private static DictData.Entry readEntry(CFFDataInput input) throws IOException
{
DictData.Entry entry = new DictData.Entry();
while (true)
@@ -181,19 +190,19 @@ public class CFFParser
{
entry.operator = readOperator(input, b0);
break;
- }
+ }
else if (b0 == 28 || b0 == 29)
{
entry.operands.add(readIntegerNumber(input, b0));
- }
+ }
else if (b0 == 30)
{
entry.operands.add(readRealNumber(input, b0));
- }
+ }
else if (b0 >= 32 && b0 <= 254)
{
entry.operands.add(readIntegerNumber(input, b0));
- }
+ }
else
{
throw new IllegalArgumentException();
@@ -202,15 +211,13 @@ public class CFFParser
return entry;
}
- private static CFFOperator readOperator(CFFDataInput input, int b0)
- throws IOException
+ private static CFFOperator readOperator(CFFDataInput input, int b0) throws IOException
{
CFFOperator.Key key = readOperatorKey(input, b0);
return CFFOperator.getOperator(key);
}
- private static CFFOperator.Key readOperatorKey(CFFDataInput input, int b0)
- throws IOException
+ private static CFFOperator.Key readOperatorKey(CFFDataInput input, int b0) throws IOException
{
if (b0 == 12)
{
@@ -220,15 +227,14 @@ public class CFFParser
return new CFFOperator.Key(b0);
}
- private static Integer readIntegerNumber(CFFDataInput input, int b0)
- throws IOException
+ private static Integer readIntegerNumber(CFFDataInput input, int b0) throws IOException
{
if (b0 == 28)
{
int b1 = input.readUnsignedByte();
int b2 = input.readUnsignedByte();
return Integer.valueOf((short) (b1 << 8 | b2));
- }
+ }
else if (b0 == 29)
{
int b1 = input.readUnsignedByte();
@@ -236,29 +242,28 @@ public class CFFParser
int b3 = input.readUnsignedByte();
int b4 = input.readUnsignedByte();
return Integer.valueOf(b1 << 24 | b2 << 16 | b3 << 8 | b4);
- }
+ }
else if (b0 >= 32 && b0 <= 246)
{
return Integer.valueOf(b0 - 139);
- }
+ }
else if (b0 >= 247 && b0 <= 250)
{
int b1 = input.readUnsignedByte();
return Integer.valueOf((b0 - 247) * 256 + b1 + 108);
- }
+ }
else if (b0 >= 251 && b0 <= 254)
{
int b1 = input.readUnsignedByte();
return Integer.valueOf(-(b0 - 251) * 256 - b1 - 108);
- }
+ }
else
{
throw new IllegalArgumentException();
}
}
- private static Double readRealNumber(CFFDataInput input, int b0)
- throws IOException
+ private static Double readRealNumber(CFFDataInput input, int b0) throws IOException
{
StringBuffer sb = new StringBuffer();
boolean done = false;
@@ -336,9 +341,9 @@ public class CFFParser
if (rosEntry != null)
{
font = new CFFFontROS();
- ((CFFFontROS)font).setRegistry(readString(rosEntry.getNumber(0).intValue()));
- ((CFFFontROS)font).setOrdering(readString(rosEntry.getNumber(1).intValue()));
- ((CFFFontROS)font).setSupplement(rosEntry.getNumber(2).intValue());
+ ((CFFFontROS) font).setRegistry(readString(rosEntry.getNumber(0).intValue()));
+ ((CFFFontROS) font).setOrdering(readString(rosEntry.getNumber(1).intValue()));
+ ((CFFFontROS) font).setSupplement(rosEntry.getNumber(2).intValue());
}
if (font == null)
@@ -346,29 +351,36 @@ public class CFFParser
// -- No specific behavior for this font
font = new CFFFont();
}
-
+
font.setName(name);
- font.addValueToTopDict("version", getString(topDict,"version"));
- font.addValueToTopDict("Notice", getString(topDict,"Notice"));
- font.addValueToTopDict("Copyright", getString(topDict,"Copyright"));
- font.addValueToTopDict("FullName", getString(topDict,"FullName"));
- font.addValueToTopDict("FamilyName", getString(topDict,"FamilyName"));
- font.addValueToTopDict("Weight", getString(topDict,"Weight"));
+ font.addValueToTopDict("version", getString(topDict, "version"));
+ font.addValueToTopDict("Notice", getString(topDict, "Notice"));
+ font.addValueToTopDict("Copyright", getString(topDict, "Copyright"));
+ font.addValueToTopDict("FullName", getString(topDict, "FullName"));
+ font.addValueToTopDict("FamilyName", getString(topDict, "FamilyName"));
+ font.addValueToTopDict("Weight", getString(topDict, "Weight"));
font.addValueToTopDict("isFixedPitch", getBoolean(topDict, "isFixedPitch", false));
font.addValueToTopDict("ItalicAngle", getNumber(topDict, "ItalicAngle", 0));
font.addValueToTopDict("UnderlinePosition", getNumber(topDict, "UnderlinePosition", -100));
font.addValueToTopDict("UnderlineThickness", getNumber(topDict, "UnderlineThickness", 50));
font.addValueToTopDict("PaintType", getNumber(topDict, "PaintType", 0));
font.addValueToTopDict("CharstringType", getNumber(topDict, "CharstringType", 2));
- font.addValueToTopDict("FontMatrix", getArray(topDict, "FontMatrix", Arrays
- .<Number> asList(Double.valueOf(0.001), Double.valueOf(0),
- Double.valueOf(0), Double.valueOf(0.001), Double
- .valueOf(0), Double.valueOf(0))));
+ font.addValueToTopDict(
+ "FontMatrix",
+ getArray(
+ topDict,
+ "FontMatrix",
+ Arrays.<Number> asList(Double.valueOf(0.001), Double.valueOf(0), Double.valueOf(0),
+ Double.valueOf(0.001), Double.valueOf(0), Double.valueOf(0))));
font.addValueToTopDict("UniqueID", getNumber(topDict, "UniqueID", null));
- font.addValueToTopDict("FontBBox", getArray(topDict, "FontBBox", Arrays
- .<Number> asList(Integer.valueOf(0), Integer.valueOf(0),
- Integer.valueOf(0), Integer.valueOf(0))));
+ font.addValueToTopDict(
+ "FontBBox",
+ getArray(
+ topDict,
+ "FontBBox",
+ Arrays.<Number> asList(Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0),
+ Integer.valueOf(0))));
font.addValueToTopDict("StrokeWidth", getNumber(topDict, "StrokeWidth", 0));
font.addValueToTopDict("XUID", getArray(topDict, "XUID", null));
@@ -378,20 +390,19 @@ public class CFFParser
IndexData charStringsIndex = readIndexData(input);
DictData.Entry charsetEntry = topDict.getEntry("charset");
CFFCharset charset;
- int charsetId = charsetEntry != null ? charsetEntry.getNumber(0)
- .intValue() : 0;
+ int charsetId = charsetEntry != null ? charsetEntry.getNumber(0).intValue() : 0;
if (charsetId == 0)
{
charset = CFFISOAdobeCharset.getInstance();
- }
+ }
else if (charsetId == 1)
{
charset = CFFExpertCharset.getInstance();
- }
+ }
else if (charsetId == 2)
{
charset = CFFExpertSubsetCharset.getInstance();
- }
+ }
else
{
input.setPosition(charsetId);
@@ -413,18 +424,17 @@ public class CFFParser
if (encodingId == 0 || rosEntry != null) // --- ROS uses StandardEncoding
{
encoding = CFFStandardEncoding.getInstance();
- }
+ }
else if (encodingId == 1)
{
encoding = CFFExpertEncoding.getInstance();
- }
+ }
else
{
input.setPosition(encodingId);
encoding = readEncoding(input, gids);
}
font.setEncoding(encoding);
-
if (rosEntry != null)
{
@@ -442,7 +452,7 @@ public class CFFParser
List<Map<String, Object>> privateDictionaries = new LinkedList<Map<String, Object>>();
List<Map<String, Object>> fontDictionaries = new LinkedList<Map<String, Object>>();
- CFFFontROS fontRos = (CFFFontROS)font;
+ CFFFontROS fontRos = (CFFFontROS) font;
for (int i = 0; i < fdIndex.getCount(); ++i)
{
@@ -457,10 +467,10 @@ public class CFFParser
fontDictMap.put("FontMatrix", getDelta(fontDictData, "FontMatrix", null));
// TODO OD-4 : Add here other keys
fontDictionaries.add(fontDictMap);
-
+
DictData.Entry privateEntry = fontDictData.getEntry("Private");
// --- Font DICT is invalid without "Private" entry
- if ( privateEntry == null)
+ if (privateEntry == null)
{
throw new IOException("Missing Private Dictionary");
}
@@ -490,7 +500,7 @@ public class CFFParser
privDict.put("defaultWidthX", getNumber(privateDict, "defaultWidthX", Integer.valueOf(0)));
privDict.put("nominalWidthX", getNumber(privateDict, "nominalWidthX", Integer.valueOf(0)));
- int localSubrOffset = (Integer)getNumber(privateDict, "Subrs", Integer.valueOf(0));
+ int localSubrOffset = (Integer) getNumber(privateDict, "Subrs", Integer.valueOf(0));
if (localSubrOffset == 0)
{
font.setLocalSubrIndex(new IndexData(0));
@@ -500,13 +510,13 @@ public class CFFParser
input.setPosition(privateOffset + localSubrOffset);
font.setLocalSubrIndex(readIndexData(input));
}
-
+
privateDictionaries.add(privDict);
}
fontRos.setFontDict(fontDictionaries);
fontRos.setPrivDict(privateDictionaries);
-
+
DictData.Entry fdSelectEntry = topDict.getEntry("FDSelect");
int fdSelectPos = fdSelectEntry.getNumber(0).intValue();
input.setPosition(fdSelectPos);
@@ -514,7 +524,7 @@ public class CFFParser
font.addValueToPrivateDict("defaultWidthX", Integer.valueOf(1000));
font.addValueToPrivateDict("nominalWidthX", Integer.valueOf(0));
-
+
fontRos.setFdSelect(fdSelect);
}
@@ -539,14 +549,14 @@ public class CFFParser
font.addValueToPrivateDict("StemSnapV", getDelta(privateDict, "StemSnapV", null));
font.addValueToPrivateDict("ForceBold", getBoolean(privateDict, "ForceBold", false));
font.addValueToPrivateDict("LanguageGroup", getNumber(privateDict, "LanguageGroup", Integer.valueOf(0)));
- font.addValueToPrivateDict("ExpansionFactor",
+ font.addValueToPrivateDict("ExpansionFactor",
getNumber(privateDict, "ExpansionFactor", Double.valueOf(0.06)));
- font.addValueToPrivateDict("initialRandomSeed",
+ font.addValueToPrivateDict("initialRandomSeed",
getNumber(privateDict, "initialRandomSeed", Integer.valueOf(0)));
font.addValueToPrivateDict("defaultWidthX", getNumber(privateDict, "defaultWidthX", Integer.valueOf(0)));
font.addValueToPrivateDict("nominalWidthX", getNumber(privateDict, "nominalWidthX", Integer.valueOf(0)));
-
- int localSubrOffset = (Integer)getNumber(privateDict, "Subrs", Integer.valueOf(0));
+
+ int localSubrOffset = (Integer) getNumber(privateDict, "Subrs", Integer.valueOf(0));
if (localSubrOffset == 0)
{
font.setLocalSubrIndex(new IndexData(0));
@@ -610,8 +620,7 @@ public class CFFParser
return entry != null ? entry.getArray() : defaultValue;
}
- private CFFEncoding readEncoding(CFFDataInput dataInput, int[] gids)
- throws IOException
+ private CFFEncoding readEncoding(CFFDataInput dataInput, int[] gids) throws IOException
{
int format = dataInput.readCard8();
int baseFormat = format & 0x7f;
@@ -619,19 +628,18 @@ public class CFFParser
if (baseFormat == 0)
{
return readFormat0Encoding(dataInput, format, gids);
- }
+ }
else if (baseFormat == 1)
{
return readFormat1Encoding(dataInput, format, gids);
- }
+ }
else
{
throw new IllegalArgumentException();
}
}
- private Format0Encoding readFormat0Encoding(CFFDataInput dataInput, int format,
- int[] gids) throws IOException
+ private Format0Encoding readFormat0Encoding(CFFDataInput dataInput, int format, int[] gids) throws IOException
{
Format0Encoding encoding = new Format0Encoding();
encoding.format = format;
@@ -649,8 +657,7 @@ public class CFFParser
return encoding;
}
- private Format1Encoding readFormat1Encoding(CFFDataInput dataInput, int format,
- int[] gids) throws IOException
+ private Format1Encoding readFormat1Encoding(CFFDataInput dataInput, int format, int[] gids) throws IOException
{
Format1Encoding encoding = new Format1Encoding();
encoding.format = format;
@@ -676,8 +683,7 @@ public class CFFParser
return encoding;
}
- private void readSupplement(CFFDataInput dataInput, EmbeddedEncoding encoding)
- throws IOException
+ private void readSupplement(CFFDataInput dataInput, EmbeddedEncoding encoding) throws IOException
{
encoding.nSups = dataInput.readCard8();
encoding.supplement = new EmbeddedEncoding.Supplement[encoding.nSups];
@@ -698,18 +704,17 @@ public class CFFParser
* @return
* @throws IOException
*/
- private CIDKeyedFDSelect readFDSelect(CFFDataInput dataInput, int nGlyphs, CFFFontROS ros)
- throws IOException
+ private CIDKeyedFDSelect readFDSelect(CFFDataInput dataInput, int nGlyphs, CFFFontROS ros) throws IOException
{
int format = dataInput.readCard8();
if (format == 0)
{
return readFormat0FDSelect(dataInput, format, nGlyphs, ros);
- }
+ }
else if (format == 3)
{
return readFormat3FDSelect(dataInput, format, nGlyphs, ros);
- }
+ }
else
{
throw new IllegalArgumentException();
@@ -769,7 +774,7 @@ public class CFFParser
fdselect.sentinel = dataInput.readCard16();
return fdselect;
}
-
+
/**
* Container of a Format 3 FDSelect data (see "The Compact Font Format Specification" chapter "FDSelect" ).
*/
@@ -785,7 +790,9 @@ public class CFFParser
super(owner);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.fontbox.cff.CIDKeyedFDSelect#getFd(int)
*/
@Override
@@ -795,9 +802,9 @@ public class CFFParser
{
if (range3[i].first >= glyph)
{
- if (i + 1 < nbRanges )
+ if (i + 1 < nbRanges)
{
- if (range3[i+1].first > glyph )
+ if (range3[i + 1].first > glyph)
{
return range3[i].fd;
}
@@ -812,7 +819,7 @@ public class CFFParser
if (sentinel > glyph)
{
return range3[i].fd;
- }
+ }
else
{
return -1;
@@ -838,14 +845,14 @@ public class CFFParser
{
private int first;
private int fd;
-
+
@Override
public String toString()
{
return getClass().getName() + "[first=" + first + ", fd=" + fd + "]";
}
}
-
+
/**
* Container of a Format 0 FDSelect data (see "The Compact Font Format Specification" chapter "FDSelect" ).
*/
@@ -859,7 +866,9 @@ public class CFFParser
super(owner);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.fontbox.cff.CIDKeyedFDSelect#getFd(int)
*/
@Override
@@ -868,7 +877,7 @@ public class CFFParser
Map<String, byte[]> charString = owner.getCharStringsDict();
Set<String> keys = charString.keySet();
// ---- search the position of the given glyph
- for (Mapping mapping: owner.getMappings())
+ for (Mapping mapping : owner.getMappings())
{
if (mapping.getSID() == glyph && charString.containsKey(mapping.getName()))
{
@@ -889,23 +898,21 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[format=" + format + ", fds="
- + Arrays.toString(fds) + "]";
+ return getClass().getName() + "[format=" + format + ", fds=" + Arrays.toString(fds) + "]";
}
}
-
- private CFFCharset readCharset(CFFDataInput dataInput, int nGlyphs)
- throws IOException
+
+ private CFFCharset readCharset(CFFDataInput dataInput, int nGlyphs) throws IOException
{
int format = dataInput.readCard8();
if (format == 0)
{
return readFormat0Charset(dataInput, format, nGlyphs);
- }
+ }
else if (format == 1)
{
return readFormat1Charset(dataInput, format, nGlyphs);
- }
+ }
else if (format == 2)
{
return readFormat2Charset(dataInput, format, nGlyphs);
@@ -916,8 +923,7 @@ public class CFFParser
}
}
- private Format0Charset readFormat0Charset(CFFDataInput dataInput, int format,
- int nGlyphs) throws IOException
+ private Format0Charset readFormat0Charset(CFFDataInput dataInput, int format, int nGlyphs) throws IOException
{
Format0Charset charset = new Format0Charset();
charset.format = format;
@@ -930,8 +936,7 @@ public class CFFParser
return charset;
}
- private Format1Charset readFormat1Charset(CFFDataInput dataInput, int format,
- int nGlyphs) throws IOException
+ private Format1Charset readFormat1Charset(CFFDataInput dataInput, int format, int nGlyphs) throws IOException
{
Format1Charset charset = new Format1Charset();
charset.format = format;
@@ -951,9 +956,8 @@ public class CFFParser
charset.range = ranges.toArray(new Format1Charset.Range1[0]);
return charset;
}
-
- private Format2Charset readFormat2Charset(CFFDataInput dataInput, int format,
- int nGlyphs) throws IOException
+
+ private Format2Charset readFormat2Charset(CFFDataInput dataInput, int format, int nGlyphs) throws IOException
{
Format2Charset charset = new Format2Charset();
charset.format = format;
@@ -961,8 +965,7 @@ public class CFFParser
for (int i = 0; i < nGlyphs - 1;)
{
Format2Charset.Range2[] newRange = new Format2Charset.Range2[charset.range.length + 1];
- System.arraycopy(charset.range, 0, newRange, 0,
- charset.range.length);
+ System.arraycopy(charset.range, 0, newRange, 0, charset.range.length);
charset.range = newRange;
Format2Charset.Range2 range = new Format2Charset.Range2();
range.first = dataInput.readSID();
@@ -990,9 +993,8 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[major=" + major + ", minor="
- + minor + ", hdrSize=" + hdrSize + ", offSize=" + offSize
- + "]";
+ return getClass().getName() + "[major=" + major + ", minor=" + minor + ", hdrSize=" + hdrSize
+ + ", offSize=" + offSize + "]";
}
}
@@ -1019,8 +1021,7 @@ public class CFFParser
for (Entry entry : entries)
{
// Check for null entry before comparing the Font
- if (entry != null && entry.operator != null &&
- entry.operator.equals(operator))
+ if (entry != null && entry.operator != null && entry.operator.equals(operator))
{
return entry;
}
@@ -1093,8 +1094,7 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[operands=" + operands
- + ", operator=" + operator + "]";
+ return getClass().getName() + "[operands=" + operands + ", operator=" + operator + "]";
}
}
}
@@ -1116,8 +1116,9 @@ public class CFFParser
List<Supplement> getSupplements()
{
- if(supplement == null){
- return Collections.<Supplement>emptyList();
+ if (supplement == null)
+ {
+ return Collections.<Supplement> emptyList();
}
return Arrays.asList(supplement);
}
@@ -1143,8 +1144,7 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[code=" + code + ", glyph="
- + glyph + "]";
+ return getClass().getName() + "[code=" + code + ", glyph=" + glyph + "]";
}
}
}
@@ -1161,9 +1161,8 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[format=" + format + ", nCodes="
- + nCodes + ", code=" + Arrays.toString(code)
- + ", supplement=" + Arrays.toString(super.supplement) + "]";
+ return getClass().getName() + "[format=" + format + ", nCodes=" + nCodes + ", code="
+ + Arrays.toString(code) + ", supplement=" + Arrays.toString(super.supplement) + "]";
}
}
@@ -1179,9 +1178,8 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[format=" + format + ", nRanges="
- + nRanges + ", range=" + Arrays.toString(range)
- + ", supplement=" + Arrays.toString(super.supplement) + "]";
+ return getClass().getName() + "[format=" + format + ", nRanges=" + nRanges + ", range="
+ + Arrays.toString(range) + ", supplement=" + Arrays.toString(super.supplement) + "]";
}
/**
@@ -1195,8 +1193,7 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[first=" + first + ", nLeft="
- + nLeft + "]";
+ return getClass().getName() + "[first=" + first + ", nLeft=" + nLeft + "]";
}
}
}
@@ -1224,8 +1221,7 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[format=" + format + ", glyph="
- + Arrays.toString(glyph) + "]";
+ return getClass().getName() + "[format=" + format + ", glyph=" + Arrays.toString(glyph) + "]";
}
}
@@ -1240,8 +1236,7 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[format=" + format + ", range="
- + Arrays.toString(range) + "]";
+ return getClass().getName() + "[format=" + format + ", range=" + Arrays.toString(range) + "]";
}
/**
@@ -1255,8 +1250,7 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[first=" + first + ", nLeft="
- + nLeft + "]";
+ return getClass().getName() + "[first=" + first + ", nLeft=" + nLeft + "]";
}
}
}
@@ -1272,8 +1266,7 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[format=" + format + ", range="
- + Arrays.toString(range) + "]";
+ return getClass().getName() + "[format=" + format + ", range=" + Arrays.toString(range) + "]";
}
/**
@@ -1287,9 +1280,8 @@ public class CFFParser
@Override
public String toString()
{
- return getClass().getName() + "[first=" + first + ", nLeft="
- + nLeft + "]";
+ return getClass().getName() + "[first=" + first + ", nLeft=" + nLeft + "]";
}
}
}
-}
\ No newline at end of file
+}
Modified: pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeComp.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeComp.java?rev=1542748&r1=1542747&r2=1542748&view=diff
==============================================================================
--- pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeComp.java (original)
+++ pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeComp.java Sun Nov 17 15:27:33 2013
@@ -21,14 +21,14 @@ package org.apache.fontbox.ttf;
import java.io.IOException;
/**
- * This class is based on code from Apache Batik a subproject of Apache XMLGraphics.
- * see http://xmlgraphics.apache.org/batik/ for further details.
+ * This class is based on code from Apache Batik a subproject of Apache XMLGraphics. see
+ * http://xmlgraphics.apache.org/batik/ for further details.
*/
-public class GlyfCompositeComp
+public class GlyfCompositeComp
{
// Flags for composite glyphs.
-
+
/**
* If set, the arguments are words; otherwise, they are bytes.
*/
@@ -62,8 +62,7 @@ public class GlyfCompositeComp
*/
protected static final short WE_HAVE_INSTRUCTIONS = 0x0100;
/**
- * If set, this forces the aw and lsb (and rsb) for the composite to be equal to
- * those from this original glyph.
+ * If set, this forces the aw and lsb (and rsb) for the composite to be equal to those from this original glyph.
*/
protected static final short USE_MY_METRICS = 0x0200;
@@ -72,7 +71,7 @@ public class GlyfCompositeComp
private short argument1;
private short argument2;
private short flags;
- private int glyphIndex;
+ private int glyphIndex;
private double xscale = 1.0;
private double yscale = 1.0;
private double scale01 = 0.0;
@@ -88,49 +87,50 @@ public class GlyfCompositeComp
* @param bais the stream to be read
* @throws IOException is thrown if something went wrong
*/
- protected GlyfCompositeComp(TTFDataStream bais) throws IOException
+ protected GlyfCompositeComp(TTFDataStream bais) throws IOException
{
flags = bais.readSignedShort();
glyphIndex = bais.readUnsignedShort();// number of glyph in a font is uint16
// Get the arguments as just their raw values
- if ((flags & ARG_1_AND_2_ARE_WORDS) != 0)
+ if ((flags & ARG_1_AND_2_ARE_WORDS) != 0)
{
argument1 = bais.readSignedShort();
argument2 = bais.readSignedShort();
- }
- else
+ }
+ else
{
- argument1 = (short) bais.read();
- argument2 = (short) bais.read();
+ argument1 = (short) bais.readUnsignedByte();
+ argument2 = (short) bais.readUnsignedByte();
}
// Assign the arguments according to the flags
- if ((flags & ARGS_ARE_XY_VALUES) != 0)
+ if ((flags & ARGS_ARE_XY_VALUES) != 0)
{
xtranslate = argument1;
ytranslate = argument2;
- }
- else
+ }
+ else
{
+ // TODO unused?
point1 = argument1;
point2 = argument2;
}
// Get the scale values (if any)
- if ((flags & WE_HAVE_A_SCALE) != 0)
+ if ((flags & WE_HAVE_A_SCALE) != 0)
{
int i = bais.readSignedShort();
xscale = yscale = (double) i / (double) 0x4000;
- }
- else if ((flags & WE_HAVE_AN_X_AND_Y_SCALE) != 0)
+ }
+ else if ((flags & WE_HAVE_AN_X_AND_Y_SCALE) != 0)
{
short i = bais.readSignedShort();
xscale = (double) i / (double) 0x4000;
i = bais.readSignedShort();
yscale = (double) i / (double) 0x4000;
- }
- else if ((flags & WE_HAVE_A_TWO_BY_TWO) != 0)
+ }
+ else if ((flags & WE_HAVE_A_TWO_BY_TWO) != 0)
{
int i = bais.readSignedShort();
xscale = (double) i / (double) 0x4000;
@@ -145,149 +145,165 @@ public class GlyfCompositeComp
/**
* Sets the first index.
+ *
* @param idx the first index
*/
- public void setFirstIndex(int idx)
+ public void setFirstIndex(int idx)
{
firstIndex = idx;
}
/**
* Returns the first index.
+ *
* @return the first index.
*/
- public int getFirstIndex()
+ public int getFirstIndex()
{
return firstIndex;
}
/**
* Sets the index for the first contour.
+ *
* @param idx the index of the first contour
*/
- public void setFirstContour(int idx)
+ public void setFirstContour(int idx)
{
firstContour = idx;
}
/**
* Returns the index of the first contour.
+ *
* @return the index of the first contour.
*/
- public int getFirstContour()
+ public int getFirstContour()
{
return firstContour;
}
/**
* Returns argument 1.
+ *
* @return argument 1.
*/
- public short getArgument1()
+ public short getArgument1()
{
return argument1;
}
/**
* Returns argument 2.
+ *
* @return argument 2.
*/
- public short getArgument2()
+ public short getArgument2()
{
return argument2;
}
/**
* Returns the flags of the glyph.
+ *
* @return the flags.
*/
- public short getFlags()
+ public short getFlags()
{
return flags;
}
/**
* Returns the index of the first contour.
+ *
* @return index of the first contour.
*/
- public int getGlyphIndex()
+ public int getGlyphIndex()
{
return glyphIndex;
}
/**
* Returns the scale-01 value.
+ *
* @return the scale-01 value.
*/
- public double getScale01()
+ public double getScale01()
{
return scale01;
}
/**
* Returns the scale-10 value.
+ *
* @return the scale-10 value.
*/
- public double getScale10()
+ public double getScale10()
{
return scale10;
}
/**
* Returns the x-scaling value.
+ *
* @return the x-scaling value.
*/
- public double getXScale()
+ public double getXScale()
{
return xscale;
}
/**
* Returns the y-scaling value.
+ *
* @return the y-scaling value.
*/
- public double getYScale()
+ public double getYScale()
{
return yscale;
}
/**
* Returns the x-translation value.
+ *
* @return the x-translation value.
*/
- public int getXTranslate()
+ public int getXTranslate()
{
return xtranslate;
}
/**
* Returns the y-translation value.
+ *
* @return the y-translation value.
*/
- public int getYTranslate()
+ public int getYTranslate()
{
return ytranslate;
}
/**
* Transforms an x-coordinate of a point for this component.
+ *
* @param x The x-coordinate of the point to transform
* @param y The y-coordinate of the point to transform
* @return The transformed x-coordinate
*/
- public int scaleX(int x, int y)
+ public int scaleX(int x, int y)
{
- return Math.round((float)(x * xscale + y * scale10));
+ return Math.round((float) (x * xscale + y * scale10));
}
/**
* Transforms a y-coordinate of a point for this component.
+ *
* @param x The x-coordinate of the point to transform
* @param y The y-coordinate of the point to transform
* @return The transformed y-coordinate
*/
- public int scaleY(int x, int y)
+ public int scaleY(int x, int y)
{
- return Math.round((float)(x * scale01 + y * yscale));
+ return Math.round((float) (x * scale01 + y * yscale));
}
}
Modified: pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java?rev=1542748&r1=1542747&r2=1542748&view=diff
==============================================================================
--- pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java (original)
+++ pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfCompositeDescript.java Sun Nov 17 15:27:33 2013
@@ -23,236 +23,236 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-
/**
- * Glyph description for composite glyphs. Composite glyphs are made up of one
- * or more simple glyphs, usually with some sort of transformation applied to each.
- *
- * This class is based on code from Apache Batik a subproject of Apache XMLGraphics.
- * see http://xmlgraphics.apache.org/batik/ for further details.
+ * Glyph description for composite glyphs. Composite glyphs are made up of one or more simple glyphs, usually with some
+ * sort of transformation applied to each.
+ *
+ * This class is based on code from Apache Batik a subproject of Apache XMLGraphics. see
+ * http://xmlgraphics.apache.org/batik/ for further details.
*/
-public class GlyfCompositeDescript extends GlyfDescript
+public class GlyfCompositeDescript extends GlyfDescript
{
- private List<GlyfCompositeComp> components = new ArrayList<GlyfCompositeComp>();
- private GlyphData[] glyphs = null;
- private boolean beingResolved = false;
- private boolean resolved = false;
-
- /**
- * Constructor.
- *
- * @param bais the stream to be read
- * @param glyphTable the Glyphtable containing all glyphs
- * @throws IOException is thrown if something went wrong
- */
- public GlyfCompositeDescript(TTFDataStream bais, GlyphTable glyphTable) throws IOException
- {
- super((short) -1, bais);
-
- glyphs = glyphTable.getGlyphs();
-
- // Get all of the composite components
- GlyfCompositeComp comp;
- do
- {
- comp = new GlyfCompositeComp(bais);
- components.add(comp);
- }
- while ((comp.getFlags() & GlyfCompositeComp.MORE_COMPONENTS) != 0);
-
- // Are there hinting instructions to read?
- if ((comp.getFlags() & GlyfCompositeComp.WE_HAVE_INSTRUCTIONS) != 0)
- {
- readInstructions(bais, (bais.read()<<8 | bais.read()));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void resolve()
- {
- if (resolved)
- {
- return;
- }
- if (beingResolved)
- {
- System.err.println("Circular reference in GlyfCompositeDesc");
- return;
- }
- beingResolved = true;
-
- int firstIndex = 0;
- int firstContour = 0;
-
- Iterator<GlyfCompositeComp> i = components.iterator();
- while (i.hasNext())
- {
- GlyfCompositeComp comp = (GlyfCompositeComp)i.next();
- comp.setFirstIndex(firstIndex);
- comp.setFirstContour(firstContour);
-
- GlyphDescription desc;
- desc = getGlypDescription(comp.getGlyphIndex());
- if (desc != null)
- {
- desc.resolve();
- firstIndex += desc.getPointCount();
- firstContour += desc.getContourCount();
- }
- }
- resolved = true;
- beingResolved = false;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getEndPtOfContours(int i)
- {
- GlyfCompositeComp c = getCompositeCompEndPt(i);
- if (c != null)
- {
- GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
- return gd.getEndPtOfContours(i - c.getFirstContour()) + c.getFirstIndex();
- }
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public byte getFlags(int i)
- {
- GlyfCompositeComp c = getCompositeComp(i);
- if (c != null)
- {
- GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
- return gd.getFlags(i - c.getFirstIndex());
- }
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public short getXCoordinate(int i)
- {
- GlyfCompositeComp c = getCompositeComp(i);
- if (c != null)
- {
- GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
- int n = i - c.getFirstIndex();
- int x = gd.getXCoordinate(n);
- int y = gd.getYCoordinate(n);
- short x1 = (short) c.scaleX(x, y);
- x1 += c.getXTranslate();
- return x1;
- }
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public short getYCoordinate(int i)
- {
- GlyfCompositeComp c = getCompositeComp(i);
- if (c != null)
- {
- GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
- int n = i - c.getFirstIndex();
- int x = gd.getXCoordinate(n);
- int y = gd.getYCoordinate(n);
- short y1 = (short) c.scaleY(x, y);
- y1 += c.getYTranslate();
- return y1;
- }
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isComposite()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getPointCount()
- {
- if (!resolved)
- {
- System.err.println("getPointCount called on unresolved GlyfCompositeDescript");
- }
- GlyfCompositeComp c = (GlyfCompositeComp) components.get(components.size()-1);
- return c.getFirstIndex() + getGlypDescription(c.getGlyphIndex()).getPointCount();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getContourCount()
- {
- if (!resolved)
- {
- System.err.println("getContourCount called on unresolved GlyfCompositeDescript");
- }
- GlyfCompositeComp c = (GlyfCompositeComp) components.get(components.size()-1);
- return c.getFirstContour() + getGlypDescription(c.getGlyphIndex()).getContourCount();
- }
-
- /**
- * {@inheritDoc}
- */
- public int getComponentCount()
- {
- return components.size();
- }
-
- private GlyfCompositeComp getCompositeComp(int i)
- {
- GlyfCompositeComp c;
- for (int n = 0; n < components.size(); n++)
- {
- c = (GlyfCompositeComp) components.get(n);
- GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
- if (c.getFirstIndex() <= i && i < (c.getFirstIndex() + gd.getPointCount()))
- {
- return c;
- }
- }
- return null;
- }
-
- private GlyfCompositeComp getCompositeCompEndPt(int i)
- {
- GlyfCompositeComp c;
- for (int j = 0; j < components.size(); j++)
- {
- c = (GlyfCompositeComp) components.get(j);
- GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
- if (c.getFirstContour() <= i && i < (c.getFirstContour() + gd.getContourCount()))
- {
- return c;
- }
- }
- return null;
- }
-
- private GlyphDescription getGlypDescription(int index)
- {
- if (glyphs != null && index < glyphs.length)
- {
- GlyphData glyph = glyphs[index];
- if (glyph != null)
- return glyph.getDescription();
- }
- return null;
- }
+ private List<GlyfCompositeComp> components = new ArrayList<GlyfCompositeComp>();
+ private GlyphData[] glyphs = null;
+ private boolean beingResolved = false;
+ private boolean resolved = false;
+
+ /**
+ * Constructor.
+ *
+ * @param bais the stream to be read
+ * @param glyphTable the Glyphtable containing all glyphs
+ * @throws IOException is thrown if something went wrong
+ */
+ public GlyfCompositeDescript(TTFDataStream bais, GlyphTable glyphTable) throws IOException
+ {
+ super((short) -1, bais);
+
+ glyphs = glyphTable.getGlyphs();
+
+ // Get all of the composite components
+ GlyfCompositeComp comp;
+ do
+ {
+ comp = new GlyfCompositeComp(bais);
+ components.add(comp);
+ } while ((comp.getFlags() & GlyfCompositeComp.MORE_COMPONENTS) != 0);
+
+ // Are there hinting instructions to read?
+ if ((comp.getFlags() & GlyfCompositeComp.WE_HAVE_INSTRUCTIONS) != 0)
+ {
+ readInstructions(bais, (bais.readUnsignedShort()));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void resolve()
+ {
+ if (resolved)
+ {
+ return;
+ }
+ if (beingResolved)
+ {
+ System.err.println("Circular reference in GlyfCompositeDesc");
+ return;
+ }
+ beingResolved = true;
+
+ int firstIndex = 0;
+ int firstContour = 0;
+
+ Iterator<GlyfCompositeComp> i = components.iterator();
+ while (i.hasNext())
+ {
+ GlyfCompositeComp comp = (GlyfCompositeComp) i.next();
+ comp.setFirstIndex(firstIndex);
+ comp.setFirstContour(firstContour);
+
+ GlyphDescription desc;
+ desc = getGlypDescription(comp.getGlyphIndex());
+ if (desc != null)
+ {
+ desc.resolve();
+ firstIndex += desc.getPointCount();
+ firstContour += desc.getContourCount();
+ }
+ }
+ resolved = true;
+ beingResolved = false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getEndPtOfContours(int i)
+ {
+ GlyfCompositeComp c = getCompositeCompEndPt(i);
+ if (c != null)
+ {
+ GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
+ return gd.getEndPtOfContours(i - c.getFirstContour()) + c.getFirstIndex();
+ }
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte getFlags(int i)
+ {
+ GlyfCompositeComp c = getCompositeComp(i);
+ if (c != null)
+ {
+ GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
+ return gd.getFlags(i - c.getFirstIndex());
+ }
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public short getXCoordinate(int i)
+ {
+ GlyfCompositeComp c = getCompositeComp(i);
+ if (c != null)
+ {
+ GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
+ int n = i - c.getFirstIndex();
+ int x = gd.getXCoordinate(n);
+ int y = gd.getYCoordinate(n);
+ short x1 = (short) c.scaleX(x, y);
+ x1 += c.getXTranslate();
+ return x1;
+ }
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public short getYCoordinate(int i)
+ {
+ GlyfCompositeComp c = getCompositeComp(i);
+ if (c != null)
+ {
+ GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
+ int n = i - c.getFirstIndex();
+ int x = gd.getXCoordinate(n);
+ int y = gd.getYCoordinate(n);
+ short y1 = (short) c.scaleY(x, y);
+ y1 += c.getYTranslate();
+ return y1;
+ }
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isComposite()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getPointCount()
+ {
+ if (!resolved)
+ {
+ System.err.println("getPointCount called on unresolved GlyfCompositeDescript");
+ }
+ GlyfCompositeComp c = (GlyfCompositeComp) components.get(components.size() - 1);
+ return c.getFirstIndex() + getGlypDescription(c.getGlyphIndex()).getPointCount();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getContourCount()
+ {
+ if (!resolved)
+ {
+ System.err.println("getContourCount called on unresolved GlyfCompositeDescript");
+ }
+ GlyfCompositeComp c = (GlyfCompositeComp) components.get(components.size() - 1);
+ return c.getFirstContour() + getGlypDescription(c.getGlyphIndex()).getContourCount();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getComponentCount()
+ {
+ return components.size();
+ }
+
+ private GlyfCompositeComp getCompositeComp(int i)
+ {
+ GlyfCompositeComp c;
+ for (int n = 0; n < components.size(); n++)
+ {
+ c = (GlyfCompositeComp) components.get(n);
+ GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
+ if (c.getFirstIndex() <= i && i < (c.getFirstIndex() + gd.getPointCount()))
+ {
+ return c;
+ }
+ }
+ return null;
+ }
+
+ private GlyfCompositeComp getCompositeCompEndPt(int i)
+ {
+ GlyfCompositeComp c;
+ for (int j = 0; j < components.size(); j++)
+ {
+ c = (GlyfCompositeComp) components.get(j);
+ GlyphDescription gd = getGlypDescription(c.getGlyphIndex());
+ if (c.getFirstContour() <= i && i < (c.getFirstContour() + gd.getContourCount()))
+ {
+ return c;
+ }
+ }
+ return null;
+ }
+
+ private GlyphDescription getGlypDescription(int index)
+ {
+ if (glyphs != null && index < glyphs.length)
+ {
+ GlyphData glyph = glyphs[index];
+ if (glyph != null)
+ {
+ return glyph.getDescription();
+ }
+ }
+ return null;
+ }
}
Modified: pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfSimpleDescript.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfSimpleDescript.java?rev=1542748&r1=1542747&r2=1542748&view=diff
==============================================================================
--- pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfSimpleDescript.java (original)
+++ pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/GlyfSimpleDescript.java Sun Nov 17 15:27:33 2013
@@ -21,10 +21,10 @@ package org.apache.fontbox.ttf;
import java.io.IOException;
/**
- * This class is based on code from Apache Batik a subproject of Apache XMLGraphics.
- * see http://xmlgraphics.apache.org/batik/ for further details.
+ * This class is based on code from Apache Batik a subproject of Apache XMLGraphics. see
+ * http://xmlgraphics.apache.org/batik/ for further details.
*/
-public class GlyfSimpleDescript extends GlyfDescript
+public class GlyfSimpleDescript extends GlyfDescript
{
private int[] endPtsOfContours;
@@ -38,18 +38,18 @@ public class GlyfSimpleDescript extends
*
* @param numberOfContours number of contours
* @param bais the stream to be read
- * @throws IOException is thrown if something went wrong
+ * @throws IOException is thrown if something went wrong
*/
public GlyfSimpleDescript(short numberOfContours, TTFDataStream bais) throws IOException
{
super(numberOfContours, bais);
-
- /* https://developer.apple.com/fonts/TTRefMan/RM06/Chap6glyf.html
- * "If a glyph has zero contours, it need not have any glyph data."
- * set the pointCount to zero to initialize attributes and avoid nullpointer but
- * maybe there shouldn't have GlyphDescript in the GlyphData?
+
+ /*
+ * https://developer.apple.com/fonts/TTRefMan/RM06/Chap6glyf.html
+ * "If a glyph has zero contours, it need not have any glyph data." set the pointCount to zero to initialize
+ * attributes and avoid nullpointer but maybe there shouldn't have GlyphDescript in the GlyphData?
*/
- if (numberOfContours == 0)
+ if (numberOfContours == 0)
{
pointCount = 0;
return;
@@ -60,8 +60,8 @@ public class GlyfSimpleDescript extends
endPtsOfContours = bais.readUnsignedShortArray(numberOfContours);
// The last end point index reveals the total number of points
- pointCount = endPtsOfContours[numberOfContours -1] + 1;
-
+ pointCount = endPtsOfContours[numberOfContours - 1] + 1;
+
flags = new byte[pointCount];
xCoordinates = new short[pointCount];
yCoordinates = new short[pointCount];
@@ -75,7 +75,7 @@ public class GlyfSimpleDescript extends
/**
* {@inheritDoc}
*/
- public int getEndPtOfContours(int i)
+ public int getEndPtOfContours(int i)
{
return endPtsOfContours[i];
}
@@ -83,7 +83,7 @@ public class GlyfSimpleDescript extends
/**
* {@inheritDoc}
*/
- public byte getFlags(int i)
+ public byte getFlags(int i)
{
return flags[i];
}
@@ -91,7 +91,7 @@ public class GlyfSimpleDescript extends
/**
* {@inheritDoc}
*/
- public short getXCoordinate(int i)
+ public short getXCoordinate(int i)
{
return xCoordinates[i];
}
@@ -99,7 +99,7 @@ public class GlyfSimpleDescript extends
/**
* {@inheritDoc}
*/
- public short getYCoordinate(int i)
+ public short getYCoordinate(int i)
{
return yCoordinates[i];
}
@@ -107,7 +107,7 @@ public class GlyfSimpleDescript extends
/**
* {@inheritDoc}
*/
- public boolean isComposite()
+ public boolean isComposite()
{
return false;
}
@@ -115,7 +115,7 @@ public class GlyfSimpleDescript extends
/**
* {@inheritDoc}
*/
- public int getPointCount()
+ public int getPointCount()
{
return pointCount;
}
@@ -127,22 +127,22 @@ public class GlyfSimpleDescript extends
{
short x = 0;
short y = 0;
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
- if ((flags[i] & X_DUAL) != 0)
+ if ((flags[i] & X_DUAL) != 0)
{
- if ((flags[i] & X_SHORT_VECTOR) != 0)
+ if ((flags[i] & X_SHORT_VECTOR) != 0)
{
- x += (short) bais.read();
+ x += (short) bais.readUnsignedByte();
}
- }
- else
+ }
+ else
{
- if ((flags[i] & X_SHORT_VECTOR) != 0)
+ if ((flags[i] & X_SHORT_VECTOR) != 0)
{
- x += (short) -((short) bais.read());
- }
- else
+ x += (short) -((short) bais.readUnsignedByte());
+ }
+ else
{
x += bais.readSignedShort();
}
@@ -150,22 +150,22 @@ public class GlyfSimpleDescript extends
xCoordinates[i] = x;
}
- for (int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
- if ((flags[i] & Y_DUAL) != 0)
+ if ((flags[i] & Y_DUAL) != 0)
{
- if ((flags[i] & Y_SHORT_VECTOR) != 0)
+ if ((flags[i] & Y_SHORT_VECTOR) != 0)
{
- y += (short) bais.read();
+ y += (short) bais.readUnsignedByte();
}
- }
- else
+ }
+ else
{
- if ((flags[i] & Y_SHORT_VECTOR) != 0)
+ if ((flags[i] & Y_SHORT_VECTOR) != 0)
{
- y += (short) -((short) bais.read());
- }
- else
+ y += (short) -((short) bais.readUnsignedByte());
+ }
+ else
{
y += bais.readSignedShort();
}
@@ -179,25 +179,26 @@ public class GlyfSimpleDescript extends
*/
private void readFlags(int flagCount, TTFDataStream bais) throws IOException
{
- try
+ try
{
- for (int index = 0; index < flagCount; index++)
+ for (int index = 0; index < flagCount; index++)
{
- flags[index] = (byte) bais.read();
- if ((flags[index] & REPEAT) != 0)
+ flags[index] = (byte) bais.readUnsignedByte();
+ if ((flags[index] & REPEAT) != 0)
{
- int repeats = bais.read();
- for (int i = 1; i <= repeats; i++)
+ int repeats = bais.readUnsignedByte();
+ for (int i = 1; i <= repeats; i++)
{
flags[index + i] = flags[index];
}
index += repeats;
}
}
- }
- catch (ArrayIndexOutOfBoundsException e)
+ }
+ catch (ArrayIndexOutOfBoundsException e)
{
System.out.println("error: array index out of bounds");
}
}
+
}
Modified: pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java?rev=1542748&r1=1542747&r2=1542748&view=diff
==============================================================================
--- pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java (original)
+++ pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/OS2WindowsMetricsTable.java Sun Nov 17 15:27:33 2013
@@ -22,11 +22,11 @@ import java.io.IOException;
* A table in a true type font.
*
* @author Ben Litchfield (ben@benlitchfield.com)
- * @version $Revision: 1.1 $
+ *
*/
public class OS2WindowsMetricsTable extends TTFTable
{
-
+
/**
* Weight class constant.
*/
@@ -63,7 +63,7 @@ public class OS2WindowsMetricsTable exte
* Weight class constant.
*/
public static final int WEIGHT_CLASS_BLACK = 900;
-
+
/**
* Width class constant.
*/
@@ -100,7 +100,7 @@ public class OS2WindowsMetricsTable exte
* Width class constant.
*/
public static final int WIDTH_CLASS_ULTRA_EXPANDED = 9;
-
+
/**
* Family class constant.
*/
@@ -145,7 +145,7 @@ public class OS2WindowsMetricsTable exte
* Family class constant.
*/
public static final int FAMILY_CLASS_SYMBOLIC = 12;
-
+
/**
* @return Returns the achVendId.
*/
@@ -153,6 +153,7 @@ public class OS2WindowsMetricsTable exte
{
return achVendId;
}
+
/**
* @param achVendIdValue The achVendId to set.
*/
@@ -160,6 +161,7 @@ public class OS2WindowsMetricsTable exte
{
this.achVendId = achVendIdValue;
}
+
/**
* @return Returns the averageCharWidth.
*/
@@ -167,6 +169,7 @@ public class OS2WindowsMetricsTable exte
{
return averageCharWidth;
}
+
/**
* @param averageCharWidthValue The averageCharWidth to set.
*/
@@ -174,6 +177,7 @@ public class OS2WindowsMetricsTable exte
{
this.averageCharWidth = averageCharWidthValue;
}
+
/**
* @return Returns the codePageRange1.
*/
@@ -181,6 +185,7 @@ public class OS2WindowsMetricsTable exte
{
return codePageRange1;
}
+
/**
* @param codePageRange1Value The codePageRange1 to set.
*/
@@ -188,6 +193,7 @@ public class OS2WindowsMetricsTable exte
{
this.codePageRange1 = codePageRange1Value;
}
+
/**
* @return Returns the codePageRange2.
*/
@@ -195,6 +201,7 @@ public class OS2WindowsMetricsTable exte
{
return codePageRange2;
}
+
/**
* @param codePageRange2Value The codePageRange2 to set.
*/
@@ -202,6 +209,7 @@ public class OS2WindowsMetricsTable exte
{
this.codePageRange2 = codePageRange2Value;
}
+
/**
* @return Returns the familyClass.
*/
@@ -209,6 +217,7 @@ public class OS2WindowsMetricsTable exte
{
return familyClass;
}
+
/**
* @param familyClassValue The familyClass to set.
*/
@@ -216,6 +225,7 @@ public class OS2WindowsMetricsTable exte
{
this.familyClass = familyClassValue;
}
+
/**
* @return Returns the familySubClass.
*/
@@ -223,6 +233,7 @@ public class OS2WindowsMetricsTable exte
{
return familySubClass;
}
+
/**
* @param familySubClassValue The familySubClass to set.
*/
@@ -230,6 +241,7 @@ public class OS2WindowsMetricsTable exte
{
this.familySubClass = familySubClassValue;
}
+
/**
* @return Returns the firstCharIndex.
*/
@@ -237,6 +249,7 @@ public class OS2WindowsMetricsTable exte
{
return firstCharIndex;
}
+
/**
* @param firstCharIndexValue The firstCharIndex to set.
*/
@@ -244,6 +257,7 @@ public class OS2WindowsMetricsTable exte
{
this.firstCharIndex = firstCharIndexValue;
}
+
/**
* @return Returns the fsSelection.
*/
@@ -251,6 +265,7 @@ public class OS2WindowsMetricsTable exte
{
return fsSelection;
}
+
/**
* @param fsSelectionValue The fsSelection to set.
*/
@@ -258,6 +273,7 @@ public class OS2WindowsMetricsTable exte
{
this.fsSelection = fsSelectionValue;
}
+
/**
* @return Returns the fsType.
*/
@@ -265,6 +281,7 @@ public class OS2WindowsMetricsTable exte
{
return fsType;
}
+
/**
* @param fsTypeValue The fsType to set.
*/
@@ -272,6 +289,7 @@ public class OS2WindowsMetricsTable exte
{
this.fsType = fsTypeValue;
}
+
/**
* @return Returns the lastCharIndex.
*/
@@ -279,6 +297,7 @@ public class OS2WindowsMetricsTable exte
{
return lastCharIndex;
}
+
/**
* @param lastCharIndexValue The lastCharIndex to set.
*/
@@ -286,6 +305,7 @@ public class OS2WindowsMetricsTable exte
{
this.lastCharIndex = lastCharIndexValue;
}
+
/**
* @return Returns the panose.
*/
@@ -293,6 +313,7 @@ public class OS2WindowsMetricsTable exte
{
return panose;
}
+
/**
* @param panoseValue The panose to set.
*/
@@ -300,6 +321,7 @@ public class OS2WindowsMetricsTable exte
{
this.panose = panoseValue;
}
+
/**
* @return Returns the strikeoutPosition.
*/
@@ -307,6 +329,7 @@ public class OS2WindowsMetricsTable exte
{
return strikeoutPosition;
}
+
/**
* @param strikeoutPositionValue The strikeoutPosition to set.
*/
@@ -314,6 +337,7 @@ public class OS2WindowsMetricsTable exte
{
this.strikeoutPosition = strikeoutPositionValue;
}
+
/**
* @return Returns the strikeoutSize.
*/
@@ -321,6 +345,7 @@ public class OS2WindowsMetricsTable exte
{
return strikeoutSize;
}
+
/**
* @param strikeoutSizeValue The strikeoutSize to set.
*/
@@ -328,6 +353,7 @@ public class OS2WindowsMetricsTable exte
{
this.strikeoutSize = strikeoutSizeValue;
}
+
/**
* @return Returns the subscriptXOffset.
*/
@@ -335,6 +361,7 @@ public class OS2WindowsMetricsTable exte
{
return subscriptXOffset;
}
+
/**
* @param subscriptXOffsetValue The subscriptXOffset to set.
*/
@@ -342,6 +369,7 @@ public class OS2WindowsMetricsTable exte
{
this.subscriptXOffset = subscriptXOffsetValue;
}
+
/**
* @return Returns the subscriptXSize.
*/
@@ -349,6 +377,7 @@ public class OS2WindowsMetricsTable exte
{
return subscriptXSize;
}
+
/**
* @param subscriptXSizeValue The subscriptXSize to set.
*/
@@ -356,6 +385,7 @@ public class OS2WindowsMetricsTable exte
{
this.subscriptXSize = subscriptXSizeValue;
}
+
/**
* @return Returns the subscriptYOffset.
*/
@@ -363,6 +393,7 @@ public class OS2WindowsMetricsTable exte
{
return subscriptYOffset;
}
+
/**
* @param subscriptYOffsetValue The subscriptYOffset to set.
*/
@@ -370,6 +401,7 @@ public class OS2WindowsMetricsTable exte
{
this.subscriptYOffset = subscriptYOffsetValue;
}
+
/**
* @return Returns the subscriptYSize.
*/
@@ -377,6 +409,7 @@ public class OS2WindowsMetricsTable exte
{
return subscriptYSize;
}
+
/**
* @param subscriptYSizeValue The subscriptYSize to set.
*/
@@ -384,6 +417,7 @@ public class OS2WindowsMetricsTable exte
{
this.subscriptYSize = subscriptYSizeValue;
}
+
/**
* @return Returns the superscriptXOffset.
*/
@@ -391,6 +425,7 @@ public class OS2WindowsMetricsTable exte
{
return superscriptXOffset;
}
+
/**
* @param superscriptXOffsetValue The superscriptXOffset to set.
*/
@@ -398,6 +433,7 @@ public class OS2WindowsMetricsTable exte
{
this.superscriptXOffset = superscriptXOffsetValue;
}
+
/**
* @return Returns the superscriptXSize.
*/
@@ -405,6 +441,7 @@ public class OS2WindowsMetricsTable exte
{
return superscriptXSize;
}
+
/**
* @param superscriptXSizeValue The superscriptXSize to set.
*/
@@ -412,6 +449,7 @@ public class OS2WindowsMetricsTable exte
{
this.superscriptXSize = superscriptXSizeValue;
}
+
/**
* @return Returns the superscriptYOffset.
*/
@@ -419,6 +457,7 @@ public class OS2WindowsMetricsTable exte
{
return superscriptYOffset;
}
+
/**
* @param superscriptYOffsetValue The superscriptYOffset to set.
*/
@@ -426,6 +465,7 @@ public class OS2WindowsMetricsTable exte
{
this.superscriptYOffset = superscriptYOffsetValue;
}
+
/**
* @return Returns the superscriptYSize.
*/
@@ -433,6 +473,7 @@ public class OS2WindowsMetricsTable exte
{
return superscriptYSize;
}
+
/**
* @param superscriptYSizeValue The superscriptYSize to set.
*/
@@ -440,6 +481,7 @@ public class OS2WindowsMetricsTable exte
{
this.superscriptYSize = superscriptYSizeValue;
}
+
/**
* @return Returns the typeLineGap.
*/
@@ -447,6 +489,7 @@ public class OS2WindowsMetricsTable exte
{
return typeLineGap;
}
+
/**
* @param typeLineGapValue The typeLineGap to set.
*/
@@ -454,6 +497,7 @@ public class OS2WindowsMetricsTable exte
{
this.typeLineGap = typeLineGapValue;
}
+
/**
* @return Returns the typoAscender.
*/
@@ -461,6 +505,7 @@ public class OS2WindowsMetricsTable exte
{
return typoAscender;
}
+
/**
* @param typoAscenderValue The typoAscender to set.
*/
@@ -468,6 +513,7 @@ public class OS2WindowsMetricsTable exte
{
this.typoAscender = typoAscenderValue;
}
+
/**
* @return Returns the typoDescender.
*/
@@ -475,6 +521,7 @@ public class OS2WindowsMetricsTable exte
{
return typoDescender;
}
+
/**
* @param typoDescenderValue The typoDescender to set.
*/
@@ -482,6 +529,7 @@ public class OS2WindowsMetricsTable exte
{
this.typoDescender = typoDescenderValue;
}
+
/**
* @return Returns the unicodeRange1.
*/
@@ -489,6 +537,7 @@ public class OS2WindowsMetricsTable exte
{
return unicodeRange1;
}
+
/**
* @param unicodeRange1Value The unicodeRange1 to set.
*/
@@ -496,6 +545,7 @@ public class OS2WindowsMetricsTable exte
{
this.unicodeRange1 = unicodeRange1Value;
}
+
/**
* @return Returns the unicodeRange2.
*/
@@ -503,6 +553,7 @@ public class OS2WindowsMetricsTable exte
{
return unicodeRange2;
}
+
/**
* @param unicodeRange2Value The unicodeRange2 to set.
*/
@@ -510,6 +561,7 @@ public class OS2WindowsMetricsTable exte
{
this.unicodeRange2 = unicodeRange2Value;
}
+
/**
* @return Returns the unicodeRange3.
*/
@@ -517,6 +569,7 @@ public class OS2WindowsMetricsTable exte
{
return unicodeRange3;
}
+
/**
* @param unicodeRange3Value The unicodeRange3 to set.
*/
@@ -524,6 +577,7 @@ public class OS2WindowsMetricsTable exte
{
this.unicodeRange3 = unicodeRange3Value;
}
+
/**
* @return Returns the unicodeRange4.
*/
@@ -531,6 +585,7 @@ public class OS2WindowsMetricsTable exte
{
return unicodeRange4;
}
+
/**
* @param unicodeRange4Value The unicodeRange4 to set.
*/
@@ -538,6 +593,7 @@ public class OS2WindowsMetricsTable exte
{
this.unicodeRange4 = unicodeRange4Value;
}
+
/**
* @return Returns the version.
*/
@@ -545,6 +601,7 @@ public class OS2WindowsMetricsTable exte
{
return version;
}
+
/**
* @param versionValue The version to set.
*/
@@ -552,6 +609,7 @@ public class OS2WindowsMetricsTable exte
{
this.version = versionValue;
}
+
/**
* @return Returns the weightClass.
*/
@@ -559,6 +617,7 @@ public class OS2WindowsMetricsTable exte
{
return weightClass;
}
+
/**
* @param weightClassValue The weightClass to set.
*/
@@ -566,6 +625,7 @@ public class OS2WindowsMetricsTable exte
{
this.weightClass = weightClassValue;
}
+
/**
* @return Returns the widthClass.
*/
@@ -573,6 +633,7 @@ public class OS2WindowsMetricsTable exte
{
return widthClass;
}
+
/**
* @param widthClassValue The widthClass to set.
*/
@@ -580,6 +641,7 @@ public class OS2WindowsMetricsTable exte
{
this.widthClass = widthClassValue;
}
+
/**
* @return Returns the winAscent.
*/
@@ -587,6 +649,7 @@ public class OS2WindowsMetricsTable exte
{
return winAscent;
}
+
/**
* @param winAscentValue The winAscent to set.
*/
@@ -594,6 +657,7 @@ public class OS2WindowsMetricsTable exte
{
this.winAscent = winAscentValue;
}
+
/**
* @return Returns the winDescent.
*/
@@ -601,6 +665,7 @@ public class OS2WindowsMetricsTable exte
{
return winDescent;
}
+
/**
* @param winDescentValue The winDescent to set.
*/
@@ -608,6 +673,7 @@ public class OS2WindowsMetricsTable exte
{
this.winDescent = winDescentValue;
}
+
private int version;
private short averageCharWidth;
private int weightClass;
@@ -641,12 +707,12 @@ public class OS2WindowsMetricsTable exte
private int winDescent;
private long codePageRange1 = -1;
private long codePageRange2 = -1;
-
+
/**
* A tag that identifies this table type.
*/
public static final String TAG = "OS/2";
-
+
/**
* This will read the required data from the stream.
*
@@ -654,7 +720,7 @@ public class OS2WindowsMetricsTable exte
* @param data The stream to read the data from.
* @throws IOException If there is an error reading the data.
*/
- public void initData( TrueTypeFont ttf, TTFDataStream data ) throws IOException
+ public void initData(TrueTypeFont ttf, TTFDataStream data) throws IOException
{
version = data.readUnsignedShort();
averageCharWidth = data.readSignedShort();
@@ -671,14 +737,14 @@ public class OS2WindowsMetricsTable exte
superscriptYOffset = data.readSignedShort();
strikeoutSize = data.readSignedShort();
strikeoutPosition = data.readSignedShort();
- familyClass = data.read();
- familySubClass = data.read();
- panose = data.read( 10 );
+ familyClass = data.readUnsignedByte();
+ familySubClass = data.readUnsignedByte();
+ panose = data.read(10);
unicodeRange1 = data.readUnsignedInt();
unicodeRange2 = data.readUnsignedInt();
unicodeRange3 = data.readUnsignedInt();
unicodeRange4 = data.readUnsignedInt();
- achVendId = data.readString( 4 );
+ achVendId = data.readString(4);
fsSelection = data.readUnsignedShort();
firstCharIndex = data.readUnsignedShort();
lastCharIndex = data.readUnsignedShort();
@@ -687,7 +753,7 @@ public class OS2WindowsMetricsTable exte
typeLineGap = data.readSignedShort();
winAscent = data.readUnsignedShort();
winDescent = data.readUnsignedShort();
- if( version >= 1 )
+ if (version >= 1)
{
codePageRange1 = data.readUnsignedInt();
codePageRange2 = data.readUnsignedInt();