Closed stratosgear closed 2 years ago
I would create a custom class that inherits from Paragraph
and uses the Font
you want. That seems like the easiest option given the current architecture.
Kind regards, Joris Schellekens
Sorry I am not familiar with the internal architecture of borb...
Your suggestion would only work if the only way to commit text to the PDF would be through the Paragraph entity. If there was, for (a really stupid) example, a set table title command, that did not use a Paragraph, then that text would use the still default Helvetica...?
So is the paragraph the only "entry point" for submitting text for a really global way of setting ALL text fonts used in the PDF?
Just making sure! Thanks, again!
To the best of my knowledge, Paragraph
is only created inside borb
on these occasions:
SmartArt
TableUtil
to create a Table
Those usecases would not use your modified version of Paragraph
and would thus be stuck in Helvetica. Although for 2 and 3, you can easily pass a family of fonts to use.
Alternatively, you can overwrite the class method init on Paragraph
dynamically at the start of your code.
In pseudocode:
old_init = Paragraph.__init__
def new_init():
old_init
set_font_to_courier
Paragraph.__init__ = new_init
Kind regards, Joris Schellekens
Thank you for your very detailed reply!
I will have to give it a try and I will let you know.
Thanks!
Unless I am missing something, I have to always pass a
font
param in all paragraphs if I want my pdf to use something else except the default Helvetica fontIs there a way to globally set a font to be "courier" or even better, a specific custom google font, once, and all elements to use that font instead of Helvetica?