Blendend.Text.GlyphBuffer (blendend v0.3.0)
View SourceA glyph buffer holds input text (UTF-8) and, after shaping, the glyph IDs / clusters / positions produced by a font.
We normally don't draw directly from a GlyphBuffer; we turn it into a
GlyphRun first.
Summary
Functions
Allocates an empty glyph buffer.
Sets the UTF-8 text of the glyph buffer.
Same as set_utf8_text/2, but returns the glyph buffer directly.
Types
Functions
Allocates an empty glyph buffer.
On success, returns {:ok, gb}, where gb is an opaque glyph-buffer
resource.
On failure, returns {:error, reason}.
@spec new!() :: t()
Same as new/0, but returns the glyph buffer directly.
On success, returns the buffer.
On failure, raises Blendend.Error.
Sets the UTF-8 text of the glyph buffer.
This only stores the text; it does not perform shaping. To shape
the buffer we need to call Blendend.Text.Font.shape/2.
On success, returns :ok.
On failure, returns {:error, reason} (for example if the buffer is
invalid or the text cannot be stored).
Same as set_utf8_text/2, but returns the glyph buffer directly.
On success, returns the same gb.
On failure, raises Blendend.Error.
Examples:
gb =
GlyphBuffer.new!()
|> GlyphBuffer.set_utf8_text!("Hello")
|> Font.shape!(font)