Expand description
Ruby annotation layout for CJK furigana and phonetic glosses.
Ruby (ルビ) is a typographic convention used in East Asian text to place small pronunciation or reading guides above (or below) base characters. This module provides the data types and positioning algorithm for rendering ruby annotations on top of an already-shaped base text.
§Usage
- Shape both the base text and the ruby text (using any shaper).
- Call
layout_rubywith the base glyphs and ruby shaped glyphs. - Render
RubyLayout::base_glyphsnormally, then renderRubyLayout::ruby_glyphswith the y-offset fromRubyLayout::ruby_y_offset.
The calling code is responsible for increasing the line height by
RubyLayout::extra_line_height to avoid overlapping adjacent lines.
Structs§
- Ruby
Annotation - A ruby (furigana) annotation attached to a span of base text.
- Ruby
Layout - The result of a ruby layout pass.
Enums§
- Ruby
Position - Where the ruby annotation is placed relative to the base text.
Functions§
- layout_
ruby - Compute ruby layout given pre-shaped base glyphs and ruby glyphs.