summaryrefslogtreecommitdiff
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
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>
-rw-r--r--configure.ac2
-rw-r--r--do_tests.c62
-rw-r--r--do_text.c18
3 files changed, 50 insertions, 32 deletions
diff --git a/configure.ac b/configure.ac
index 93036b7..2309bae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,7 @@ yes)
esac
# Check for Xft library
-PKG_CHECK_MODULES(XFT, xft, [xft_found=yes], [xft_found=no])
+PKG_CHECK_MODULES(XFT, xft fontconfig, [xft_found=yes], [xft_found=no])
case "$xft_found" in
yes)
AC_DEFINE(XFT,1,[Xft library available])
diff --git a/do_tests.c b/do_tests.c
index 14fa328..402f4f2 100644
--- a/do_tests.c
+++ b/do_tests.c
@@ -924,7 +924,7 @@ Test test[] = {
InitText, DoText, ClearTextWin, EndText,
V1_2FEATURE, ROP, 0,
{80, False, "6x13", NULL}},
- {"-tileftext","Char in 80-char line (6x13)", NULL,
+ {"-tileftext","Char in 80-char line tiled (6x13)", NULL,
InitText, DoText, ClearTextWin, EndText,
V1_2FEATURE, ROP, 0,
{80, False, "6x13", NULL, FillTiled}},
@@ -1008,78 +1008,78 @@ Test test[] = {
"-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1",
NULL}},
#ifdef XFT
- {"-aa10text", "Char in 80-char aa line (Charter 10)", NULL,
+ {"-aa10text", "Char in 80-char aa line (DejaVu Sans 10)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 10, "charter:antialias=true:rgba=0:pixelsize=10", NULL}},
- {"-aa24text", "Char in 30-char aa line (Charter 24)", NULL,
+ {80, 10, "DejaVu Sans:antialias=true:rgba=0:pixelsize=10", NULL}},
+ {"-aa24text", "Char in 30-char aa line (DejaVu Sans 24)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {30, 24, "charter:antialias=true:rgba=0:pixelsize=24", NULL}},
+ {30, 24, "DejaVu Sans:antialias=true:rgba=0:pixelsize=24", NULL}},
{"-aaftext", "Char in 80-char aa line (Courier 12)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 12, "courier:antialias=true:rgba=0:pixelsize=12", NULL}},
- {"-a10text", "Char in 80-char a line (Charter 10)", NULL,
+ {80, 12, "Courier:antialias=true:rgba=0:pixelsize=12", NULL}},
+ {"-a10text", "Char in 80-char a line (DejaVu Sans 10)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 10, "charter:antialias=false:rgba=0:pixelsize=10", NULL}},
- {"-a24text", "Char in 30-char a line (Charter 24)", NULL,
+ {80, 10, "DejaVu Sans:antialias=false:rgba=0:pixelsize=10", NULL}},
+ {"-a24text", "Char in 30-char a line (DejaVu Sans 24)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {30, 24, "charter:antialias=false:rgba=0:pixelsize=24", NULL}},
+ {30, 24, "DejaVu Sans:antialias=false:rgba=0:pixelsize=24", NULL}},
{"-aftext", "Char in 80-char a line (Courier 12)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 12, "courier:antialias=false:rgba=0:pixelsize=12", NULL}},
- {"-rgb10text", "Char in 80-char rgb line (Charter 10)", NULL,
+ {80, 12, "Courier:antialias=false:rgba=0:pixelsize=12", NULL}},
+ {"-rgb10text", "Char in 80-char rgb line (DejaVu Sans 10)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 10, "charter:antialias=true:rgba=rgb:pixelsize=10", NULL}},
- {"-rgb24text", "Char in 30-char rgb line (Charter 24)", NULL,
+ {80, 10, "DejaVu Sans:antialias=true:rgba=rgb:pixelsize=10", NULL}},
+ {"-rgb24text", "Char in 30-char rgb line (DejaVu Sans 24)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {30, 24, "charter:antialias=true:rgba=rgb:pixelsize=24", NULL}},
+ {30, 24, "DejaVu Sans:antialias=true:rgba=rgb:pixelsize=24", NULL}},
{"-rgbftext", "Char in 80-char rgb line (Courier 12)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 12, "courier:antialias=true:rgba=rgb:pixelsize=12", NULL}},
- {"-caa10text", "Char in 80-char aa core line (Charter 10)", NULL,
+ {80, 12, "Courier:antialias=true:rgba=rgb:pixelsize=12", NULL}},
+ {"-caa10text", "Char in 80-char aa core line (DejaVu Sans 10)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 10, "charter:antialias=true:render=false:rgba=0:pixelsize=10", NULL}},
- {"-caa24text", "Char in 30-char aa core line (Charter 24)", NULL,
+ {80, 10, "DejaVu Sans:antialias=true:render=false:rgba=0:pixelsize=10", NULL}},
+ {"-caa24text", "Char in 30-char aa core line (DejaVu Sans 24)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {30, 24, "charter:antialias=true:render=false:rgba=0:pixelsize=24", NULL}},
+ {30, 24, "DejaVu Sans:antialias=true:render=false:rgba=0:pixelsize=24", NULL}},
{"-caaftext", "Char in 80-char aa core line (Courier 12)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 12, "courier:antialias=true:render=false:rgba=0:pixelsize=12", NULL}},
- {"-ca10text", "Char in 80-char a core line (Charter 10)", NULL,
+ {80, 12, "Courier:antialias=true:render=false:rgba=0:pixelsize=12", NULL}},
+ {"-ca10text", "Char in 80-char a core line (DejaVu Sans 10)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 10, "charter:antialias=false:render=false:rgba=0:pixelsize=10", NULL}},
- {"-ca24text", "Char in 30-char a core line (Charter 24)", NULL,
+ {80, 10, "DejaVu Sans:antialias=false:render=false:rgba=0:pixelsize=10", NULL}},
+ {"-ca24text", "Char in 30-char a core line (DejaVu Sans 24)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {30, 24, "charter:antialias=false:render=false:rgba=0:pixelsize=24", NULL}},
+ {30, 24, "DejaVu Sans:antialias=false:render=false:rgba=0:pixelsize=24", NULL}},
{"-caftext", "Char in 80-char a core line (Courier 12)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 12, "courier:antialias=false:render=false:rgba=0:pixelsize=12", NULL}},
- {"-crgb10text", "Char in 80-char rgb core line (Charter 10)", NULL,
+ {80, 12, "Courier:antialias=false:render=false:rgba=0:pixelsize=12", NULL}},
+ {"-crgb10text", "Char in 80-char rgb core line (DejaVu Sans 10)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 10, "charter:antialias=true:render=false:rgba=rgb:pixelsize=10", NULL}},
- {"-crgb24text", "Char in 30-char rgb core line (Charter 24)", NULL,
+ {80, 10, "DejaVu Sans:antialias=true:render=false:rgba=rgb:pixelsize=10", NULL}},
+ {"-crgb24text", "Char in 30-char rgb core line (DejaVu Sans 24)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {30, 24, "charter:antialias=true:render=false:rgba=rgb:pixelsize=24", NULL}},
+ {30, 24, "DejaVu Sans:antialias=true:render=false:rgba=rgb:pixelsize=24", NULL}},
{"-crgbftext", "Char in 80-char rgb core line (Courier 12)", NULL,
InitAAText, DoAAText, ClearTextWin, EndAAText,
V1_5FEATURE, NONROP, 0,
- {80, 12, "courier:antialias=true:render=false:rgba=rgb:pixelsize=12", NULL}},
+ {80, 12, "Courier:antialias=true:render=false:rgba=rgb:pixelsize=12", NULL}},
#endif
{"-scroll10", "Scroll 10x10 pixels", NULL,
InitScroll, DoScroll, MidScroll, EndScroll,
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,