简体   繁体   English

Cairo PDF 在创建时未转换 unicode

[英]Cairo PDF not converting unicode while creating

I am converting SVG to PDF using Cairo PDF library of Python.我正在使用 Python 的 Cairo PDF 库将 SVG 转换为 PDF。 It is working well for ASCII characters, but for Unicode chars it is displaying a square box.它适用于 ASCII 字符,但对于 Unicode 字符,它显示一个方框。 Is there any solution to deal with this problem?有没有办法解决这个问题?

cairosvg.svg2pdf(
    url='svg_file_with_unicode_character.svg',
    write_to='output.expecting_unicode_character.pdf',
    output_height=720,
    output_width=1200
    )   

I got a solution for this.我有一个解决方案。 I included a font called GNU Unifont in SVG as following:我在 SVG 中包含了一个名为GNU Unifont的字体,如下所示:

.font-class{
      font-family: Unifont 
}

Which seems to have all the required glyphs for Unicode chars that I need.这似乎具有我需要的 Unicode 字符的所有必需字形。

Kudos to GNU Unifont!向 GNU Unifont 致敬! from hint "add font-family" by @RobertLongson来自@RobertLongson 的提示“添加字体系列”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM