Font sizes with Polybios
Posted: Wed Apr 22, 2020 8:04 pm
I'd like to render a preview of contents that would be written to a PDF file by Hollywood functions to a Hollywood display, but texts that I render to the Hollywood display seem to appear in different size in the actual PDF file, even though I use same fonts and sizes.
Here's an example code what I've tried now (on MorphOS):
As you can see, I've tried to load fonts though Hollywood/system, but also directly as TTF files. It's the same result in both cases and looks like this.
Rendered in the Hollywood display it looks like this:

But in the PDF file it looks like this (even when loaded with Polybos itself):

So why it's much bigger in the PDF? Should I scale something according something or how could I get them closer to the same sizes?
Page sizes are same for the display (595x842) and PDF (A4 = 595x842), and font sizes are defined to same 24 for both. PDF coordinates seem to match with Hollywood display with other operations, but only the text looks different.
Any advice or suggestions would be very welcome!
Here's an example code what I've tried now (on MorphOS):
Code: Select all
@REQUIRE "polybios"
@DISPLAY {Width=595, Height=842, Color=#WHITE}
font$ = "Arial"
;font$ = "System:Fonts/_ttf/Arial.TTF"
size = 24
text$ = "This is a text line!!1 gjyq"
OpenFont(1, font$, size, {Engine = #FONTENGINE_INBUILT})
UseFont(1)
SetFontColor(#BLACK)
SetFontStyle(#ANTIALIAS)
TextOut(0, 0, text$)
doc=pdf.CreateDocument()
page = doc:AddPage()
page:SetSize(#HPDF_PAGE_SIZE_A4, #HPDF_PAGE_PORTRAIT)
font = doc:LoadFont(font$)
;font = doc:LoadTTFont(font$, True)
font = doc:GetFont(font)
page:SetFontAndSize(font, size)
page:BeginText()
page:TextOut(0, 842 - size, text$)
page:EndText()
doc:SaveToFile("ram:test.pdf")
WaitLeftMouse()
Rendered in the Hollywood display it looks like this:

But in the PDF file it looks like this (even when loaded with Polybos itself):

So why it's much bigger in the PDF? Should I scale something according something or how could I get them closer to the same sizes?
Page sizes are same for the display (595x842) and PDF (A4 = 595x842), and font sizes are defined to same 24 for both. PDF coordinates seem to match with Hollywood display with other operations, but only the text looks different.
Any advice or suggestions would be very welcome!

