APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.tools.hiero

public Class Kerning

extends Object
Class Inheritance
Imports
com.badlogic.gdx.utils.IntArray, .IntIntMap, java.io.ByteArrayInputStream, .ByteArrayOutputStream, .EOFException, .IOException, .InputStream

Reads a TTF font file and provides access to kerning information. Thanks to the Apache FOP project for their inspiring work!
Author
Nathan Sweet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private int
private int
private Kerning.TTFInputStream
private IntIntMap
private int
private float

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public IntIntMap
getKernings()

Returns: A map from pairs of glyph codes to their kerning in pixels.

public void
load(InputStream
The data for the TTF font.
inputStream
,
int
The font size to use to determine kerning pixel offsets.
fontSize
)

private IntArray[]
readClassDefinition(int position, int classCount)

private void
private void
private int[]
private void
readExtensionPositioningFormat1(int subTablePosition)

private void
readExtensionPositioningSubtable(int subTablePosition)

private void
private void
readHEAD(int fontSize)

private void
private void
readPairAdjustmentSubtable(int subTablePosition)

private void
readPairPositioningAdjustmentFormat1(long subTablePosition)

private void
private void
readSubtable(int type, int subTablePosition)

private void
readSubtables(int type, int lookupPosition)

private void
private int
readXAdvanceFromValueRecord(int valueFormat)

private void
storeKerningOffset(int firstGlyphCode, int secondGlyphCode, int offset)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

gposOffsetback to summary
private int gposOffset
headOffsetback to summary
private int headOffset
inputback to summary
private Kerning.TTFInputStream input
kerningsback to summary
private IntIntMap kernings
kernOffsetback to summary
private int kernOffset
scaleback to summary
private float scale

Constructor Detail

Kerningback to summary
public Kerning()

Method Detail

getKerningsback to summary
public IntIntMap getKernings()
Returns:IntIntMap

A map from pairs of glyph codes to their kerning in pixels. Each map key encodes two glyph codes: the high 16 bits form the first glyph code, and the low 16 bits form the second.

loadback to summary
public void load(InputStream inputStream, int fontSize) throws IOException
Parameters
inputStream:InputStream

The data for the TTF font.

fontSize:int

The font size to use to determine kerning pixel offsets.

Exceptions
IOException:
If the font could not be read.
readClassDefinitionback to summary
private IntArray[] readClassDefinition(int position, int classCount) throws IOException
readClassDefinitionFormat1back to summary
private void readClassDefinitionFormat1(IntArray[] glyphsByClass) throws IOException
readClassDefinitionFormat2back to summary
private void readClassDefinitionFormat2(IntArray[] glyphsByClass) throws IOException
readCoverageTableback to summary
private int[] readCoverageTable() throws IOException
readExtensionPositioningFormat1back to summary
private void readExtensionPositioningFormat1(int subTablePosition) throws IOException
readExtensionPositioningSubtableback to summary
private void readExtensionPositioningSubtable(int subTablePosition) throws IOException
readGPOSback to summary
private void readGPOS() throws IOException
readHEADback to summary
private void readHEAD(int fontSize) throws IOException
readKERNback to summary
private void readKERN() throws IOException
readPairAdjustmentSubtableback to summary
private void readPairAdjustmentSubtable(int subTablePosition) throws IOException
readPairPositioningAdjustmentFormat1back to summary
private void readPairPositioningAdjustmentFormat1(long subTablePosition) throws IOException
readPairPositioningAdjustmentFormat2back to summary
private void readPairPositioningAdjustmentFormat2(int subTablePosition) throws IOException
readSubtableback to summary
private void readSubtable(int type, int subTablePosition) throws IOException
readSubtablesback to summary
private void readSubtables(int type, int lookupPosition) throws IOException
readTableDirectoryback to summary
private void readTableDirectory() throws IOException
readXAdvanceFromValueRecordback to summary
private int readXAdvanceFromValueRecord(int valueFormat) throws IOException
storeKerningOffsetback to summary
private void storeKerningOffset(int firstGlyphCode, int secondGlyphCode, int offset)
com.badlogic.gdx.tools.hiero back to summary

private Class Kerning.TTFInputStream

extends ByteArrayInputStream
Class Inheritance

Field Summary

Inherited from java.io.ByteArrayInputStream:
bufcountmarkpos

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
private static byte[]
public byte
public short
public int
public long
public int
public int[]
public void
seek(int position)

Inherited from java.io.ByteArrayInputStream:
availableclosemarkmarkSupportedreadreadreadAllBytesreadNBytesresetskiptransferTo

Constructor Detail

TTFInputStreamback to summary
public TTFInputStream(InputStream input) throws IOException

Method Detail

getPositionback to summary
public int getPosition()
readAllBytesback to summary
private static byte[] readAllBytes(InputStream input) throws IOException
readByteback to summary
public byte readByte() throws IOException
readShortback to summary
public short readShort() throws IOException
readUnsignedByteback to summary
public int readUnsignedByte() throws IOException
readUnsignedLongback to summary
public long readUnsignedLong() throws IOException
readUnsignedShortback to summary
public int readUnsignedShort() throws IOException
readUnsignedShortArrayback to summary
public int[] readUnsignedShortArray(int count) throws IOException
seekback to summary
public void seek(int position)