Skip to content

Automatic combined style map names are passed to ufo2ft with undesirable values #1161

@NightFurySL2001

Description

@NightFurySL2001

When using fontmake to instantiate a UFO from designspace with multilingual names, the instance style map family names include additional undesirable names that should not be included.

For example, if I include this Python code in ufo2ft:

        print(instance.localisedFamilyName)
        print(instance.localisedStyleName)
        print(instance.localisedStyleMapFamilyName)
        print(instance.localisedStyleMapStyleName)

before https://github.com/googlefonts/ufo2ft/blob/9cda1f16f25d7941f0f8a82b5ae1788150bf18d1/Lib/ufo2ft/instantiator.py#L782.

Using this designspace:

<?xml version='1.0' encoding='utf-8'?>
<designspace format="4.0">
    <axes>
        <axis
            minimum="100"
            maximum="700"
            default="100"
            tag="wght"
            name="weight"
        >
            <labelname xml:lang="en">Weight</labelname>
            <labelname xml:lang="zh">字重</labelname>
            <map output="100" input="100"/>
            <map output="165" input="200"/>
            <map output="275" input="300"/>
            <map output="360" input="400"/>
            <map output="425" input="450"/>
            <map output="505" input="500"/>
            <map output="602" input="600"/>
            <map output="700" input="700"/>
            <labels>
                <label uservalue="100" name="Thin"/>
                <label uservalue="200" name="ExtraLight"/>
                <label uservalue="300" name="Light"/>
                <label uservalue="400" name="Regular"/>
                <label uservalue="450" name="Text"/>
                <label uservalue="500" name="Medium"/>
                <label uservalue="600" name="Semibold"/>
                <label uservalue="700" name="Bold"/>
            </labels>
        </axis>
    </axes>
    <sources>
        <source
            familyname="Frex Sans GB VF"
            stylename="Bold"
            filename="masters/FrexSansGBVF-Bold.ufo"
            name="Bold"
        >
            <familyname xml:lang="zh">械黑 GB VF</familyname>
            <location>
                <dimension xvalue="700" name="weight"/>
            </location>
        </source>
        <source
            familyname="Frex Sans GB VF"
            stylename="Thin"
            filename="masters/FrexSansGBVF-Thin.ufo"
            name="Thin"
        >
            <familyname xml:lang="zh">械黑 GB VF</familyname>
            <lib copy="1"/>
            <groups copy="1"/>
            <info copy="1"/>
            <features copy="1"/>
            <location>
                <dimension xvalue="100" name="weight"/>
            </location>
        </source>
    </sources>
    <instances>
        <instance
            familyname="Frex Sans GB"
            stylename="Thin"
            filename="instances/FrexSansGB-Thin.ufo"
            name="Thin"
        >
            <location>
                <dimension xvalue="100" name="weight"/>
            </location>
            <familyname xml:lang="zh">械黑 GB</familyname>
            <stylename xml:lang="zh">Thin</stylename>
        </instance>
        <instance
            familyname="Frex Sans GB"
            stylename="Regular"
            filename="instances/FrexSansGB-Regular.ufo"
            name="Regular"
        >
            <location>
                <dimension xvalue="360" name="weight"/>
            </location>
            <familyname xml:lang="zh">械黑 GB</familyname>
            <stylename xml:lang="zh">Regular</stylename>
        </instance>
        <instance
            familyname="Frex Sans GB"
            stylename="Bold"
            filename="instances/FrexSansGB-Bold.ufo"
            name="Bold"
        >
            <location>
                <dimension xvalue="700" name="weight"/>
            </location>
            <familyname xml:lang="zh">械黑 GB</familyname>
            <stylename xml:lang="zh">Bold</stylename>
        </instance>
    </instances>
</designspace>

Running fontmake -i Thin -o ufo -m test.designspace, the output is follow:

INFO:fontmake.font_project:Loading 2 DesignSpace source UFOs
INFO:fontmake.font_project:Interpolating master UFOs from designspace
INFO:fontmake.font_project:Generating instance UFO for 'Thin'
{'zh': '械黑 GB'}
{'zh': 'Thin'}
{'en': 'Frex Sans GB VF Thin', 'zh': '械黑 GB VF Thin'} // <-- where do this come from???
{}
INFO:fontmake.font_project:Saving instances\FrexSansGB-Thin.uf

Pretty sure this isn't on ufo2ft as I've written this part and there is a test case testing this exact scenario.

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