Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t set font on fragments without font when processing fallback #263 #743

Merged
merged 1 commit into from
Jul 18, 2014
Merged

Conversation

petesharum
Copy link

The issue comes from the difference in how Prawn::Text::Formatted::Box and Prawn::Text handle styles. The fragments that are passed from Prawn::Text to Prawn::Text::Formatted::Box 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 but no styles. This patch preserves the original (:font-less) 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.

@practicingruby
Copy link
Member

Thanks. I'm going to need to do some homework and remind myself of how our fallback font system is supposed to work, but this patch has a reproducible error and a test, so I'll certainly try to review it in time for the next release, if not sooner.

@practicingruby practicingruby merged commit d49017b into prawnpdf:master Jul 18, 2014
@practicingruby
Copy link
Member

Thanks for the patch. Because your pull request was accepted, you now have commit access to Prawn. Please see our contributor guidelines, and happy hacking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants