Show the postscript variations name prefix when listing fonts

This commit is contained in:
Kovid Goyal
2024-04-23 09:02:40 +05:30
parent f7f8b4cdf6
commit 98dac1020d
4 changed files with 5 additions and 5 deletions

View File

@@ -31,7 +31,7 @@ class NamedStyle(TypedDict):
class VariableData(TypedDict):
axes: Tuple[VariableAxis, ...]
named_styles: Tuple[NamedStyle, ...]
variations_postscript_name_prefix: str
class FontFeature:

View File

@@ -51,11 +51,11 @@ def create_font_map(all_fonts: Tuple[FontConfigPattern, ...]) -> FontMap:
@lru_cache()
def all_fonts_map(monospaced: bool = True) -> FontMap:
if monospaced:
ans = fc_list(FC_DUAL) + fc_list(FC_MONO)
ans = fc_list(spacing=FC_DUAL) + fc_list(spacing=FC_MONO)
else:
# allow non-monospaced and bitmapped fonts as these are used for
# symbol_map
ans = fc_list(-1, True)
ans = fc_list(allow_bitmapped_fonts=True)
return create_font_map(ans)

View File

@@ -59,7 +59,7 @@ def create_family_groups(monospaced: bool = True) -> Dict[str, List[ListedFont]]
def show_variable(f: ListedFont, psnames: bool) -> None:
vd = get_variable_data_for_descriptor(f)
p = italic(f['family'])
p = italic(vd['variations_postscript_name_prefix'] or f['family'])
p = f"{p} {variable_font_label('Variable font')}"
print(indented(p))
print(indented(variable_font_label('Axes of variation'), level=2))

View File

@@ -849,7 +849,7 @@ get_variable_data(Face *self, PyObject *a UNUSED) {
if (!s) return NULL;
PyTuple_SET_ITEM(axes, i, s);
}
return Py_BuildValue("{sO sO}", "axes", axes, "named_styles", named_styles);
return Py_BuildValue("{sO sO sN}", "axes", axes, "named_styles", named_styles, "variations_postscript_name_prefix", _get_best_name(self, 25));
}
StringCanvas