Request for more options for text object's FontName.

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Mark Szlazak
Posts: 439
Joined: Tue Apr 04, 2017 6:06 pm
Location: SF Bay Area, California

Request for more options for text object's FontName.

Post by Mark Szlazak »

Seems like only Arial can be used for a text object's ViewObject.FontName. Can more fonts be added?
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Request for more options for text object's FontName.

Post by yorik »

You can use any font present on your system... Just set the name there instead of Arial..
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Request for more options for text object's FontName.

Post by Jee-Bee »

Is tit possible to make a dropdown menu here that shows the presented fonts. I have no clue what fonts are all installed on all/ any of mys system(s).
Not talking about what type fonts were accepted. I can imagine that a few of my \latex fonts are not accepted...
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Request for more options for text object's FontName.

Post by yorik »

Jee-Bee wrote:Is tit possible to make a dropdown menu here that shows the presented fonts.
Yes, that is on my radar for some time. Qt provides that already, we would just need to implement a new property type.
However, before that I would lie to find a way to unify the different font systems, for ex. Draft ShapeString uses a direct path to a ttf file, and I haven't found a relaiable way yet to convert between ttf file path and font name. Plus, coin also accepts not only font names but families (Arial,Sans Serif,sans) or even styles (Arial:bold). Not too sure yet of how to unify all that...
Mark Szlazak
Posts: 439
Joined: Tue Apr 04, 2017 6:06 pm
Location: SF Bay Area, California

Re: Request for more options for text object's FontName.

Post by Mark Szlazak »

Thank you Yorik. I must be setting it wrong in script because none of these work:

txt.ViewObject.FontName = "Times Roman" (or "Courier" or "Script", etc)

Also, font styles setting would really be nice to have!

BTW, I am in the Part workbench. How do i find out what fonts work?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Request for more options for text object's FontName.

Post by wmayer »

Yes, that is on my radar for some time. Qt provides that already, we would just need to implement a new property type.
We have the type PropertyFont for long time.

Code: Select all

obj=App.ActiveDocument.addObject("App::FeaturePython")
obj.addProperty("App::PropertyFont","Font")
The property editor shows a combo box with all the font names.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Request for more options for text object's FontName.

Post by yorik »

:D one more feature that was there since the beginning and that you only discover years later
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Request for more options for text object's FontName.

Post by wandererfan »

yorik wrote:However, before that I would lie to find a way to unify the different font systems, for ex. Draft ShapeString uses a direct path to a ttf file, and I haven't found a relaiable way yet to convert between ttf file path and font name.
for X11 (Linux and ?OSX?)

Code: Select all

//this:
QString family = QString::fromUtf8("Arial");
QFont font(family);
font.setItalic(true);
...
FT_Face FTFont = font.freetypeFace();

//can replace this:
error = FT_New_Face(FTLib,FontSpec,FaceIndex, &FTFont); 
These posts are about the same problem in Windows.
https://stackoverflow.com/questions/167 ... ndle-hfont
https://stackoverflow.com/questions/457 ... old-italic
https://stackoverflow.com/questions/113 ... -c-windows
Mark Szlazak
Posts: 439
Joined: Tue Apr 04, 2017 6:06 pm
Location: SF Bay Area, California

Re: Request for more options for text object's FontName.

Post by Mark Szlazak »

wmayer wrote:
Yes, that is on my radar for some time. Qt provides that already, we would just need to implement a new property type.
We have the type PropertyFont for long time.

Code: Select all

obj=App.ActiveDocument.addObject("App::FeaturePython")
obj.addProperty("App::PropertyFont","Font")
The property editor shows a combo box with all the font names.
Thanks wmayer but I get nothing happening when i tried these in the console. How am I suppose to use this?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Request for more options for text object's FontName.

Post by wmayer »

Thanks wmayer but I get nothing happening when i tried these in the console. How am I suppose to use this?
Select the object in the Tree view and then in the Data tab of the Property Editor you get a "Font" item which you can click on.
Post Reply