Skip to main content

layout_ruby

Function layout_ruby 

Source
pub fn layout_ruby(
    base_glyphs: &[PositionedGlyph],
    ruby_shaped: &[ShapedGlyph],
    annotation: &RubyAnnotation,
    ruby_px_size: f32,
    base_line_height: f32,
) -> RubyLayout
Expand description

Compute ruby layout given pre-shaped base glyphs and ruby glyphs.

§Arguments

  • base_glyphs — already-shaped and positioned glyphs for the base text. Must not be empty when annotation.base_range is non-empty; the function will return an empty ruby result if base_glyphs is empty.
  • ruby_shaped — already-shaped (but not yet positioned) glyphs for the ruby text. x_advance values are interpreted as pixel advances scaled by ruby_px_size (i.e. the shaper was called with ruby_px_size as the font size).
  • annotation — the annotation metadata (base byte range + position).
  • ruby_px_size — font size in pixels used to shape the ruby text. Typically base_px_size * 0.5.
  • base_line_height — height of the base line in pixels. Used to compute the y offset so that the ruby does not overlap the base glyphs.

§Returns

A RubyLayout containing the base glyphs unchanged and the ruby glyphs positioned horizontally centred over the base span.