| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
KB.Text.Shape
Synopsis
- withContext :: (Context -> IO r) -> IO r
- data Context = Context {
- handle :: ShapeContext
- fonts :: IORef (IntMap ByteStringRC)
- createContext :: IO Context
- destroyContext :: Context -> IO ()
- data Font
- pushFontFromFile :: Context -> FilePath -> Int -> IO Font
- pushFontFromMemory :: Context -> ByteString -> Int -> IO Font
- pushFont :: Context -> Font -> IO Int
- popFont :: Context -> IO (Int, Font)
- run :: Context -> ((?shapeContext :: ShapeContext) => IO ()) -> IO [(Run, [Glyph])]
- data Run = Run {
- font :: Font
- script :: Script
- paragraphDirection :: Direction
- direction :: Direction
- flags :: BreakFlags
- data Glyph = Glyph {
- codepoint :: Char
- id :: Word16
- uid :: Word16
- codepointIndex :: Int
- offsetX :: Int
- offsetY :: Int
- advanceX :: Int
- advanceY :: Int
- attachGlyph :: Maybe Glyph
- decomposition :: Word64
- classes :: Word32
- flags :: GlyphFlags
- joiningType :: UnicodeJoiningType
- unicodeFlags :: Word8
- syllabicClass :: Word8
- syllabicPosition :: Word8
- useClass :: Word8
- combiningClass :: Word8
- gpos :: Glyph -> GPOS Int
- data GPOS a = GPOS {}
- text_ :: (?shapeContext :: ShapeContext) => Text -> IO ()
- char_ :: (?shapeContext :: ShapeContext) => Char -> IO ()
- withFeature_ :: (?shapeContext :: ShapeContext) => FeatureTag -> Int -> IO r -> IO r
- pushFeature_ :: (?shapeContext :: ShapeContext) => FeatureTag -> Int -> IO ()
- popFeature_ :: (?shapeContext :: ShapeContext) => FeatureTag -> IO Int
- stripGlyph :: Glyph -> IO Glyph
The slow part
destroyContext :: Context -> IO () Source #
Adding fonts
The context is capable of managing multiple fonts through a font stack. The font stack will hold references to all fonts in use by the context. Whenever you try to shape some text, the context will check to see if it is supported by the font at the top of the stack. If it is not, it will try the next font down, and so on, until all fonts have been tried. As such, you should push your fallback fonts first, and your preferred fonts last.
An opaque handle to the font data.
pushFontFromMemory :: Context -> ByteString -> Int -> IO Font Source #
Turning texts into glyphs
Text runs with uniform direction and script.
The result of a text segmentation work.
Glyphs ready to rasterize.
The result of a text shaping work.
Constructors
| Glyph | |
Fields
| |
Feeding input
text_ :: (?shapeContext :: ShapeContext) => Text -> IO () Source #
Add a chunk of text to the shaping run.
This will not add extra characters like newlines or whitespace. You may want to call this multiple times instead of concatentating everything.
char_ :: (?shapeContext :: ShapeContext) => Char -> IO () Source #
Add one codepoint to the shaping run.
The context has a feature stack that allows you to manipulate font features hierarchically. When you give text to the context, it will apply all feature overrides that are on the stack at the time.
If two feature overrides use the same tag, then only the latest one, i.e. the one higher in the stack, is applied.
withFeature_ :: (?shapeContext :: ShapeContext) => FeatureTag -> Int -> IO r -> IO r Source #
pushFeature_ :: (?shapeContext :: ShapeContext) => FeatureTag -> Int -> IO () Source #
popFeature_ :: (?shapeContext :: ShapeContext) => FeatureTag -> IO Int Source #