public class TTFSubSetFile extends TTFFile
OpenFont.PostScriptVersion
Modifier and Type | Field and Description |
---|---|
protected int |
currentPos |
protected int[] |
glyphOffsets
Stores the glyph offsets so that we can end strings at glyph boundaries
|
protected int |
locaOffset |
protected java.util.Map<OFTableName,OFDirTabEntry> |
newDirTabs
The dir tab entries in the new subset font.
|
protected java.util.Map<OFTableName,java.lang.Integer> |
offsets |
protected byte[] |
output |
protected int |
realSize |
advancedTableReader, cid, dirTabs, embedFontName, familyNames, fontFile, fullName, lastLoca, locaFormat, log, mtxTab, nhmtx, notice, numberOfGlyphs, postScriptName, subFamilyName, TRACE_ENABLED, unicodeMappings, useAdvanced, useKerning
Constructor and Description |
---|
TTFSubSetFile()
Default Constructor
|
TTFSubSetFile(boolean useKerning,
boolean useAdvanced)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected int[] |
buildSubsetIndexToOrigIndexMap(java.util.Map<java.lang.Integer,java.lang.Integer> glyphs) |
protected void |
createCheckSumAdjustment() |
protected boolean |
createCvt(FontFileReader in)
Copy the cvt table as is from original font to subset font
|
protected void |
createDirectory()
Create the directory table
|
protected boolean |
createFpgm(FontFileReader in)
Copy the fpgm table as is from original font to subset font
|
protected void |
createHead(FontFileReader in)
Copy the head table as is from original font to subset font
and set indexToLocaFormat to long and set
checkSumAdjustment to 0, store offset to checkSumAdjustment
in checkSumAdjustmentOffset
|
protected void |
createHhea(FontFileReader in,
int size)
Copy the hhea table as is from original font to subset font
and fill in size of hmtx table
|
protected void |
createHmtx(FontFileReader in,
java.util.Map<java.lang.Integer,java.lang.Integer> glyphs)
Create the hmtx table by copying metrics from original
font to subset font.
|
protected void |
createLoca(int size)
Create an empty loca table without updating checksum
|
protected void |
createMaxp(FontFileReader in,
int size)
Copy the maxp table as is from original font to subset font
and set num glyphs to size
|
protected boolean |
createName(FontFileReader in)
Copy the name table as is from the original.
|
protected boolean |
createOS2(FontFileReader in)
Copy the OS/2 table as is from the original.
|
protected void |
createPost(FontFileReader in) |
protected boolean |
createPrep(FontFileReader in)
Copy the prep table as is from original font to subset font
|
protected static int |
getCheckSum(byte[] data,
int start,
int size) |
byte[] |
getFontSubset()
Returns a subset of the fonts (readFont() MUST be called first in order to create the
subset).
|
protected void |
pad4()
Create a padding in the fontfile to align
on a 4-byte boundary
|
void |
readFont(FontFileReader in,
java.lang.String name,
java.lang.String header,
java.util.Map<java.lang.Integer,java.lang.Integer> glyphs)
Reads a font and creates a subset of the font.
|
protected void |
scanGlyphs(FontFileReader in,
java.util.Map<java.lang.Integer,java.lang.Integer> subsetGlyphs) |
void |
stream(TTFOutputStream ttfOut)
Streams a font.
|
protected void |
updateCheckSum(int tableStart,
int tableSize,
OFTableName tableName) |
protected void |
writeBytes(byte[] b) |
protected void |
writeULong(int pos,
int s)
Appends a ULONG to the output array,
at the given position without changing currentPos
|
protected void |
writeUShort(int s)
Appends a USHORT to the output array,
updates currentPost but not realSize
|
protected void |
writeUShort(int pos,
int s)
Appends a USHORT to the output array,
at the given position without changing currentPos
|
getLastGlyfLocation, initializeFont, readIndexToLocation, readName, updateBBoxAndOffset
checkTTC, convertTTFUnit2PDFUnit, createCMaps, determineAscDesc, getAnsiKerning, getBBox, getBBoxRaw, getBoundingBoxes, getCapHeight, getCharSetName, getCharWidth, getCharWidthRaw, getCMaps, getCopyrightNotice, getDirectoryEntry, getEmbedFontName, getFamilyNames, getFirstChar, getFlags, getFontBBox, getFullName, getGDEF, getGPOS, getGSUB, getItalicAngle, getKerning, getLastChar, getLowerCaseAscent, getLowerCaseDescent, getMtx, getNumGlyphs, getPadSize, getPostScriptName, getStemV, getStrikeoutPosition, getStrikeoutThickness, getSubFamilyName, getTTCnames, getUnderlinePosition, getUnderlineThickness, getWeightClass, getWidths, getXHeight, guessVerticalMetricsFromGlyphBBox, handleCharacterSpacing, hasAdvancedTable, initAnsiWidths, isCFF, isEmbeddable, main, printStuff, readCMAP, readDirTabs, readFont, readFont, readFont, readFontHeader, readHorizontalHeader, readHorizontalMetrics, readKerning, readOS2, readPCLT, readPostScript, seekTab
protected byte[] output
protected int realSize
protected int currentPos
protected java.util.Map<OFTableName,java.lang.Integer> offsets
protected int locaOffset
protected int[] glyphOffsets
protected java.util.Map<OFTableName,OFDirTabEntry> newDirTabs
public TTFSubSetFile()
public TTFSubSetFile(boolean useKerning, boolean useAdvanced)
useKerning
- true if kerning data should be loadeduseAdvanced
- true if advanced typographic tables should be loadedprotected void createDirectory()
protected void createLoca(int size) throws java.io.IOException
java.io.IOException
protected boolean createCvt(FontFileReader in) throws java.io.IOException
java.io.IOException
protected boolean createFpgm(FontFileReader in) throws java.io.IOException
java.io.IOException
protected boolean createName(FontFileReader in) throws java.io.IOException
java.io.IOException
protected boolean createOS2(FontFileReader in) throws java.io.IOException
java.io.IOException
protected void createMaxp(FontFileReader in, int size) throws java.io.IOException
java.io.IOException
protected void createPost(FontFileReader in) throws java.io.IOException
java.io.IOException
protected boolean createPrep(FontFileReader in) throws java.io.IOException
java.io.IOException
protected void createHhea(FontFileReader in, int size) throws java.io.IOException
java.io.IOException
protected void createHead(FontFileReader in) throws java.io.IOException
java.io.IOException
protected int[] buildSubsetIndexToOrigIndexMap(java.util.Map<java.lang.Integer,java.lang.Integer> glyphs)
protected void createHmtx(FontFileReader in, java.util.Map<java.lang.Integer,java.lang.Integer> glyphs) throws java.io.IOException
java.io.IOException
public void readFont(FontFileReader in, java.lang.String name, java.lang.String header, java.util.Map<java.lang.Integer,java.lang.Integer> glyphs) throws java.io.IOException
in
- FontFileReader to read fromname
- Name to be checked for in the font fileglyphs
- Map of glyphs (glyphs has old index as (Integer) key and
new index as (Integer) value)java.io.IOException
- in case of an I/O problempublic byte[] getFontSubset()
public void stream(TTFOutputStream ttfOut) throws java.io.IOException
OpenFont
protected void scanGlyphs(FontFileReader in, java.util.Map<java.lang.Integer,java.lang.Integer> subsetGlyphs) throws java.io.IOException
java.io.IOException
protected void writeBytes(byte[] b)
protected void writeUShort(int s)
protected void writeUShort(int pos, int s)
protected void writeULong(int pos, int s)
protected void pad4()
protected void updateCheckSum(int tableStart, int tableSize, OFTableName tableName)
protected static int getCheckSum(byte[] data, int start, int size)
protected void createCheckSumAdjustment()
Copyright 1999-2017 The Apache Software Foundation. All Rights Reserved.