[ Bug ] Draft preferences: problems with font settings

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

[ Bug ] Draft preferences: problems with font settings

Post by Roy_043 »

I am experiencing several issues with the font settings in the Draft preferences.

A. Default ShapeString font file:
When I browse to the Windows font folder I get the message that I am not authorized to open this file. Although I obviously have read permission for the font folder. Pasting the name of a TTF file in the input field works just fine. Does FreeCAD request write permission for the font folder?

B. Font family:
In the docs this is mentioned as a font family: Arial,Helvetica,sans. But on my system this does not work. Instead of a 'sans' font I get some default 'serif' font (see C). Entering Arial works. But many other TTF also results in the use of the default font (the 'Font Name' property shows the selected font, but the displayed font in the Model View is the default 'serif' font). Strangely TTF fonts that are not displayed properly for Draft Texts can be used without issue for Draft ShapeStrings.

C. Default font:
Where is this default font defined? If this is a FreeCAD/Draft setting (hardcoded?) then using a font that has a richer character set would be better. The current default lacks certain important 'CAD' characters: Ø°²³. See here.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17477 (Git)
Build type: Release
Branch: master
Hash: 8806e4490606d7a1be52c831049b17d8c8d9c320
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Last edited by Roy_043 on Fri Apr 10, 2020 2:00 pm, edited 1 time in total.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Draft preferences: problems with font settings

Post by wandererfan »

Roy_043 wrote: Fri Aug 02, 2019 3:51 pm I am experiencing several issues with the font settings in the Draft preferences.

A. Default ShapeString font file:
<<snip>>
B. Font family:
<<snip>>
C. Default font:
<<snip>>
full disclosure: I am not an expert at Windows.

A. Read this post. It explains why you might not be able to select font files in Windows and what to do about it.

B. If Qt, for whatever reason, can not find a match to the font family you ask for, it tries to find the best match it can among the fonts that it can access, which might be a system or Qt default font. More than you ever wanted to know is here in the discussion of the "font matching algorithm".

C: The "default font" is not defined in FreeCAD. It is whatever Qt gets from the OS and could be different on Win/OSX/*nix.

Consider asking for a change here:

Code: Select all

in Draft.py

def makeText(stringslist,point=Vector(0,0,0),screen=False):
.....
    obj.ViewObject.FontName = getParam("textfont","")   #<<<< no default specified
Maybe something as generic as "Sans"?
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft preferences: problems with font settings

Post by Roy_043 »

@wandererfan: Thank you for your answer.

A.
Using UR_'s tip works. But having to remove the read-only and system attributes from the Font folder is not an ideal solution.

B.
It is quite confusing that the Font Name property drop down list, for a Draft Text f.e., displays all the fonts in the Windows font folder (even if the folder has the read-only and system attributes set), but that the majority of the fonts cannot be used.

C.
The issue with missing characters can occur with any font of course. It would be better if such a character would be displayed as a question mark or a rectangle instead of just a space.
Last edited by Roy_043 on Mon Aug 05, 2019 8:57 am, edited 1 time in total.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft preferences: problems with font settings

Post by Roy_043 »

B.
If you change the Draft font preference in the BIM_Setup dialog, the dropdown displays the correct preview for all fonts in the Windows font folder. This makes it even harder to understand why most fonts can't be used.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Draft preferences: problems with font settings

Post by yorik »

There have been some reports of people unable to change the draft font on windows already.. So far we've never been able to pinpoint what exactly was happening... The symptom is this, you can set just any font name, the texts are always displayed in "the default font".

That default font is a hard-coded times new roman-like font in coin3D, that is always guaranteed to be there...

The difficulty is that coin3d is supposed to handle fonts itself, ie. we just pass it the font family string, and it does the rest. So there is little opportunity for us to see what could be done..

About the shapestring tool needing write access, that is really strange indeed, it shouldn't happen... I'll test if it does that here too...
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft preferences: problems with font settings

Post by Roy_043 »

yorik wrote: Sat Aug 10, 2019 2:01 am About the shapestring tool needing write access, that is really strange indeed, it shouldn't happen... I'll test if it does that here too...
Note that Windows message says: 'not authorized to open this file' ('file' not 'folder').
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft preferences: problems with font settings

Post by Roy_043 »

Another Windows-only file access issue that is perhaps related or can maybe provide a clue?:
https://forum.freecadweb.org/viewtopic. ... 39#p337939
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Draft preferences: problems with font settings

Post by wandererfan »

Roy_043 wrote: Wed Oct 02, 2019 7:56 am Another Windows-only file access issue that is perhaps related or can maybe provide a clue?:
https://forum.freecadweb.org/viewtopic. ... 39#p337939
I think you are on to something @Roy_043. I had a quick look at Gui/FileDialog.cpp last night and it looks like it might have the same issue we had with TD Templates. I should have some time for a deeper look today.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Draft preferences: problems with font settings

Post by wandererfan »

issue #4153 for Point A above.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Draft preferences: problems with font settings

Post by wandererfan »

Roy_043 wrote: Wed Oct 02, 2019 7:56 am Another Windows-only file access issue that is perhaps related or can maybe provide a clue?:
https://forum.freecadweb.org/viewtopic. ... 39#p337939
After looking into this, I would say the Draft Preference problem is definitely not the same issue the file rename problem.

Its a wide spread issue - see issue #4153 for details.

The batch file in the bug report fixed it for me.
Post Reply