You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't add characters from the Supplementary Multilingual Plane (SMP), using TrueType fonts. I downloaded a few fonts for Egyptian hieroglyphs and cuneiform characters to add them to a PDF, however, it doesn't seem to work.
Here's my python (2.7) code using the reportlab package:
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
if __name__ == "__main__":
# register fonts
pdfmetrics.registerFont(TTFont('gardiner', '/usr/share/fonts/truetype/ttf-ancient-scripts/Gardiner313.ttf'))
pdfmetrics.registerFont(TTFont('aegyptus', '/usr/share/fonts/truetype/ttf-ancient-scripts/Aegyptus313.ttf'))
pdfmetrics.registerFont(TTFont('noto', 'NotoSansCuneiform-Regular.ttf'))
# Test with first 20 glphs in each block
hieroglyph_test_string = " ".join([unichr(0x13000 + x) for x in range(20)])
cuneiform_test_string = " ".join([unichr(0x12000 + x) for x in range(20)])
my_canvas = canvas.Canvas("bmp1_test.pdf", pagesize=letter)
y_pos, y_decrement = [letter[1] - 50], 50
def test_font(font_name, chars):
my_canvas.setFont(font_name, 20)
my_canvas.drawString(50, y_pos[0], chars)
y_pos[0] -= y_decrement
print "\nWrote: %s\n" % (chars,)
test_font('gardiner', hieroglyph_test_string)
test_font('aegyptus', cuneiform_test_string)
test_font('noto', cuneiform_test_string)
my_canvas.save()
But it just displays as boxes in the PDF.
I know the fonts are installed, because the chars print on my terminal just fine.
Are there any steps I'm missing here?
The text was updated successfully, but these errors were encountered:
I can't add characters from the Supplementary Multilingual Plane (SMP), using TrueType fonts. I downloaded a few fonts for Egyptian hieroglyphs and cuneiform characters to add them to a PDF, however, it doesn't seem to work.
Here's my python (2.7) code using the reportlab package:
But it just displays as boxes in the PDF.
I know the fonts are installed, because the chars print on my terminal just fine.
Are there any steps I'm missing here?
The text was updated successfully, but these errors were encountered: