dear-imgui-2.3.0: Haskell bindings for Dear ImGui.
Safe HaskellSafe-Inferred
LanguageHaskell2010

DearImGui.Raw.Font.GlyphRanges

Description

Font glyph ranges builder

Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call buildRanges.

Low-level example of usage:

  -- import ImGui.Fonts
  -- import ImGui.Raw.GlyphRangesBuilder as GRB

  builder <- GRB.new

  GRB.addRanges builder getGlyphRangesDefault
  liftIO $ withCString Привет $ GRB.addText builder
  rangesVec <- GRB.buildRanges builder
  let ranges = GRB.fromRangesVector rangesVec

  addFontFromFileTTF'
    ".imguimiscfontsDroidSans.ttf" 12
    Nothing
    (Just ranges)

  -- it is strictly necessary to explicitly build the atlas
  buildFontAtlas

  -- resource destruction comes only after the building
  GRB.destroyRangesVector rangesVec
  GRB.destroy builder
Synopsis

Documentation

newtype GlyphRanges Source #

Glyph ranges handle

Wraps ImWchar*.

Constructors

GlyphRanges (Ptr ImWchar) 

Built-in ranges

getBuiltin :: Builtin -> GlyphRanges Source #

Get builtin glyph ranges from a tag.

builtinSetup :: Builtin -> Maybe GlyphRanges Source #

Special case of getBuiltin, but for font source setup.

Preparing a builder

newtype GlyphRangesBuilder Source #

Glyph ranges builder handle

Wraps ImFontGlyphRangesBuilder*.

new :: MonadIO m => m GlyphRangesBuilder Source #

Create an instance of builder

destroy :: MonadIO m => GlyphRangesBuilder -> m () Source #

Destroy an instance of builder

Should be used after font atlas building.

addChar :: MonadIO m => GlyphRangesBuilder -> ImWchar -> m () Source #

Add character

addText :: MonadIO m => GlyphRangesBuilder -> CString -> m () Source #

Add string (each character of the UTF-8 string are added)

addRanges :: MonadIO m => GlyphRangesBuilder -> GlyphRanges -> m () Source #

Add ranges, e.g. 'addRanges builder getGlyphRangesDefault' to force add all of ASCII/Latin+Ext

Extracting data

newtype GlyphRangesVector Source #

Glyph ranges vector handle to keep builder output

Wraps ImVectorImWchar*.

Constructors

GlyphRangesVector (Ptr ()) 

buildRangesVector :: MonadIO m => GlyphRangesBuilder -> m GlyphRangesVector Source #

Build new ranges and create ranges vector instance, containing them

fromRangesVector :: GlyphRangesVector -> GlyphRanges Source #

Extract glyph ranges from a vector

Should be used before vector destruction.

destroyRangesVector :: MonadIO m => GlyphRangesVector -> m () Source #

Destroy a ranges vector instance

Should be used after font atlas building.