linusromer / mf2outline

mf2outline is a python script that converts METAFONT fonts to outline formats like OpenType.
GNU General Public License v3.0
9 stars 3 forks source link

AttributeError when using mf2outline.py #7

Open NargesSayah opened 1 month ago

NargesSayah commented 1 month ago

Hi Linus,

I'm trying to convert a Metafont file (font.mf) to an OpenType font (.otf) as a part of my Master's research on Info-typography. Thanks to @MarcoMueller, I learned about using mf2outline.py for this task. However, I'm encountering an issue.

Here are the steps I took:

  1. Installed the necessary dependencies:
brew install automake autoconf libtool pkg-config glib gobject-introspection cairo pango libspiro libuninameslist libxml2 libpng libtiff giflib libicns
  1. Installed FontForge with Python support:
brew install fontforge --with-python
  1. Ran the mf2outline.py script:
python3 mf2outline.py font.mf

However, I received the following error:

Traceback (most recent call last):
  File "/Users/narges/Workspace/MScThesis/Local/InfoTypo-master/Metaflop/metaflop-www/metaflop-font-bespoke/mf2outline.py", line 1342, in <module>
    font = fontforge.font()
           ^^^^^^^^^^^^^^
AttributeError: module 'fontforge' has no attribute 'font'

I tried reinstalling FontForge or using fontforge.open("font.mf") instead, but neither approach resolved the issue.

Could you please advise on the correct method to convert a Metafont file to an OpenType font, or suggest any steps I might have missed?

linusromer commented 1 month ago

It sounds like python-fontforge is not properly installed. Are you able to use other python scripts that use the fontforge module? May be related: https://github.com/fontforge/fontforge/issues/4542 I guess you know mftrace, which does not rely on python-fontforge and metapost but rather metafont itself?

NargesSayah commented 1 month ago

It sounds like python-fontforge is not properly installed. Are you able to use other python scripts that use the fontforge module? May be related: fontforge/fontforge#4542 I guess you know mftrace, which does not rely on python-fontforge and metapost but rather metafont itself?

Thank you for responding, @linusromer.

You're right, FontForge is not officially supported on macOS and the version available through Brew is not developed by their team. Eventually, I could run

fontforge mf2outline.py font.mf 

without errors, generating a .otf file. However, the output file appears to be incorrectly structured. When I load a sample text with this font, the characters render in a disorganized and unintelligible manner. I suspect there might be an issue with the conversion process.

I've attached the resulting .otf file in case you want to take a look at it.

Also, I did try to work with mftrace initially but encountered other issues, which I explained to Marco and Alexis here: https://github.com/metaflop/metaflop-www/issues/447#issue-2334593766 And they advised me to use mf2outline instead.

Archive.zip

linusromer commented 1 month ago

I have tested your font and there was indeed a problem (one variable had to be cast to integer). Here is the solved version: bespoke-problem-solved.zip I will try to update mf2outline.py soon.

linusromer commented 1 month ago

Ooops, @koffeinfrei has already fixed the integer cast. If you have taken mf2outline from pip you may have got an outdated format.