Trying to use reportlab through python 3 to write a document that includes macrons (ā ē ī ō ū), but the macrons are showing up as boxes (■). The document is written in Arial font -- but if I open up the file in a word processor to check the font, the boxes are in 'Segoe UI Symbol' font.
For importing in Arial as a font that supports a broad range of unicode characters (which seems to have worked):
import reportlab.rl_config
reportlab.rl_config.warnOnMissingFontGlyphs = 0
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
pdfmetrics.registerFont(TTFont('Arial', 'Arial.ttf'))
I also import a dictionary through json, looking something like this when I open the json file in notepad:
{"example1":"b\u0101s"}
The program reads and writes this dictionary:
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
doc = SimpleDocTemplate("hello.pdf")
Story = [Spacer(1,2*inch)]
style = styles["Normal"]
with open('CompDict.json','r') as f:
m_dic=json.load(f)
for key,value in m_dic:
p=Paragraph(key+":"+value,style)
Story.append(p)
doc.build(Story)
The outcome should be a pdf with example1:bās but instead comes out as example1:b■s