mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-06-30 13:14:56 -04:00
config: font_parse(): handle font family names with \-:,
These characters have special meaning, and when they appear in the font *family name*, they need to be escaped in the font pattern. Before this patch, even if the user did escape them properly, _we_ un-escaped them in FcNameUnparse(), causing the wrong font to be loaded later.
This commit is contained in:
parent
ebaa878dce
commit
22ea71117c
1 changed files with 19 additions and 1 deletions
20
config.c
20
config.c
|
|
@ -4123,7 +4123,25 @@ config_font_parse(const char *pattern, struct config_font *font)
|
|||
FcPatternRemove(pat, FC_SIZE, 0);
|
||||
FcPatternRemove(pat, FC_PIXEL_SIZE, 0);
|
||||
|
||||
char *stripped_pattern = (char *)FcNameUnparse(pat);
|
||||
/* Only the family part, with '\', '-', ':' and ',' \-escaped */
|
||||
FcChar8 *escaped_family = FcPatternFormat(
|
||||
pat, (const FcChar8 *)"%{+family{%{family|escape(\\\\-:,)}}}");
|
||||
|
||||
/* Everything but the family, size and pixelsize */
|
||||
FcChar8 *rest = FcPatternFormat(
|
||||
pat, (const FcChar8 *)"%{-family,size,pixelsize{%{=unparse}}}");
|
||||
|
||||
char *stripped_pattern = NULL;
|
||||
if (escaped_family == NULL || rest == NULL) {
|
||||
free(escaped_family);
|
||||
free(rest);
|
||||
stripped_pattern = (char *)FcNameUnparse(pat);
|
||||
} else {
|
||||
stripped_pattern = xasprintf("%s%s", escaped_family, rest);
|
||||
free(escaped_family);
|
||||
free(rest);
|
||||
}
|
||||
|
||||
FcPatternDestroy(pat);
|
||||
|
||||
LOG_DBG("%s: pt-size=%.2f, px-size=%d", stripped_pattern, pt_size, px_size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue