Since updating to prawn 2.5.0, we face issues with font embedding and incorrectly or missing glyphs.
Reproduction example:
This reproduction example assumes that the file Arial Unicode MS.TTF is present in the local working directory. While the font is shipped with Microsoft Office by default and can be licensed by Microsoft, it is also available on GitHub (for example here). With the file being available, a simple irb can be started and the following script can be executed:
require 'prawn'
@pdf = Prawn::Document.new()
@pdf.font_families.update("ArialUnicodeMS" => {normal: {file: "Arial Unicode MS.TTF"}})
@pdf.font "ArialUnicodeMS", style: :normal
@pdf.text_rendering_mode :fill_stroke do
@pdf.draw_text "Demo Text @ Draw Text", size: 22.0, style: :normal, text_anchor: "middle", at: [0, 500], offset: [0, 0]
end
@pdf.render_file('prawn.pdf')
puts "Done"
Issues noticed:
After reducing the issue to the above-given minimal reproduction example, we are pretty confident to face a bug in Prawn. Otherwise, we probably misunderstood the subsetting and font-embedding and would be grateful about some advice - Thank you!
--
prawn: 2.5.0
Ruby: 3.3.5
Adobe Acrobat Pro: 2024.003.20121
Since updating to prawn 2.5.0, we face issues with font embedding and incorrectly or missing glyphs.
Reproduction example:
This reproduction example assumes that the file
Arial Unicode MS.TTFis present in the local working directory. While the font is shipped with Microsoft Office by default and can be licensed by Microsoft, it is also available on GitHub (for example here). With the file being available, a simpleirbcan be started and the following script can be executed:Issues noticed:
The
@character included in the text is not shown in Acrobat. Instead (after a few seconds), an error is shown:Cannot extract the embedded font 'e23202+ArialUnicodeMS'. Some characters may not display or print correctly.The documentation for
font_familiesindicates that the default forsubsetisfalse. However, this doesn't seem to be the case and it rather appears thatsubset: trueis the default since 528a37d. Given the above example, explicitly specifyingsubset: truedoesn't change anything (with regard to showing the@or the file size of the resulting PDF`)However, changing the option to
subset: false, the full TTF file is embedded and the PDF file size dramatically increases (due to the large TTF):After reducing the issue to the above-given minimal reproduction example, we are pretty confident to face a bug in Prawn. Otherwise, we probably misunderstood the subsetting and font-embedding and would be grateful about some advice - Thank you!
--
prawn:
2.5.0Ruby:
3.3.5Adobe Acrobat Pro:
2024.003.20121