[metapost] Fonts without *.tfm (MP as library)

Dmitry Solomennikov dmitrys99 at mail.ru
Tue Nov 2 16:34:14 CET 2010


Some time ago I wrote a question about embedding MP into application
(as library).
Today I can use MP (providing Qt's widget for output).

There were no need to use text at all. But everything is changing.
Now I need to use "label" operator in MP's code.

It works, but not so well as I need.
After processing "label" operator MP's library produces
mp_text_object, which contains text and six int field, which are the
affine transformation matrix. Everything goes well while one use
fonts, known to TeX, or, more precisely, which have corresponding
*.tfm files.

This is not the case for me. I want to use arbitrary fonts.

So, the question is: How to avoid use of *.tfm files and still use
transformation matrix?

I've found three possible ways.

1) Build *.tfm file on-the-fly with utilites like "ttf2tfm".
This approach has many disadvantages - what about Type 1 fonts,
Linux fonts etc.; what about font naming?

2) Provide one dummy *.tfm file for all fonts.
Well, it works. But the main problem is the precision of
calculations. Especially for different font sizes.

3) Fill font_info structure and return font_number to MP.
For any font in a system I can read font metrics and other
information. So I can provide any (same?) informations as in *.tfm,
but actually I do not understand, how to fill font_info correctly.
The information in tfmin.w is very short for complete understanding.

Most attractive way is 3), but second is working.

Are there any different solutions?

Thanks a lot!


More information about the metapost mailing list