1 /* t1minimize.cc -- make minimal copy of a Type 1 font
2  *
3  * Copyright (c) 2003-2019 Eddie Kohler
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation; either version 2 of the License, or (at your option)
8  * any later version. This program is distributed in the hope that it will be
9  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11  * Public License for more details.
12  */
13 
14 #ifdef HAVE_CONFIG_H
15 # include <config.h>
16 #endif
17 #include "t1minimize.hh"
18 #include <efont/t1item.hh>
19 #include <stdio.h>
20 
21 using namespace Efont;
22 
23 Type1Font *
minimize(Type1Font * font)24 minimize(Type1Font *font)
25 {
26     Vector<double> xuid_extension;
27     xuid_extension.push_back(0x000395C1);
28     Type1Font *output = Type1Font::skeleton_make_copy(font, font->font_name(), &xuid_extension);
29 
30     // Subrs
31     for (int i = 0; i < font->nsubrs(); i++)
32 	if (Type1Subr *s = font->subr_x(i))
33 	    output->set_subr(s->subrno(), s->t1cs(), s->definer());
34 
35     // CharStrings
36     for (int i = 0; i < font->nglyphs(); i++)
37 	if (Type1Subr *g = font->glyph_x(i))
38 	    output->add_glyph(Type1Subr::make_glyph(g->name(), g->t1cs(), g->definer()));
39 
40     return output;
41 }
42