Skip to main content

Module ruby

Module ruby 

Source
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

  1. Shape both the base text and the ruby text (using any shaper).
  2. Call layout_ruby with the base glyphs and ruby shaped glyphs.
  3. Render RubyLayout::base_glyphs normally, then render RubyLayout::ruby_glyphs with the y-offset from RubyLayout::ruby_y_offset.

The calling code is responsible for increasing the line height by RubyLayout::extra_line_height to avoid overlapping adjacent lines.

Structs§

RubyAnnotation
A ruby (furigana) annotation attached to a span of base text.
RubyLayout
The result of a ruby layout pass.

Enums§

RubyPosition
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.