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)  

vhea.c
Go to the documentation of this file.
1 #include "vhea.h"
2 
3 #include "support/util.h"
4 
5 static INLINE void initVhea(table_vhea *vhea) {
6  memset(vhea, 0, sizeof(*vhea));
7  vhea->version = 0x10000;
8 }
9 static INLINE void disposeVhea(MOVE table_vhea *vhea) {
10  // trivial
11 }
13 
15  table_vhea *vhea = NULL;
16  FOR_TABLE(OTFCC_CHR('v','h','e','a'), table) {
18  size_t length = table.length;
19  if (length >= 36) {
20  NEW(vhea);
21  vhea->version = read_32s(data);
22  vhea->ascent = read_16s(data + 4);
23  vhea->descent = read_16s(data + 6);
24  vhea->lineGap = read_16s(data + 8);
25  vhea->advanceHeightMax = read_16s(data + 10);
26  vhea->minTop = read_16s(data + 12);
27  vhea->minBottom = read_16s(data + 14);
28  vhea->yMaxExtent = read_16s(data + 16);
29  vhea->caretSlopeRise = read_16s(data + 18);
30  vhea->caretSlopeRun = read_16s(data + 20);
31  vhea->caretOffset = read_16s(data + 22);
32  vhea->dummy0 = 0;
33  vhea->dummy1 = 0;
34  vhea->dummy2 = 0;
35  vhea->dummy3 = 0;
36  vhea->metricDataFormat = 0;
37  vhea->numOfLongVerMetrics = read_16u(data + 34);
38  return vhea;
39  } else {
40  logWarning("Table 'vhea' corrupted.")
41  }
42  }
43  return NULL;
44 }
46  if (!table) return;
47  json_value *vhea = json_object_new(11);
48  loggedStep("vhea") {
49  json_object_push(vhea, "version", json_double_new(otfcc_from_fixed(table->version)));
50  json_object_push(vhea, "ascent", json_integer_new(table->ascent));
51  json_object_push(vhea, "descent", json_integer_new(table->descent));
52  json_object_push(vhea, "lineGap", json_integer_new(table->lineGap));
53  json_object_push(vhea, "advanceHeightMax", json_integer_new(table->advanceHeightMax));
54  json_object_push(vhea, "minTop", json_integer_new(table->minTop));
55  json_object_push(vhea, "minBottom", json_integer_new(table->minBottom));
56  json_object_push(vhea, "yMaxExtent", json_integer_new(table->yMaxExtent));
57  json_object_push(vhea, "caretSlopeRise", json_integer_new(table->caretSlopeRise));
58  json_object_push(vhea, "caretSlopeRun", json_integer_new(table->caretSlopeRun));
59  json_object_push(vhea, "caretOffset", json_integer_new(table->caretOffset));
60  json_object_push(root, "vhea", vhea);
61  }
62 }
63 
65  table_vhea *vhea = NULL;
67  if ((table = json_obj_get_type(root, "vhea", json_object))) {
68  vhea = table_iVhea.create();
69  if (!vhea) return NULL;
70  loggedStep("vhea") {
71  vhea->version = otfcc_to_fixed(json_obj_getnum(table, "version"));
72  vhea->ascent = json_obj_getnum_fallback(table, "ascent", 0);
73  vhea->descent = json_obj_getnum_fallback(table, "descent", 0);
74  vhea->lineGap = json_obj_getnum_fallback(table, "lineGap", 0);
75  vhea->advanceHeightMax = json_obj_getnum_fallback(table, "advanceHeightMax", 0);
76  vhea->minTop = json_obj_getnum_fallback(table, "minTop", 0);
77  vhea->minBottom = json_obj_getnum_fallback(table, "minBottom", 0);
78  vhea->yMaxExtent = json_obj_getnum_fallback(table, "yMaxExtent", 0);
79  vhea->caretSlopeRise = json_obj_getnum_fallback(table, "caretSlopeRise", 0);
80  vhea->caretSlopeRun = json_obj_getnum_fallback(table, "caretSlopeRun", 0);
81  vhea->caretOffset = json_obj_getnum_fallback(table, "caretOffset", 0);
82  }
83  }
84  return vhea;
85 }
86 
88  if (!vhea) return NULL;
90  bufwrite32b(buf, vhea->version);
91  bufwrite16b(buf, vhea->ascent);
92  bufwrite16b(buf, vhea->descent);
93  bufwrite16b(buf, vhea->lineGap);
95  bufwrite16b(buf, vhea->minTop);
96  bufwrite16b(buf, vhea->minBottom);
97  bufwrite16b(buf, vhea->yMaxExtent);
100  bufwrite16b(buf, vhea->caretOffset);
101  bufwrite16b(buf, 0);
102  bufwrite16b(buf, 0);
103  bufwrite16b(buf, 0);
104  bufwrite16b(buf, 0);
105  bufwrite16b(buf, 0);
107  return buf;
108 }
static uint16_t read_16u(const uint8_t *src)
Definition: bin-io.h:121
static int16_t read_16s(const uint8_t *src)
Definition: bin-io.h:153
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 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
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
#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
caryll_standardRefType(table_vhea, table_iVhea, initVhea, disposeVhea)
table_vhea * otfcc_parseVhea(const json_value *root, const otfcc_Options *options)
Definition: vhea.c:64
caryll_Buffer * otfcc_buildVhea(const table_vhea *vhea, const otfcc_Options *options)
Definition: vhea.c:87
void otfcc_dumpVhea(const table_vhea *table, json_value *root, const otfcc_Options *options)
Definition: vhea.c:45
static INLINE void initVhea(table_vhea *vhea)
Definition: vhea.c:5
static INLINE void disposeVhea(MOVE table_vhea *vhea)
Definition: vhea.c:9
table_vhea * otfcc_readVhea(const otfcc_Packet packet, const otfcc_Options *options)
Definition: vhea.c:14
Definition: vhea.h:6
int16_t dummy2
Definition: vhea.h:20
int16_t caretOffset
Definition: vhea.h:17
int16_t caretSlopeRun
Definition: vhea.h:16
int16_t dummy1
Definition: vhea.h:19
int16_t caretSlopeRise
Definition: vhea.h:15
uint16_t numOfLongVerMetrics
Definition: vhea.h:23
int16_t advanceHeightMax
Definition: vhea.h:11
int16_t ascent
Definition: vhea.h:8
f16dot16 version
Definition: vhea.h:7
int16_t minBottom
Definition: vhea.h:13
int16_t metricDataFormat
Definition: vhea.h:22
int16_t descent
Definition: vhea.h:9
int16_t lineGap
Definition: vhea.h:10
int16_t yMaxExtent
Definition: vhea.h:14
int16_t dummy3
Definition: vhea.h:21
int16_t dummy0
Definition: vhea.h:18
int16_t minTop
Definition: vhea.h:12
Definition: table.h:30