~ubuntu-branches/ubuntu/natty/luatex/natty

« back to all changes in this revision

Viewing changes to source/texk/web2c/luatexdir/font/mapfile.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2009-12-25 09:47:05 UTC
  • mfrom: (1.1.9 upstream) (4.2.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091225094705-y33rpflo8t4u9nag
Tags: 0.50.0-1
* new upstream release
* disable fix-hurd-ftbfs patch, included upstream
* disable upstram-fixes, included upstream
* disable ubuntu_libpoppler-0.11, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* mapfile.c
2
 
   
 
2
 
3
3
   Copyright 1996-2006 Han The Thanh <thanh@pdftex.org>
4
 
   Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
 
4
   Copyright 2006-2009 Taco Hoekwater <taco@luatex.org>
5
5
 
6
6
   This file is part of LuaTeX.
7
7
 
18
18
   You should have received a copy of the GNU General Public License along
19
19
   with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
20
20
 
 
21
static const char _svn_version[] =
 
22
    "$Id: mapfile.c 3282 2009-12-21 21:55:47Z hhenkel $ "
 
23
    "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.50.0/source/texk/web2c/luatexdir/font/mapfile.c $";
 
24
 
21
25
#include <math.h>
22
26
#include "ptexlib.h"
23
27
#include <kpathsea/c-auto.h>
24
28
#include <kpathsea/c-memstr.h>
25
29
#include <string.h>
26
 
#include "luatex-api.h"
27
 
 
28
 
static const char _svn_version[] =
29
 
    "$Id: mapfile.c 2331 2009-04-18 16:39:50Z hhenkel $ "
30
 
    "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/font/mapfile.c $";
31
30
 
32
31
#define FM_BUF_SIZE     1024
33
32
 
34
33
static FILE *fm_file;
35
34
 
36
35
static unsigned char *fm_buffer = NULL;
37
 
static integer fm_size = 0;
38
 
static integer fm_curbyte = 0;
 
36
static int fm_size = 0;
 
37
static int fm_curbyte = 0;
39
38
 
40
 
#define fm_open()       \
41
 
    (fm_file = fopen((char *) nameoffile + 1, FOPEN_RBIN_MODE))
 
39
#define fm_open(a)       \
 
40
    (fm_file = fopen((char *)(a), FOPEN_RBIN_MODE))
42
41
#define fm_read_file()  \
43
42
    readbinfile(fm_file,&fm_buffer,&fm_size)
44
43
#define fm_close()      xfclose(fm_file, cur_file_name)
48
47
    (c == 10 || c == '*' || c == '#' || c == ';' || c == '%')
49
48
 
50
49
typedef enum { FM_DUPIGNORE, FM_REPLACE, FM_DELETE } updatemode;
51
 
typedef enum { MAPFILE, MAPLINE } maptype;
52
50
 
53
51
typedef struct mitem {
54
52
    updatemode mode;            /* FM_DUPIGNORE or FM_REPLACE or FM_DELETE */
87
85
    fm->encname = NULL;
88
86
    fm->type = 0;
89
87
    fm->slant = 0;
90
 
    fm->extend = 0;
 
88
    fm->extend = 1000;
91
89
    fm->links = 0;
92
90
    fm->pid = -1;
93
91
    fm->eid = -1;
94
92
    fm->subfont = NULL;
95
 
    fm->in_use = false;
 
93
    unset_slantset(fm);
 
94
    unset_extendset(fm);
 
95
    unset_inuse(fm);
96
96
    return fm;
97
97
}
98
98
 
121
121
    xfree(ff);
122
122
}
123
123
 
124
 
static fm_entry *dummy_fm_entry()
 
124
static fm_entry *dummy_fm_entry(void)
125
125
{
126
126
    static const fm_entry const_fm_entry;
127
127
    return (fm_entry *) & const_fm_entry;
130
130
/**********************************************************************/
131
131
 
132
132
struct avl_table *tfm_tree = NULL;
133
 
struct avl_table *ps_tree = NULL;
134
133
struct avl_table *ff_tree = NULL;
135
134
struct avl_table *encname_tree = NULL;
136
135
 
143
142
                  ((const fm_entry *) pb)->tfm_name);
144
143
}
145
144
 
146
 
/* AVL sort fm_entry into ps_tree by ps_name, slant, and extend */
147
 
 
148
 
static int comp_fm_entry_ps(const void *pa, const void *pb, void *p)
149
 
{
150
 
    int i;
151
 
    const fm_entry *p1 = (const fm_entry *) pa, *p2 = (const fm_entry *) pb;
152
 
    (void) p;
153
 
    assert(p1->ps_name != NULL && p2->ps_name != NULL);
154
 
    if ((i = strcmp(p1->ps_name, p2->ps_name)))
155
 
        return i;
156
 
    cmp_return(p1->slant, p2->slant);
157
 
    cmp_return(p1->extend, p2->extend);
158
 
    return 0;
159
 
}
160
 
 
161
145
/* AVL sort ff_entry into ff_tree by ff_name */
162
146
 
163
147
static int comp_ff_entry(const void *pa, const void *pb, void *p)
167
151
                  ((const ff_entry *) pb)->ff_name);
168
152
}
169
153
 
170
 
static void create_avl_trees()
 
154
static void create_avl_trees(void)
171
155
{
172
156
    assert(tfm_tree == NULL);
173
157
    tfm_tree = avl_create(comp_fm_entry_tfm, NULL, &avl_xallocator);
174
158
    assert(tfm_tree != NULL);
175
 
    assert(ps_tree == NULL);
176
 
    ps_tree = avl_create(comp_fm_entry_ps, NULL, &avl_xallocator);
177
 
    assert(ps_tree != NULL);
178
159
    assert(ff_tree == NULL);
179
160
    ff_tree = avl_create(comp_ff_entry, NULL, &avl_xallocator);
180
161
    assert(ff_tree != NULL);
183
164
    assert(encname_tree != NULL);
184
165
}
185
166
 
186
 
/*
187
 
The function avl_do_entry() is not completely symmetrical with regards
188
 
to tfm_name and ps_name handling, e. g. a duplicate tfm_name gives a
189
 
"goto exit", and no ps_name link is tried. This is to keep it compatible
190
 
with the original version.
191
 
*/
192
 
 
193
167
int avl_do_entry(fm_entry * fm, int mode)
194
168
{
195
169
    fm_entry *p;
196
170
    void *a;
197
171
    void **aa;
198
 
 
199
 
    /* handle tfm_name link */
200
 
 
201
172
    if (strcmp(fm->tfm_name, nontfm)) {
202
173
        p = (fm_entry *) avl_find(tfm_tree, fm);
203
174
        if (p != NULL) {
210
181
                break;
211
182
            case FM_REPLACE:
212
183
            case FM_DELETE:
213
 
                if (p->in_use) {
 
184
                if (is_inuse(p)) {
214
185
                    pdftex_warn
215
186
                        ("fontmap entry for `%s' has been used, replace/delete not allowed",
216
187
                         fm->tfm_name);
219
190
                a = avl_delete(tfm_tree, p);
220
191
                assert(a != NULL);
221
192
                unset_tfmlink(p);
222
 
                if (!has_pslink(p))
223
 
                    delete_fm_entry(p);
 
193
                delete_fm_entry(p);
224
194
                break;
225
195
            default:
226
196
                assert(0);
232
202
            set_tfmlink(fm);
233
203
        }
234
204
    }
235
 
 
236
 
    /* handle ps_name link */
237
 
 
238
 
    if (fm->ps_name != NULL) {
239
 
        p = (fm_entry *) avl_find(ps_tree, fm);
240
 
        if (p != NULL) {
241
 
            switch (mode) {
242
 
            case FM_DUPIGNORE:
243
 
                goto exit;
244
 
                break;
245
 
            case FM_REPLACE:
246
 
            case FM_DELETE:
247
 
                if (p->in_use)
248
 
                    goto exit;
249
 
                a = avl_delete(ps_tree, p);
250
 
                assert(a != NULL);
251
 
                unset_pslink(p);
252
 
                if (!has_tfmlink(p))
253
 
                    delete_fm_entry(p);
254
 
                break;
255
 
            default:
256
 
                assert(0);
257
 
            }
258
 
        }
259
 
        if (mode != FM_DELETE && is_t1fontfile(fm) && is_included(fm)) {
260
 
            aa = avl_probe(ps_tree, fm);
261
 
            assert(aa != NULL);
262
 
            set_pslink(fm);
263
 
        }
264
 
    }
265
205
  exit:
266
 
    if (!has_tfmlink(fm) && !has_pslink(fm))    /* e. g. after FM_DELETE */
 
206
    if (!has_tfmlink(fm))       /* e. g. after FM_DELETE */
267
207
        return 1;               /* deallocation of fm_entry structure required */
268
208
    else
269
209
        return 0;
320
260
        a += 2;
321
261
    }
322
262
 
323
 
    /* SlantFont and ExtendFont can be used only with Type1 fonts */
324
 
    if ((fm->slant != 0 || fm->extend != 0)
325
 
        && !(is_t1fontfile(fm) && is_included(fm))) {
326
 
        if (warn)
327
 
            pdftex_warn
328
 
                ("invalid entry for `%s': SlantFont/ExtendFont can be used only with embedded Type1 fonts",
329
 
                 fm->tfm_name);
330
 
        a += 4;
331
 
    }
332
 
 
333
263
    /* the value of SlantFont and ExtendFont must be reasonable */
334
 
    if (abs(fm->slant) > 1000) {
 
264
    if (fm->slant < FONT_SLANT_MIN || fm->slant > FONT_SLANT_MAX) {
335
265
        if (warn)
336
266
            pdftex_warn
337
267
                ("invalid entry for `%s': too big value of SlantFont (%g)",
338
268
                 fm->tfm_name, fm->slant / 1000.0);
339
269
        a += 8;
340
270
    }
341
 
    if (abs(fm->extend) > 2000) {
 
271
    if (fm->extend < FONT_EXTEND_MIN || fm->extend > FONT_EXTEND_MAX) {
342
272
        if (warn)
343
273
            pdftex_warn
344
274
                ("invalid entry for `%s': too big value of ExtendFont (%g)",
414
344
 
415
345
/**********************************************************************/
416
346
 
417
 
static void fm_scan_line()
 
347
static void fm_scan_line(void)
418
348
{
419
349
    int a, b, c, j, u = 0, v = 0;
420
350
    float d;
477
407
                        s--;    /* e. g. 0.5ExtendFont: %f = 0.5E */
478
408
                    if (str_prefix(s, "SlantFont")) {
479
409
                        d *= 1000.0;    /* correct rounding also for neg. numbers */
480
 
                        fm->slant = (integer) (d > 0 ? d + 0.5 : d - 0.5);
 
410
                        fm->slant = (int) (d > 0 ? d + 0.5 : d - 0.5);
 
411
                        set_slantset(fm);
481
412
                        r = s + strlen("SlantFont");
482
413
                    } else if (str_prefix(s, "ExtendFont")) {
483
414
                        d *= 1000.0;
484
 
                        fm->extend = (integer) (d > 0 ? d + 0.5 : d - 0.5);
485
 
                        if (fm->extend == 1000)
486
 
                            fm->extend = 0;
 
415
                        fm->extend = (int) (d > 0 ? d + 0.5 : d - 0.5);
 
416
                        set_extendset(fm);
487
417
                        r = s + strlen("ExtendFont");
488
418
                    } else {    /* unknown name */
489
419
                        for (r = s; *r != ' ' && *r != '"' && *r != '\0'; r++); /* jump over name */
552
482
    if (is_fontfile(fm) && strlen(fm_fontfile(fm)) > 3) {
553
483
        if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".ttf") == 0)
554
484
            set_truetype(fm);
 
485
        else if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".ttc") == 0)
 
486
            set_truetype(fm);
555
487
        else if (strcasecmp(strend(fm_fontfile(fm)) - 4, ".otf") == 0)
556
488
            set_opentype(fm);
557
489
        else
575
507
 
576
508
/**********************************************************************/
577
509
 
578
 
void fm_read_info()
 
510
void fm_read_info(void)
579
511
{
580
512
    int callback_id;
581
513
    int file_opened = 0;
582
 
    char *ftemp = NULL;
 
514
 
583
515
    if (tfm_tree == NULL)
584
516
        create_avl_trees();
585
517
    if (mitem->line == NULL)    /* nothing to do */
587
519
    mitem->lineno = 1;
588
520
    switch (mitem->type) {
589
521
    case MAPFILE:
590
 
        set_cur_file_name(mitem->line);
591
522
        if (fm_buffer != NULL) {
592
523
            xfree(fm_buffer);
593
524
            fm_buffer = NULL;
594
525
        }
595
526
        fm_curbyte = 0;
596
527
        fm_size = 0;
597
 
        callback_id = callback_defined(find_map_file_callback);
598
 
        if (callback_id > 0) {
599
 
            if (run_callback
600
 
                (callback_id, "S->S", (char *) (nameoffile + 1), &ftemp)) {
601
 
                if (ftemp != NULL && strlen(ftemp)) {
602
 
                    free(nameoffile);
603
 
                    namelength = strlen(ftemp);
604
 
                    nameoffile = xmalloc(namelength + 2);
605
 
                    strcpy((char *) (nameoffile + 1), ftemp);
606
 
                    free(ftemp);
607
 
                }
608
 
            }
609
 
        } else {
610
 
            ftemp =
611
 
                kpse_find_file((char *) (nameoffile + 1), kpse_fontmap_format,
612
 
                               0);
613
 
            if (ftemp != NULL) {
614
 
                free(nameoffile);
615
 
                namelength = strlen(ftemp);
616
 
                nameoffile = xmalloc(namelength + 2);
617
 
                strcpy((char *) (nameoffile + 1), ftemp);
618
 
                free(ftemp);
619
 
            }
620
 
        }
621
 
        callback_id = callback_defined(read_map_file_callback);
622
 
        if (callback_id > 0) {
623
 
            if (run_callback(callback_id, "S->bSd", (char *) (nameoffile + 1),
624
 
                             &file_opened, &fm_buffer, &fm_size)) {
625
 
                if (file_opened) {
626
 
                    if (fm_size > 0) {
627
 
                        cur_file_name = (char *) nameoffile + 1;
628
 
                        if (tracefilenames)
629
 
                            tex_printf("{%s", cur_file_name);
630
 
                        while (!fm_eof()) {
631
 
                            fm_scan_line();
632
 
                            mitem->lineno++;
 
528
        cur_file_name = luatex_find_file(mitem->line, find_map_file_callback);
 
529
        if (cur_file_name) {
 
530
            callback_id = callback_defined(read_map_file_callback);
 
531
            if (callback_id > 0) {
 
532
                if (run_callback(callback_id, "S->bSd", cur_file_name,
 
533
                                 &file_opened, &fm_buffer, &fm_size)) {
 
534
                    if (file_opened) {
 
535
                        if (fm_size > 0) {
 
536
                            if (tracefilenames)
 
537
                                tex_printf("{%s", cur_file_name);
 
538
                            while (!fm_eof()) {
 
539
                                fm_scan_line();
 
540
                                mitem->lineno++;
 
541
                            }
 
542
                            if (tracefilenames)
 
543
                                tex_printf("}");
 
544
                            fm_file = NULL;
633
545
                        }
634
 
                        if (tracefilenames)
635
 
                            tex_printf("}");
636
 
                        fm_file = NULL;
637
 
                    }
638
 
                } else {
639
 
                    pdftex_warn("cannot open font map file");
640
 
                }
641
 
            } else {
642
 
                pdftex_warn("cannot open font map file");
643
 
            }
644
 
        } else {
645
 
            if (!fm_open()) {
646
 
                pdftex_warn("cannot open font map file");
647
 
            } else {
648
 
                fm_read_file();
649
 
                cur_file_name = (char *) nameoffile + 1;
650
 
                tex_printf("{%s", cur_file_name);
651
 
                while (!fm_eof()) {
652
 
                    fm_scan_line();
653
 
                    mitem->lineno++;
654
 
                }
655
 
                fm_close();
656
 
                tex_printf("}");
657
 
                fm_file = NULL;
658
 
            }
 
546
                    } else {
 
547
                        pdftex_warn("cannot open font map file");
 
548
                    }
 
549
                } else {
 
550
                    pdftex_warn("cannot open font map file");
 
551
                }
 
552
            } else {
 
553
                if (!fm_open(cur_file_name)) {
 
554
                    pdftex_warn("cannot open font map file");
 
555
                } else {
 
556
                    fm_read_file();
 
557
                    tex_printf("{%s", cur_file_name);
 
558
                    while (!fm_eof()) {
 
559
                        fm_scan_line();
 
560
                        mitem->lineno++;
 
561
                    }
 
562
                    fm_close();
 
563
                    tex_printf("}");
 
564
                    fm_file = NULL;
 
565
                }
 
566
            }
 
567
            cur_file_name = NULL;
659
568
        }
660
569
        break;
661
570
    case MAPLINE:
680
589
    if (tfm_tree == NULL)
681
590
        fm_read_info();         /* only to read default map file */
682
591
    tfm = font_name(f);
 
592
    if (tfm == NULL)            /* wide, lua loaded fonts may not have a name */
 
593
        return (fm_entry_ptr) dummy_fm_entry();
683
594
    assert(strcmp(tfm, nontfm));
684
595
 
685
 
    /* Look up for full <tfmname>[+-]<expand> */
 
596
    /* Look up for tfmname */
686
597
    tmp.tfm_name = tfm;
687
598
    fm = (fm_entry *) avl_find(tfm_tree, &tmp);
688
599
    if (fm != NULL) {
689
 
        fm->in_use = true;
 
600
        set_inuse(fm);
690
601
        return (fm_entry_ptr) fm;
691
602
    }
692
603
    return (fm_entry_ptr) dummy_fm_entry();
697
608
    if (font_map(f) == NULL)
698
609
        set_font_map(f, (fm_entry_ptr) fmlookup(f));
699
610
    assert(font_map(f) != NULL);
 
611
    /* TODO: this still overrides already set font_slant(f) */
 
612
    if (is_slantset((fm_entry *) font_map(f)))
 
613
        font_slant(f) = ((fm_entry *) font_map(f))->slant;
 
614
    if (is_extendset((fm_entry *) font_map(f)))
 
615
        font_extend(f) = ((fm_entry *) font_map(f))->extend;
700
616
    return font_map(f) != (fm_entry_ptr) dummy_fm_entry();
701
617
}
702
618
 
703
 
/* check whether a map entry is valid for font replacement */
704
 
 
705
 
static boolean fm_valid_for_font_replacement(fm_entry * fm)
706
 
{
707
 
    ff_entry *ff;
708
 
 
709
 
    assert(fm != NULL);
710
 
    assert(is_fontfile(fm));    /* ps_tree should contain only entries with font file */
711
 
    assert(is_type1(fm));       /* ps_tree should contain only Type1 entries */
712
 
 
713
 
    ff = check_ff_exist(fm->ff_name, false);
714
 
    assert(ff != NULL);
715
 
    if (ff->ff_path == NULL)    /* ...there is no font file available */
716
 
        return false;
717
 
    return true;                /* all tests passed */
718
 
}
719
 
 
720
 
/**********************************************************************/
721
 
/*
722
 
 * lookup fontmap by ps_name;
723
 
 * used for Type1 font replacement when embedding of PDF files
724
 
 */
725
 
 
726
 
fm_entry *lookup_fontmap(char *ps_name)
727
 
{
728
 
    fm_entry *fm, *fm2, tmp;
729
 
    char *a, *b, *c, *d, *e, *s;
730
 
    int i, sl, ex;
731
 
    struct avl_traverser t, t2;
732
 
    if (tfm_tree == NULL)
733
 
        fm_read_info();         /* only to read default map file */
734
 
    assert(ps_name != NULL);
735
 
    s = ps_name;
736
 
    if (strlen(ps_name) > 7) {  /* check for subsetted name tag */
737
 
        for (i = 0; i < 6; i++, s++)
738
 
            if (*s < 'A' || *s > 'Z')
739
 
                break;
740
 
        if (i == 6 && *s == '+')
741
 
            s++;                /* if name tag found, skip behind it */
742
 
        else
743
 
            s = ps_name;
744
 
    }
745
 
 
746
 
    /*
747
 
     * Scan -Slant_<slant> and -Extend_<extend> font name extensions;
748
 
     * three valid formats:
749
 
     * <fontname>-Slant_<slant>
750
 
     * <fontname>-Slant_<slant>-Extend_<extend>
751
 
     * <fontname>-Extend_<extend>
752
 
     * Slant entry must come _before_ Extend entry
753
 
     */
754
 
 
755
 
    tmp.slant = 0;
756
 
    tmp.extend = 0;
757
 
    if ((a = strstr(s, "-Slant_")) != NULL) {
758
 
        b = a + strlen("-Slant_");
759
 
        sl = (int) strtol(b, &e, 10);
760
 
        if ((e != b) && (e == strend(b))) {
761
 
            tmp.slant = sl;
762
 
            *a = '\0';          /* ps_name string ends before "-Slant_" */
763
 
        } else {
764
 
            if (e != b) {       /* only if <slant> is valid number */
765
 
                if ((c = strstr(e, "-Extend_")) != NULL) {
766
 
                    d = c + strlen("-Extend_");
767
 
                    ex = (int) strtol(d, &e, 10);
768
 
                    if ((e != d) && (e == strend(d))) {
769
 
                        tmp.slant = sl;
770
 
                        tmp.extend = ex;
771
 
                        *a = '\0';      /* ps_name string ends before "-Slant_" */
772
 
                    }
773
 
                }
774
 
            }
775
 
        }
776
 
    } else {
777
 
        if ((a = strstr(s, "-Extend_")) != NULL) {
778
 
            b = a + strlen("-Extend_");
779
 
            ex = (int) strtol(b, &e, 10);
780
 
            if ((e != b) && (e == strend(b))) {
781
 
                tmp.extend = ex;
782
 
                *a = '\0';      /* ps_name string ends before "-Extend_" */
783
 
            }
784
 
        }
785
 
    }
786
 
    tmp.ps_name = s;
787
 
 
788
 
    fm = (fm_entry *) avl_t_find(&t, ps_tree, &tmp);
789
 
    if (fm == NULL)
790
 
        return NULL;            /* no entry found */
791
 
 
792
 
    /* at this point we know there is at least one fm_entry with given ps_name;
793
 
     * we test all such entries and return the first one that is valid for font
794
 
     * replacement */
795
 
 
796
 
    t2 = t;
797
 
    fm2 = (fm_entry *) avl_t_prev(&t2);
798
 
 
799
 
    /* search forward */
800
 
    do {
801
 
        if (fm_valid_for_font_replacement(fm))
802
 
            return fm;
803
 
        fm = (fm_entry *) avl_t_next(&t);
804
 
    } while (fm != NULL && comp_fm_entry_ps(fm, &tmp, NULL) == 0);
805
 
 
806
 
    /* search backward */
807
 
    while (fm2 != NULL && comp_fm_entry_ps(fm2, &tmp, NULL) == 0) {
808
 
        if (fm_valid_for_font_replacement(fm2))
809
 
            return fm2;
810
 
        fm2 = (fm_entry *) avl_t_prev(&t2);
811
 
    }
812
 
 
813
 
    return NULL;
814
 
}
815
 
 
816
619
/**********************************************************************/
817
620
/*
818
621
 * Process map file given by its name or map line contents. Items not
868
671
    }
869
672
}
870
673
 
871
 
void pdfmapfile(integer t)
 
674
void pdfmapfile(int t)
872
675
{
873
 
    process_map_item(makecstring(tokens_to_string(t)), MAPFILE);
874
 
    flush_str(last_tokens_string);
 
676
    char *s = tokenlist_to_cstring(t, true, NULL);
 
677
    process_map_item(s, MAPFILE);
 
678
    free(s);
875
679
}
876
680
 
877
 
void pdfmapline(integer t)
 
681
void pdfmapline(int t)
878
682
{
879
 
    process_map_item(makecstring(tokens_to_string(t)), MAPLINE);
880
 
    flush_str(last_tokens_string);
 
683
    char *s = tokenlist_to_cstring(t, true, NULL);
 
684
    process_map_item(s, MAPLINE);
 
685
    free(s);
881
686
}
882
687
 
883
688
void pdf_init_map_file(string map_name)
898
703
 * same fonts are to be embedded.
899
704
 *
900
705
 * The ff_tree contains only font files, which are actually needed,
901
 
 * so this tree typically is much smaller than the tfm_tree or ps_tree.
 
706
 * so this tree typically is much smaller than the tfm_tree.
902
707
 */
903
708
 
904
709
ff_entry *check_ff_exist(char *ff_name, boolean is_tt)
958
763
    fm_entry *fm;
959
764
    (void) pb;
960
765
    fm = (fm_entry *) pa;
961
 
    if (!has_pslink(fm))
962
 
        delete_fm_entry(fm);
963
 
    else
964
 
        unset_tfmlink(fm);
965
 
}
966
 
 
967
 
static void destroy_fm_entry_ps(void *pa, void *pb)
968
 
{
969
 
    fm_entry *fm;
970
 
    (void) pb;
971
 
    fm = (fm_entry *) pa;
972
 
    if (!has_tfmlink(fm))
973
 
        delete_fm_entry(fm);
974
 
    else
975
 
        unset_pslink(fm);
 
766
    delete_fm_entry(fm);
976
767
}
977
768
 
978
769
static void destroy_ff_entry(void *pa, void *pb)
989
780
        avl_destroy(tfm_tree, destroy_fm_entry_tfm);
990
781
        tfm_tree = NULL;
991
782
    }
992
 
    if (ps_tree != NULL) {
993
 
        avl_destroy(ps_tree, destroy_fm_entry_ps);
994
 
        ps_tree = NULL;
995
 
    }
996
783
    if (ff_tree != NULL) {
997
784
        avl_destroy(ff_tree, destroy_ff_entry);
998
785
        ff_tree = NULL;