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)  

caryll-sfnt.c
Go to the documentation of this file.
1 #include "support/util.h"
2 #include "otfcc/sfnt.h"
3 
4 #define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
5 
7  for (uint32_t count = 0; count < font->count; count++) {
8  (void)fseek(file, font->offsets[count], SEEK_SET);
9 
10  font->packets[count].sfnt_version = otfcc_get32u(file);
11  font->packets[count].numTables = otfcc_get16u(file);
12  font->packets[count].searchRange = otfcc_get16u(file);
13  font->packets[count].entrySelector = otfcc_get16u(file);
14  font->packets[count].rangeShift = otfcc_get16u(file);
15  NEW(font->packets[count].pieces, font->packets[count].numTables);
16 
17  for (uint32_t i = 0; i < font->packets[count].numTables; i++) {
18  font->packets[count].pieces[i].tag = otfcc_get32u(file);
19  font->packets[count].pieces[i].checkSum = otfcc_get32u(file);
20  font->packets[count].pieces[i].offset = otfcc_get32u(file);
21  font->packets[count].pieces[i].length = otfcc_get32u(file);
22  NEW(font->packets[count].pieces[i].data, font->packets[count].pieces[i].length);
23  }
24 
25  for (uint32_t i = 0; i < font->packets[0].numTables; i++) {
26  (void)fseek(file, font->packets[count].pieces[i].offset, SEEK_SET);
27  (void)fread(font->packets[count].pieces[i].data, font->packets[count].pieces[i].length,
28  1, file);
29  }
30  }
31 }
32 
34  if (!file) return NULL;
36  NEW(font);
37 
38  font->type = otfcc_get32u(file);
39 
40  switch (font->type) {
41  case OTFCC_CHR('O','T','T','O'):
42  case 0x00010000:
43  case OTFCC_CHR('t','r','u','e'):
44  case OTFCC_CHR('t','y','p','1'):
45  font->count = 1;
46  NEW(font->offsets, font->count);
47  NEW(font->packets, font->count);
48  font->offsets[0] = 0;
50  break;
51 
52  case OTFCC_CHR('t','t','c','f'):
54  font->count = otfcc_get32u(file);
55  NEW(font->offsets, font->count);
56  NEW(font->packets, font->count);
57 
58  for (uint32_t i = 0; i < font->count; i++) {
59  font->offsets[i] = otfcc_get32u(file);
60  }
61 
63  break;
64 
65  default:
66  font->count = 0;
67  font->offsets = NULL;
68  font->packets = NULL;
69  break;
70  }
71 
72  fclose(file);
73 
74  return font;
75 }
76 
78  if (!font) return;
79  if (font->count > 0) {
80  for (uint32_t count = 0; count < font->count; count++) {
81  for (int i = 0; i < font->packets[count].numTables; i++) {
82  FREE(font->packets[count].pieces[i].data);
83  }
84  FREE(font->packets[count].pieces);
85  }
86  FREE(font->packets);
87  }
88  FREE(font->offsets);
89  FREE(font);
90 }
#define font
Definition: aptex-macros.h:175
#define count(a)
Definition: aptex-macros.h:781
static uint32_t otfcc_get32u(FILE *file)
Definition: bin-io.h:97
static uint16_t otfcc_get16u(FILE *file)
Definition: bin-io.h:87
#define OTFCC_CHR(a, b, c, d)
Definition: caryll-sfnt.c:4
static void otfcc_read_packets(otfcc_SplineFontContainer *font, FILE *file)
Definition: caryll-sfnt.c:6
otfcc_SplineFontContainer * otfcc_readSFNT(FILE *file)
Definition: caryll-sfnt.c:33
void otfcc_deleteSFNT(otfcc_SplineFontContainer *font)
Definition: caryll-sfnt.c:77
#define fread
Definition: xxstdio.h:25
#define fseek
Definition: xxstdio.h:30
static void
Definition: fpif.c:118
const unsigned char FREE
Definition: image.cpp:34
#define SEEK_SET
Definition: jmemansi.c:26
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
#define NEW
Definition: gdkanji.c:77
unsigned int uint32_t
Definition: stdint.h:80
#define fclose
Definition: debug.h:100
Definition: filedef.h:30
Definition: pbmfont.h:11
#define FILE
Definition: t1stdio.h:34