Add support for all Pango font weight options

This commit is contained in:
Simon Long 2025-04-23 17:03:02 +01:00 committed by GitHub
parent 44295c0c13
commit 6a810ad762
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 72 additions and 4 deletions

View file

@ -862,8 +862,31 @@ set_font_attr(struct font *font, const char *nodename, const char *content)
font->slant = FONT_SLANT_NORMAL;
}
} else if (!strcmp(nodename, "weight")) {
font->weight = !strcasecmp(content, "bold") ?
FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL;
if (!strcasecmp(content, "thin")) {
font->weight = FONT_WEIGHT_THIN;
} else if (!strcasecmp(content, "ultralight")) {
font->weight = FONT_WEIGHT_ULTRALIGHT;
} else if (!strcasecmp(content, "light")) {
font->weight = FONT_WEIGHT_LIGHT;
} else if (!strcasecmp(content, "semilight")) {
font->weight = FONT_WEIGHT_SEMILIGHT;
} else if (!strcasecmp(content, "book")) {
font->weight = FONT_WEIGHT_BOOK;
} else if (!strcasecmp(content, "medium")) {
font->weight = FONT_WEIGHT_MEDIUM;
} else if (!strcasecmp(content, "semibold")) {
font->weight = FONT_WEIGHT_SEMIBOLD;
} else if (!strcasecmp(content, "bold")) {
font->weight = FONT_WEIGHT_BOLD;
} else if (!strcasecmp(content, "ultrabold")) {
font->weight = FONT_WEIGHT_ULTRABOLD;
} else if (!strcasecmp(content, "heavy")) {
font->weight = FONT_WEIGHT_HEAVY;
} else if (!strcasecmp(content, "ultraheavy")) {
font->weight = FONT_WEIGHT_ULTRAHEAVY;
} else {
font->weight = FONT_WEIGHT_NORMAL;
}
}
}