Parse GASP table
This commit is contained in:
parent
0cda68e19b
commit
b87abcbf2f
@ -18,6 +18,7 @@ module Graphics.Fountainhead.Parser
|
|||||||
, fixedP
|
, fixedP
|
||||||
, fontDirectoryP
|
, fontDirectoryP
|
||||||
, fpgmTableP
|
, fpgmTableP
|
||||||
|
, gaspTableP
|
||||||
, glyfTableP
|
, glyfTableP
|
||||||
, hdmxTableP
|
, hdmxTableP
|
||||||
, headTableP
|
, headTableP
|
||||||
@ -97,6 +98,8 @@ import Graphics.Fountainhead.TrueType
|
|||||||
, FontDirectionHint(..)
|
, FontDirectionHint(..)
|
||||||
, FontDirectory(..)
|
, FontDirectory(..)
|
||||||
, FontStyle(..)
|
, FontStyle(..)
|
||||||
|
, GASPRange(..)
|
||||||
|
, GASPTable(..)
|
||||||
, GlyfTable(..)
|
, GlyfTable(..)
|
||||||
, GlyphArgument(..)
|
, GlyphArgument(..)
|
||||||
, GlyphCoordinate(..)
|
, GlyphCoordinate(..)
|
||||||
@ -842,8 +845,7 @@ cmapFormat4TableP = do
|
|||||||
entrySelector' <- Megaparsec.Binary.word16be
|
entrySelector' <- Megaparsec.Binary.word16be
|
||||||
rangeShift' <- Megaparsec.Binary.word16be
|
rangeShift' <- Megaparsec.Binary.word16be
|
||||||
endCode' <- vectorNP segCount Megaparsec.Binary.word16be
|
endCode' <- vectorNP segCount Megaparsec.Binary.word16be
|
||||||
rangeShift' <- Megaparsec.Binary.word16be
|
void $ Megaparsec.chunk $ ByteString.pack [0, 0] -- reservedPad 0.
|
||||||
-- reservedPad 0.
|
|
||||||
startCode' <- vectorNP segCount Megaparsec.Binary.word16be
|
startCode' <- vectorNP segCount Megaparsec.Binary.word16be
|
||||||
idDelta' <- vectorNP segCount Megaparsec.Binary.word16be
|
idDelta' <- vectorNP segCount Megaparsec.Binary.word16be
|
||||||
idRangeOffset' <- vectorNP segCount Megaparsec.Binary.word16be
|
idRangeOffset' <- vectorNP segCount Megaparsec.Binary.word16be
|
||||||
@ -1211,3 +1213,20 @@ bMidlineP
|
|||||||
<|> (Megaparsec.single 12 $> LowPointedMidline)
|
<|> (Megaparsec.single 12 $> LowPointedMidline)
|
||||||
<|> (Megaparsec.single 13 $> LowSerifedMidline)
|
<|> (Megaparsec.single 13 $> LowSerifedMidline)
|
||||||
<?> "bMidline"
|
<?> "bMidline"
|
||||||
|
|
||||||
|
-- * Grid-fitting And Scan-conversion Procedure.
|
||||||
|
|
||||||
|
gaspTableP :: Parser GASPTable
|
||||||
|
gaspTableP = do
|
||||||
|
version' <- Megaparsec.Binary.word16be
|
||||||
|
numberRanges <- fromIntegral <$> Megaparsec.Binary.word16be
|
||||||
|
parsedRanges <- Megaparsec.count numberRanges gaspRangeP
|
||||||
|
Megaparsec.eof
|
||||||
|
pure $ GASPTable
|
||||||
|
{ version = version'
|
||||||
|
, gaspRange = parsedRanges
|
||||||
|
}
|
||||||
|
where
|
||||||
|
gaspRangeP = GASPRange
|
||||||
|
<$> Megaparsec.Binary.word16be
|
||||||
|
<*> Megaparsec.Binary.word16be
|
||||||
|
@ -40,6 +40,8 @@ module Graphics.Fountainhead.TrueType
|
|||||||
, FontDirectionHint(..)
|
, FontDirectionHint(..)
|
||||||
, FontDirectory(..)
|
, FontDirectory(..)
|
||||||
, FontStyle(..)
|
, FontStyle(..)
|
||||||
|
, GASPRange(..)
|
||||||
|
, GASPTable(..)
|
||||||
, GlyfTable(..)
|
, GlyfTable(..)
|
||||||
, GlyphArgument(..)
|
, GlyphArgument(..)
|
||||||
, GlyphCoordinate(..)
|
, GlyphCoordinate(..)
|
||||||
@ -71,6 +73,7 @@ module Graphics.Fountainhead.TrueType
|
|||||||
, PostSubtable(..)
|
, PostSubtable(..)
|
||||||
, PostTable(..)
|
, PostTable(..)
|
||||||
, PrepTable(..)
|
, PrepTable(..)
|
||||||
|
, RangeGaspBehavior(..)
|
||||||
, SimpleGlyphDefinition(..)
|
, SimpleGlyphDefinition(..)
|
||||||
, TableDirectory(..)
|
, TableDirectory(..)
|
||||||
, TrueMaxpTable(..)
|
, TrueMaxpTable(..)
|
||||||
@ -387,8 +390,9 @@ data OutlineFlag = OutlineFlag
|
|||||||
newtype GlyfTable = GlyfTable (Vector GlyphDescription)
|
newtype GlyfTable = GlyfTable (Vector GlyphDescription)
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
-- * Character to glyph mapping table
|
-- 'cmap' table
|
||||||
|
|
||||||
|
-- | Character to glyph mapping table.
|
||||||
data CmapTable = CmapTable
|
data CmapTable = CmapTable
|
||||||
{ version :: Word16 -- ^ Version number is zero.
|
{ version :: Word16 -- ^ Version number is zero.
|
||||||
-- | Encodings with an offset into subtables map.
|
-- | Encodings with an offset into subtables map.
|
||||||
@ -1273,3 +1277,29 @@ data KernFormat2Table = KernFormat2Table
|
|||||||
, classTableHeader :: ClassTableHeader
|
, classTableHeader :: ClassTableHeader
|
||||||
, values :: [Int16]
|
, values :: [Int16]
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
|
-- * 'gasp' table
|
||||||
|
|
||||||
|
-- | Grid-fitting And Scan-conversion Procedure.
|
||||||
|
data GASPTable = GASPTable
|
||||||
|
{ version :: Word16 -- ^ Version number (set to 0).
|
||||||
|
, gaspRange :: [GASPRange] -- ^ Sorted by ppem.
|
||||||
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
|
data GASPRange = GASPRange
|
||||||
|
{ rangeMaxPPEM :: Word16 -- ^ Upper limit of range, in PPEM.
|
||||||
|
, rangeGaspBehavior :: Word16 -- ^ Flags describing desired rasterizer behavior.
|
||||||
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
|
data RangeGaspBehavior
|
||||||
|
= KGASPGridFit -- ^ Use gridfitting.
|
||||||
|
| KGASPDoGray -- ^ Use grayscale rendering.
|
||||||
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
instance Enum RangeGaspBehavior
|
||||||
|
where
|
||||||
|
toEnum 1 = KGASPGridFit
|
||||||
|
toEnum 2 = KGASPDoGray
|
||||||
|
toEnum _ = error "Unknown range GASP behavior"
|
||||||
|
fromEnum KGASPGridFit = 1
|
||||||
|
fromEnum KGASPDoGray = 2
|
||||||
|
Loading…
Reference in New Issue
Block a user