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)  

gpos-single.c
Go to the documentation of this file.
1 #include "gpos-single.h"
2 #include "gpos-common.h"
3 
5  Handle.dispose(&entry->target);
6 }
7 
9  .init = NULL, .copy = NULL, .dispose = deleteGposSingleEntry};
10 
13 
15  uint32_t offset, const glyphid_t maxGlyphs,
16  const otfcc_Options *options) {
17  subtable_gpos_single *subtable = iSubtable_gpos_single.create();
18  otl_Coverage *targets = NULL;
19 
20  checkLength(offset + 6);
21 
22  uint16_t subtableFormat = read_16u(data + offset);
23  targets = Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
24  if (!targets || targets->numGlyphs == 0) goto FAIL;
25 
26  if (subtableFormat == 1) {
28  read_gpos_value(data, tableLength, offset + 6, read_16u(data + offset + 4));
29  for (glyphid_t j = 0; j < targets->numGlyphs; j++) {
30  iSubtable_gpos_single.push(subtable,
32  .target = Handle.dup(targets->glyphs[j]), .value = v,
33  }));
34  }
35  } else {
36  uint16_t valueFormat = read_16u(data + offset + 4);
37  uint16_t valueCount = read_16u(data + offset + 6);
38  checkLength(offset + 8 + position_format_length(valueFormat) * valueCount);
39  if (valueCount != targets->numGlyphs) goto FAIL;
40 
41  for (glyphid_t j = 0; j < targets->numGlyphs; j++) {
43  subtable,
45  .target = Handle.dup(targets->glyphs[j]),
46  .value = read_gpos_value(data, tableLength,
47  offset + 8 + j * position_format_length(valueFormat),
48  valueFormat),
49  }));
50  }
51  }
52  if (targets) Coverage.free(targets);
53  return (otl_Subtable *)subtable;
54 
55 FAIL:
56  if (targets) Coverage.free(targets);
57  iSubtable_gpos_single.free(subtable);
58  return NULL;
59 }
60 
62  const subtable_gpos_single *subtable = &(_subtable->gpos_single);
63  json_value *st = json_object_new(subtable->length);
64  for (glyphid_t j = 0; j < subtable->length; j++) {
65  json_object_push(st, subtable->items[j].target.name,
66  gpos_dump_value(subtable->items[j].value));
67  }
68  return st;
69 }
71  subtable_gpos_single *subtable = iSubtable_gpos_single.create();
72  for (glyphid_t j = 0; j < _subtable->u.object.length; j++) {
73  if (_subtable->u.object.values[j].value &&
74  _subtable->u.object.values[j].value->type == json_object) {
75  sds gname = sdsnewlen(_subtable->u.object.values[j].name,
76  _subtable->u.object.values[j].name_length);
78  subtable, ((otl_GposSingleEntry){
79  .target = Handle.fromName(gname),
80  .value = gpos_parse_value(_subtable->u.object.values[j].value),
81  }));
82  }
83  }
84  return (otl_Subtable *)subtable;
85 }
86 
88  const subtable_gpos_single *subtable = &(_subtable->gpos_single);
89  bool isConst = subtable->length > 0;
90  uint16_t format = 0;
91  if (subtable->length > 0) {
92  for (glyphid_t j = 0; j < subtable->length; j++) {
93  isConst = isConst && (subtable->items[j].value.dx == subtable->items[0].value.dx) &&
94  (subtable->items[j].value.dy == subtable->items[0].value.dy) &&
95  (subtable->items[j].value.dWidth == subtable->items[0].value.dWidth) &&
96  (subtable->items[j].value.dHeight == subtable->items[0].value.dHeight);
98  }
99  }
100  otl_Coverage *cov = Coverage.create();
101  for (glyphid_t j = 0; j < subtable->length; j++) {
102  Coverage.push(cov, Handle.dup(subtable->items[j].target));
103  }
104 
105  caryll_Buffer *coverageBuf = Coverage.build(cov);
106 
107  if (isConst) {
108  bk_Block *b =
109  (bk_new_Block(b16, 1, // Format
110  p16, bk_newBlockFromBuffer(coverageBuf), // coverage
111  b16, format, // format
112  bkembed, bk_gpos_value(subtable->items[0].value, format), // value
113  bkover));
114  Coverage.free(cov);
115  return bk_build_Block(b);
116  } else {
117  bk_Block *b = bk_new_Block(b16, 2, // Format
118  p16, bk_newBlockFromBuffer(coverageBuf), // coverage
119  b16, format, // format
120  b16, subtable->length, // quantity
121  bkover);
122  for (glyphid_t k = 0; k < subtable->length; k++) {
123  bk_push(b, bkembed, bk_gpos_value(subtable->items[k].value, format), // value
124  bkover);
125  }
126  Coverage.free(cov);
127  return bk_build_Block(b);
128  }
129 }
static uint16_t read_16u(const uint8_t *src)
Definition: bin-io.h:121
bk_Block * bk_newBlockFromBuffer(MOVE caryll_Buffer *buf)
Definition: bkblock.c:98
bk_Block * bk_new_Block(int type0,...)
Definition: bkblock.c:72
bk_Block * bk_push(bk_Block *b, int type0,...)
Definition: bkblock.c:81
@ bkembed
Definition: bkblock.h:24
@ b16
Definition: bkblock.h:17
@ p16
Definition: bkblock.h:19
@ bkover
Definition: bkblock.h:15
caryll_Buffer * bk_build_Block(bk_Block *root)
Definition: bkgraph.c:396
#define b
Definition: jpegint.h:372
int v
Definition: dviconv.c:10
struct rect data
Definition: dvipdfm.c:64
uint8_t required_position_format(otl_PositionValue v)
Definition: gpos-common.c:195
json_value * gpos_dump_value(otl_PositionValue value)
Definition: gpos-common.c:177
otl_PositionValue read_gpos_value(font_file_pointer data, uint32_t tableLength, uint32_t offset, uint16_t format)
Definition: gpos-common.c:167
bk_Block * bk_gpos_value(otl_PositionValue v, uint16_t format)
Definition: gpos-common.c:207
otl_PositionValue gpos_parse_value(json_value *pos)
Definition: gpos-common.c:185
uint8_t position_format_length(uint16_t format)
Definition: gpos-common.c:159
json_value * json_object_push(json_value *object, const char *name, json_value *)
json_value * json_object_new(size_t length)
#define NULL
Definition: ftobjs.h:61
unsigned short uint16_t
Definition: stdint.h:79
unsigned int uint32_t
Definition: stdint.h:80
pdf_obj * entry
Definition: pdfdoc.c:64
#define Handle
Definition: aliases.h:45
uint8_t * font_file_pointer
Definition: aliases.h:41
#define Coverage
Definition: aliases.h:58
iSubtable_gpos_single
Definition: otl.d:20821
otl_BuildHeuristics
Definition: otl.d:20979
int k
Definition: otp-parser.c:70
static int format
Definition: pbmclean.c:15
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst st
static int offset
Definition: ppmtogif.c:642
uint16_t glyphid_t
Definition: primitives.h:14
@ json_object
Definition: json.h:85
#define checkLength(offset)
Definition: common.h:13
sds sdsnewlen(const void *init, size_t initlen)
char * sds
Definition: sds.h:41
unsigned int name_length
Definition: json.h:103
char * name
Definition: json.h:102
struct _json_value * value
Definition: json.h:105
json_type type
Definition: json.h:113
unsigned int length
Definition: json.h:123
struct _json_value::@1795::@1798 object
json_object_entry * values
Definition: json.h:132
union _json_value::@1795 u
OWNING sds name
Definition: handle.h:21
otfcc_GlyphHandle * glyphs
Definition: coverage.h:8
glyphid_t numGlyphs
Definition: coverage.h:6
OWNING otl_PositionValue value
Definition: otl.h:116
OWNING otfcc_GlyphHandle target
Definition: otl.h:115
pos_t dy
Definition: otl.h:41
pos_t dHeight
Definition: otl.h:43
pos_t dWidth
Definition: otl.h:42
pos_t dx
Definition: otl.h:40
Definition: stemdb.c:56
otl_GposSingleEntry * items
Definition: otl.d:20820
int j
Definition: t4ht.c:1589
json_value * otl_gpos_dump_single(const otl_Subtable *_subtable)
Definition: gpos-single.c:61
static void deleteGposSingleEntry(otl_GposSingleEntry *entry)
Definition: gpos-single.c:4
caryll_standardVectorImpl(subtable_gpos_single, otl_GposSingleEntry, gss_typeinfo, iSubtable_gpos_single)
otl_Subtable * otl_gpos_parse_single(const json_value *_subtable, const otfcc_Options *options)
Definition: gpos-single.c:70
otl_Subtable * otl_read_gpos_single(const font_file_pointer data, uint32_t tableLength, uint32_t offset, const glyphid_t maxGlyphs, const otfcc_Options *options)
Definition: gpos-single.c:14
caryll_Buffer * otfcc_build_gpos_single(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics)
Definition: gpos-single.c:87
static caryll_ElementInterface(otl_GposSingleEntry)
Definition: gpos-single.c:8
subtable_gpos_single gpos_single
Definition: otl.h:192
Definition: obx.h:51
#define FAIL(ec)