Skip to content

Incorrect handling of font widths (and styles?) in FontsData #15

@kontur

Description

@kontur

So this issue was brought to my attention by one of the users of my Wordpress plugin using this library. Using two fonts of a family of the same weight and style but with differing widths will fail to display any but the first font. For example a narrow and extended cut.

The warning in FontsData will get triggered, but obviously it is expected that both files have same weight and style, so this is a false positive and misleading. Both fonts are still loaded and are present in the ._data object. In the same function, the returned result gets reduced to single entries for each weight (at least that's what I think happens in this slightly dense code at the function's end), so widgets like the FamilyChooser will only receive one font.

(Related, but of less importance, the FamilyChooser's buttons fail to show the width, so will display a narrow bold as "Familyname 700" - so even if it correctly received both fonts, they both would show as "Familyname 700" for a bold narrow and bold extended.)

I also saw how the family name is extracted in the same file and was wondering if essentially the problem here is a semantic one. For example, is Open Sans a family, or are Open Sans Regular, Open Sans Condensed and Open Sans Extended separate families? I understand the naming scheme to work like FamilyName-WidthWeightStyle, so that would put width next to weight and style, only the library doesn't handle it like that.

Upon inspecting some more how the returned value is structured I noticed that for a Regular and Italic of same weight and family there also is only one value returned, Family > Weight > FontId - so am I missing the point or are both issues the same and need a solution for better structuring the returned family values that exposes style, weight and width?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions