I'm trying to load a separate TTF font, and it displays fine under Hollywood, but when I write a PDF with it, I only get some wrong characters or just empty space where the international characters should be.
I've tried to change between UTF-8 and ISO encodings, and the only time I've seen characters correctly in a PDF file, is when I use ISO encoding and disable the Embedding option in the LoadTTFont function. Then it renders the "ä" character in my example on MorphOS PDF viewers, but still the same file doesn't render the character correcly under Windows! And disabling Embedding isn't nice, because then some viewers (like VPDF) don't render character spacings correctly.
So, am I doing something wrong or is there something that should be fixed in Polybios?
Here's the test code I've been playing with now:
Code: Select all
@OPTIONS {Encoding = #ENCODING_ISO8859_1}
@REQUIRE "polybios"
@DISPLAY {Width=595, Height=842, Color=#WHITE}
font$ = "System:MorphOS/Fonts/_ttf/DejaVuSans.ttf"
size = 24
text$ = "This is ä text line!!1"
; Enable this line if your editor uses UTF-8 and disable otherwise
; text$ = ConvertStr(text$, #ENCODING_UTF8, #ENCODING_ISO8859_1)
SetFont(font$, size, {Engine = #FONTENGINE_INBUILT, UsePoints=True})
SetFontColor(#BLACK)
SetFontStyle(#ANTIALIAS)
TextOut(0, 0, text$)
doc=pdf.CreateDocument()
; This doesn't seem to make any difference:
;doc:UseUTFEncodings()
page = doc:AddPage()
page:SetSize(#HPDF_PAGE_SIZE_A4, #HPDF_PAGE_PORTRAIT)
; Setting False here will make characters to work in some degree under MorphOS,
; but generates a spacing issue on some readers + doesn't still work under Windows
f$ = doc:LoadTTFont(font$, True)
font = doc:GetFont(f$)
page:SetFontAndSize(font, size)
page:BeginText()
page:TextOut(0, 842 - size, text$)
page:EndText()
doc:SaveToFile("ram:test.pdf")
WaitLeftMouse()