tryvin/figma-linux-font-helper

It doesn't work

sdurnov opened this issue · 7 comments

I've installed p3 and pip3 on my Ubuntu machine.
Ran script.
Ran python3 server.py

python3 server.py
 * Serving Flask app "server" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:18412/ (Press CTRL+C to quit)

Reloaded Chrome, opened Figma, opened project with local font - font wasn't found. In Account settings Figma says Local Fonts are not available on this system.

Doesn't work on mine either. Tried on both Chromium and Firefox, also my command line outputted this too when I tried using firefox but it didn't help:

127.0.0.1 - - [15/May/2019 11:55:46] "GET /figma/font-files HTTP/1.1" 200-

Hi, I've had similar issues.

First, make sure your fonts are listed by the fc-list command. If not, follow the instructions (these are for fedora, but might be similar in other distros) here: https://docs.fedoraproject.org/en-US/quick-docs/adding-new-fonts-fedora/

Also i had to edit helpers.py:62 (get_font_list method) and add or font_file.endswith(".otf"), because i only had .otf font files.

I ALSO had to tinker around with font file names. Started working after that.

Hi! I have the same issue. I use font with extension ttf and it's in the fc-list command list, but unfortunately it's not present in the Figma.

Doesn't work on mine either.

Traceback (most recent call last):
  File "server.py", line 18, in <module>
    FONT_FILES = get_font_list()
  File "/home/spazione/Downloads/figma-linux-font-helper-master/helpers.py", line 90, in get_font_list
    font_extra_info = get_font_extra_information(list(font_list.keys()))
  File "/home/spazione/Downloads/figma-linux-font-helper-master/helpers.py", line 33, in get_font_extra_information
    subprocess.getstatusoutput('fc-scan %s' % (file_list,))
  File "/usr/lib/python3.5/subprocess.py", line 495, in getstatusoutput
    data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT)
  File "/usr/lib/python3.5/subprocess.py", line 316, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 383, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
    raise child_exception_type(errno_num, err_msg)
OSError: [Errno 7] Argument list too long

Doesn't work on mine either.

Traceback (most recent call last):
  File "server.py", line 18, in <module>
    FONT_FILES = get_font_list()
  File "/home/spazione/Downloads/figma-linux-font-helper-master/helpers.py", line 90, in get_font_list
    font_extra_info = get_font_extra_information(list(font_list.keys()))
  File "/home/spazione/Downloads/figma-linux-font-helper-master/helpers.py", line 33, in get_font_extra_information
    subprocess.getstatusoutput('fc-scan %s' % (file_list,))
  File "/usr/lib/python3.5/subprocess.py", line 495, in getstatusoutput
    data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT)
  File "/usr/lib/python3.5/subprocess.py", line 316, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 383, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
    raise child_exception_type(errno_num, err_msg)
OSError: [Errno 7] Argument list too long

You have a lot of fonts. I mean they're more than sh allows.
Solution is to use fclist.py or use something different than subprocess call.

I've also had problems getting this to work on my Ubuntu 20.04 machine with Firefox browser. The server seemed to be working, with the following log output, but no local fonts were available on Figma:

$ python server.py 
 * Serving Flask app "server" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:18412/ (Press CTRL+C to quit)
127.0.0.1 - - [03/Mar/2021 21:39:07] "GET /figma/font-files HTTP/1.1" 200 -

It turns out it was a cross-origin request policy problem, which I've fixed and created a pull request. Hope that helps someone.

Closing this as the PR was "merged"