- Home /
How can I obtain an exportable font size?
Hey, I have an A4 page width a pixel size of 210*297. Which have a 1:1 translation to mm. Then I have a textmesh on that page, with some text. All fine. Now comes the problem, I want to export this and create a pdf from the extracted data, but the font size is bogus.
The text : "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" fills up exactly one line of 210 px/mm with the font size 32.9. In indesign if I do the same there I get a fontsize of 9.35pt.
I know I could do a easy calculation with these numbers 32.9/9.35 = 3.5187166, which then will be my ratio. My problem here is that this might not be the same for all fonts or it might not be accurate. my biggest problem is that I do not want a line-break in a different place in unity vs a pdf.
Is there a better and more accurate way to calculate this per font used?
Just start the app in a regular size, and anchor the text accordingly to the screen. WHen you resize the pdf, unity canvas scaler will do the work. Just make sure your text is set to overflow, on both the horizontal and vertical scales. Hope this helps?
That won't do, I need to be able to save the config for the Text$$anonymous$$esh to a file, xml for example. And then send it to a pdf generator. So if I export this:
<page width="210" height="297">
<textFrame fontSize="36" x="0" y="0" width="210" height="120">Lorem ipsum dolor sit amet, id tritani aliquando omittantur eum.</textFrame>
</page>
If that fontSize is 36 in Unity, when it's really 10-ish pt in a real document, I'll have a problem. Then the text will display differently in Unity and the in generated pdf.