Portability | GHC |
---|---|
Stability | highly unstable |
Maintainer | Stephen Tetley <stephen.tetley@gmail.com> |
AFM file parser.
Note - AFM Version 2.0 used by GhostScript and Version 3.0+ have numerous differences.
- data AfmUnit
- afmValue :: FromPtSize u => AfmUnit -> PtSize -> u
- afmUnitScale :: AfmUnit -> PtSize
- type PSCharCode = Int
- type PSEncodingScheme = String
- type AfmBoundingBox = BoundingBox AfmUnit
- type AfmKey = String
- type GlobalInfo = Map AfmKey String
- data AfmFile = AfmFile {}
- data AfmGlyphMetrics = AfmGlyphMetrics {
- afm_char_code :: !PSCharCode
- afm_width_vector :: !(Vec2 AfmUnit)
- afm_char_name :: !String
- type FontLoadErr = String
- type FontLoadResult cu = Either FontLoadErr (GlyphMetricsTable cu)
- data FontLoader cu = forall interim . FontLoader {
- unit_scale_fun :: cu -> PtSize
- path_to_font_dir :: FilePath
- file_name_locator :: FontName -> FilePath
- font_parser :: FilePath -> IO (Either String interim)
- post_process :: interim -> GlyphMetricsTable cu
- loadFont :: FontLoader cu -> FontName -> IO (FontLoadResult cu)
- type BaseGlyphMetrics = Map FontName GlyphMetrics
- loadBaseGlyphMetrics :: FontLoader u -> [FontName] -> IO BaseGlyphMetrics
- buildGlyphMetricsTable :: BoundingBox AfmUnit -> Vec2 AfmUnit -> AfmUnit -> AfmFile -> GlyphMetricsTable AfmUnit
Afm Unit
Wrapped Double representing 1/1000 of the scale factor (Point size) of a font. AFM files encode all measurements as these units.
afmValue :: FromPtSize u => AfmUnit -> PtSize -> uSource
Compute the size of a measurement in Afm units scaled by the point size of the font.
afmUnitScale :: AfmUnit -> PtSizeSource
Glyph metrics
type PSCharCode = IntSource
Afm files index glyphs by PostScript character code. This is not the same as Unicode, ASCII...
It is expected to be determined by EncodingScheme
in the
Global Font Information Section.
type PSEncodingScheme = StringSource
type GlobalInfo = Map AfmKey StringSource
Wumpus needs a very small subset of AFM files, common to both version 2.0 and version 4.1.
Note - Bounding Box is mandatory for AFM versions 3.0 and 4.1
Cap Height is optional in AFM versions 3.0 and 4.1. As Wumpus uses cap height in calculations, glyph metrics must be build with an arbitrary value if it is not present.
Encoding Scheme is optional in AFM files.
data AfmGlyphMetrics Source
AfmGlyphMetrics | |
|
Font loading
type FontLoadErr = StringSource
type FontLoadResult cu = Either FontLoadErr (GlyphMetricsTable cu)Source
data FontLoader cu Source
forall interim . FontLoader | |
|
loadFont :: FontLoader cu -> FontName -> IO (FontLoadResult cu)Source
loadBaseGlyphMetrics :: FontLoader u -> [FontName] -> IO BaseGlyphMetricsSource