Text Art

TextLayout

DigitalArt.TextLayoutModule
TextLayout

Pure layout of text along parametric curves. Produces Vector{PlacedGlyph} using real FreeType font metrics. No rendering, no file I/O.

DigitalArt.TextLayout.LayoutOptionsType
LayoutOptions(; kwargs...)

Tuning for layout_text. baseline_offset is in em units along the curve normal (positive moves text to the left of the direction of travel). curvature_threshold, min_scale and max_scale only apply when adaptive.

DigitalArt.TextLayout.PlacedGlyphType
PlacedGlyph

One laid-out character: which glyph, where it sits, its rotation, and the font size it was sized at. A Vector{PlacedGlyph} is the inspectable, testable seam between layout (this module) and rendering (TextRender).

DigitalArt.TextLayout.adaptive_fontsizeMethod
adaptive_fontsize(κ, base; min_scale=0.3, max_scale=2.0, threshold=1.0)

Scale base by local curvature κ: linear from max_scale (κ=0) to 1.0 (κ=threshold), then exponential decay clamped at min_scale.

DigitalArt.TextLayout.computer_modernMethod
computer_modern(; style=:regular) -> FontMetrics

Load the bundled New Computer Modern face — the project default typeface, the serif Donald Knuth designed for TeX. style(:regular, :bold, :italic, :bolditalic). Loaded by path from MathTeXEngine's assets, so no system font installation is required.

DigitalArt.TextLayout.computer_modern_pathMethod
computer_modern_path(; style=:regular) -> String

Absolute path to a bundled New Computer Modern OTF file. Pass this to Makie's text!(...; font=...) so rendering uses the true face rather than a name-matched substitute. style(:regular, :bold, :italic, :bolditalic).

DigitalArt.TextLayout.kernMethod
kern(fm, a, b) -> Float64

Horizontal kerning adjustment between adjacent chars a,b in em units. Returns 0.0 when the font has no kerning pair.

DigitalArt.TextLayout.layout_textMethod
layout_text(text, f, fm; t_start=0.0, t_end=2π, opts=LayoutOptions())

Lay out text along curve f using font metrics fm. Returns a Vector{PlacedGlyph}. With opts.auto_fit, binary-searches the base font size so the text fills opts.target_fill_ratio of the curve's arc length.

DigitalArt.TextLayout.load_fontMethod
load_font(name) -> FontMetrics

Load a font face by name. Fails loudly rather than silently substituting: FTA.findfont performs fuzzy fallback (e.g. resolving "CMU Serif" to PT Serif), so this checks the resolved face's family name contains the requested name (case/space-insensitive) and errors otherwise. For guaranteed Computer Modern, prefer computer_modern().

DigitalArt.TextLayout.load_font_fileMethod
load_font_file(path) -> FontMetrics

Load a font face directly from a file path (no name matching, no fallback). Throws if the file cannot be loaded.

DigitalArt.TextLayout.walk_glyphsMethod
walk_glyphs(text, f, fm, t_start, t_end; kwargs...) -> Vector{PlacedGlyph}

Place each character of text along curve f by advancing real metric widths along arc length. Each glyph takes its own local tangent angle and is offset along the curve normal by baseline_offset. Characters past the curve end are dropped.

Glyphs follow the tangent exactly — no π flip is applied to keep letters upright. Wrapping text around a closed curve therefore renders the far arc upside-down, which is the intended look: any "readability" flip introduces a seam where orientation jumps discontinuously and the reading direction reverses, which reads worse than the inversion it removes.

TextRender

DigitalArt.TextRenderModule
TextRender

Renders Vector{PlacedGlyph} (from TextLayout) with CairoMakie. Rendering and file I/O live here, separate from layout.

DigitalArt.TextRender.render_animationMethod
render_animation(glyphs, filename; f=nothing, framerate=10,
    font=computer_modern_path(), color=:black, show_curve=true,
    figure_size=(800,800))

Write an animation revealing glyphs one at a time (prefixes of the vector) — the project's glyph-by-glyph "creation flow" goal. filename should end in .mp4 or .gif. Rebuilds the drawn glyphs each frame onto a single axis so the curve (if shown) stays fixed while letters accumulate.

DigitalArt.TextRender.render_glyphsMethod
render_glyphs(glyphs; f=nothing, t_range=(0.0,2π), font=computer_modern_path(),
    color=:black, show_curve=false, curve_color=:lightblue,
    figure_size=(800,800)) -> Figure

Draw each placed glyph. font defaults to the bundled Computer Modern OTF file path (passed to Makie's text! as a path so it renders the true face, not a name-matched substitute). Optionally draw the underlying curve f.