High-level text helpers for Blendend.
This module is surface over the lower-level text modules:
Blendend.Text.Face– load and inspect font facesBlendend.Text.Font– create fonts, metrics, shapingBlendend.Text.GlyphBuffer– input text / shaped glyph storageBlendend.Text.GlyphRun– view for shaped glyphs, ready to draw
For the most direct "just draw this UTF-8 text" call, see
Blendend.Canvas.Fill.utf8_text/6 and Blendend.Canvas.Stroke.utf8_text/6.
Summary
Functions
Computes text metrics for the given text and font.
Shapes text with the given font and returns a GlyphRun.
Types
Functions
Computes text metrics for the given text and font.
Internally this uses a glyph buffer and Font.get_text_metrics/2.
Examples
iex>Blendend.Text.metrics(font, "blendend")
{:ok,
%{
"advance_x" => 183.264,
"advance_y" => -0.0,
"bbox_x0" => 1.104,
"bbox_x1" => 183.264,
"bbox_y0" => -0.0,
"bbox_y1" => -0.0
}}
Shapes text with the given font and returns a GlyphRun.
Internally this:
- allocates a
GlyphBuffer - sets its UTF-8 text
- calls the underlying shaping engine via
Font.shape/2 - returns the resulting
GlyphRun
Use this when you want to inspect or reuse the shaped glyphs.
On success, returns a GlyphRun.
On failure, returns {:error, reason}.
Examples
gr = Blendend.Text.shape(font, "blendend!")
Blendend.Text.GlyphRun.fill!(canvas, font, 60, 245, gr, fill: rgb(60, 60, 60))