kb-text-shape
Safe HaskellNone
LanguageGHC2021

KB.Text.Shape

Synopsis

The slow part

withContext :: (Context -> IO r) -> IO r Source #

data Context Source #

Constructors

Context 

Fields

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.

data Font Source #

An opaque handle to the font data.

Instances

Instances details
Storable Font Source # 
Instance details

Defined in KB.Text.Shape.FFI.Handles

Methods

sizeOf :: Font -> Int #

alignment :: Font -> Int #

peekElemOff :: Ptr Font -> Int -> IO Font #

pokeElemOff :: Ptr Font -> Int -> Font -> IO () #

peekByteOff :: Ptr b -> Int -> IO Font #

pokeByteOff :: Ptr b -> Int -> Font -> IO () #

peek :: Ptr Font -> IO Font #

poke :: Ptr Font -> Font -> IO () #

Show Font Source # 
Instance details

Defined in KB.Text.Shape.FFI.Handles

Methods

showsPrec :: Int -> Font -> ShowS #

show :: Font -> String #

showList :: [Font] -> ShowS #

Eq Font Source # 
Instance details

Defined in KB.Text.Shape.FFI.Handles

Methods

(==) :: Font -> Font -> Bool #

(/=) :: Font -> Font -> Bool #

Ord Font Source # 
Instance details

Defined in KB.Text.Shape.FFI.Handles

Methods

compare :: Font -> Font -> Ordering #

(<) :: Font -> Font -> Bool #

(<=) :: Font -> Font -> Bool #

(>) :: Font -> Font -> Bool #

(>=) :: Font -> Font -> Bool #

max :: Font -> Font -> Font #

min :: Font -> Font -> Font #

Turning texts into glyphs

run :: Context -> ((?shapeContext :: ShapeContext) => IO ()) -> IO [(Run, [Glyph])] Source #

Run the segmentation and shaping.

NB: Make sure you did load some fonts and text data!

Add content with text_ and char_, which you may wrap in feature tag sections.

data Run Source #

Text runs with uniform direction and script.

The result of a text segmentation work.

Instances

Instances details
Show Run Source # 
Instance details

Defined in KB.Text.Shape

Methods

showsPrec :: Int -> Run -> ShowS #

show :: Run -> String #

showList :: [Run] -> ShowS #

Eq Run Source # 
Instance details

Defined in KB.Text.Shape

Methods

(==) :: Run -> Run -> Bool #

(/=) :: Run -> Run -> Bool #

data Glyph Source #

Glyphs ready to rasterize.

The result of a text shaping work.

Constructors

Glyph 

Fields

Instances

Instances details
Show Glyph Source # 
Instance details

Defined in KB.Text.Shape

Methods

showsPrec :: Int -> Glyph -> ShowS #

show :: Glyph -> String #

showList :: [Glyph] -> ShowS #

Eq Glyph Source # 
Instance details

Defined in KB.Text.Shape

Methods

(==) :: Glyph -> Glyph -> Bool #

(/=) :: Glyph -> Glyph -> Bool #

HasField "gpos" Glyph (GPOS Int) Source # 
Instance details

Defined in KB.Text.Shape

Methods

getField :: Glyph -> GPOS Int #

gpos :: Glyph -> GPOS Int Source #

Extract glyph positioning information.

data GPOS a Source #

Constructors

GPOS 

Fields

Instances

Instances details
Functor GPOS Source # 
Instance details

Defined in KB.Text.Shape

Methods

fmap :: (a -> b) -> GPOS a -> GPOS b #

(<$) :: a -> GPOS b -> GPOS a #

HasField "gpos" Glyph (GPOS Int) Source # 
Instance details

Defined in KB.Text.Shape

Methods

getField :: Glyph -> GPOS Int #

Show a => Show (GPOS a) Source # 
Instance details

Defined in KB.Text.Shape

Methods

showsPrec :: Int -> GPOS a -> ShowS #

show :: GPOS a -> String #

showList :: [GPOS a] -> ShowS #

Eq a => Eq (GPOS a) Source # 
Instance details

Defined in KB.Text.Shape

Methods

(==) :: GPOS a -> GPOS a -> Bool #

(/=) :: GPOS a -> GPOS a -> Bool #

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 #

Internals

stripGlyph :: Glyph -> IO Glyph Source #

Remove the internals and pointer data