How to add SHX fonts for use by Matplotlib drawing back-end #710
-
Hi @mozman! First of all, thanks for an awesome package!🤩 While running the rendering using
I succeeded to fix an issue for the fonts available as TFF, however still getting the same warning for the AutoCAD fonts saved as SHX. So my question is: is there a way to somehow import the SHX fonts from AutoCAD into Thanks in advance for your feedback!🙂 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
The SHX font format is not documented or supported by many libraries/packages like Sometimes the
... but "isocp" is included in the default cache files Edit: usual the "isocp" font should be mapped to "isocp___.ttf", maybe you can upload a simple example DXF which shows your issue. |
Beta Was this translation helpful? Give feedback.
-
Hi @mozman! Ok got it, thanks for your feedback! Will retry with Regarding the "isocp" issue, I created a dummy DXF with some text using "Txt" and "isocp" fonts. By default, it returns me this warning for both of these fonts and draws the text using some default font. You can find this dummy DXF below: Please note: I run the |
Beta Was this translation helpful? Give feedback.
-
I tested your
Next I copied on Linux the replacement fonts into Deleted Conclusion: the TTF replacement fonts are not available system wide, or Matplotlib can't find it, or the Matplotlib font cache is outdated. |
Beta Was this translation helpful? Give feedback.
-
@mozman Ok sounds clear, thanks for your feedback!🙂 By the way, I also found some solution that is a bit ugly from the software engineering and the code readability point of view, but that does the trick in case when someone has a folder with .ttf files that they don't want to install globally (like it was in my case). More specifically, if from os.path import join
import matplotlib.font_manager as font_manager
for font in font_manager.findSystemFonts(custom_fonts_paths):
font_manager.fontManager.addfont(font)
class FixedFontManager(font_manager.FontManager):
def __init__(self, size=None, weight='normal'):
super().__init__(size, weight)
for font in font_manager.findSystemFonts(custom_fonts_paths):
self.addfont(font)
font_manager.FontManager = FixedFontManager Note: the code above must be placed before the code that calls the |
Beta Was this translation helpful? Give feedback.
@mozman Ok sounds clear, thanks for your feedback!🙂
By the way, I also found some solution that is a bit ugly from the software engineering and the code readability point of view, but that does the trick in case when someone has a folder with .ttf files that they don't want to install globally (like it was in my case). More specifically, if
custom_fonts_paths
is alist
with paths to the folders with custom fonts, then the following worked for me: