python-3.x - 无法使 ReportLab 正确打印 unicode 字体
问题描述
我正在尝试使用 hygothic-medium 字体打印韩文字符。我在 site-packages\reportlab\fonts 文件夹下的字体为 'korean.h2gtrm.ttf' 文件。我做了以下事情: -
pdfmetrics.registerFont(UnicodeCIDFont(TTFont('HYGothic-
Medium','korean.h2gtrm.ttf')))
pdfmetrics.registerFontFamily('HYGothic-Medium',normal='HYGothic-
Medium',bold='HYGothic-Medium',italic='HYGothic-
Medium',boldItalic='HYGothic-
Medium')
addMapping('HYGothic-Medium',0, 0, 'korean.h2gtrm') #normal
addMapping('HYGothic-Medium', 0, 1, 'korean.h2gtrm')
addMapping('HYGothic-Medium',1, 0, 'korean.h2gtrm')
addMapping('HYGothic-Medium',1, 1, 'korean.h2gtrm')
pstyle= ParagraphStyle(name='KOR', fontName = 'HYGothic-Medium',
fontSize = 10 ))
p=Paragraph(text,pstyle)) # where text is my Korean characters
story.append(p) # error !!
我收到以下错误:-
Can't map determine family/bold/italic for hygothic-medium
paragraph text '<para>\uc724\uadfc Machine</para>' caused exception
有什么建议么 ?。
解决方案
推荐阅读
- python - 是否根据相当于“交换”元素的计数直接替换数组中的元素?
- ibm-midrange - 如何将json数据存储到输出数组中
- mysql - GCP Bigquery,我想在一列中通过分类值聚合一些值
- mysql - MySQL:如何从具有重复值且满足多个条件的表中检索条目?
- react-native - imagePicker 导致 android 中的应用重启
- inheritance - JavaFx,如何正确覆盖两者:树表视图中的 getChildren() 和 getChildren().add(newNode)
- c# - 使用 EF 或原始 SQL 在数据库之间复制表的有效方法?
- android - 强制停止运行 gradle build 的 android studio 后应该删除哪些文件夹?
- python - 如何对 Dask bag 分区进行子集化
- android - 为什么我在抽屉模式下使用服务和 TMultiView 关闭我的 android 应用程序时会收到 ANR