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)  

maxp.c
Go to the documentation of this file.
1 #include "maxp.h"
2 
3 #include "support/util.h"
4 
5 static INLINE void initMaxp(table_maxp *maxp) {
6  memset(maxp, 0, sizeof(*maxp));
7  maxp->version = 0x10000;
8 }
10  // trivial
11 }
13 
15  FOR_TABLE(OTFCC_CHR('m','a','x','p'), table) {
17  uint32_t length = table.length;
18 
19  if (length != 32 && length != 6) {
20  logWarning("table 'maxp' corrupted.\n");
21  } else {
22  table_maxp *maxp = table_iMaxp.create();
24  maxp->numGlyphs = read_16u(data + 4);
25  if (maxp->version == 0x00010000) { // TrueType Format 1
26  maxp->maxPoints = read_16u(data + 6);
27  maxp->maxContours = read_16u(data + 8);
28  maxp->maxCompositePoints = read_16u(data + 10);
29  maxp->maxCompositeContours = read_16u(data + 12);
30  maxp->maxZones = read_16u(data + 14);
31  maxp->maxTwilightPoints = read_16u(data + 16);
32  maxp->maxStorage = read_16u(data + 18);
33  maxp->maxFunctionDefs = read_16u(data + 20);
34  maxp->maxInstructionDefs = read_16u(data + 22);
35  maxp->maxStackElements = read_16u(data + 24);
36  maxp->maxSizeOfInstructions = read_16u(data + 26);
37  maxp->maxComponentElements = read_16u(data + 28);
38  maxp->maxComponentDepth = read_16u(data + 30);
39  } else { // CFF OTF Format 0.5
40  maxp->maxPoints = 0;
41  maxp->maxContours = 0;
42  maxp->maxCompositePoints = 0;
43  maxp->maxCompositeContours = 0;
44  maxp->maxZones = 0;
45  maxp->maxTwilightPoints = 0;
46  maxp->maxStorage = 0;
47  maxp->maxFunctionDefs = 0;
48  maxp->maxInstructionDefs = 0;
49  maxp->maxStackElements = 0;
50  maxp->maxSizeOfInstructions = 0;
51  maxp->maxComponentElements = 0;
52  maxp->maxComponentDepth = 0;
53  }
54  return maxp;
55  }
56  }
57  return NULL;
58 }
59 
61  if (!table) return;
62  loggedStep("maxp") {
65  json_object_push(maxp, "numGlyphs", json_integer_new(table->numGlyphs));
66  json_object_push(maxp, "maxPoints", json_integer_new(table->maxPoints));
67  json_object_push(maxp, "maxContours", json_integer_new(table->maxContours));
68  json_object_push(maxp, "maxCompositePoints", json_integer_new(table->maxCompositePoints));
69  json_object_push(maxp, "maxCompositeContours",
70  json_integer_new(table->maxCompositeContours));
71  json_object_push(maxp, "maxZones", json_integer_new(table->maxZones));
72  json_object_push(maxp, "maxTwilightPoints", json_integer_new(table->maxTwilightPoints));
73  json_object_push(maxp, "maxStorage", json_integer_new(table->maxStorage));
74  json_object_push(maxp, "maxFunctionDefs", json_integer_new(table->maxFunctionDefs));
75  json_object_push(maxp, "maxInstructionDefs", json_integer_new(table->maxInstructionDefs));
76  json_object_push(maxp, "maxStackElements", json_integer_new(table->maxStackElements));
77  json_object_push(maxp, "maxSizeOfInstructions",
78  json_integer_new(table->maxSizeOfInstructions));
79  json_object_push(maxp, "maxComponentElements",
80  json_integer_new(table->maxComponentElements));
81  json_object_push(maxp, "maxComponentDepth", json_integer_new(table->maxComponentDepth));
82  json_object_push(root, "maxp", maxp);
83  }
84 }
85 
87  table_maxp *maxp = table_iMaxp.create();
89  if ((table = json_obj_get_type(root, "maxp", json_object))) {
90  loggedStep("maxp") {
92  maxp->numGlyphs = json_obj_getnum(table, "numGlyphs");
93  maxp->maxZones = json_obj_getnum(table, "maxZones");
94  maxp->maxTwilightPoints = json_obj_getnum(table, "maxTwilightPoints");
95  maxp->maxStorage = json_obj_getnum(table, "maxStorage");
96  maxp->maxFunctionDefs = json_obj_getnum(table, "maxFunctionDefs");
97  maxp->maxInstructionDefs = json_obj_getnum(table, "maxInstructionDefs");
98  maxp->maxStackElements = json_obj_getnum(table, "maxStackElements");
99  }
100  }
101  return maxp;
102 }
103 
105  if (!maxp) return NULL;
106  caryll_Buffer *buf = bufnew();
109  if (maxp->version > 0x00005000) {
112  bufwrite16b(buf, maxp->maxCompositePoints);
113  bufwrite16b(buf, maxp->maxCompositeContours);
115  bufwrite16b(buf, maxp->maxTwilightPoints);
117  bufwrite16b(buf, maxp->maxFunctionDefs);
118  bufwrite16b(buf, maxp->maxInstructionDefs);
119  bufwrite16b(buf, maxp->maxStackElements);
120  bufwrite16b(buf, maxp->maxSizeOfInstructions);
121  bufwrite16b(buf, maxp->maxComponentElements);
122  bufwrite16b(buf, maxp->maxComponentDepth);
123  }
124  return buf;
125 }
static uint16_t read_16u(const uint8_t *src)
Definition: bin-io.h:121
static int32_t read_32s(const uint8_t *src)
Definition: bin-io.h:156
#define OTFCC_CHR(a, b, c, d)
Definition: caryll-font.c:7
struct rect data
Definition: dvipdfm.c:64
table_iMaxp
Definition: glyf.d:17931
json_value * json_object_push(json_value *object, const char *name, json_value *)
json_value * json_integer_new(int64_t)
json_value * json_object_new(size_t length)
json_value * json_double_new(double)
static double json_obj_getnum(const json_value *obj, const char *key)
Definition: json-funcs.h:81
static json_value * json_obj_get_type(const json_value *obj, const char *key, const json_type type)
Definition: json-funcs.h:34
#define NULL
Definition: ftobjs.h:61
unsigned int uint32_t
Definition: stdint.h:80
#define INLINE
Definition: port.h:26
#define buf
#define length(c)
Definition: ctangleboot.c:65
#define root
Definition: ctangleboot.c:69
#define logWarning(...)
Definition: aliases.h:14
uint8_t * font_file_pointer
Definition: aliases.h:41
#define FOR_TABLE(name, table)
Definition: aliases.h:33
#define loggedStep(...)
Definition: aliases.h:6
@ MOVE
Definition: pl-parser.h:87
double otfcc_from_fixed(const f16dot16 x)
Definition: primitives.c:14
f16dot16 otfcc_to_fixed(const double x)
Definition: primitives.c:17
bstring c int memset(void *s, int c, int length)
void bufwrite32b(caryll_Buffer *buf, uint32_t x)
Definition: buffer.c:82
void bufwrite16b(caryll_Buffer *buf, uint16_t x)
Definition: buffer.c:58
caryll_Buffer * bufnew(void)
Definition: buffer.c:4
@ json_object
Definition: json.h:85
static INLINE void initMaxp(table_maxp *maxp)
Definition: maxp.c:5
caryll_Buffer * otfcc_buildMaxp(const table_maxp *maxp, const otfcc_Options *options)
Definition: maxp.c:104
void otfcc_dumpMaxp(const table_maxp *table, json_value *root, const otfcc_Options *options)
Definition: maxp.c:60
static INLINE void disposeMaxp(MOVE table_maxp *maxp)
Definition: maxp.c:9
caryll_standardRefType(table_maxp, table_iMaxp, initMaxp, disposeMaxp)
table_maxp * otfcc_readMaxp(const otfcc_Packet packet, const otfcc_Options *options)
Definition: maxp.c:14
table_maxp * otfcc_parseMaxp(const json_value *root, const otfcc_Options *options)
Definition: maxp.c:86
Definition: ttf.h:413
uint16 maxZones
Definition: ttf.h:420
int32 version
Definition: ttf.h:414
uint16 maxStorage
Definition: ttf.h:422
uint16 maxPoints
Definition: ttf.h:416
uint16 numGlyphs
Definition: ttf.h:415
uint16 maxContours
Definition: ttf.h:417
Definition: maxp.h:6
Definition: table.h:30