prawnpdf/prawn — pull request #742 by petesharum (2014-06-27 20:45:02+00:00)
Title: Issue #263

The issue emerges in the differences in how ```Prawn::Text::Formatted::Box``` and ```Prawn::Text``` handle styles. The fragments that are passed from ```Prawn::Text``` don't specify a font, relying on the font set on the document. After ```Prawn::Text::Formatted::Box#analyze_glyphs_for_fallback_support```, the fragments are rewritten with font families specified and no styles. This patch preserves that state for resulting fragments that don't require fallback.

Example that reproduces the issue (starting from example in manual):

pdf_data = Prawn::Document.new do
fallback_fonts ["Times-Roman"]

["Courier", "Helvetica", "Times-Roman"].each do |example_font|
move_down 20

[:bold, :bold_italic, :italic, :normal].each do |style|
font example_font, :style => style do
text "I'm writing in #{example_font} (#{style})"
end
end
end
end

In this version, styles have no effect. Commenting ```fallback_fonts ["Times-Roman"]``` shows the styles working.