yashlamba / yashlamba/handwrite

--family is ignored for font.familyname; FontForge/potrace failures exit 0

Open
#93 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
543
Forks
52
PR merge metrics
No merged PRs in 30d

Description

I found a few correctness issues in the font-generation pipeline. They look distinct from #92 (alpha threshold) and #83/#82 (FontForge missing).

1. --family does not set the font’s internal family name

In handwrite/svgtottf.py set_properties() (around lines 47–55):

family = self.metadata.get("family", None) or fontname
self.font.familyname = fontname   # uses --filename, not --family

--family is written into SFNT names when sfnt_names exists (lines 64–67), but self.font.familyname always uses fontname (--filename / config). Installed fonts then show the wrong family in font pickers.

Fix: self.font.familyname = family, and keep fontname / fullname consistent with the SFNT names.

2. FontForge and potrace failures are ignored

  • svgtottf.py lines 28–41: subprocess.run(...) with no check=True and no return-code check. If ffpython/fontforge fails, the CLI can still exit 0 with no .ttf.
  • pngtosvg.py line 48: same for potrace.

Fix: subprocess.run(..., check=True, capture_output=True) and surface stderr. You already raise PotraceNotFound when the binary is missing; a failed conversion should be just as visible.

3. Missing sfnt_names in a custom config → KeyError

Lines 64–68 guard updates to sfnt_names, but line 70 always does:

self.config["sfnt_names"]["UniqueID"] = ...

A minimal config without sfnt_names crashes.

Fix: self.config.setdefault("sfnt_names", {}) before writing UniqueID.

4. Temp directory leaked on failure

handwrite/cli.py converters() (lines 17–37) creates tempfile.mkdtemp() when --directory is omitted, and only rmtrees it if run() succeeds. Any exception in SHEETtoPNG / PNGtoSVG / SVGtoTTF leaves the temp dir behind.

Fix: try/finally around run().

Also, output_directory is never makedirs’d; a missing output path fails late inside FontForge.

Happy to open a PR if you want.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with handwrite/svgtottf.py, especially set_properties() and its subprocess calls, then inspect handwrite/pngtosvg.py and handwrite/cli.py converters(). Verify the family and sfnt_names cases, conversion failures, cleanup on exceptions, and creation of a missing output directory. Done means each reported failure is surfaced and temporary resources are cleaned up.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.