File: fm-fontutils.c

package info (click to toggle)
font-manager 0.5.7-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 2,108 kB
  • ctags: 678
  • sloc: python: 4,741; ansic: 1,144; sh: 666; makefile: 168
file content (662 lines) | stat: -rw-r--r-- 20,631 bytes parent folder | download
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
/* fm-fontutils.c
 *
 * Font Manager, a font management application for the GNOME desktop
 *
 * Copyright (C) 2009, 2010 Jerry Casiano
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to:
 *
 *   Free Software Foundation, Inc.
 *   51 Franklin Street, Fifth Floor
 *   Boston, MA 02110-1301, USA
*/

#include <unistd.h>
#include <glib.h>
#include <glib/gprintf.h>
#include <glib/gstdio.h>

#include <pango/pangofc-fontmap.h>
#include <fontconfig/fcfreetype.h>
#include FT_SFNT_NAMES_H
#include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TABLES_H
#include FT_TYPES_H
#include FT_TYPE1_TABLES_H
#include FT_XFREE86_H

#include "fm-fontutils.h"

static int _vendor_matches(const FT_Char vendor[4], const FT_Char *vendor_id);
static void _get_base_font_info(FontInfo *fontinfo, const FT_Face face, const gchar *filepath, int index);
static void _get_ps_info(FontInfo *fontinfo, PS_FontInfoRec ps_info, FT_Face face);
static void _get_sfnt_info(FontInfo *fontinfo, FT_Face face);
static void _get_foundry_from_notice(const FT_String *notice, FontInfo *fontinfo);
static void _get_foundry_from_vendor_id(const FT_Char vendor[4], FontInfo *fontinfo);

/**
 * FcListFiles:
 *
 * Returns: a pointer to a GSList containing filepaths for installed font files
 *
 * Caller is responsible for freeing the returned list, i.e.
 *
 *      g_slist_foreach(list, (GFunc) g_free, NULL);
 *      g_slist_free(list);
 */
GSList *
FcListFiles()
{
    int         i;
    FcPattern   *pattern;
    FcFontSet   *fontset;
    FcObjectSet *objectset = 0;
    GSList      *filelist = NULL;

    g_assert(FcInit());

    pattern = FcNameParse((FcChar8 *) ":");
    objectset = FcObjectSetBuild (FC_FILE, NULL);
    fontset = FcFontList(0, pattern, objectset);

    for (i = 0; i < fontset->nfont; i++)
    {
        FcChar8         *file;

        if (FcPatternGetString(fontset->fonts[i], FC_FILE, 0, &file) == FcResultMatch)
            filelist = g_slist_prepend(filelist, g_strdup((const gchar *) file));
    }

    if (objectset)
        FcObjectSetDestroy(objectset);
    if (pattern)
        FcPatternDestroy(pattern);
    if (fontset)
        FcFontSetDestroy(fontset);

    return filelist;
}

/**
 * FcListUserDirs:
 *
 * Returns: a pointer to a GSList containing filepaths for user font directories
 *
 * Caller is responsible for freeing the returned list, i.e.
 *
 *      g_slist_foreach(list, (GFunc) g_free, NULL);
 *      g_slist_free(list);
 */
GSList *
FcListUserDirs()
{
    FcChar8     *directory;
    FcStrList   *fdlist;
    GSList      *dirlist = NULL;

    g_assert(FcInit());

    fdlist = FcConfigGetFontDirs(NULL);
    while ((directory = FcStrListNext(fdlist)))
    {
        if (g_access((const gchar *) directory, W_OK) == 0)
            dirlist = g_slist_prepend(dirlist, directory);
    }

    FcStrListDone(fdlist);

    return dirlist;
}

/**
 * FT_Get_Face_Count:
 *
 * @filepath:   Filepath to a font file.
 *
 * Returns:     The number of faces contained in the font file.
 */
FT_Long
FT_Get_Face_Count(const char *filepath)
{
    FT_Face         face;
    FT_Library      library;
    FT_Error        error;
    FT_Long         num_faces;

    error = FT_Init_FreeType(&library);
    if (error)
    {
        /* Index 0 is always valid */
        return 1;
    }

    error = FT_New_Face(library, filepath, 0, &face);
    if (error)
    {
        FT_Done_FreeType(library);
        return 1;
    }

    num_faces = face->num_faces;
    FT_Done_Face(face);
    FT_Done_FreeType(library);

    return num_faces;
}

#define ADD_PROP(prop, val)                                                    \
    {                                                                          \
        if (val)                                                               \
        {                                                                      \
            g_free_and_nullify(prop);                                          \
            prop = g_strdup(val);                                              \
        }                                                                      \
    }                                                                          \

/**
 * FT_Get_Font_Info:
 *
 * @fontinfo:   A FontInfo structure to store information in.
 * @filepath:   The filepath of the font to examine
 * @index:      The face within the file to examine. 0 is always valid.
 *
 * Returns:     FreeType2 error code
 */
FT_Error
FT_Get_Font_Info(FontInfo *fontinfo, const char *filepath, int index)
{
    FT_Face         face;
    FT_Library      library;
    FT_Error        error;
    TT_OS2          *os2;
    PS_FontInfoRec  ps_info;

    gsize           filesize = 0;
    gchar           *font       = NULL,
                    *checksum   = NULL;

    if (G_UNLIKELY(!g_file_get_contents(filepath, &font, &filesize, NULL)))
    {
        error = FT_Err_Cannot_Open_Resource;
        return error;
    }

    error = FT_Init_FreeType(&library);
    if (G_UNLIKELY(error))
        return error;

    error = FT_New_Memory_Face(library,
                                (const FT_Byte *) font,
                                (FT_Long) filesize, index, &face);
    if (G_UNLIKELY(error))
        return error;

    ADD_PROP(fontinfo->filepath, filepath);

    if (g_access((const gchar *) filepath, W_OK) == 0)
        ADD_PROP(fontinfo->owner, "User");

    if (G_UNLIKELY(index != 0))
    {
        g_free_and_nullify(fontinfo->face);
        fontinfo->face = g_strdup_printf("%i", index);
    }

    g_free_and_nullify(fontinfo->filesize);
    /* fontinfo->filesize = g_strdup_printf("%zu", (size_t) filesize); */
    fontinfo->filesize = g_format_size_for_display(filesize);
    g_free_and_nullify(checksum);
    checksum = g_compute_checksum_for_data(G_CHECKSUM_MD5,
                                            (const guchar *) font, filesize);
    ADD_PROP(fontinfo->checksum, checksum);
    g_free_and_nullify(checksum);

    _get_base_font_info(fontinfo, face, filepath, index);

    if (G_LIKELY(FT_IS_SFNT(face)))
    {
        _get_sfnt_info(fontinfo, face);
    }
    else if (FT_Get_PS_Font_Info(face, &ps_info) == 0)
    {
        _get_ps_info(fontinfo, ps_info, face);
    }

    if (G_LIKELY(FT_Get_X11_Font_Format(face) != NULL))
    {
        ADD_PROP(fontinfo->filetype, FT_Get_X11_Font_Format(face));
    }

    if (G_LIKELY(FT_Get_Postscript_Name(face) != NULL))
    {
        ADD_PROP(fontinfo->psname, FT_Get_Postscript_Name(face));
    }

    os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
    if (G_LIKELY(os2 && os2->version >= 0x0001 && os2->version != 0xffff))
    {
        _get_foundry_from_vendor_id(os2->achVendID, fontinfo);
        g_free_and_nullify(fontinfo->panose);
        fontinfo->panose = g_strdup_printf("%i:%i:%i:%i:%i:%i:%i:%i:%i:%i",
                                os2->panose[0], os2->panose[1], os2->panose[2],
                                os2->panose[3], os2->panose[4], os2->panose[5],
                                os2->panose[6], os2->panose[7], os2->panose[8],
                                os2->panose[9]);
    }

    FT_Done_Face(face);
    FT_Done_FreeType(library);
    g_free_and_nullify(font);

    return error;
}

static void
_get_base_font_info(FontInfo *fontinfo, const FT_Face face,
                        const gchar *filepath, int index)
{
    int                     i;
    FcBlanks                *blanks;
    FcPattern               *pattern;
    FcFontSet               *fontset;
    FcObjectSet             *os;
    PangoFontDescription    *descr;

    /* Need to add this font to the configuration, it may not be there in the
     * case where this font is not installed yet or possibly just installed
     */
    FcConfigAppFontAddFile(FcConfigGetCurrent(), filepath);

    blanks = FcBlanksCreate();
    os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, NULL);
    pattern = FcFreeTypeQueryFace(face, (const FcChar8 *) fontinfo->filepath,
                                                                index, blanks);
    fontset = FcFontList (NULL, pattern, os);

    for (i = 0; i < fontset->nfont; i++)
    {
        FcChar8         *family,
                        *style;

        if (FcPatternGetString(fontset->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch)
            ADD_PROP(fontinfo->family, family);
        if (FcPatternGetString(fontset->fonts[i], FC_STYLE, 0, &style) == FcResultMatch)
            ADD_PROP(fontinfo->style, style);
    }

    descr = pango_fc_font_description_from_pattern(pattern, FALSE);
    ADD_PROP(fontinfo->pdescr, pango_font_description_to_string(descr));
    ADD_PROP(fontinfo->pfamily, (char *) pango_font_description_get_family(descr));

    switch(pango_font_description_get_style(descr))
    {
        case PANGO_STYLE_NORMAL:
            ADD_PROP(fontinfo->pstyle, "Roman");
            break;
        case PANGO_STYLE_OBLIQUE:
            ADD_PROP(fontinfo->pstyle, "Oblique");
            break;
        case PANGO_STYLE_ITALIC:
            ADD_PROP(fontinfo->pstyle, "Italic");
            break;
        default:
            break;
    }

    switch(pango_font_description_get_variant(descr))
    {
        case PANGO_VARIANT_NORMAL:
            ADD_PROP(fontinfo->pvariant, "Normal");
            break;
        case PANGO_VARIANT_SMALL_CAPS:
            ADD_PROP(fontinfo->pvariant, "Small Caps");
            break;
        default:
            break;
    }

    switch(pango_font_description_get_weight(descr))
    {
        case PANGO_WEIGHT_THIN:
            ADD_PROP(fontinfo->pweight, "Thin");
            break;
        case PANGO_WEIGHT_ULTRALIGHT:
            ADD_PROP(fontinfo->pweight, "Ultra-Light");
            break;
        case PANGO_WEIGHT_LIGHT:
            ADD_PROP(fontinfo->pweight, "Light");
            break;
        case PANGO_WEIGHT_BOOK:
            ADD_PROP(fontinfo->pweight, "Book");
            break;
        case PANGO_WEIGHT_NORMAL:
            ADD_PROP(fontinfo->pweight, "Regular");
            break;
        case PANGO_WEIGHT_MEDIUM:
            ADD_PROP(fontinfo->pweight, "Medium");
            break;
        case PANGO_WEIGHT_SEMIBOLD:
            ADD_PROP(fontinfo->pweight, "Semi-Bold");
            break;
        case PANGO_WEIGHT_BOLD:
            ADD_PROP(fontinfo->pweight, "Bold");
            break;
        case PANGO_WEIGHT_ULTRABOLD:
            ADD_PROP(fontinfo->pweight, "Ultra-Bold");
            break;
        case PANGO_WEIGHT_HEAVY:
            ADD_PROP(fontinfo->pweight, "Heavy");
            break;
        case PANGO_WEIGHT_ULTRAHEAVY:
            ADD_PROP(fontinfo->pweight, "Ultra-Heavy");
            break;
        default:
            break;
    }

    switch(pango_font_description_get_stretch(descr))
    {
        case PANGO_STRETCH_ULTRA_CONDENSED:
            ADD_PROP(fontinfo->pstretch, "Ultra-Condensed");
            break;
        case PANGO_STRETCH_EXTRA_CONDENSED:
            ADD_PROP(fontinfo->pstretch, "Extra-Condensed");
            break;
        case PANGO_STRETCH_CONDENSED:
            ADD_PROP(fontinfo->pstretch, "Condensed");
            break;
        case PANGO_STRETCH_SEMI_CONDENSED:
            ADD_PROP(fontinfo->pstretch, "Semi-Condensed");
            break;
        case PANGO_STRETCH_NORMAL:
            ADD_PROP(fontinfo->pstretch, "Normal");
            break;
        case PANGO_STRETCH_SEMI_EXPANDED:
            ADD_PROP(fontinfo->pstretch, "Semi-Expanded");
            break;
        case PANGO_STRETCH_EXPANDED:
            ADD_PROP(fontinfo->pstretch, "Expanded");
            break;
        case PANGO_STRETCH_EXTRA_EXPANDED:
            ADD_PROP(fontinfo->pstretch, "Extra-Expanded");
            break;
        case PANGO_STRETCH_ULTRA_EXPANDED:
            ADD_PROP(fontinfo->pstretch, "Ultra-Expanded");
            break;
        default:
            break;
    }

    pango_font_description_free(descr);

    if (os)
        FcObjectSetDestroy(os);
    if (blanks)
        FcBlanksDestroy(blanks);
    if (pattern)
        FcPatternDestroy(pattern);
    if (fontset)
        FcFontSetDestroy(fontset);
}

#define ADD_PS_PROP(prop, val)                                                 \
    {                                                                          \
        if (val && g_utf8_validate(val, -1, NULL))                            \
            {                                                                  \
                g_free_and_nullify(prop);                                      \
                prop = g_strdup(val);                                          \
            }                                                                  \
    }                                                                          \

/* These two are mostly lifted from fontilus by James Henstridge. Thanks. :-) */
static void
_get_ps_info(FontInfo *fontinfo, PS_FontInfoRec ps_info, const FT_Face face)
{
    ADD_PS_PROP(fontinfo->family, ps_info.family_name);
    ADD_PS_PROP(fontinfo->style, ps_info.weight);
    ADD_PS_PROP(fontinfo->version, ps_info.version);

    if (ps_info.notice && g_utf8_validate(ps_info.notice, -1, NULL))
    {
        ADD_PS_PROP(fontinfo->copyright, ps_info.notice);
        _get_foundry_from_notice(ps_info.notice, fontinfo);
    }
}

#define ADD_SFNT_PROP(prop, val)                                               \
    {                                                                          \
        if (val)                                                               \
        {                                                                      \
            g_free_and_nullify(prop);                                          \
            prop = g_strdup(val);                                              \
            g_free_and_nullify(val);                                           \
        }                                                                      \
    }                                                                          \

#define G_CONVERT_8_2_16BE(sname)                                              \
        g_convert((const gchar *) sname.string,                               \
                sname.string_len, "UTF-8", "UTF-16BE", NULL, NULL, NULL)     \

static void
_get_sfnt_info(FontInfo *fontinfo, const FT_Face face)
{
    gint    index,
            namecount = FT_Get_Sfnt_Name_Count(face);
    gchar   *version = NULL,
            *copyright = NULL,
            *description = NULL,
            *license = NULL,
            *license_url = NULL,
            *foundry = NULL;

    for (index=0; index < namecount; index++)
    {
        FT_SfntName sname;

        if (FT_Get_Sfnt_Name(face, index, &sname) != 0)
            continue;

        /* Only handle the unicode names for US langid */
        if (!(sname.platform_id == TT_PLATFORM_MICROSOFT &&
                sname.encoding_id == TT_MS_ID_UNICODE_CS &&
                sname.language_id == TT_MS_LANGID_ENGLISH_UNITED_STATES))
            continue;

        switch (sname.name_id)
        {
            case TT_NAME_ID_COPYRIGHT:
                g_free_and_nullify(copyright);
                copyright = G_CONVERT_8_2_16BE(sname);
                break;
            case TT_NAME_ID_VERSION_STRING:
                g_free_and_nullify(version);
                version = G_CONVERT_8_2_16BE(sname);
                break;
            case TT_NAME_ID_DESCRIPTION:
                g_free_and_nullify(description);
                description = G_CONVERT_8_2_16BE(sname);
                break;
            case TT_NAME_ID_LICENSE:
                g_free_and_nullify(license);
                license = G_CONVERT_8_2_16BE(sname);
                break;
            case TT_NAME_ID_LICENSE_URL:
                g_free_and_nullify(license_url);
                license_url = G_CONVERT_8_2_16BE(sname);
                break;
            case TT_NAME_ID_MANUFACTURER:
                g_free_and_nullify(foundry);
                foundry = G_CONVERT_8_2_16BE(sname);
                break;
            default:
                break;
        }
    }

    ADD_SFNT_PROP(fontinfo->version, version);
    ADD_SFNT_PROP(fontinfo->copyright, copyright);
    ADD_SFNT_PROP(fontinfo->description, description);
    ADD_SFNT_PROP(fontinfo->license, license);
    ADD_SFNT_PROP(fontinfo->license_url, license_url);

    if (foundry)
    {
        if(g_strcmp0(foundry, "Unknown") == 0)
            _get_foundry_from_notice(foundry, fontinfo);

        if (g_strcmp0(fontinfo->foundry, "Unknown") == 0
                            && (int) strlen(foundry) < 50)
        {
            g_free_and_nullify(fontinfo->foundry);
            fontinfo->foundry = g_strstrip(g_strdup(foundry));
        }

        g_free_and_nullify(foundry);
    }
}

/*
 * Vendor/Notice data sourced from fcfreetype.c, ttmkfdir by Joerg Pommnitz and
 * of course http://developer.apple.com/fonts/TTRefMan/RM06/Chap6OS2.html
 */

/*
 * Order is significant for NoticeData.
 */
static const struct
{
    const char vendor[45];
    const char foundry[20];
}
NoticeData[] =
{
    {"Bigelow", "Bigelow & Holmes"},
    {"Adobe", "Adobe"},
    {"Bitstream", "Bitstream"},
    {"Monotype", "Monotype"},
    {"Linotype", "Linotype"},
    {"LINOTYPE-HELL", "Linotype"},
    {"IBM", "IBM"},
    {"URW", "URW"},
    {"International Typeface Corporation", "ITC"},
    {"Tiro Typeworks", "Tiro"},
    {"XFree86", "XFree86"},
    {"Microsoft", "Microsoft"},
    {"Omega", "Omega"},
    {"Font21", "Hwan"},
    {"HanYang System", "HanYang"}
};

static const struct
{
    const FT_Char   vendor[5];
    const char      foundry[50];
}
VendorData[] =
{
    {"ACG ", "AGFA Compugraphic"},
    {"ADBE", "Adobe"},
    {"AGFA", "AGFA Compugraphic"},
    {"ALTS", "Altsys"},
    {"APPL", "Apple"},
    {"ARPH", "Arphic"},
    {"ATEC", "Alltype"},
    {"BERT", "Berthold"},
    {"B&H ", "Bigelow & Holmes"},
    {"B?  ", "Bigelow & Holmes"},
    {"BITS", "Bitstream"},
    {"CANO", "Cannon"},
    {"DTC ", "Digital Typeface Corp."},
    {"DYNA", "Dynalab"},
    {"EPSN", "Epson"},
    {"FJ  ", "Fujitsu"},
    {"HP  ", "Hewlett-Packard"},
    {"IBM ", "IBM"},
    {"ITC ", "ITC"},
    {"IMPR", "Impress"},
    {"KATF", "Kingsley/ATF"},
    {"LANS", "Lanston Type Co., Ltd."},
    {"LARA", "Larabie Fonts"},
    {"LEAF", "Interleaf"},
    {"LETR", "Letraset"},
    {"LINO", "Linotype"},
    {"MACR", "Macromedia"},
    {"MONO", "Monotype"},
    {"MS  ", "Microsoft"},
    {"MT  ", "Monotype"},
    {"NEC ", "NEC"},
    {"PARA", "Paratype"},
    {"QMSI", "QMS/Imagen"},
    {"RICO", "Ricoh"},
    {"URW ", "URW"},
    {"Y&Y ", "Y&Y"},
    {"ZSFT", "ZSoft"}
};

#define STRUCT_LEN(s) (int) (sizeof (s) / sizeof (s[0]))
#define NOTICE_ENTRIES STRUCT_LEN(NoticeData)
#define VENDOR_ENTRIES STRUCT_LEN(VendorData)

static gboolean
_vendor_matches(const FT_Char vendor[4], const FT_Char *vendor_id)
{
    gboolean    result;
    GString     *a, *b;

    /* vendor is not necessarily NUL-terminated. */
    a = g_string_new_len((const gchar *) vendor, 4);
    b = g_string_new_len((const gchar *) vendor_id, 4);
    result = g_string_equal(a, b);
    g_string_free(a, TRUE);
    g_string_free(b, TRUE);

    return result;
}

static void
_get_foundry_from_notice(const FT_String *notice, FontInfo *fontinfo)
{
    int     i;

    if (notice)
    {
        for(i = 0; i < NOTICE_ENTRIES; i++)
        {
            if (g_strrstr((const char *) notice, NoticeData[i].vendor))
            {
                g_free_and_nullify(fontinfo->foundry);
                fontinfo->foundry = g_strdup(NoticeData[i].foundry);
                break;
            }
        }
    }
}

static void
_get_foundry_from_vendor_id(const FT_Char vendor[4], FontInfo *fontinfo)
{
    int     i;

    if (vendor)
    {
        for(i = 0; i < VENDOR_ENTRIES; i++)
        {
            if (_vendor_matches(vendor, VendorData[i].vendor))
            {
                g_free_and_nullify(fontinfo->foundry);
                fontinfo->foundry = g_strdup(VendorData[i].foundry);
                break;
            }
        }
    }
}