w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ttf2afm.c File Reference
#include <kpathsea/kpathsea.h>
#include <time.h>
#include <pdftexdir/ptexmac.h>
#include <pdftexdir/writettf.h>
#include <string.h>
#include "macnames.c"
Include dependency graph for ttf2afm.c:

Go to the source code of this file.

Classes

struct  _unicode_entry
 
struct  mtx_entry
 
struct  _kern_entry
 

Macros

#define AS_NAME   0
 
#define AS_INDEX   1
 
#define AS_UNICODE   2
 
#define VERSION   "1.02"
 
#define NOGLYPH_ASSIGNED_YET   USHRT_MAX
 
#define enc_getchar()   xgetc(encfile)
 
#define enc_eof()   feof(encfile)
 
#define pdftex_fail   ttf_fail
 
#define print_str(S)   if (S != NULL) fprintf(outfile, #S " %s\n", escape_eol(S))
 
#define print_dimen(N)   if (N != 0) fprintf(outfile, #N " %i\n", (int)get_ttf_funit(N))
 
#define get_ttf_funit(n)
 

Typedefs

typedef struct _unicode_entry unicode_entry
 
typedef struct _kern_entry kern_entry
 

Functions

static void ttf_fail (const char *fmt,...)
 
static void ttf_warn (const char *fmt,...)
 
static int xgetc (FILE *stream)
 
static long ttf_getnum (int s)
 
static dirtab_entryname_lookup (const char *s)
 
static void ttf_seek_tab (const char *name, TTF_LONG offset)
 
static void ttf_seek_off (const char *name, TTF_LONG offset)
 
static void store_kern_value (TTF_USHORT i, TTF_USHORT j, TTF_FWORD v)
 
static void free_tabs (void)
 
static void enc_getline (void)
 
static void read_encoding (char *encname)
 
static void append_unicode (long glyph_index, TTF_USHORT code)
 
static void read_cmap (void)
 
static char * make_name (long platform_id, int len)
 
static void read_font (void)
 
static int null_glyph (const char *s)
 
static void print_glyph_name (FILE *f, long glyph_index, int convention)
 
static void print_char_metric (FILE *f, int charcode, long glyph_index)
 
static char * escape_eol (char *s)
 
static void print_afm (char *date, char *fontname)
 
static void print_encoding (char *fontname)
 
static void usage (void)
 
int main (int argc, char **argv)
 

Variables

char * FontName = NULL
 
char * FullName = NULL
 
char * FamilyName = NULL
 
char * Notice = NULL
 
char * Version = NULL
 
char * Weight = NULL
 
TTF_LONG ItalicAngle = 0
 
TTF_LONG IsFixedPitch = 0
 
TTF_LONG FontBBox1 = 0
 
TTF_LONG FontBBox2 = 0
 
TTF_LONG FontBBox3 = 0
 
TTF_LONG FontBBox4 = 0
 
TTF_LONG UnderlinePosition = 0
 
TTF_LONG UnderlineThickness = 0
 
TTF_LONG CapHeight = 0
 
TTF_LONG XHeight = 0
 
TTF_LONG Ascender = 0
 
TTF_LONG Descender = 0
 
char * cur_file_name = NULL
 
char * bname = NULL
 
FILEfontfile
 
FILEencfile
 
FILEoutfile = NULL
 
char enc_line [1024]
 
int print_glyph = 0
 
int print_cmap = 0
 
int use_ext_enc = 0
 
int select_unicode = 1
 
int printing_enc = 0
 
TTF_USHORT upem
 
TTF_USHORT ntabs
 
int nhmtx
 
int post_format
 
int loca_format
 
long nglyphs
 
int nkernpairs = 0
 
int names_count = 0
 
char * ps_glyphs_buf = NULL
 
dirtab_entrydir_tab
 
mtx_entrymtx_tab
 
kern_entrykern_tab
 
char * enc_names [256]
 
cmap_entrycmap_tab
 
TTF_USHORT ncmapsubtabs
 
long cmap_offset
 
TTF_USHORT unicode_map [0xFFFF]
 

Macro Definition Documentation

◆ AS_INDEX

#define AS_INDEX   1

Definition at line 38 of file ttf2afm.c.

◆ AS_NAME

#define AS_NAME   0

Definition at line 37 of file ttf2afm.c.

◆ AS_UNICODE

#define AS_UNICODE   2

Definition at line 39 of file ttf2afm.c.

◆ enc_eof

#define enc_eof ( )    feof(encfile)

Definition at line 47 of file ttf2afm.c.

◆ enc_getchar

#define enc_getchar ( )    xgetc(encfile)

Definition at line 46 of file ttf2afm.c.

◆ get_ttf_funit

#define get_ttf_funit (   n)
Value:
(n < 0 ? -((-n/upem)*1000 + ((-n%upem)*1000)/upem) :\
((n/upem)*1000 + ((n%upem)*1000)/upem))
#define n
Definition: t4ht.c:1290
TTF_USHORT upem
Definition: ttf2afm.c:109

Definition at line 53 of file ttf2afm.c.

◆ NOGLYPH_ASSIGNED_YET

#define NOGLYPH_ASSIGNED_YET   USHRT_MAX

Definition at line 44 of file ttf2afm.c.

◆ pdftex_fail

#define pdftex_fail   ttf_fail

Definition at line 48 of file ttf2afm.c.

◆ print_dimen

#define print_dimen (   N)    if (N != 0) fprintf(outfile, #N " %i\n", (int)get_ttf_funit(N))

Definition at line 51 of file ttf2afm.c.

◆ print_str

#define print_str (   S)    if (S != NULL) fprintf(outfile, #S " %s\n", escape_eol(S))

Definition at line 50 of file ttf2afm.c.

◆ VERSION

#define VERSION   "1.02"

Definition at line 41 of file ttf2afm.c.

Typedef Documentation

◆ kern_entry

typedef struct _kern_entry kern_entry

◆ unicode_entry

typedef struct _unicode_entry unicode_entry

Function Documentation

◆ append_unicode()

static void append_unicode ( long  glyph_index,
TTF_USHORT  code 
)
static

Definition at line 325 of file ttf2afm.c.

References assert(), code, glyph_index, m, mtx_tab, nglyphs, NULL, u, v, and xtalloc.

Referenced by read_cmap().

◆ enc_getline()

static void enc_getline ( void  )
static

Definition at line 262 of file ttf2afm.c.

References append_char_to_buf, append_eol, c, ENC_BUF_SIZE, enc_eof, enc_getchar, enc_line, p, and ttf_fail().

Referenced by read_encoding().

◆ escape_eol()

static char* escape_eol ( char *  s)
static

Definition at line 786 of file ttf2afm.c.

References d, dest, e, NULL, p, s, strend, strlen(), and xtalloc.

◆ free_tabs()

static void free_tabs ( void  )
static

Definition at line 230 of file ttf2afm.c.

References cmap_tab, dir_tab, enc_names, free, i, kern_tab, mtx_tab, nglyphs, notdef, NULL, p, ps_glyphs_buf, q, r, u, mtx_entry::unicode_list, v, and xfree.

Referenced by main().

◆ main()

◆ make_name()

static char* make_name ( long  platform_id,
int  len 
)
static

Definition at line 429 of file ttf2afm.c.

References buf, get_char, i, len, p, ttf_warn(), and xstrdup.

Referenced by read_font().

◆ name_lookup()

static dirtab_entry* name_lookup ( const char *  s)
static

Definition at line 182 of file ttf2afm.c.

References dir_tab, ntabs, NULL, p, s, and strncmp().

Referenced by read_font(), and ttf_seek_tab().

◆ null_glyph()

static int null_glyph ( const char *  s)
static

Definition at line 716 of file ttf2afm.c.

References notdef, NULL, and s.

Referenced by print_glyph_name().

◆ print_afm()

◆ print_char_metric()

static void print_char_metric ( FILE f,
int  charcode,
long  glyph_index 
)
static

Definition at line 773 of file ttf2afm.c.

References assert(), f, fprintf, get_ttf_funit, glyph_index, mtx_tab, nglyphs, print_glyph, print_glyph_name(), and wx.

Referenced by print_afm().

◆ print_encoding()

◆ print_glyph_name()

◆ read_cmap()

◆ read_encoding()

static void read_encoding ( char *  encname)
static

◆ read_font()

◆ store_kern_value()

static void store_kern_value ( TTF_USHORT  i,
TTF_USHORT  j,
TTF_FWORD  v 
)
static

Definition at line 208 of file ttf2afm.c.

References _kern_entry::adjacent, i, j, kern_tab, _kern_entry::next, NULL, v, _kern_entry::value, and xtalloc.

Referenced by read_font().

◆ ttf_fail()

static void ttf_fail ( const char *  fmt,
  ... 
)
static

◆ ttf_getnum()

static long ttf_getnum ( int  s)
static

Definition at line 169 of file ttf2afm.c.

References c, fontfile, i, s, ttf_fail(), and xgetc().

Referenced by writetype0().

◆ ttf_seek_off()

static void ttf_seek_off ( const char *  name,
TTF_LONG  offset 
)
static

Definition at line 202 of file ttf2afm.c.

References fontfile, fseek, name, offset, SEEK_SET, and ttf_fail().

Referenced by print_encoding(), read_cmap(), and read_font().

◆ ttf_seek_tab()

static void ttf_seek_tab ( const char *  name,
TTF_LONG  offset 
)
static

Definition at line 193 of file ttf2afm.c.

References fontfile, fseek, name, name_lookup(), NULL, offset, p, SEEK_SET, and ttf_fail().

Referenced by read_cmap(), read_font(), and writetype0().

◆ ttf_warn()

static void ttf_warn ( const char *  fmt,
  ... 
)
static

◆ usage()

static void usage ( void  )
static

Definition at line 1036 of file ttf2afm.c.

References _exit(), cur_file_name, fprintf, and NULL.

Referenced by main().

◆ xgetc()

static int xgetc ( FILE stream)
static

Definition at line 161 of file ttf2afm.c.

References c, EOF, getc, and ttf_fail().

Referenced by ttf_getnum().

Variable Documentation

◆ Ascender

TTF_LONG Ascender = 0

Definition at line 95 of file ttf2afm.c.

Referenced by print_afm(), read_font(), and tt_face_load_hhea().

◆ bname

char* bname = NULL

Definition at line 99 of file ttf2afm.c.

Referenced by comp_bfname(), if(), main(), mrb_file_basename(), and print_encoding().

◆ CapHeight

TTF_LONG CapHeight = 0

Definition at line 93 of file ttf2afm.c.

Referenced by print_afm(), read_font(), and tt_face_load_pclt().

◆ cmap_offset

long cmap_offset

Definition at line 125 of file ttf2afm.c.

Referenced by print_encoding(), read_cmap(), and ttf_read_cmap().

◆ cmap_tab

cmap_entry* cmap_tab

Definition at line 123 of file ttf2afm.c.

Referenced by free_tabs(), print_encoding(), and read_cmap().

◆ cur_file_name

char* cur_file_name = NULL

Definition at line 98 of file ttf2afm.c.

Referenced by main(), read_cmap(), read_encoding(), read_font(), ttf_fail(), ttf_warn(), and usage().

◆ Descender

TTF_LONG Descender = 0

Definition at line 96 of file ttf2afm.c.

Referenced by print_afm(), read_font(), and tt_face_load_hhea().

◆ dir_tab

dirtab_entry* dir_tab

Definition at line 118 of file ttf2afm.c.

Referenced by free_tabs(), name_lookup(), read_font(), and writetype0().

◆ enc_line

char enc_line[1024]

Definition at line 101 of file ttf2afm.c.

Referenced by enc_getline(), and read_encoding().

◆ enc_names

char* enc_names[256]

Definition at line 121 of file ttf2afm.c.

Referenced by free_tabs(), print_afm(), and read_encoding().

◆ encfile

◆ FamilyName

char* FamilyName = NULL

Definition at line 81 of file ttf2afm.c.

Referenced by main(), print_afm(), and read_font().

◆ FontBBox1

TTF_LONG FontBBox1 = 0

Definition at line 87 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ FontBBox2

TTF_LONG FontBBox2 = 0

Definition at line 88 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ FontBBox3

TTF_LONG FontBBox3 = 0

Definition at line 89 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ FontBBox4

TTF_LONG FontBBox4 = 0

Definition at line 90 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ fontfile

◆ FontName

char* FontName = NULL

Definition at line 79 of file ttf2afm.c.

Referenced by main(), print_afm(), and read_font().

◆ FullName

char* FullName = NULL

Definition at line 80 of file ttf2afm.c.

Referenced by main(), print_afm(), and read_font().

◆ IsFixedPitch

TTF_LONG IsFixedPitch = 0

Definition at line 86 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ ItalicAngle

TTF_LONG ItalicAngle = 0

Definition at line 85 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ kern_tab

kern_entry* kern_tab

Definition at line 120 of file ttf2afm.c.

Referenced by free_tabs(), print_afm(), read_font(), and store_kern_value().

◆ loca_format

int loca_format

Definition at line 113 of file ttf2afm.c.

Referenced by read_font().

◆ mtx_tab

◆ names_count

int names_count = 0

Definition at line 116 of file ttf2afm.c.

Referenced by load_enc(), load_enc_file(), print_afm(), and read_encoding().

◆ ncmapsubtabs

TTF_USHORT ncmapsubtabs

Definition at line 124 of file ttf2afm.c.

Referenced by print_encoding(), read_cmap(), and ttf_read_cmap().

◆ nglyphs

◆ nhmtx

int nhmtx

Definition at line 111 of file ttf2afm.c.

Referenced by read_font().

◆ nkernpairs

int nkernpairs = 0

Definition at line 115 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ Notice

char* Notice = NULL

Definition at line 82 of file ttf2afm.c.

Referenced by main(), print_afm(), and read_font().

◆ ntabs

TTF_USHORT ntabs

Definition at line 110 of file ttf2afm.c.

Referenced by name_lookup(), and read_font().

◆ outfile

FILE * outfile = NULL

Definition at line 100 of file ttf2afm.c.

Referenced by main(), and print_afm().

◆ post_format

int post_format

Definition at line 112 of file ttf2afm.c.

Referenced by read_font().

◆ print_cmap

static void print_cmap = 0

Definition at line 103 of file ttf2afm.c.

Referenced by main().

◆ print_glyph

int print_glyph = 0

Definition at line 102 of file ttf2afm.c.

Referenced by main(), print_afm(), print_char_metric(), print_encoding(), and read_font().

◆ printing_enc

int printing_enc = 0

Definition at line 106 of file ttf2afm.c.

Referenced by print_encoding(), and print_glyph_name().

◆ ps_glyphs_buf

char* ps_glyphs_buf = NULL

Definition at line 117 of file ttf2afm.c.

Referenced by free_tabs(), and read_font().

◆ select_unicode

int select_unicode = 1

Definition at line 105 of file ttf2afm.c.

Referenced by main(), and read_cmap().

◆ UnderlinePosition

TTF_LONG UnderlinePosition = 0

Definition at line 91 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ UnderlineThickness

TTF_LONG UnderlineThickness = 0

Definition at line 92 of file ttf2afm.c.

Referenced by print_afm(), and read_font().

◆ unicode_map

TTF_USHORT unicode_map[0xFFFF]

Definition at line 127 of file ttf2afm.c.

Referenced by print_afm(), and read_cmap().

◆ upem

◆ use_ext_enc

int use_ext_enc = 0

Definition at line 104 of file ttf2afm.c.

Referenced by main(), and print_afm().

◆ Version

char* Version = NULL

Definition at line 83 of file ttf2afm.c.

Referenced by main(), print_afm(), and read_font().

◆ Weight

char* Weight = NULL

Definition at line 84 of file ttf2afm.c.

Referenced by main(), print_afm(), and read_font().

◆ XHeight

TTF_LONG XHeight = 0

Definition at line 94 of file ttf2afm.c.

Referenced by print_afm(), and read_font().