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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
#include <config.h>
#include "test.h"
#include <libnautilus-extensions/nautilus-font-manager.h>
static const char *
font_type_to_string (NautilusFontType font_type)
{
if (font_type == NAUTILUS_FONT_POSTSCRIPT) {
return "postscript";
}
return "truetype";
}
// microsoft Webdings
// microsoft Wingdings
// monotype OCR
// URW Zapf
// xfree86 cursor
typedef struct
{
char *key;
char *font_file_name;
} Style;
typedef struct
{
char *title;
char *foundry;
char *family;
char *key;
GList *style_list;
} Entry;
static gboolean
font_iterator_callback (const char *font_file_name,
NautilusFontType font_type,
const char *foundry,
const char *family,
const char *weight,
const char *slant,
const char *set_width,
const char *char_set_registry,
const char *char_set_encoding,
gpointer callback_data)
{
char *key;
Entry *entry;
Style *style;
GHashTable *font_table;
g_return_val_if_fail (font_file_name != NULL, FALSE);
g_return_val_if_fail (foundry != NULL, FALSE);
g_return_val_if_fail (family != NULL, FALSE);
g_return_val_if_fail (weight != NULL, FALSE);
g_return_val_if_fail (slant != NULL, FALSE);
g_return_val_if_fail (set_width != NULL, FALSE);
g_return_val_if_fail (char_set_registry != NULL, FALSE);
g_return_val_if_fail (char_set_encoding != NULL, FALSE);
g_return_val_if_fail (callback_data != NULL, FALSE);
font_table = callback_data;
key = g_strdup_printf ("%s %s", foundry, family);
entry = g_hash_table_lookup (font_table, key);
if (entry == NULL) {
entry = g_new0 (Entry, 1);
entry->key = g_strdup (key);
entry->foundry = g_strdup (foundry);
entry->family = g_strdup (family);
g_hash_table_insert (font_table, entry->key, entry);
}
g_assert (entry != NULL);
g_assert (g_hash_table_lookup (font_table, key) == entry);
g_free (key);
style = g_new0 (Style, 1);
style->key = g_strdup_printf ("%s %s %s", weight, slant, set_width);
style->font_file_name = g_strdup (font_file_name);
entry->style_list = g_list_append (entry->style_list, style);
if (1) {
g_print ("%s %s %s-%s-%s-%s-%s-%s-%s\n",
font_type_to_string (font_type),
font_file_name,
foundry,
family,
weight,
slant,
set_width,
char_set_registry,
char_set_encoding);
}
return TRUE;
}
static void
font_table_for_each_callback (gpointer key,
gpointer value,
gpointer callback_data)
{
char *entry_key;
g_return_if_fail (key != NULL);
g_return_if_fail (value != NULL);
//g_return_if_fail (callback_data != NULL);
entry_key = key;
if (0) g_print ("%s\n", entry_key);
}
int
main (int argc, char* argv[])
{
GHashTable *font_table = NULL;
test_init (&argc, &argv);
font_table = g_hash_table_new (g_str_hash, g_str_equal);
nautilus_font_manager_for_each_font (font_iterator_callback, font_table);
g_hash_table_foreach (font_table, font_table_for_each_callback, NULL);
return test_quit (EXIT_SUCCESS);
}
|