Hello,
I'm need to use a specific font in a workbench. I did not find any example in the existing Workbenchs of declaration or use of a font in a Python code. Would someone have a start of track to integrate this font?
Thanks a lot
Cuq
Use a Specific Font
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Use a Specific Font
Moved from Developers forum.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Use a Specific Font
Please explain better, you could not change a font used in UI for a specific WB, they are mostly set using Qt stylesheet, if not you have to make by hand all your WB GUI and assign to each widget a specific font and size.
If you want to use a font for other uses it is another matter.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Use a Specific Font
See: viewtopic.php?t=75573&start=30#p657250
Code: Select all
fontFile = App.getResourceDir() + "Mod/TechDraw/Resources/fonts/osifont-lgpl3fe.ttf"
fontId = QtGui.QFontDatabase.addApplicationFont(fontFile)
Re: Use a Specific Font
Thank you so much @Roy_043 works Like a charm :
Code: Select all
def __init__(self):
"This function is executed when FreeCAD starts"
from PySide import QtGui
fontFile = os.path.join(FreeCAD.getResourceDir(), "Mod", "TechDraw", "Resources", "fonts", "osifont-lgpl3fe.ttf")
fontId = QtGui.QFontDatabase.addApplicationFont(fontFile)
FreeCAD.Console.PrintMessage("{} Added as QtGui Font Id : {}\n".format(fontFile,fontId))
pass