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)  

gasp.c
Go to the documentation of this file.
1 #include "gasp.h"
2 
3 #include "support/util.h"
4 
5 
6 #define GASP_DOGRAY 0x0002
7 #define GASP_GRIDFIT 0x0001
8 #define GASP_SYMMETRIC_GRIDFIT 0x0004
9 #define GASP_SYMMETRIC_SMOOTHING 0x0008
10 
13 
14 static INLINE void initGasp(table_gasp *gasp) {
15  gasp->version = 1;
16  gasp_iRecordList.init(&gasp->records);
17 }
19  gasp_iRecordList.dispose(&gasp->records);
20 }
21 
23 
25  table_gasp *gasp = NULL;
26  FOR_TABLE(OTFCC_CHR('g','a','s','p'), table) {
28  uint32_t length = table.length;
29  if (length < 4) { goto FAIL; }
30  gasp = table_iGasp.create();
31  gasp->version = read_16u(data);
32  tableid_t numRanges = read_16u(data + 2);
33  if (length < 4 + numRanges * 4) { goto FAIL; }
34 
35  for (uint32_t j = 0; j < numRanges; j++) {
36  gasp_Record record;
37  record.rangeMaxPPEM = read_16u(data + 4 + j * 4);
38  uint16_t rangeGaspBehavior = read_16u(data + 4 + j * 4 + 2);
39  record.dogray = !!(rangeGaspBehavior & GASP_DOGRAY);
40  record.gridfit = !!(rangeGaspBehavior & GASP_GRIDFIT);
41  record.symmetric_smoothing = !!(rangeGaspBehavior & GASP_SYMMETRIC_SMOOTHING);
42  record.symmetric_gridfit = !!(rangeGaspBehavior & GASP_SYMMETRIC_GRIDFIT);
43  gasp_iRecordList.push(&gasp->records, record);
44  }
45  return gasp;
46 
47  FAIL:
48  logWarning("table 'gasp' corrupted.\n");
49  table_iGasp.free(gasp);
50  gasp = NULL;
51  }
52  return NULL;
53 }
55  if (!table) return;
56  loggedStep("gasp") {
57  json_value *t = json_array_new(table->records.length);
58  for (uint16_t j = 0; j < table->records.length; j++) {
59  json_value *rec = json_object_new(5);
60  json_object_push(rec, "rangeMaxPPEM",
61  json_integer_new(table->records.items[j].rangeMaxPPEM));
62  json_object_push(rec, "dogray", json_boolean_new(table->records.items[j].dogray));
63  json_object_push(rec, "gridfit", json_boolean_new(table->records.items[j].gridfit));
64  json_object_push(rec, "symmetric_smoothing",
65  json_boolean_new(table->records.items[j].symmetric_smoothing));
66  json_object_push(rec, "symmetric_gridfit",
67  json_boolean_new(table->records.items[j].symmetric_gridfit));
68  json_array_push(t, rec);
69  }
70  json_object_push(root, "gasp", t);
71  }
72 }
73 
75  table_gasp *gasp = NULL;
77  if ((table = json_obj_get_type(root, "gasp", json_array))) {
78  loggedStep("gasp") {
79  gasp = table_iGasp.create();
80  for (uint16_t j = 0; j < table->u.array.length; j++) {
81  json_value *r = table->u.array.values[j];
82  if (!r || r->type != json_object) continue;
83  gasp_Record record;
84  record.rangeMaxPPEM = json_obj_getint_fallback(r, "rangeMaxPPEM", 0xFFFF);
85  record.dogray = json_obj_getbool(r, "dogray");
86  record.gridfit = json_obj_getbool(r, "gridfit");
87  record.symmetric_smoothing = json_obj_getbool(r, "symmetric_smoothing");
88  record.symmetric_gridfit = json_obj_getbool(r, "symmetric_gridfit");
89  gasp_iRecordList.push(&gasp->records, record);
90  }
91  }
92  }
93  return gasp;
94 }
95 
97  if (!gasp) return NULL;
99  bufwrite16b(buf, 1);
100  bufwrite16b(buf, gasp->records.length);
101  for (uint16_t j = 0; j < gasp->records.length; j++) {
102  gasp_Record *r = &(gasp->records.items[j]);
103  bufwrite16b(buf, r->rangeMaxPPEM);
104  bufwrite16b(buf, (r->dogray ? GASP_DOGRAY : 0) | (r->gridfit ? GASP_GRIDFIT : 0) |
105  (r->symmetric_gridfit ? GASP_SYMMETRIC_GRIDFIT : 0) |
106  (r->symmetric_smoothing ? GASP_SYMMETRIC_SMOOTHING : 0));
107  }
108  return buf;
109 }
static uint16_t read_16u(const uint8_t *src)
Definition: bin-io.h:121
#define OTFCC_CHR(a, b, c, d)
Definition: caryll-font.c:7
struct rect data
Definition: dvipdfm.c:64
table_iGasp
Definition: gasp.d:17892
gasp_iRecord
Definition: gasp.d:17883
gasp_iRecordList
Definition: gasp.d:17885
json_value * json_boolean_new(int)
json_value * json_array_new(size_t length)
json_value * json_array_push(json_value *array, json_value *)
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)
static int32_t json_obj_getint_fallback(const json_value *obj, const char *key, int32_t fallback)
Definition: json-funcs.h:118
static json_value * json_obj_get_type(const json_value *obj, const char *key, const json_type type)
Definition: json-funcs.h:34
static bool json_obj_getbool(const json_value *obj, const char *key)
Definition: json-funcs.h:135
#define NULL
Definition: ftobjs.h:61
unsigned short uint16_t
Definition: stdint.h:79
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
int r
Definition: ppmqvga.c:68
uint16_t tableid_t
Definition: primitives.h:17
void bufwrite16b(caryll_Buffer *buf, uint16_t x)
Definition: buffer.c:58
caryll_Buffer * bufnew(void)
Definition: buffer.c:4
@ json_array
Definition: json.h:86
@ json_object
Definition: json.h:85
table_gasp * otfcc_parseGasp(const json_value *root, const otfcc_Options *options)
Definition: gasp.c:74
caryll_standardType(gasp_Record, gasp_iRecord)
caryll_standardRefType(table_gasp, table_iGasp, initGasp, disposeGasp)
#define GASP_SYMMETRIC_GRIDFIT
Definition: gasp.c:8
void otfcc_dumpGasp(const table_gasp *table, json_value *root, const otfcc_Options *options)
Definition: gasp.c:54
caryll_standardVectorImpl(gasp_RecordList, gasp_Record, gasp_iRecord, gasp_iRecordList)
static INLINE void initGasp(table_gasp *gasp)
Definition: gasp.c:14
#define GASP_DOGRAY
Definition: gasp.c:6
#define GASP_GRIDFIT
Definition: gasp.c:7
#define GASP_SYMMETRIC_SMOOTHING
Definition: gasp.c:9
caryll_Buffer * otfcc_buildGasp(const table_gasp *gasp, const otfcc_Options *options)
Definition: gasp.c:96
table_gasp * otfcc_readGasp(const otfcc_Packet packet, const otfcc_Options *options)
Definition: gasp.c:24
static INLINE void disposeGasp(MOVE table_gasp *gasp)
Definition: gasp.c:18
glyphsize_t rangeMaxPPEM
Definition: gasp.h:7
bool gridfit
Definition: gasp.h:9
bool dogray
Definition: gasp.h:8
bool symmetric_smoothing
Definition: gasp.h:10
bool symmetric_gridfit
Definition: gasp.h:11
Definition: dvips.h:235
Definition: table.h:30
int j
Definition: t4ht.c:1589
#define FAIL(ec)