#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mdvi.h"
#include "private.h"
Go to the source code of this file.
void flush_font_metrics |
( |
void |
) | |
|
void free_font_metrics |
( |
TFMInfo * |
info) | |
|
TFMInfo* get_font_metrics |
( |
const char * |
short_name, |
|
|
int |
type, |
|
|
const char * |
filename |
|
) |
| |
Definition at line 650 of file tfmfile.c.
661 short_name, tfm->
links));
672 DEBUG((
DBG_FONTS,
"(mt) loading font metric data from `%s'\n", file, file));
680 #ifdef WITH_AFM_FILES
682 status = afm_load_file(file, &tfm->
tfminfo);
char* lookup_font_metrics |
( |
const char * |
name, |
|
|
int * |
type |
|
) |
| |
Definition at line 595 of file tfmfile.c.
600 #ifndef WITH_AFM_FILES
604 file = kpse_find_tfm(
name);
608 file = kpse_find_ofm(
name);
612 if(ext &&
STREQ(ext,
"tfm"))
617 #ifdef WITH_AFM_FILES
619 file = kpse_find_file(
name, kpse_afm_format, 0);
622 file = kpse_find_file(
name, kpse_afm_format, 0);
625 file = kpse_find_tfm(
name);
static int ofm1_load_file |
( |
FILE * |
in, |
|
|
TFMInfo * |
info |
|
) |
| |
|
static |
Definition at line 299 of file tfmfile.c.
301 int lh, bc, ec, nw, nh, nd;
339 fread(info->
coding, 39, 1, in);
342 strcpy(info->
coding,
"FontSpecific");
348 fread(info->
family, i, 1, in);
351 strcpy(info->
family,
"unspecified");
356 fseek(in, 4L*nco, SEEK_SET);
362 end = info->
chars + size;
364 for(tch = info->
chars, i = 0; i < ncw; i++) {
377 fseek(in, (
long)npc * 2, SEEK_CUR);
382 while(nr-- >= 0 && tch < end)
394 if(fread(tfm, 4, size, in) != size) {
400 #ifdef WORD_LITTLE_ENDIAN
404 heights = widths + nw;
405 depths = heights + nh;
407 if(widths[0] || heights[0] || depths[0])
412 for(tch = info->
chars; tch < end; tch++) {
static int ofm_load_file |
( |
const char * |
filename, |
|
|
TFMInfo * |
info |
|
) |
| |
|
static |
Definition at line 431 of file tfmfile.c.
433 int lf, lh, bc, ec, nw, nh, nd;
448 in = fopen(filename,
"rb");
470 DEBUG((
DBG_FONTS,
"(mt) reading Level-0 OFM file `%s'\n", filename));
472 lf =
fuget4(in); checksum = nwords;
473 lh =
fuget4(in); checksum += lh;
475 ec =
fuget4(in); checksum += 2 * (ec - bc + 1);
476 nw =
fuget4(in); checksum += nw;
477 nh =
fuget4(in); checksum += nh;
478 nd =
fuget4(in); checksum += nd;
487 if(checksum == lf + 1) {
497 if(checksum != lf || bc > ec + 1 || ec > 65535)
511 if(n < 0 || n > 39) {
512 mdvi_warning(
_(
"%s: font coding scheme truncated to 40 bytes\n"),
516 fread(info->
coding, 39, 1, in);
519 strcpy(info->
coding,
"FontSpecific");
525 fread(info->
family, i, 1, in);
528 strcpy(info->
family,
"unspecified");
532 fseek(in, 4L*(nwords + lh), SEEK_SET);
534 size = 2*(ec - bc + 1) + nw + nh + nd;
536 if(fread(tfm, 4, size, in) != size) {
541 #ifdef WORD_LITTLE_ENDIAN
545 charinfo = cb; cb += 2*(ec - bc + 1);
546 widths = cb; cb += nw;
547 heights = cb; cb += nh;
550 if(widths[0] || heights[0] || depths[0]) {
570 ptr = (
Uchar *)charinfo;
571 for(i = bc; i <= ec; ptr += 4, i++) {
590 mdvi_error(
_(
"%s: File corrupted, or not a TFM file\n"), filename);
static void swap_array |
( |
Uint32 * |
ptr, |
|
|
int |
n |
|
) |
| |
|
inlinestatic |
Definition at line 51 of file tfmfile.c.
57 *ptr++ = ((i & 0xff000000) >> 24)
58 | ((i & 0x00ff0000) >> 8)
59 | ((i & 0x0000ff00) << 8)
60 | ((i & 0x000000ff) << 24);
int tfm_load_file |
( |
const char * |
filename, |
|
|
TFMInfo * |
info |
|
) |
| |
Definition at line 149 of file tfmfile.c.
151 int lf, lh, bc, ec, nw, nh, nd, ne;
165 in = fopen(filename,
"rb");
173 if(fstat(fileno(in), &st) < 0)
176 if(st.st_size == 0 || st.st_size >= 16384)
180 size = 4 *
ROUND(st.st_size, 4);
181 if(size != st.st_size)
182 mdvi_warning(
_(
"Warning: TFM file `%s' has suspicious size\n"),
185 if(fread(tfm, st.st_size, 1, in) != 1)
197 lh =
muget2(ptr); checksum += 6 + lh;
199 ec =
muget2(ptr); checksum += ec - bc + 1;
200 nw =
muget2(ptr); checksum += nw;
201 nh =
muget2(ptr); checksum += nh;
202 nd =
muget2(ptr); checksum += nd;
206 ne =
muget2(ptr); checksum += ne;
210 cb = (
Int32 *)tfm; cb += 6 + lh;
211 charinfo = cb; cb += size;
212 widths = cb; cb += nw;
213 heights = cb; cb += nh;
216 if(widths[0] || heights[0] || depths[0] ||
217 checksum != lf || bc - 1 > ec || ec > 255 || ne > 256)
231 if(n < 0 || n > 39) {
232 mdvi_warning(
_(
"%s: font coding scheme truncated to 40 bytes\n"),
240 strcpy(info->
coding,
"FontSpecific");
249 strcpy(info->
family,
"unspecified");
262 #ifdef WORD_LITTLE_ENDIAN
268 ptr = (
Uchar *)charinfo;
269 for(i = bc; i <= ec; ptr += 3, i++) {
272 ndx = (int)*ptr; ptr++;
279 ndx = ((*ptr >> 4) & 0xf);
292 mdvi_error(
_(
"%s: File corrupted, or not a TFM file\n"), filename);