aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_do_font_descriptions_match.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-10 18:59:00 +0100
committerMattias Andrée <maandree@kth.se>2023-01-10 18:59:00 +0100
commit73e12ac4d3553f05a0337cd8d49d8ec3084a3788 (patch)
treee129ebee5e03fbe8a2eb321fe6d809d7aba24e2c /libfonts_do_font_descriptions_match.c
parentm + implement libfonts_do_{decoded_,}font_descriptions_match (diff)
downloadlibfonts-73e12ac4d3553f05a0337cd8d49d8ec3084a3788.tar.gz
libfonts-73e12ac4d3553f05a0337cd8d49d8ec3084a3788.tar.bz2
libfonts-73e12ac4d3553f05a0337cd8d49d8ec3084a3788.tar.xz
libfonts_do_font_descriptions_match: attempt to decode first to handle unnormalized data
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libfonts_do_font_descriptions_match.c')
-rw-r--r--libfonts_do_font_descriptions_match.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/libfonts_do_font_descriptions_match.c b/libfonts_do_font_descriptions_match.c
index 1bf6069..9936856 100644
--- a/libfonts_do_font_descriptions_match.c
+++ b/libfonts_do_font_descriptions_match.c
@@ -6,27 +6,25 @@
int
libfonts_do_font_descriptions_match(const char *desc, const char *spec)
{
+ struct libfonts_font_description desc_decoded;
+ struct libfonts_font_description spec_decoded;
+
if (!spec)
return !desc;
if (!desc)
return 0;
- while (*spec && *desc) {
- if (spec[0] == '*' && (!spec[1] || spec[1] == '-')) {
- spec++;
- while (*desc && *desc != '-')
- desc++;
- } else {
- while (*spec && *desc && *spec != '-' && *desc != '-') {
- if (*spec != *desc && *spec != '?')
- return 0;
- }
- }
- if (*spec != *desc || (*spec && *spec != '-'))
- return 0;
+ if (strlen(desc) > 255 || strlen(spec) > 255) {
+ fallback:
+ desc_decoded.private_font_name = desc;
+ spec_decoded.private_font_name = spec;
+ } else {
+ if (libfonts_decode_font_description(&desc_decoded, desc) ||
+ libfonts_decode_font_description(&spec_decoded, spec))
+ goto fallback;
}
- return *spec == *desc;
+ return libfonts_do_decoded_font_descriptions_match(&desc_decoded, &spec_decoded);
}