Skip to content

Commit

Permalink
Set font in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bynect committed Jan 1, 2025
1 parent b7abe8f commit 9a267f2
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 4 deletions.
98 changes: 98 additions & 0 deletions test/data/fonts/DejaVuSansMono.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)


Bitstream Vera Fonts Copyright
------------------------------

Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:

The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.

The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".

This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.

The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.

Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.

Arev Fonts Copyright
------------------------------

Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:

The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.

The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".

This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.

The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.
Binary file added test/data/fonts/DejaVuSansMono.ttf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/data/fonts/fonts.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir prefix="cwd">test/data/fonts</dir>
<cachedir prefix="cwd">test/data/fonts</cachedir>
<config></config>
</fontconfig>
13 changes: 10 additions & 3 deletions test/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ struct length get_small_max_height(void)
// by notification content
// future tests targeting dynamic sizing logic could be added
// to address this limitation
struct length height = { 0, 10 };
return height;
struct length height = { 0, 10 };
return height;
}

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

extern PangoFontDescription *pango_fdesc; // HACK
pango_fdesc = pango_font_description_from_string(settings.font);

SHUFFLE_TESTS(time(NULL), {
RUN_TEST(test_layout_from_notification);
RUN_TEST(test_layout_from_notification_icon_off);
Expand All @@ -392,4 +395,8 @@ SUITE(suite_draw)
RUN_TEST(test_layout_render_no_gaps);
RUN_TEST(test_layout_render_gaps);
});

pango_font_description_free(pango_fdesc);
cairo_destroy(c);
cairo_surface_destroy(s);
}
11 changes: 10 additions & 1 deletion test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
#include <stdlib.h>

#include "../src/log.h"
#include "../src/utils.h"
#include "../src/settings.h"
#include "helpers.h"

const char *base;
char *base;

SUITE_EXTERN(suite_settings_data);
SUITE_EXTERN(suite_utils);
Expand Down Expand Up @@ -42,6 +43,11 @@ int main(int argc, char *argv[]) {
bool printlog = log && atoi(log) ? true : false;
dunst_log_init(!printlog);

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

// initialize settings
char **configs = g_malloc0(2 * sizeof(char *));
Expand Down Expand Up @@ -70,6 +76,9 @@ int main(int argc, char *argv[]) {
settings_free(&settings);
g_strfreev(configs);

g_free(fontsconf);
g_free(base);

// this returns the error code
GREATEST_MAIN_END();
}
Expand Down

0 comments on commit 9a267f2

Please sign in to comment.