Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to register arial font? #120

Open
lizard-Szilard opened this issue Aug 5, 2023 · 0 comments
Open

How to register arial font? #120

lizard-Szilard opened this issue Aug 5, 2023 · 0 comments

Comments

@lizard-Szilard
Copy link

BUG/PROBLEM REPORT / FEATURE REQUEST

What I did:

<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="example_01.pdf">
 <template showBoundary="1"> <!--Debugging is now turned on, frame outlines -->
 <!--will appear on the page -->
<docinit>
        <registerTTFont faceName="Arial" fileName="./msttcorefonts/arial.ttf" />
        <registerTTFont faceName="Arial-Bold" fileName="./msttcorefonts/arialbd.ttf" />
        <addMapping faceName="Arial" bold="0" italic="0" pasName="Arial"/>
        <addMapping faceName="Arial-Bold" bold="1" italic="0" psName="Arial-Bold"/>

</docinit>
 <pageTemplate id="main">
 <!-- two frames are defined here: -->
 <frame id="first" x1="100" y1="400" width="150" height="200"/>
 <frame id="second" x1="300" y1="400" width="150" height="200"/>
 </pageTemplate>
 </template>
 <stylesheet>
 <!-- still empty...-->
		<paraStyle name="Arial" fontName="Arial" fontSize="11" spaceBefore="0.5 cm"/>
		<paraStyle name="Arial-Bold" fontName="Arial-Bold" fontSize="11" spaceBefore="0.5 cm"/>
 </stylesheet>

 <story>
 <para style="Arial">
    Welcome to RML
 </para>

 </story>
</document>
from reportlab.lib.fonts import addMapping
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

pdfmetrics.registerFont(TTFont("Arial", "./msttcorefonts/Arial.ttf"))
pdfmetrics.registerFont(TTFont("Arial-Bold", "./msttcorefonts/arialbd.ttf"))

from z3c.rml import rml2pdf

addMapping("Arial", 0, 0, "Arial")
addMapping("Arial", 0, 1, "Arial")
addMapping("Arial", 1, 0, "Arial-Bold")
addMapping("Arial", 1, 1, "Arial-Bold")

rml2pdf.go("example0.prep", "example_01.pdf")

What actually happened:

     I have tried move font file in the same dir but still error

What version of Python and Zope/Addons I am using:

Python 3.11.4

Linux ubuntu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant