1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3 This file is part of systemd.
5 Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 * This tries opening the binary unifont glyph-array and renders some glyphs.
24 * The glyphs are then compared to hard-coded glyphs.
30 #include "unifont-def.h"
33 static void render(char *w, const unifont_glyph *g) {
35 const uint8_t *d = g->data;
37 for (j = 0; j < 16; ++j) {
38 for (i = 0; i < 8 * g->cwidth; ++i) {
39 if (d[i / 8] & (1 << (7 - i % 8)))
51 static void test_unifont(void) {
56 assert_se(unifont_new(&u) >= 0);
58 /* lookup invalid font */
59 assert_se(unifont_lookup(u, &g, 0xffffffffU) < 0);
61 /* lookup and render 'A' */
62 assert_se(unifont_lookup(u, &g, 'A') >= 0);
63 assert_se(g.width == 8);
64 assert_se(g.height == 16);
65 assert_se(g.stride >= 1);
66 assert_se(g.cwidth == 1);
67 assert_se(g.data != NULL);
69 assert_se(!strcmp(buf,
88 /* lookup and render '什' */
89 assert_se(unifont_lookup(u, &g, 0x4ec0) >= 0);
90 assert_se(g.width == 16);
91 assert_se(g.height == 16);
92 assert_se(g.stride >= 2);
93 assert_se(g.cwidth == 2);
94 assert_se(g.data != NULL);
96 assert_se(!strcmp(buf,
118 int main(int argc, char **argv) {
119 if (access(UNIFONT_PATH, F_OK))