summaryrefslogtreecommitdiff
path: root/src/Graphics/Fountainhead/TrueType.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-04-18 10:52:24 +0200
committerEugen Wissner <belka@caraus.de>2023-04-18 10:52:24 +0200
commit57478f83625c885a3c5fdfdc84450eee9a3b5b1d (patch)
tree2a0a8041769002ebb77ed0161956c73088d7cf06 /src/Graphics/Fountainhead/TrueType.hs
parent929ab04c2cdaa2c2296a2bf64582981fed52eb8e (diff)
downloadfountainhead-57478f83625c885a3c5fdfdc84450eee9a3b5b1d.tar.gz
Add kern table formats 1 and 2
Diffstat (limited to 'src/Graphics/Fountainhead/TrueType.hs')
-rw-r--r--src/Graphics/Fountainhead/TrueType.hs58
1 files changed, 56 insertions, 2 deletions
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)