summaryrefslogtreecommitdiff
path: root/backend/dvi/mdvi-lib/t1.c
blob: 12bb01fac48aa523ca31f872767bbfc01e009dac (plain)
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
/*
 * Copyright (C) 2000, Matias Atria
 *
 * 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 2 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 the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

/*
 * Type1 font support for MDVI
 *
 * We use T1lib only as a rasterizer, not to draw glyphs.
 */

#include <config.h>
#include "mdvi.h"

#ifdef WITH_TYPE1_FONTS

#include <stdio.h>
#include <t1lib.h>
#include "private.h"

static int	t1lib_initialized = 0;

typedef struct t1info {
	struct t1info *next;
	struct t1info *prev;
	char	*fontname;	/* (short) name of this font */
	int	t1id;		/* T1lib's id for this font */
	int	hasmetrics;	/* have we processed this font? */
	TFMInfo *tfminfo;	/* TFM data is shared */
	DviFontMapInfo mapinfo;
	DviEncoding *encoding;
} T1Info;

static void  t1_font_remove __PROTO((T1Info *));
static int   t1_load_font __PROTO((DviParams *, DviFont *));
static int   t1_font_get_glyph __PROTO((DviParams *, DviFont *, int));
static void  t1_font_shrink_glyph
		__PROTO((DviContext *, DviFont *, DviFontChar *, DviGlyph *));
static void  t1_free_data __PROTO((DviFont *));
static void  t1_reset_font __PROTO((DviFont *));
static char *t1_lookup_font __PROTO((const char *, Ushort *, Ushort *));

/* only symbol exported by this file */
DviFontInfo t1_font_info = {
	"Type1",
	1, /* scaling supported by format */
	t1_load_font,
	t1_font_get_glyph,
	t1_font_shrink_glyph,
	mdvi_shrink_glyph_grey,
	t1_free_data,
	t1_reset_font,
	t1_lookup_font,	/* lookup */
	kpse_type1_format,
	NULL
};

/* this seems good enough for most DVI files */
#define T1_HASH_SIZE	31

/* If these parameters change, we must delete all size information
 * in all fonts, and reset the device resolutions in T1lib */
static int t1lib_xdpi = -1;
static int t1lib_ydpi = -1;

static ListHead t1fonts = {NULL, NULL, 0};
static DviHashTable t1hash;

/* Type1 fonts need their own `lookup' function. Here is how it works:
 * First we try to find the font by its given name. If that fails, we
 * query the font maps. A typical font map entry may contain the line
 *
 * ptmr8rn Times-Roman ".82 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc <ptmr
 *
 * which means: If you're looking for the font `ptmr8rn' load `Times-Roman'
 * which is in `ptmr' instead, and extend it by 0.82 points, then reencode
 * it with the vector TeXBase1Encoding from the file `8r.enc'. This will
 * fail if the entry looks like this:
 *
 * ptmr8rn Times-Roman ".82 ExtendFont TeXBase1Encoding ReEncodeFont" <8r.enc
 *
 * because to deal with this we would need to be able to locate the font file
 * for the `Times-Roman' font ourselves, and that's beyond the scope of mdvi.
 * But hey, we tried hard.
 */
char	*t1_lookup_font(const char *name, Ushort *hdpi, Ushort *vdpi)
{
	char	*filename;
	char	*newname;
	const char *ext;
	DviFontMapInfo info;

	DEBUG((DBG_TYPE1, "(t1) looking for `%s'\n", name));

	/* first let's try the font we were asked for */
	filename = kpse_find_file(name, kpse_type1_format, 1);
	if(filename != NULL) {
		/* we got it */
		return filename;
	}

	DEBUG((DBG_TYPE1, "(t1) %s: not found, querying font maps\n", name));
	/* now query the fontmap */
	if(mdvi_query_fontmap(&info, name) < 0) {
		/* it's not there either */
		return NULL;
	}

	/* check what we got */
	if(info.fullfile) {
		DEBUG((DBG_TYPE1, "(t1) %s: found `%s' (cached)\n",
			name, info.fullfile));
		/* this is a cached lookup */
		return mdvi_strdup(info.fullfile);
	}

	/* no file associated to this font? */
	if(info.fontfile == NULL)
		return info.psname ? mdvi_ps_find_font(info.psname) : NULL;

	/* let's extract the extension */
	ext = file_extension(info.fontfile);
	if(ext && !STREQ(ext, "pfa") && !STREQ(ext, "pfb")) {
		DEBUG((DBG_TYPE1,
			"(t1) %s: associated name `%s' is not Type1\n",
			name, info.fontfile));
		/* it's not a Type1 font */
		return NULL;
	}

	/* get the `base' name */
	if(ext) {
		newname = mdvi_strdup(info.fontfile);
		newname[ext - info.fontfile - 1] = 0;
	} else
		newname = (char *)name; /* we don't modify this */

	/* look it up */
	DEBUG((DBG_TYPE1, "(t1) looking for `%s' on behalf of `%s'\n",
		newname, name));
	filename = kpse_find_file(newname, kpse_type1_format, 1);

	/* we don't need this anymore */
	if(newname != name)
		mdvi_free(newname);
	if(filename == NULL) {
		DEBUG((DBG_TYPE1, "(t1) %s: not found\n", name));
		return NULL;
	}

	DEBUG((DBG_TYPE1, "(t1) %s: found as `%s'\n", name, filename));
	/* got it! let's remember this */
	mdvi_add_fontmap_file(name, filename);
	return filename;
}

static void t1_reset_resolution(int xdpi, int ydpi)
{
	int	i;
	int	nfonts;

	DEBUG((DBG_TYPE1, "(t1) resetting device resolution (current: (%d,%d))\n",
		t1lib_xdpi, t1lib_ydpi));
#if T1LIB_VERSION < 5
	nfonts = T1_Get_no_fonts();
#else
	nfonts = T1_GetNoFonts();
#endif

	for(i = 0; i < nfonts; i++)
		T1_DeleteAllSizes(i);
	/* reset device resolutions */
	if(T1_SetDeviceResolutions((float)xdpi, (float)ydpi) < 0)
		mdvi_warning(_("(t1) failed to reset device resolution\n"));
	else
		DEBUG((DBG_TYPE1,
			"(t1) reset successful, new resolution is (%d, %d)\n",
			xdpi, ydpi));
	t1lib_xdpi = xdpi;
	t1lib_ydpi = ydpi;
}

static void t1_reset_font(DviFont *font)
{
	T1Info *info = (T1Info *)font->private;

	if(info == NULL)
		return;
	DEBUG((DBG_FONTS, "(t1) resetting font `%s'\n", font->fontname));
	/* just mark the font as not having metric info. It will be reset
	 * automatically later */
	info->hasmetrics = 0;
}

static void t1_transform_font(T1Info *info)
{
	if(!info->hasmetrics && info->encoding != NULL) {
		DEBUG((DBG_TYPE1, "(t1) %s: encoding with vector `%s'\n",
			info->fontname, info->encoding->name));
		T1_DeleteAllSizes(info->t1id);
		if(T1_ReencodeFont(info->t1id, info->encoding->vector) < 0)
			mdvi_warning(_("%s: could not encode font\n"), info->fontname);
	}
	if(info->mapinfo.slant) {
		DEBUG((DBG_TYPE1, "(t1) %s: slanting by %.3f\n",
			info->fontname,
			MDVI_FMAP_SLANT(&info->mapinfo)));
		T1_SlantFont(info->t1id,
			MDVI_FMAP_SLANT(&info->mapinfo));
	}
	if(info->mapinfo.extend) {
		DEBUG((DBG_TYPE1, "(t1) %s: extending by %.3f\n",
			info->fontname,
			MDVI_FMAP_EXTEND(&info->mapinfo)));
		T1_ExtendFont(info->t1id,
			MDVI_FMAP_EXTEND(&info->mapinfo));
	}
}

/* if this function is called, we really need this font */
static int t1_really_load_font(DviParams *params, DviFont *font, T1Info *info)
{
	int	i;
	T1Info	*old;
	int	t1id;
	int	copied;
	int	status;

	DEBUG((DBG_TYPE1, "(t1) really_load_font(%s)\n", info->fontname));

	/* if the parameters changed, reset T1lib */
	if(t1lib_xdpi != params->dpi || t1lib_ydpi != params->vdpi)
		t1_reset_resolution(params->dpi, params->vdpi);

	/* if we already have a T1lib id, do nothing */
	if(info->t1id != -1) {
		info->hasmetrics = 1;
		/* apply slant and extend again */
		t1_transform_font(info);
		return 0;
	}

	/* before we even attempt to load the font, make sure we have metric
	 * data for it */
	info->tfminfo = mdvi_ps_get_metrics(info->fontname);
	if(info->tfminfo == NULL) {
		DEBUG((DBG_FONTS,
			"(t1) %s: no metric data, font ignored\n",
			info->fontname));
		goto t1_error;
	}
	/* fix this */
	font->design = info->tfminfo->design;

	/* check if we have a font with this name (maybe at a different size) */
	old = (T1Info *)mdvi_hash_lookup(&t1hash, (unsigned char *)info->fontname);
	if(old == info) {
		/* let's avoid confusion */
		old = NULL;
	}
	if(old && old->t1id != -1) {
		/* let's take advantage of T1lib's font sharing */
		t1id = T1_CopyFont(old->t1id);
		DEBUG((DBG_TYPE1, "(t1) %s -> %d (CopyFont)\n",
			info->fontname, t1id));
		copied = 1;
	} else {
		t1id = T1_AddFont(font->filename);
		DEBUG((DBG_TYPE1, "(t1) %s -> %d (AddFont)\n",
			info->fontname, t1id));
		copied = 0;
	}
	if(t1id < 0)
		goto t1_error;
	info->t1id = t1id;

	/*
	 * a minor optimization: If the old font in the hash table has
	 * not been loaded yet, replace it by this one, so we can use
	 * CopyFont later.
	 */
	if(old && old->t1id == -1) {
		DEBUG((DBG_TYPE1, "(t1) font `%s' exchanged in hash table\n",
			info->fontname));
		mdvi_hash_remove(&t1hash, (unsigned char *)old->fontname);
		mdvi_hash_add(&t1hash, (unsigned char *)info->fontname,
			info, MDVI_HASH_UNCHECKED);
	}

	/* now let T1lib load it */
	if(!copied && T1_LoadFont(info->t1id) < 0) {
		DEBUG((DBG_TYPE1, "(t1) T1_LoadFont(%d) failed with error %d\n",
			info->t1id, T1_errno));
		goto t1_error;
	}
	DEBUG((DBG_TYPE1, "(t1) T1_LoadFont(%d) -> Ok\n", info->t1id));

	/* get information from the fontmap */
	status = mdvi_query_fontmap(&info->mapinfo, info->fontname);
	if(!status && info->mapinfo.encoding)
	   	info->encoding = mdvi_request_encoding(info->mapinfo.encoding);
	t1_transform_font(info);

	i = info->tfminfo->hic - info->tfminfo->loc + 1;
	if(i != font->hic - font->loc + 1) {
		/* reset to optimal size */
		font->chars = mdvi_realloc(font->chars, i * sizeof(DviFontChar));
	}

	/* get the scaled characters metrics */
	get_tfm_chars(params, font, info->tfminfo, 0);
	info->hasmetrics = 1;

	DEBUG((DBG_TYPE1, "(t1) font `%s' really-loaded\n", info->fontname));
	return 0;

t1_error:
	/* some error does not allows us to use this font. We need to reset
	 * the font structure, so the font system can try to read this
	 * font in a different class */

	/* first destroy the private data */
	t1_font_remove(info);
	/* now reset all chars -- this is the important part */
	mdvi_free(font->chars);
	font->chars = NULL;
	font->loc = font->hic = 0;
	return -1;
}

static int init_t1lib(DviParams *params)
{
	int	t1flags;

#ifdef WORD_LITTLE_ENDIAN
	/* try making T1lib use bitmaps in our format, but if this
	 * fails we'll convert the bitmap ourselves */
	T1_SetBitmapPad(BITMAP_BITS);
#endif
	T1_SetDeviceResolutions((float)params->dpi, (float)params->vdpi);
	t1flags = IGNORE_CONFIGFILE|IGNORE_FONTDATABASE|T1_NO_AFM;
	if(DEBUGGING(TYPE1))
		t1flags |= LOGFILE;
	if(T1_InitLib(t1flags) == NULL)
		return (t1lib_initialized = -1);
	if(DEBUGGING(TYPE1)) {
		DEBUG((DBG_TYPE1, "T1lib debugging output saved in t1lib.log\n"));
		T1_SetLogLevel(T1LOG_DEBUG);
	}
	/* initialize our hash table, but don't allocate memory for it
	 * until we use it */
	mdvi_hash_init(&t1hash);
	DEBUG((DBG_TYPE1, "(t1) t1lib %s initialized -- resolution is (%d, %d), pad is %d bits\n",
		T1_GetLibIdent(), params->dpi, params->vdpi, T1_GetBitmapPad()));
	t1lib_initialized = 1;
	t1lib_xdpi = params->dpi;
	t1lib_ydpi = params->vdpi;
	return 0;
}

static int t1_load_font(DviParams *params, DviFont *font)
{
	T1Info	*info;
	int	i;

	if(t1lib_initialized < 0)
		return -1;
	else if(t1lib_initialized == 0 && init_t1lib(params) < 0)
		return -1;

	if(font->in != NULL) {
		/* we don't need this */
		fclose(font->in);
		font->in = NULL;
	}

	info = xalloc(T1Info);

	/*
	 * mark the font as `unregistered' with T1lib. It will
	 * be added when we actually use it
	 */
	info->t1id = -1;

	/* add the font to our list */
	info->fontname = font->fontname;
	info->hasmetrics = 0;
	info->encoding = NULL;
	info->mapinfo.psname = NULL;
	info->mapinfo.encoding = NULL;
	info->mapinfo.fontfile = NULL;
	info->mapinfo.extend = 0;
	info->mapinfo.slant = 0;
	info->encoding = NULL;

	/* create the hash table if we have not done so yet */
	if(t1hash.nbucks == 0)
		mdvi_hash_create(&t1hash, T1_HASH_SIZE);
	mdvi_hash_add(&t1hash, (unsigned char *) info->fontname, info, MDVI_HASH_UNIQUE);
	listh_append(&t1fonts, LIST(info));

	font->private = info;

	/* reset everything */
	font->chars = xnalloc(DviFontChar, 256);
	font->loc = 0;
	font->hic = 255;
	for(i = 0; i < 256; i++) {
		font->chars[i].code = i;
		font->chars[i].offset = 1;
		font->chars[i].loaded = 0;
		font->chars[i].glyph.data = NULL;
		font->chars[i].shrunk.data = NULL;
		font->chars[i].grey.data = NULL;
	}

	return 0;
}

#define GLYPH_WIDTH(g) \
	((g)->metrics.rightSideBearing - (g)->metrics.leftSideBearing)
#define GLYPH_HEIGHT(g) \
	((g)->metrics.ascent - (g)->metrics.descent)

static inline BITMAP *t1_glyph_bitmap(GLYPH *glyph)
{
	int	w, h, pad;

	w = GLYPH_WIDTH(glyph);
	h = GLYPH_HEIGHT(glyph);

	if(!w || !h)
		return MDVI_GLYPH_EMPTY;

	pad = T1_GetBitmapPad();
	return bitmap_convert_lsb8((unsigned char *)glyph->bits, w, h, ROUND(w, pad) * (pad >> 3));
}

static void t1_font_shrink_glyph(DviContext *dvi, DviFont *font, DviFontChar *ch, DviGlyph *dest)
{
	double	size;
	GLYPH	*glyph;
	T1Info	*info;
	T1_TMATRIX matrix;

	info = (T1Info *)font->private;
	ASSERT(info != NULL);

	DEBUG((DBG_TYPE1, "(t1) shrinking glyph for character %d in `%s' (%d,%d)\n",
		ch->code, font->fontname, ch->width, ch->height));
	size = (double)font->scale / (dvi->params.tfm_conv * 0x100000);
	size = 72.0 * size / 72.27;
	matrix.cxx = 1.0/(double)dvi->params.hshrink;
	matrix.cyy = 1.0/(double)dvi->params.vshrink;
	matrix.cxy = 0.0;
	matrix.cyx = 0.0;
	glyph = T1_SetChar(info->t1id, ch->code, (float)size, &matrix);

	dest->data = t1_glyph_bitmap(glyph);
	dest->x = -glyph->metrics.leftSideBearing;
	dest->y = glyph->metrics.ascent;
	dest->w = GLYPH_WIDTH(glyph);
	dest->h = GLYPH_HEIGHT(glyph);

#ifndef NODEBUG
	if(DEBUGGING(BITMAP_DATA)) {
		DEBUG((DBG_BITMAP_DATA,
			"(t1) %s: t1_shrink_glyph(%d): (%dw,%dh,%dx,%dy) -> (%dw,%dh,%dx,%dy)\n",
			ch->glyph.w, ch->glyph.h, ch->glyph.x, ch->glyph.y,
			dest->w, dest->h, dest->x, dest->y));
		bitmap_print(stderr, (BITMAP *)dest->data);
	}
#endif
	/* transform the glyph - we could do this with t1lib, but we do
	 * it ourselves for now */
	font_transform_glyph(dvi->params.orientation, dest);
}

static int t1_font_get_glyph(DviParams *params, DviFont *font, int code)
{
	T1Info	*info = (T1Info *)font->private;
	GLYPH	*glyph;
	DviFontChar *ch;
	double	size;
	T1_TMATRIX matrix;
	int	dpi;

	ASSERT(info != NULL);
	if(!info->hasmetrics && t1_really_load_font(params, font, info) < 0)
		return -1;
	ch = FONTCHAR(font, code);
	if(!ch || !glyph_present(ch))
		return -1;
	ch->loaded = 1;
	if(!ch->width || !ch->height) {
		ch->glyph.x = ch->x;
		ch->glyph.y = ch->y;
		ch->glyph.w = ch->width;
		ch->glyph.h = ch->height;
		ch->glyph.data = NULL;
		return 0;
	}

	/* load the glyph with T1lib (this is done only once for each glyph) */

	/* get size in TeX points (tfm_conv includes dpi and magnification) */
	size = (double)font->scale / (params->tfm_conv * 0x100000);
	/* and transform into PostScript points */
	size = 72.0 * size / 72.27;

	dpi = Max(font->hdpi, font->vdpi);
	/* we don't want the glyph to be cached twice (once by us, another by
	 * T1lib), so we use an identity matrix to tell T1lib not to keep the
	 * glyph around */
	matrix.cxx = (double)font->hdpi / dpi;
	matrix.cyy = (double)font->vdpi / dpi;
	matrix.cxy = matrix.cyx = 0.0;
	glyph = T1_SetChar(info->t1id, ch->code, (float)size, &matrix);
	if(glyph == NULL) {
		ch->glyph.x = ch->x;
		ch->glyph.y = ch->y;
		ch->glyph.w = ch->width;
		ch->glyph.h = ch->height;
		ch->glyph.data = NULL;
		ch->missing = 1;
		return 0;
	}
	/* and make it a bitmap */
	ch->glyph.data = t1_glyph_bitmap(glyph);
	ch->glyph.x = -glyph->metrics.leftSideBearing;
	ch->glyph.y = glyph->metrics.ascent;
	ch->glyph.w = GLYPH_WIDTH(glyph);
	ch->glyph.h = GLYPH_HEIGHT(glyph);

	/* let's also fix the glyph's origin
	 * (which is not contained in the TFM) */
	ch->x = ch->glyph.x;
	ch->y = ch->glyph.y;
	/* let's fix these too */
	ch->width = ch->glyph.w;
	ch->height = ch->glyph.h;

	return 0;
}

static void t1_font_remove(T1Info *info)
{
	T1Info	*old;

	/* first remove it from our list */
	listh_remove(&t1fonts, LIST(info));

	/* it it's in the hash table, we may need to replace this by another font */
	old = (T1Info *)mdvi_hash_lookup(&t1hash, (unsigned char *)info->fontname);
	if(old == info) {
		mdvi_hash_remove(&t1hash, (unsigned char *) info->fontname);
		/* go through the list and see if there is another
		 * font with this name */
		for(old = (T1Info *)t1fonts.head; old; old = old->next)
			if(STREQ(old->fontname, info->fontname))
				break;
		if(old != NULL)
			mdvi_hash_add(&t1hash, (unsigned char *) old->fontname, old,
				MDVI_HASH_UNCHECKED);
	}
	/* release our encoding vector */
	if(info->encoding) {
		DEBUG((DBG_TYPE1, "(t1) %s: releasing vector `%s'\n",
			info->fontname, info->encoding->name));
		mdvi_release_encoding(info->encoding, 1);
	}

	/* now get rid of it */
	if(info->t1id != -1) {
		DEBUG((DBG_TYPE1, "(t1) %s: T1_DeleteFont(%d)\n",
			info->fontname, info->t1id));
		T1_DeleteFont(info->t1id);
	} else
		DEBUG((DBG_TYPE1, "(t1) %s: not loaded yet, DeleteFont skipped\n",
			info->fontname));

	if(info->tfminfo)
		free_font_metrics(info->tfminfo);
	/*mdvi_free(info->fontname);*/
	mdvi_free(info);
}

static void t1_free_data(DviFont *font)
{
	/* called after all the glyphs are destroyed */

	if(font->private == NULL) {
		/* this is perfectly normal, it just means the font has
		 * not been requested by MDVI yet */
		return;
	}

	/* destroy this data */

	t1_font_remove((T1Info *)font->private);
	font->private = NULL;

	/*
	 * if this is the last T1 font, reset the T1 library
	 * It is important that we do this, because this is will be called
	 * when the resolution or the magnification changes.
	 */
	if(t1fonts.count == 0) {
		DEBUG((DBG_TYPE1, "(t1) last font removed -- closing T1lib\n"));
		T1_CloseLib();
		t1lib_initialized = 0;
		t1lib_xdpi = -1;
		t1lib_ydpi = -1;
	}
}

#endif /* WITH_TYPE1_FONTS */