Class: Idml::Render::Renderers::TextFrameRenderer

Inherits:
Object
  • Object
show all
Extended by:
SimpleText, VerticalEmit
Defined in:
lib/idml/render/renderers/text_frame_renderer.rb

Overview

Renders an IDML TextFrame on a Pdfrb::Content::Canvas.

Pipeline:

1. Resolve the linked Story via Package#story_by_id.
2. Extract `Paragraph`s via StyleResolver (carries PSR
 attributes like SpaceBefore, FirstLineIndent, AutoLeading
 alongside the CSR runs).
3. Build a layout `Frame` from the TextFrame's geometric
 bounds plus TextFramePreference insets.
4. For each paragraph: shape glyphs (Shaper), wrap to the
 inset/indent-adjusted width (LineBreaker), align (Justifier),
 position vertically (VerticalLayout), and emit one
 `canvas.text` per line. Tracks the y cursor across
 paragraphs and runs so text flows top-to-bottom.
5. Records each positioned line in PositionTracker so
 HyperlinkEmitter can compute precise per-source link rects.

Falls back to a single canvas.text_rich per frame when no FontMetrics is available (no shaper → no wrap → rough output).

Constant Summary collapse

DEFAULT_SIZE =
12.0
RUBY_SIZE_FACTOR =
0.5

Class Method Summary collapse

Methods included from VerticalEmit

emit_upright_glyph, emit_vertical_ruby, emit_vertical_run, emit_vertical_stack, flush_vertical_segment, keep_all_deferred?, keep_flagged?, resume_vertical_paragraph, ruby_vertical_x, tatechuyoko_group, vertical_available_columns, vertical_fits?, vertical_keep_deferred?, vertical_paragraph, vertical_render, vertical_room, vertical_story?, window_deferred?, with_next_deferred?

Methods included from SimpleText

build_rich_runs, collect_runs, emit_simple_footnotes, simple_render

Class Method Details

.render(canvas, context) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/idml/render/renderers/text_frame_renderer.rb', line 37

def self.render(canvas, context)
  frame = context.item
  return unless frame.parent_story

  story = context.package&.story_by_id(frame.parent_story)
  return unless story

  box = frame_box(frame, context.page_height)
  state = initial_chain_state(frame, story, context)
  render_inline_tables(canvas, story, box, context, state)
  render_anchored_objects(canvas, story, context)

  return unless state

  vertical = vertical_story?(story)
  render_text(canvas, state, context, box, vertical: vertical)
  store_chain_state(frame, state, context)
end

.side_or_zero(spacing) ⇒ Object



274
275
276
277
278
# File 'lib/idml/render/renderers/text_frame_renderer.rb', line 274

def self.side_or_zero(spacing)
  [0, 1, 2, 3].map do |index|
    spacing.sides[index] || 0.0
  end
end