Skip to content

Python font.transform(psMat.scale(FACTOR)) does not give the same result as Scale Uniformly in the GUI. #4976

@kwand

Description

@kwand

When reporting a bug/issue:

  • Screenshot
  • The FontForge version and the operating system you're using
  • The behavior you expect to see, and the actual behavior
  • Steps to reproduce the behavior
  • (optional) Possible solution/fix/workaround

Fontforge version (on Arch Linux 5.17.1)

fontforge -v
Copyright (c) 2000-2022. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Version: 20220308
 Based on sources from 2022-03-29 01:43 UTC-ML-D-GDK3.
 Based on source from git with hash: 7fec181549677e62cfb16101972f479183082c29
fontforge 20220308
build date: 2022-03-29 01:43 UTC

As titled. I would like to be able to perform a Scale Uniformly on all glyphs in a font via Python scripting, but so far I have not been able to replicate the same functionality via font.transform() - which, as far as I'm aware, the only method that I can use to replicate it. In particular, I've noticed the MATH table does not get scaled in Python, but it is (correctly, IMO) when done via the GUI.

Expected Behaviour
font.transform(psMat.scale(FACTOR) does the same thing as a GUI Scale Uniformly... with all glyphs selected (and checkboxes checked. Since font.transform() can only take in one argument, I think it's appropriate it is applied to the categories specified in the checkboxes. Either this, or more options should be exposed via font.transform()).

Note that "by all checkboxes checked", I mean this:

Screenshot

image

Actual Behaviour
The two methods are not equivalent - in particular, the MATH table does not get scaled in Python. I do not know what else has not been missed in Python, but I suspect there may be more than just the MATH table that was not scaled.

Screenshots

image
image

Concrete steps to reproduce

  1. Open a font with an OpenType MATH table in the GUI and in Python (i.e. a math font. You can download the Garamond-Math.otf that I was working with from here: https://ctan.org/tex-archive/fonts/garamond-math)
  2. Scale the font in the GUI with all glyphs selected (Ctrl+A) and options as seen in the screenshot above. Scaling factor can be 110% for simplicity
  3. Do the same thing in Python i.e.
f.selection.all() # f is the variable we loaded the font into
f.transform(psMat.scale(1.10))
  1. Save both versions (GUI and Python) and open them both up in the GUI. Notice that in particular the MATH table has not been scaled in Python.

Possible solution/fix/workaround

Expose a font.scaleUniformly() function in Python or add more parameters to font.transform(), allowing me to choose all the same categories in the GUI for transformation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions