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)  

hhea.c
Go to the documentation of this file.
1 #include "hhea.h"
2 
3 #include "support/util.h"
4 
5 static INLINE void initHhea(table_hhea *hhea) {
6  memset(hhea, 0, sizeof(*hhea));
7  hhea->version = 0x10000;
8 }
9 static INLINE void disposeHhea(MOVE table_hhea *hhea) {
10  // trivial
11 }
13 
15  FOR_TABLE(OTFCC_CHR('h','h','e','a'), table) {
17  uint32_t length = table.length;
18 
19  if (length < 36) {
20  logWarning("table 'hhea' corrupted.\n");
21  } else {
22  table_hhea *hhea;
23  NEW(hhea);
24  hhea->version = read_32s(data);
25  hhea->ascender = read_16u(data + 4);
26  hhea->descender = read_16u(data + 6);
27  hhea->lineGap = read_16u(data + 8);
28  hhea->advanceWidthMax = read_16u(data + 10);
29  hhea->minLeftSideBearing = read_16u(data + 12);
30  hhea->minRightSideBearing = read_16u(data + 14);
31  hhea->xMaxExtent = read_16u(data + 16);
32  hhea->caretSlopeRise = read_16u(data + 18);
33  hhea->caretSlopeRun = read_16u(data + 20);
34  hhea->caretOffset = read_16u(data + 22);
35  hhea->reserved[0] = read_16u(data + 24);
36  hhea->reserved[1] = read_16u(data + 26);
37  hhea->reserved[2] = read_16u(data + 28);
38  hhea->reserved[3] = read_16u(data + 30);
39  hhea->metricDataFormat = read_16u(data + 32);
40  hhea->numberOfMetrics = read_16u(data + 34);
41  return hhea;
42  }
43  }
44  return NULL;
45 }
46 
48  if (!table) return;
49  loggedStep("hhea") {
50  json_value *hhea = json_object_new(13);
51  json_object_push(hhea, "version", json_double_new(otfcc_from_fixed(table->version)));
52  json_object_push(hhea, "ascender", json_integer_new(table->ascender));
53  json_object_push(hhea, "descender", json_integer_new(table->descender));
54  json_object_push(hhea, "lineGap", json_integer_new(table->lineGap));
55  json_object_push(hhea, "advanceWidthMax", json_integer_new(table->advanceWidthMax));
56  json_object_push(hhea, "minLeftSideBearing", json_integer_new(table->minLeftSideBearing));
57  json_object_push(hhea, "minRightSideBearing", json_integer_new(table->minRightSideBearing));
58  json_object_push(hhea, "xMaxExtent", json_integer_new(table->xMaxExtent));
59  json_object_push(hhea, "caretSlopeRise", json_integer_new(table->caretSlopeRise));
60  json_object_push(hhea, "caretSlopeRun", json_integer_new(table->caretSlopeRun));
61  json_object_push(hhea, "caretOffset", json_integer_new(table->caretOffset));
62  json_object_push(root, "hhea", hhea);
63  }
64 }
65 
67  table_hhea *hhea = table_iHhea.create();
69  if ((table = json_obj_get_type(root, "hhea", json_object))) {
70  loggedStep("hhea") {
71  hhea->version = otfcc_to_fixed(json_obj_getnum_fallback(table, "version", 0));
72  hhea->ascender = json_obj_getnum_fallback(table, "ascender", 0);
73  hhea->descender = json_obj_getnum_fallback(table, "descender", 0);
74  hhea->lineGap = json_obj_getnum_fallback(table, "lineGap", 0);
75  hhea->advanceWidthMax = json_obj_getnum_fallback(table, "advanceWidthMax", 0);
76  hhea->minLeftSideBearing = json_obj_getnum_fallback(table, "minLeftSideBearing", 0);
77  hhea->minRightSideBearing = json_obj_getnum_fallback(table, "minRightSideBearing", 0);
78  hhea->xMaxExtent = json_obj_getnum_fallback(table, "xMaxExtent", 0);
79  hhea->caretSlopeRise = json_obj_getnum_fallback(table, "caretSlopeRise", 0);
80  hhea->caretSlopeRun = json_obj_getnum_fallback(table, "caretSlopeRun", 0);
81  hhea->caretOffset = json_obj_getnum_fallback(table, "caretOffset", 0);
82  }
83  }
84  return hhea;
85 }
86 
88  if (!hhea) return NULL;
90  bufwrite32b(buf, hhea->version);
91  bufwrite16b(buf, hhea->ascender);
92  bufwrite16b(buf, hhea->descender);
93  bufwrite16b(buf, hhea->lineGap);
97  bufwrite16b(buf, hhea->xMaxExtent);
100  bufwrite16b(buf, hhea->caretOffset);
101  bufwrite16b(buf, hhea->reserved[0]);
102  bufwrite16b(buf, hhea->reserved[1]);
103  bufwrite16b(buf, hhea->reserved[2]);
104  bufwrite16b(buf, hhea->reserved[3]);
105  bufwrite16b(buf, 0);
107  return buf;
108 }
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
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 json_value * json_obj_get_type(const json_value *obj, const char *key, const json_type type)
Definition: json-funcs.h:34
static double json_obj_getnum_fallback(const json_value *obj, const char *key, double fallback)
Definition: json-funcs.h:105
#define NULL
Definition: ftobjs.h:61
#define NEW
Definition: gdkanji.c:77
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
void otfcc_dumpHhea(const table_hhea *table, json_value *root, const otfcc_Options *options)
Definition: hhea.c:47
table_hhea * otfcc_parseHhea(const json_value *root, const otfcc_Options *options)
Definition: hhea.c:66
static INLINE void disposeHhea(MOVE table_hhea *hhea)
Definition: hhea.c:9
caryll_standardRefType(table_hhea, table_iHhea, initHhea, disposeHhea)
caryll_Buffer * otfcc_buildHhea(const table_hhea *hhea, const otfcc_Options *options)
Definition: hhea.c:87
static INLINE void initHhea(table_hhea *hhea)
Definition: hhea.c:5
table_hhea * otfcc_readHhea(const otfcc_Packet packet, const otfcc_Options *options)
Definition: hhea.c:14
Definition: hhea.h:6
int16_t lineGap
Definition: hhea.h:11
uint16_t numberOfMetrics
Definition: hhea.h:21
uint16_t advanceWidthMax
Definition: hhea.h:12
int16_t descender
Definition: hhea.h:10
int16_t minRightSideBearing
Definition: hhea.h:14
int16_t xMaxExtent
Definition: hhea.h:15
int16_t minLeftSideBearing
Definition: hhea.h:13
f16dot16 version
Definition: hhea.h:8
int16_t caretSlopeRise
Definition: hhea.h:16
int16_t metricDataFormat
Definition: hhea.h:20
int16_t caretSlopeRun
Definition: hhea.h:17
int16_t reserved[4]
Definition: hhea.h:19
int16_t ascender
Definition: hhea.h:9
int16_t caretOffset
Definition: hhea.h:18
Definition: table.h:30