Skip to content

Commit 328e9f8

Browse files
committed
Set font in tests
1 parent b7abe8f commit 328e9f8

File tree

5 files changed

+126
-5
lines changed

5 files changed

+126
-5
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
2+
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
3+
4+
5+
Bitstream Vera Fonts Copyright
6+
------------------------------
7+
8+
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
9+
a trademark of Bitstream, Inc.
10+
11+
Permission is hereby granted, free of charge, to any person obtaining a copy
12+
of the fonts accompanying this license ("Fonts") and associated
13+
documentation files (the "Font Software"), to reproduce and distribute the
14+
Font Software, including without limitation the rights to use, copy, merge,
15+
publish, distribute, and/or sell copies of the Font Software, and to permit
16+
persons to whom the Font Software is furnished to do so, subject to the
17+
following conditions:
18+
19+
The above copyright and trademark notices and this permission notice shall
20+
be included in all copies of one or more of the Font Software typefaces.
21+
22+
The Font Software may be modified, altered, or added to, and in particular
23+
the designs of glyphs or characters in the Fonts may be modified and
24+
additional glyphs or characters may be added to the Fonts, only if the fonts
25+
are renamed to names not containing either the words "Bitstream" or the word
26+
"Vera".
27+
28+
This License becomes null and void to the extent applicable to Fonts or Font
29+
Software that has been modified and is distributed under the "Bitstream
30+
Vera" names.
31+
32+
The Font Software may be sold as part of a larger software package but no
33+
copy of one or more of the Font Software typefaces may be sold by itself.
34+
35+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
36+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
37+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
38+
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
39+
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
40+
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
41+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
42+
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
43+
FONT SOFTWARE.
44+
45+
Except as contained in this notice, the names of Gnome, the Gnome
46+
Foundation, and Bitstream Inc., shall not be used in advertising or
47+
otherwise to promote the sale, use or other dealings in this Font Software
48+
without prior written authorization from the Gnome Foundation or Bitstream
49+
Inc., respectively. For further information, contact: fonts at gnome dot
50+
org.
51+
52+
Arev Fonts Copyright
53+
------------------------------
54+
55+
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
56+
57+
Permission is hereby granted, free of charge, to any person obtaining
58+
a copy of the fonts accompanying this license ("Fonts") and
59+
associated documentation files (the "Font Software"), to reproduce
60+
and distribute the modifications to the Bitstream Vera Font Software,
61+
including without limitation the rights to use, copy, merge, publish,
62+
distribute, and/or sell copies of the Font Software, and to permit
63+
persons to whom the Font Software is furnished to do so, subject to
64+
the following conditions:
65+
66+
The above copyright and trademark notices and this permission notice
67+
shall be included in all copies of one or more of the Font Software
68+
typefaces.
69+
70+
The Font Software may be modified, altered, or added to, and in
71+
particular the designs of glyphs or characters in the Fonts may be
72+
modified and additional glyphs or characters may be added to the
73+
Fonts, only if the fonts are renamed to names not containing either
74+
the words "Tavmjong Bah" or the word "Arev".
75+
76+
This License becomes null and void to the extent applicable to Fonts
77+
or Font Software that has been modified and is distributed under the
78+
"Tavmjong Bah Arev" names.
79+
80+
The Font Software may be sold as part of a larger software package but
81+
no copy of one or more of the Font Software typefaces may be sold by
82+
itself.
83+
84+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
88+
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92+
OTHER DEALINGS IN THE FONT SOFTWARE.
93+
94+
Except as contained in this notice, the name of Tavmjong Bah shall not
95+
be used in advertising or otherwise to promote the sale, use or other
96+
dealings in this Font Software without prior written authorization
97+
from Tavmjong Bah. For further information, contact: tavmjong @ free
98+
. fr.

test/data/fonts/DejaVuSansMono.ttf

327 KB
Binary file not shown.

test/data/fonts/fonts.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
3+
<fontconfig>
4+
<dir prefix="cwd">test/data/fonts</dir>
5+
<cachedir prefix="cwd">test/data/fonts</cachedir>
6+
<config></config>
7+
</fontconfig>

test/draw.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ struct length get_small_max_height(void)
7777
// by notification content
7878
// future tests targeting dynamic sizing logic could be added
7979
// to address this limitation
80-
struct length height = { 0, 10 };
81-
return height;
80+
struct length height = { 0, 10 };
81+
return height;
8282
}
8383

8484
int get_expected_dimension_height(int layout_count, int height)
@@ -293,7 +293,7 @@ TEST test_calculate_dimensions_height_min(void)
293293
{
294294
struct length original_height = settings.height;
295295
bool orginal_gap_size = settings.gap_size;
296-
// NOTE: Should be big enough to fit the notification nicely
296+
// NOTE: Should be big enough to fit the notification nicely
297297
settings.height.min = 100;
298298
settings.height.max = 200;
299299
settings.gap_size = 0;
@@ -382,6 +382,9 @@ SUITE(suite_draw)
382382
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
383383
c = cairo_create(s);
384384

385+
extern PangoFontDescription *pango_fdesc; // HACK
386+
pango_fdesc = pango_font_description_from_string(settings.font);
387+
385388
SHUFFLE_TESTS(time(NULL), {
386389
RUN_TEST(test_layout_from_notification);
387390
RUN_TEST(test_layout_from_notification_icon_off);
@@ -392,4 +395,8 @@ SUITE(suite_draw)
392395
RUN_TEST(test_layout_render_no_gaps);
393396
RUN_TEST(test_layout_render_gaps);
394397
});
398+
399+
pango_font_description_free(pango_fdesc);
400+
cairo_destroy(c);
401+
cairo_surface_destroy(s);
395402
}

test/test.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
#include <stdlib.h>
77

88
#include "../src/log.h"
9+
#include "../src/utils.h"
910
#include "../src/settings.h"
1011
#include "helpers.h"
1112

12-
const char *base;
13+
char *base;
1314

1415
SUITE_EXTERN(suite_settings_data);
1516
SUITE_EXTERN(suite_utils);
@@ -33,7 +34,7 @@ SUITE_EXTERN(suite_input);
3334
GREATEST_MAIN_DEFS();
3435

3536
int main(int argc, char *argv[]) {
36-
base = getenv("TESTDIR");
37+
base = g_strdup(getenv("TESTDIR"));
3738
base = realpath(base ? base : "./test", NULL);
3839

3940
/* By default do not print out warning messages, when executing tests.
@@ -42,6 +43,11 @@ int main(int argc, char *argv[]) {
4243
bool printlog = log && atoi(log) ? true : false;
4344
dunst_log_init(!printlog);
4445

46+
// Initialize fonts
47+
// NOTE: This was added for a pango/fontconfig problem that
48+
// causes bogus values when no font is found
49+
char *fontsconf = g_strconcat(base, "/data/fonts", NULL);
50+
safe_setenv("FONTCONFIG_PATH", fontsconf);
4551

4652
// initialize settings
4753
char **configs = g_malloc0(2 * sizeof(char *));
@@ -70,6 +76,9 @@ int main(int argc, char *argv[]) {
7076
settings_free(&settings);
7177
g_strfreev(configs);
7278

79+
g_free(fontsconf);
80+
g_free(base);
81+
7382
// this returns the error code
7483
GREATEST_MAIN_END();
7584
}

0 commit comments

Comments
 (0)