aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_do_decoded_font_descriptions_match.c
blob: 69f7cf0c8d3f10a406c7fd754f72069228b3b6c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST


#define LIST_ALL_FIELDS(X, _)\
	X(xlfd_version) _\
	X(foundry) _\
	X(family_name) _\
	X(weight_name) _\
	X(slant) _\
	X(setwidth_name) _\
	X(add_style_name) _\
	X(pixel_size) _\
	X(point_size) _\
	X(resolution_x) _\
	X(resolution_y) _\
	X(spacing) _\
	X(average_width) _\
	X(charset_registry) _\
	X(charset_encoding) _\
	X(charset_subset)


static int
equal(const char *desc, const char *spec)
{
	size_t i;

	if (!spec)
		return !desc;
	if (spec[0] == '*' && !spec[1])
		return 1;
	if (!desc)
		return 0;

	for (; desc[i] && spec[i]; i++)
		if (spec[i] != desc[i] && spec[i] != '?')
			return 0;

	return desc[i] == spec[i];
}

int
libfonts_do_decoded_font_descriptions_match(const struct libfonts_font_description *desc,
                                            const struct libfonts_font_description *spec)
{
	if (desc->private_font_name || spec->private_font_name)
		return libfonts_do_font_descriptions_match(desc->private_font_name, spec->private_font_name);

#define X(F)\
	if (!equal(desc->F, spec->F))\
		return 0
	LIST_ALL_FIELDS(X, ;);
#undef X

	return libfonts_do_font_descriptions_match(desc->unrecognised_fields, spec->unrecognised_fields);
}


#else


int
main(void)
{
	return 0; /* XXX add test */
}


#endif