Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions TODO.pdf/65-pdfrb-019-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# TODO PDF 65: pdfrb 0.19.0 feature integration

## Status: PARTIALLY DONE

## What was implemented

1. **Canvas#text_lines**: TextFrameRenderer uses `canvas.text_lines`
instead of N separate `canvas.text` calls per line. Single batch
call for all lines within a run.

## What remains (pdfrb bugs)

2. **glyph_width for TTF**: pdfrb 0.19.0 has `Fonts#glyph_width` but
returns 0 for TrueType fonts (bug: "undefined method glyph_id_for
for String"). Standard 14 Type1 fonts work correctly. Cannot
replace FontMetrics/Fontisan until this is fixed.

3. **Pdfrb::FontResolver**: Returns nil for common fonts (Helvetica.ttc
on macOS). Cannot replace Fontisan-based resolver yet.

4. **Font subsetting**: `Fonts#add` accepts `**opts` but `subset: true`
behavior unverified. Standard 14 fonts don't need FontFile embedding.

## Acceptance criteria

- [x] TextFrameRenderer uses canvas.text_lines
- [ ] FontMetrics replaced with pdfrb glyph_width (blocked by TTF bug)
- [ ] FontResolver replaced with Pdfrb::FontResolver (blocked by .ttc)
- [ ] Font subsetting verified
14 changes: 10 additions & 4 deletions lib/idml/render/renderers/text_frame_renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,21 @@ def self.render_run_lines(canvas, run, context, box, font, baseline_y)
glyphs: glyphs, frame_width: box[:width],
)

line_texts = []
lines.each do |line|
break if baseline_y < box[:y]

line_text = line.glyphs.map { |g| [g.codepoint].pack("U") }.join
canvas.text(line_text, at: [box[:x], baseline_y],
font: context.font_ps_name,
size: size)
line_texts << line.glyphs.map { |g| [g.codepoint].pack("U") }.join
baseline_y -= size * LEADING_FACTOR
end

if line_texts.any?
canvas.text_lines(line_texts,
font: context.font_ps_name,
size: size,
at: [box[:x], box[:y] + box[:height] - size],
leading: size * LEADING_FACTOR)
end
baseline_y
end
private_class_method :render_run_lines
Expand Down
Loading