Draft ShapeString can't open symbolic links?

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
Post Reply
Sam
Posts: 177
Joined: Sun Mar 20, 2016 6:19 pm

Draft ShapeString can't open symbolic links?

Post by Sam »

Code: Select all

OS: KDE Flatpak runtime (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: (HEAD detached at 0.20)
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.9.9, Qt 5.15.5, Coin 4.0.0, Vtk 8.2.0, OCC 7.6.2
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * Help 1.0.3
  * kicadStepUpMod 10.14.5
Draft ShapeString doesn't seem to be able to look in /usr/share/texmf/fonts for fonts. That's probably reasonable for a flatpak install. Don't know.

Anyway, I make a symbolic link to the font I want from my projects directory. Now:
  1. The file selection dialog doesn't show symbolic links
  2. Putting the path to the link results in an error:

    Code: Select all

    14:51:02  Traceback (most recent call last):
      File "/app/freecad/Mod/Draft/draftobjects/shapestring.py", line 67, in execute
        CharList = Part.makeWireString(obj.String,obj.FontFile,obj.Size,obj.Tracking)
    <class 'Part.OCCError'>: Font file not found: /home/sam/Documents/FreeCAD/lmmono9-regular.otf
    14:51:02  Recompute failed! Please check report view.
    
Things work as expected if the font is copied into my projects folder.
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: Draft ShapeString can't open symbolic links?

Post by Syres »

I don't use flatpak so haven't been able to confirm but I believe any fonts that flatpak needs access to by default should be in ~/.local/share/fonts therefore you will need to copy them over from locations that flatpak cannot. This obviously is not ideal due to duplication but it is a known security limitation to the best of my knowledge.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Draft ShapeString can't open symbolic links?

Post by adrianinsaval »

note that a link most likely wouldn't work anyways because if flatpak can't access the original location it cannot follow the link either.
Sam
Posts: 177
Joined: Sun Mar 20, 2016 6:19 pm

Re: Draft ShapeString can't open symbolic links?

Post by Sam »

My real issue is why won't it open a symlink. I see a comment in the test code that alludes to someone before me wondering the same thing...

It may be that flatpak can't open symlinks, but a quick google only finds others' quirks.

I had a couple of cursory searches through the git repo, but I didn't spot where draft is requesting the user select a file.

Small wins though... I have just found that you can set a default font, which is an obvious need, but still nice to find.
Syres wrote: Sun Aug 07, 2022 11:29 am I don't use flatpak so haven't been able to confirm but I believe any fonts that flatpak needs access to by default should be in ~/.local/share/fonts therefore you will need to copy them over from locations that flatpak cannot. This obviously is not ideal due to duplication but it is a known security limitation to the best of my knowledge.
You may be right.

Certainly flatpak can access some places outside a users home though. And surely a font would be world readable.

Regardless, the file chooser that draft opens to look for a font seems to prefer to start in:
  1. The folder the default font is in
  2. The folder the current file is in, if it's writeable
  3. Your home directory.
It looks for *.* too, which isn't ideal. It'd be good if it just looked for appropriate file types.
Sam
Posts: 177
Joined: Sun Mar 20, 2016 6:19 pm

Re: Draft ShapeString can't open symbolic links?

Post by Sam »

adrianinsaval wrote: Sun Aug 07, 2022 9:15 pm note that a link most likely wouldn't work anyways because if flatpak can't access the original location it cannot follow the link either.
Ha! Sometimes the obvious things elude me!
Post Reply