-
Notifications
You must be signed in to change notification settings - Fork 300
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
Ability to use font specified at path #198
Comments
Agreed, I added this to the CQ2.1 issue list. |
I was just working on doing this. Excellent that you are already planning on implementing it. The use of the "typing" module threw me off for a bit, but this appears to load a font properly. register the fontfont_mgr = cq.occ_impl.importers.OCP.Font.Font_FontMgr font_mgr_instance = font_mgr.GetInstance_s() font_list = cq.occ_impl.importers.OCP.Font.Font_NListOfSystemFont() a_string = cq.occ_impl.shapes.TCollection_AsciiString system_font = cq.occ_impl.importers.OCP.Font.Font_SystemFont(a_string("Liberation Sans")) system_font.SetFontPath(font_aspect, a_string("""C:\Windows\fonts\LiberationSans.ttf""")) font_mgr_instance.RegisterFont(system_font, False) #check if it worked font_instance.FontName().ToCString() font_instance.FontPath(font_aspect).ToCString() font_mgr_instance.AvailableFonts(font_list) while font_list.Size(): |
@cactrot Would you be interested in putting together a PR for this? |
I believe the merge of #453 resolves this issue. |
Yep, seems that way. Closing. |
It would be handy to be able to use a font located at a specific file path. Right now you can specify what font to use with
text()
by font name. PythonOCC/OCE will search the registered system fonts to find the named font. As far as I can tell there is currently no way in CadQuery to use a non-system font.register_font
fromOCC.Core.Addons
does provide capability to register a font for use. I propose that we wrapregister_font
and either allow a file path to be passed totext
, and then register and use that font, or create a separate function to allow users to register additional fonts.The text was updated successfully, but these errors were encountered: