metaflop / metaflop-www

A free and open source (FOSS) web application for modulating your own METAFONTs
http://www.metaflop.com
GNU General Public License v3.0
181 stars 14 forks source link

Issue with Metafont mftrace Command Execution in Designer Mode #447

Closed NargesSayah closed 1 month ago

NargesSayah commented 1 month ago

I am currently working on a project where I need to create OTF/TTF files of custom fonts after adjusting font parameters in the font.mf file. To achieve this, I am following the procedure outlined for designers, specifically using mftrace to trace the Metafont output.

However, it seems that the command to run Metafont is failing, and as a result, no .gf file is being produced, causing the subsequent file operations to fail. This problem occurs when I execute the following command:

mftrace --tfm=font.tfm --encoding=tex256 font.2602gf

Here is a snippet of the error message I am receiving:

mftrace 1.2.20
Font `font.2602gf'...
Unknown encoding `  '; assuming tex256.
Using encoding file: `/usr/local/Cellar/texlive/20240312/share/texmf-dist/fonts/enc/dvips/base/tex256.enc'
Debug: size=20.0, size_points=332.08800332088003, mag=3.01125, prod=3613.5
Running Metafont...warning: mf: command exited with value 256 (ignored)

Metafont failed. Excerpt from the log file:

*****Traceback (most recent call last):
  File "/usr/local/bin/mftrace", line 903, in gen_pixel_font
    with open(f'{filename}.{int(prod)}gf'):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'font.2602gf.3613gf'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/mftrace", line 1427, in <module>
    main()
  File "/usr/local/bin/mftrace", line 1421, in main
    do_file (filename)
  File "/usr/local/bin/mftrace", line 1393, in do_file
    base = gen_pixel_font (basename, metric, options.magnification)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/mftrace", line 934, in gen_pixel_font
    start = m.start(0)
            ^^^^^^^
AttributeError: 'NoneType' object has no attribute 'start'
Exception ignored in: <function TempDirectory.__del__ at 0x10ad8bd80>
Traceback (most recent call last):
  File "/usr/local/bin/mftrace", line 131, in __del__
  File "/usr/local/bin/mftrace", line 128, in clean
ImportError: sys.meta_path is None, Python is likely shutting down

The main error seems to stem from the gen_pixel_font function within mftrace, where the Metafont command does not successfully produce the expected .gf file. I have verified that both font.tfm and font.2602gf exist and are readable. Here are the details:

ls -l font.tfm
-rw-r--r--@ 1 user  staff  13124 Jun  4 16:18 font.tfm

ls -l font.2602gf
-rw-r--r--@ 1 user  staff  850440 Jun  4 15:50 font.2602gf

I have also run Metafont manually using the command:

mf '\mode=ljfour; mag=1; input font'

which successfully generates font.600gf.

Could you provide guidance on resolving this issue?

koffeinfrei commented 1 month ago

@NargesSayah Could you provide a minimal reproducible input file that results in the described error?

@MarcoMueller Would you mind having a look?

NargesSayah commented 1 month ago

@NargesSayah Could you provide a minimal reproducible input file that results in the described error?

@MarcoMueller Would you mind having a look?

Thank you for responding. This is the font.mf file that I'm using. It's one of your uploaded font files (bespoke) that I have edited and simply changed some of the font variables like height. font.zip

MarcoMueller commented 1 month ago

@NargesSayah we use mf2outline from @linusromer. mf2outline is a python script that converts METAFONT fonts to outline formats like OpenType. I recommend you install the package and give it a try. There is a documentation available. https://github.com/metaflop/metaflop-www/wiki/From-METAFONT-to-outline https://github.com/linusromer/mf2outline Kind regards Marco

NargesSayah commented 1 month ago

@NargesSayah we use mf2outline from @linusromer. mf2outline is a Python script that converts METAFONT fonts to outline formats like OpenType. I recommend you install the package and give it a try. There is a documentation available. https://github.com/metaflop/metaflop-www/wiki/From-METAFONT-to-outline https://github.com/linusromer/mf2outline Kind regards Marco

Thank you @MarcoMueller for your response and for directing me toward mf2outline by @linusromer. I'll follow up with Linus for further support.

Cheers.