TTF Text Font
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: TTF Text Font
Very nice macro, as usual Mario!
I would also like much to have the ShapeString ui to use the simple font chooser that other controls use in FreeCAD...
Unfortunately, that control returns only a name of a font: "Arial", "Times New Roman", etc... and Qt doesn't provide any way to retrieve the actual file of that font!! And given the different platforms (linux, mac, win) all manage that differently, and the fact that the file name can be different than the font name, and there can be different files for italic, bold,...) it becomes quickly a nightmare.
If you search for it on the net you'll find other coders pulling their hairs to find a solution to this, but I couldn't find any that would work for us, support all the platforms, etc
I would also like much to have the ShapeString ui to use the simple font chooser that other controls use in FreeCAD...
Unfortunately, that control returns only a name of a font: "Arial", "Times New Roman", etc... and Qt doesn't provide any way to retrieve the actual file of that font!! And given the different platforms (linux, mac, win) all manage that differently, and the fact that the file name can be different than the font name, and there can be different files for italic, bold,...) it becomes quickly a nightmare.
If you search for it on the net you'll find other coders pulling their hairs to find a solution to this, but I couldn't find any that would work for us, support all the platforms, etc
Re: TTF Text Font
hi
this new macro (Macro_Fonts_Win10_PYMP) use the matplotlib tools for font : (extract of my macro)
and the return is : (see end line)
the macro is dedicate for the Windows 10 (the window font is empty) users but is you testing it on Linux , Mac .... "merci"
PS: I discovered a bug ShapeString see here my precedent post would you please correct thanks (also with other font can work)
i search for the path with "éçèèà.." un casse tête
mario
this macro is different of the precedent macro (Window_fonts above)
this new macro (Macro_Fonts_Win10_PYMP) use the matplotlib tools for font : (extract of my macro)
Code: Select all
##https://matplotlib.org/_modules/matplotlib/font_manager.html
if setSystemFonts == 0:
files_All_Fonts = matplotlib.font_manager.findSystemFonts(pathSearch, "ttf") # fait toutes les fontes ? ()
else:
files_All_Fonts = fontman.findSystemFonts(pathSearch) # fait toutes les fontes (et dans tous les sous dossiers)
Code: Select all
# nameFamily = matplotlib.font_manager.FontProperties(fname=fonte).get_family() ##['sans-serif']
# nameStyle = matplotlib.font_manager.FontProperties(fname=fonte).get_style() #normal
# nameVariant = matplotlib.font_manager.FontProperties(fname=fonte).get_variant() #normal
# nameWeight = matplotlib.font_manager.FontProperties(fname=fonte).get_weight() #normal
# nameStretch = matplotlib.font_manager.FontProperties(fname=fonte).get_stretch() #normal
# nameFileComp = matplotlib.font_manager.FontProperties(fname=fonte).get_file() ##c:\windows\fonts\NotoNaskhArabicUI-Regular.ttf
# nameSize = matplotlib.font_manager.FontProperties(fname=fonte).get_size() #10.0
nameName = matplotlib.font_manager.FontProperties(fname=fonte).get_name() ##Noto Naskh Arabic UI
# nameSizePoint = matplotlib.font_manager.FontProperties(fname=fonte).get_size_in_points() #10.0
# nameSlant = matplotlib.font_manager.FontProperties(fname=fonte).get_slant() #normal
# namePattern = matplotlib.font_manager.FontProperties(fname=fonte).get_fontconfig_pattern() #:family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:file=c:\windows\fonts\NotoNaskhArabicUI-Regular.ttf:size=10.0
PS: I discovered a bug ShapeString see here my precedent post would you please correct thanks (also with other font can work)
i search for the path with "éçèèà.." un casse tête
rendu pas 100% pour toutes les fontes ! , merci
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: TTF Text Font
Aaah, interesting! I'll play a bit with that...
Ok, fixing that now
Re: TTF Text Font
I am using Windows 10 and FreeCAD 0.18. When I try to use the Draft|Shape from Text tool and I attempt to brows for a font file, no fonts are visible in the standard C:\windows\fonts folder. If I copy a font, say Arial.ttf, to my desktop folder, that font is visible when browsing for a font. I note that there are many fonts actually in the c:\windows\fonts folder, they just aren't visible to the font file browse dialog for some reason.
Perhaps this visibility problem is caused by the security system under Windows 10? I've tried running FreeCAD "as Administrator" with elevated security permissions, but that does not help. I've tried taking ownership of the fonts folder and it's contents, but that does not help either.
I could copy all the fonts I need into some new folder I myself create and sidestep, or work around, this problem. But this does not seem to be a very good solution, IMHO. I think it would be better for FreeCAD to find and use the designated font "database" in the standard C:\windows\fonts folder. That seems to be the expected behavior, is it not?
I notice other people in this thread have similar problems in this area. Is this recognized as a bug? Is it even recognized as a problem? Does someone else have a better work-around (other than copying fonts) for this problem?
Perhaps this visibility problem is caused by the security system under Windows 10? I've tried running FreeCAD "as Administrator" with elevated security permissions, but that does not help. I've tried taking ownership of the fonts folder and it's contents, but that does not help either.
I could copy all the fonts I need into some new folder I myself create and sidestep, or work around, this problem. But this does not seem to be a very good solution, IMHO. I think it would be better for FreeCAD to find and use the designated font "database" in the standard C:\windows\fonts folder. That seems to be the expected behavior, is it not?
I notice other people in this thread have similar problems in this area. Is this recognized as a bug? Is it even recognized as a problem? Does someone else have a better work-around (other than copying fonts) for this problem?
pbisson,
casual FreeCAD user and fan
casual FreeCAD user and fan
Re: TTF Text Font
I'm using win 10 version 1903 too.
And this is file open dialog from DraftWB->Shapestring->Font file button:
Done with this workflow:
- open command prompt as administrator
- execute attrib -r - s c:\windows\fonts
- execute takeown /a /f c:\windows\fonts
that's all.
But caution, furthermore administator has ownership and not TrustedInstaller.
And this is file open dialog from DraftWB->Shapestring->Font file button:
Done with this workflow:
- open command prompt as administrator
- execute attrib -r - s c:\windows\fonts
- execute takeown /a /f c:\windows\fonts
that's all.
But caution, furthermore administator has ownership and not TrustedInstaller.
Re: TTF Text Font
Thanks UR_. I was doing basically the same thing, but on the contents of the \fonts folder, not the folder itself.
After I changed the attributes and set ownership to the adminstrators group on the folder itself, the font dialog worked properly.
Much appreciated.
After I changed the attributes and set ownership to the adminstrators group on the folder itself, the font dialog worked properly.
Much appreciated.
pbisson,
casual FreeCAD user and fan
casual FreeCAD user and fan
- papyblaise
- Veteran
- Posts: 8015
- Joined: Thu Jun 13, 2019 4:28 pm
- Location: France
Re: TTF Text Font
In front with this same problem whith Windows's fonts "vous n'étes pas autotriser..." , I decided to create a new folder in Freecad "Lib/Font and carbon copy the Windows 's font on this , and from this date finish problems
Re: TTF Text Font
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
-
- Posts: 1
- Joined: Mon Oct 28, 2019 5:08 pm
Re: TTF Text Font
Sans serif fonts are popular font styles used everywhere for their clean, modern appearance. They are different from so-called "wheelbase" fonts because they do not have these small lines protruding from the ends and bases of the letter (that is to say, serifs). Therefore, we include the French word sans (which means "without").
- wandererfan
- Veteran
- Posts: 6324
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: TTF Text Font
See this: https://www.forum.freecadweb.org/viewto ... 10#p339884 to solve without changing ownership.