From: Po Lu Date: Thu, 24 Aug 2023 01:08:11 +0000 (+0800) Subject: Properly detect medium fonts X-Git-Tag: archive/raspbian/1%30.1+1-3+rpi1^2~2^2~20^2~4479 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1986484d4d0b77e5c9f00217cdf2da28b6b6cf11;p=emacs.git Properly detect medium fonts * src/sfntfont.c (sfnt_decode_family_style): Refer to the preferred family and subfamily if present. --- diff --git a/src/sfntfont.c b/src/sfntfont.c index e2dfdaff3b6..f2dc05c886e 100644 --- a/src/sfntfont.c +++ b/src/sfntfont.c @@ -322,11 +322,30 @@ sfnt_decode_family_style (struct sfnt_name_table *name, struct sfnt_name_record family_rec, style_rec; unsigned char *family_data, *style_data; - family_data = sfnt_find_name (name, SFNT_NAME_FONT_FAMILY, + /* Because MS-Windows is incapable of treating font families + comprising more than four styles correctly, the TrueType + specification incorporates additional PREFERRED_FAMILY and + PREFERRED_SUBFAMILY name resources that are meant to be consulted + over the traditional family and subfamily resources. When + present within fonts supplying unusual styles, these names hold + the ``actual'' typographic family and style of the font, in lieu + of the font family with the style affixed to the front and + Regular. */ + + family_data = sfnt_find_name (name, SFNT_NAME_PREFERRED_FAMILY, &family_rec); - style_data = sfnt_find_name (name, SFNT_NAME_FONT_SUBFAMILY, + + if (!family_data) + family_data = sfnt_find_name (name, SFNT_NAME_FONT_FAMILY, + &family_rec); + + style_data = sfnt_find_name (name, SFNT_NAME_PREFERRED_SUBFAMILY, &style_rec); + if (!style_data) + style_data = sfnt_find_name (name, SFNT_NAME_FONT_SUBFAMILY, + &style_rec); + if (!family_data || !style_data) return 1;