kb-text-shape 0.1.0.0 → 0.1.0.1
raw patch · 4 files changed
+26/−9 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ KB.Text.Shape: data ShapeContext
+ KB.Text.Shape: withFont_ :: (?shapeContext :: ShapeContext) => Font -> IO () -> IO ()
Files
- CHANGELOG.md +6/−2
- README.md +2/−2
- kb-text-shape.cabal +2/−2
- src/KB/Text/Shape.hs +16/−3
CHANGELOG.md view
@@ -6,6 +6,10 @@ and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). -## Unreleased+## 0.1.0.1 - 2026-03-15 -## 0.1.0.0 - YYYY-MM-DD+- Added `withFont_`. This allows reusing the font stacks for text styling too.++## 0.1.0.0 - 2025-12-30++Initial release.
README.md view
@@ -1,8 +1,8 @@ # kb-text-shape -Haskell wrapper for the `kb_text_shape.h` unicode segmentation and shaping library.+Haskell wrapper for the [kb_text_shape.h] unicode segmentation and shaping library (v2.06). -[kb\_text\_shape.h]: https://github.com/JimmyLefevre/kb/blob/main/kb_text_shape.h+[kb_text_shape.h]: https://github.com/JimmyLefevre/kb/blob/main/kb_text_shape.h > ``` > Your text A Text runs with B Sequence of glyphs C
kb-text-shape.cabal view
@@ -1,11 +1,11 @@ cabal-version: 2.2 --- This file has been generated from package.yaml by hpack version 0.38.1.+-- This file has been generated from package.yaml by hpack version 0.39.1. -- -- see: https://github.com/sol/hpack name: kb-text-shape-version: 0.1.0.0+version: 0.1.0.1 synopsis: Unicode segmentation and shaping using kb_text_shape category: Font homepage: https://github.com/dpwiz/kb-text-shape#readme
src/KB/Text/Shape.hs view
@@ -20,8 +20,10 @@ , gpos , GPOS(..) -- ** Feeding input+ , Handles.ShapeContext , text_ , char_+ , withFont_ -- $features , withFeature_ , pushFeature_@@ -32,7 +34,7 @@ import Control.Monad import Data.IORef-import Foreign+import Foreign hiding (void) import Foreign.C import Prelude hiding (id) @@ -173,6 +175,17 @@ (fromIntegral strLen) Enums.USER_ID_GENERATION_MODE_CODEPOINT_INDEX +{- | Run a section with extra fonts on the stack.++The text added here will first consider the new font.+This may be used to implement text styles by pushing bold/italic variants.+-}+withFont_ :: (?shapeContext :: Handles.ShapeContext) => Handles.Font -> IO () -> IO ()+withFont_ f action = do+ void $! ShapeContext.kbts_ShapePushFont ?shapeContext f+ action+ void $! ShapeContext.kbts_ShapePopFont ?shapeContext+ {- $features The context has a feature stack that allows you to manipulate font features hierarchically.@@ -185,9 +198,9 @@ withFeature_ :: (?shapeContext :: Handles.ShapeContext) => Enums.FeatureTag -> Int -> IO r -> IO r withFeature_ tag value action = do- ShapeContext.kbts_ShapePushFeature ?shapeContext tag (fromIntegral value)+ pushFeature_ tag value r <- action- _ <- ShapeContext.kbts_ShapePopFeature ?shapeContext tag+ _ <- popFeature_ tag pure r pushFeature_ :: (?shapeContext :: Handles.ShapeContext) => Enums.FeatureTag -> Int -> IO ()