summaryrefslogtreecommitdiff
path: root/do_text.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2020-04-03 16:48:10 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-04-13 15:28:07 -0700
commit95a84fd5584873885f3123f25b6424008409afc1 (patch)
tree81158b4a2955d099b888ce92349b95004c472d52 /do_text.c
parentc0ba2f7af7270f2e6edf1bc2386c97ed3f0783cb (diff)
Validate fonts used in Xft tests
This compares the font family from the loaded font with the requested family and skips tests where the requested family wasn't available. It's not perfect, as someone could have a mis-configured font family, but should catch most incorrect font usages. I've also switched from Charter to DejaVu Sans as that is more widely installed. Signed-off-by: Keith Packard <keithp@keithp.com> Part-of: <https://gitlab.freedesktop.org/xorg/test/x11perf/-/merge_requests/1>
Diffstat (limited to 'do_text.c')
-rw-r--r--do_text.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/do_text.c b/do_text.c
index 8d28def..355ba8d 100644
--- a/do_text.c
+++ b/do_text.c
@@ -409,6 +409,8 @@ InitAAText(XParms xp, Parms p, int64_t reps)
{
char ch;
XRenderColor color;
+ FcValue value;
+ int v_len;
aafont = XftFontOpenName (xp->d, DefaultScreen (xp->d), p->font);
@@ -418,6 +420,22 @@ InitAAText(XParms xp, Parms p, int64_t reps)
p->font);
return 0;
}
+ if (FcPatternGet(aafont->pattern, FC_FAMILY, 0, &value) != FcResultMatch ||
+ value.type != FcTypeString)
+ {
+ printf("Could not load font '%s', benchmark omitted\n",
+ p->font);
+ XftFontClose (xp->d, aafont);
+ return 0;
+ }
+ v_len = strlen((char *) value.u.s);
+ if (strncmp((char *) value.u.s, p->font, v_len) != 0 || p->font[v_len] != ':') {
+ printf("Could not load font '%s' (found %s), benchmark omitted\n",
+ p->font,
+ (char *) value.u.s);
+ XftFontClose (xp->d, aafont);
+ return 0;
+ }
aadraw = XftDrawCreate (xp->d, xp->w,
xp->vinfo.visual,