Skip to content

Add system font support#77

Draft
gregdavill wants to merge 1 commit intomainfrom
font-selection
Draft

Add system font support#77
gregdavill wants to merge 1 commit intomainfrom
font-selection

Conversation

@gregdavill
Copy link
Copy Markdown
Owner

Summary

Here is initial work on adding system font support.

  • Add UI control for the wx.FontPicker Button
  • Use of wx.FontPicker to select a system font
  • Store font family,italic,bold state in config/footprint
  • Attempt to restore this info, to support editing
  • Make use of this info when using svg2mod's svg.Text object.

Open Questions

  • I think the UI looks cleaner if we have "System Font" in the main drop down list. What do people think? When it's not selected the FontPicker is greyed out.

  • I've seen a fair few fonts not render correctly. I suspect there is an issue with the search paths used by wx and the ones used by svg2mod?
    Maybe if we have errors forward them into the UI? Instead of just displaying blank?

  • If a user opens a design that has a footprint generated with a font they do not have. how should we handle editing?

Demo

2022-03-03.23-30-48.mp4

@HDR
Copy link
Copy Markdown
Contributor

HDR commented Mar 3, 2022

Fonts not rendering is probably because the filename and font name are different, i kept running into this when i was messing with font selection.

@gregdavill
Copy link
Copy Markdown
Owner Author

That seems like what's happening. Ultimately fonttools is what creates a polygon from ttf's. It wants a full path to the font file. svg2mod populates a table of "system fonts" that it fronts in these folders.

_os_font_paths = {
"Darwin": ["/Library/Fonts", "~/Library/Fonts"],
"Linux": ["/usr/share/fonts","/usr/local/share/fonts","~/.local/share/fonts"],
"Windows": ["C:/Windows/Fonts", "~/AppData/Local/Microsoft/Windows/Fonts"]
}

On linux you can put fonts in more places. So I suspect that wxFontPicker is pulling in fonts that svg2mod hasn't got a path for.
It would be perfect if we could a path directly from wx.Font. But, atleast from my understanding, that's not possible.

@HaydenHu
Copy link
Copy Markdown

这似乎是正在发生的事情。最终,fonttools 是从 ttf 创建一个多边形的。它需要字体文件的完整路径。svg2mod 填充了它在这些文件夹中的“系统字体”表。

_os_font_paths = {
"Darwin": ["/Library/Fonts", "~/Library/Fonts"],
"Linux": ["/usr/share/fonts","/usr/local/share/fonts","~/.local/share/fonts"],
"Windows": ["C:/Windows/Fonts", "~/AppData/Local/Microsoft/Windows/Fonts"]
}

在 linux 上,您可以将字体放在更多位置。所以我怀疑 wxFontPicker 正在引入 svg2mod 没有路径的字体。 如果我们可以直接从 wx.Font 获得路径,那将是完美的。但是,至少根据我的理解,这是不可能的。

After selecting a system font, the preview cannot be generated and the result is empty
kicad6.0.6_1
win10
image

@gregdavill gregdavill marked this pull request as draft May 6, 2024 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants