Figma-Linux / figma-linux

Figma is the first interface design tool based in the browser, making it easier for teams to create software. Join us in https://t.me/figma_linux
GNU General Public License v2.0
2.66k stars 159 forks source link

Local font variants do not work #363

Open clotodex opened 8 months ago

clotodex commented 8 months ago

Bug description Local fonts are found but their variants are not available. The only available variant is "regular". Figma did some changes to font loading and how it queries the font-helper - but I think this should not affect it. fc-list and other tools all show the font variants so I am sure they are installed correctly. Also the folders are known to figma, otherwise it would not load them at all.

Screenshots 1706625438_grim

The pop-up-menu for the fonts variant only allows regular. (see Geist and Geist Variable font)

Additional context There are a few issues that might be related, but none of their workarounds or version upgrades worked.

252 #24

clotodex commented 8 months ago

This might be an issue for fresh fonts. Existing fonts I used with old figma versions load fine, just newer ones, which have not been loaded by figma before dont work (maybe there is a cache, and that is why old variants still work?)

richardbowman commented 7 months ago

This issue effectively blocks me from using Figma right now because I can't edit any text. I'd love to help debug. I see my fonts are properly installed, Gnome's font manager properly shows them as variants of the same font as does fc-list, but Figma-linux is showing all of the fonts as separate fonts, which means you can't map them.

/home/$user/.local/share/fonts/Roobert-SemiBoldItalic.ttf: Roobert,Roobert SemiBold:style=SemiBold Italic,Italic
/home/$user/.local/share/fonts/Roobert-Light.ttf: Roobert,Roobert Light:style=Light,Regular
/home/$user/.local/share/fonts/Roobert-MediumItalic.ttf: Roobert,Roobert Medium:style=Medium Italic,Italic
/home/$user/.local/share/fonts/Roobert-Bold.ttf: Roobert:style=Bold
/home/$user/.local/share/fonts/Roobert-RegularItalic.ttf: Roobert:style=Regular Italic,Italic
/home/$user/.local/share/fonts/Roobert-SemiBold.ttf: Roobert,Roobert SemiBold:style=SemiBold,Regular
/home/$user/.local/share/fonts/Roobert-LightItalic.ttf: Roobert,Roobert Light:style=Light Italic,Italic
/home/$user/.local/share/fonts/Roobert-HeavyItalic.ttf: Roobert,Roobert Heavy:style=Heavy Italic,Italic
/home/$user/.local/share/fonts/Roobert-BoldItalic.ttf: Roobert:style=Bold Italic
/home/$user/.local/share/fonts/Roobert-Medium.ttf: Roobert,Roobert Medium:style=Medium,Regular
/home/$user/.local/share/fonts/Roobert-Heavy.ttf: Roobert,Roobert Heavy:style=Heavy,Regular
/home/$user/.local/share/fonts/Roobert-Regular.ttf: Roobert:style=Regular

Screenshot from 2024-03-04 11-43-23 Screenshot from 2024-03-04 11-43-32

richardbowman commented 7 months ago

Ok I see the issue, you need to change the function in TTF.js to properly use preferredFamily and preferredSubFamily names:

  public getData(): Fonts.IFontsFigmaItem {
    const nameTable = this.getNameTable();
    const os2Table = this.getOS2Table();

    logger.info(JSON.stringify(nameTable));

    return {
      postscript: nameTable.postscriptName,
      family: nameTable.preferredFamily ?? nameTable.fontFamily,
      id: nameTable.fontFamily,
      style: nameTable.preferredSubFamily ?? nameTable.fontSubFamily ?? "Regular",
      weight: os2Table.weightClass,
      stretch: 5,
      italic: nameTable.fontSubFamily === "Italic",
    };
  }
lutzseverino commented 6 months ago

Could this be related to variable fonts not working? I'm creating an issue about that right now.

Palingenae commented 1 month ago

I confirm that local font variants do not display properly in font list in Figma. They're listed as bold or regular, sometimes with their Italic.

Also, "Installed by you" features does not seem to work either...

image