diff --git a/src/Graphics/Fountainhead/TrueType.hs b/src/Graphics/Fountainhead/TrueType.hs index 2b70841..de51575 100644 --- a/src/Graphics/Fountainhead/TrueType.hs +++ b/src/Graphics/Fountainhead/TrueType.hs @@ -779,8 +779,9 @@ data KernFormat0Pair = KernFormat0Pair } deriving (Eq, Show) data KernFormat0Table = KernFormat0Table - { nPairs :: Word16 -- ^ The number of kerning pairs in this subtable. - , searchRange :: Word16 -- ^ The largest power of two less than or equal to the value of nPairs, multiplied by the size in bytes of an entry in the subtable. + -- | The largest power of two less than or equal to the value of nPairs, + -- multiplied by the size in bytes of an entry in the subtable. + { searchRange :: Word16 -- | This is calculated as log2 of the largest power of two less than or -- equal to the value of nPairs. This value indicates how many iterations of -- the search loop have to be made. For example, in a list of eight items, @@ -792,3 +793,56 @@ data KernFormat0Table = KernFormat0Table , rangeShift :: Word16 , pairs :: [KernFormat0Pair] } deriving (Eq, Show) + +-- | Kern subtable format 1 header. +data StateHeader = StateHeader + { stateSize :: Word16 -- ^ Number of classes defined for this table. + -- | Offset from the beginning of the state table to the beginning of the + -- class subtable. + , classTableOffset :: Word16 + -- | Offset from the beginning of the state table to the beginning of the + -- state array. + , stateArrayOffset :: Word16 + -- | Offset from the beginning of the state table to the beginning of the + -- entry subtable. + , entryTableOffset :: Word16 + -- | Offset from the beginning of the state table to the beginning of the + -- state table values. + , valueOffset :: Word16 + } deriving (Eq, Show) + +data StateEntry = StateEntry + { newState :: Word16 + , flags :: Word16 + } deriving (Eq, Show) + +data KernFormat1Table = KernFormat1Table + { stateHeader :: StateHeader + , firstGlyph :: Word16 + , classArray :: ByteString + , stateArray :: ByteString + , entries :: [StateEntry] + } deriving (Eq, Show) + +data SimpleArrayHeader = SimpleArrayHeader + { rowWidth :: Word16 -- ^ The width, in bytes, of a row in the subtable. + -- | Offset from beginning of this subtable to the left-hand offset table. + , leftOffsetTable :: Word16 + -- | Offset from beginning of this subtable to right-hand offset table. + , rightOffsetTable :: Word16 + -- | Offset from beginning of this subtable to the start of the kerning + -- array. + , array :: Word16 + } deriving (Eq, Show) + +data ClassTableHeader = ClassTableHeader + { firstGlyph -- ^ First glyph in class range. + -- | The offsets array for all of the glyphs in the range. + , offsets :: [Word16] + } deriving (Eq, Show) + +data KernFormat2Table = KernFormat2Table + { simpleArrayHeader :: SimpleArrayHeader + , classTableHeader :: ClassTableHeader + , values :: [Int16] + } deriving (Eq, Show)