简体   繁体   中英

How to use Adobe afm fonts in matplotlib text?

I want to add a text to a figure using an AFM font. I know that I can pass the fontproperties or the fontname keyword argument when creating a text.

Regarding the usage of AFM fonts in matplotlib, I found this and this .

I can't pass a Font instance create by matplotlib.font_manager.afmFontProperty as fontproperties kwarg.

The font I intend to use is URW Chancery L and located in /usr/share/fonts/type1/gsfonts/z003034l.afm . How can I make matplotlib use this font?

Also I looked for converters from afm to ttf but could not find any, maybe you have a suggestion?

I'm using matplotlib 1.5.3 on Ubuntu 16.04.

What is an "AFM font"? AFM files are A dobe F ont M etrics files, which only contain metadata around glyph bounds, kerning pairs, etc. as a convenient lookup mechanism when you don't want to mine the real font file for that information (handy for typesetting, where having the metrics available as separate resource makes things a hell of a lot faster), they are not themselves fonts in any way. You would still need a (now mostly defunct) .pfa or .pfb font file ("printer font; ascii" and "printer font; binary", respectively) to do any kind of actual text rendering. Without those, all you can do is mark the appropriate region in which text would be drawn if you also had the font itself available =)

(this is actually what TeX and PDF do - they use the font metrics to construct "empty boxes" inside of which text will ultimately be rendered once all the typesetting has been determined and the boxes no longer move around)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM