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)  

gsub-ligature.c
Go to the documentation of this file.
1 #include "gsub-ligature.h"
2 
4  Handle.dispose(&entry->to);
5  DELETE(Coverage.free, entry->from);
6 }
8  .init = NULL, .copy = NULL, .dispose = deleteGsubLigatureEntry};
9 
12 
14  uint32_t offset, const glyphid_t maxGlyphs,
15  const otfcc_Options *options) {
17  checkLength(offset + 6);
18 
19  otl_Coverage *startCoverage =
20  Coverage.read(data, tableLength, offset + read_16u(data + offset + 2));
21  if (!startCoverage) goto FAIL;
22  glyphid_t setCount = read_16u(data + offset + 4);
23  if (setCount != startCoverage->numGlyphs) goto FAIL;
24  checkLength(offset + 6 + setCount * 2);
25 
26  uint32_t ligatureCount = 0;
27  for (glyphid_t j = 0; j < setCount; j++) {
28  uint32_t setOffset = offset + read_16u(data + offset + 6 + j * 2);
30  ligatureCount += read_16u(data + setOffset);
32  }
33 
34  for (glyphid_t j = 0; j < setCount; j++) {
35  uint32_t setOffset = offset + read_16u(data + offset + 6 + j * 2);
37  for (glyphid_t k = 0; k < lc; k++) {
38  uint32_t ligOffset = setOffset + read_16u(data + setOffset + 2 + k * 2);
39  checkLength(ligOffset + 4);
40  glyphid_t ligComponents = read_16u(data + ligOffset + 2);
41  checkLength(ligOffset + 2 + ligComponents * 2);
42 
43  otl_Coverage *cov = Coverage.create();
44  Coverage.push(cov, Handle.fromIndex(startCoverage->glyphs[j].index));
45  for (glyphid_t m = 1; m < ligComponents; m++) {
46  Coverage.push(cov, Handle.fromIndex(read_16u(data + ligOffset + 2 + m * 2)));
47  }
49  subtable, ((otl_GsubLigatureEntry){
50  .from = cov, .to = Handle.fromIndex(read_16u(data + ligOffset)),
51  }));
52  }
53  }
54  Coverage.free(startCoverage);
55  return (otl_Subtable *)subtable;
56 FAIL:
57  iSubtable_gsub_ligature.free(subtable);
58  return NULL;
59 }
60 
62  const subtable_gsub_ligature *subtable = &(_subtable->gsub_ligature);
63  json_value *st = json_array_new(subtable->length);
64  for (glyphid_t j = 0; j < subtable->length; j++) {
66  json_object_push(entry, "from", Coverage.dump(subtable->items[j].from));
67  json_object_push(entry, "to",
69  subtable->items[j].to.name));
71  }
73  json_object_push(ret, "substitutions", st);
74  return ret;
75 }
76 
78  if (json_obj_get_type(_subtable, "substitutions", json_array)) {
79  _subtable = json_obj_get_type(_subtable, "substitutions", json_array);
80 
82  glyphid_t n = _subtable->u.array.length;
83 
84  for (glyphid_t k = 0; k < n; k++) {
85  json_value *entry = _subtable->u.array.values[k];
86  json_value *_from = json_obj_get_type(entry, "from", json_array);
88  if (!_from || !_to) continue;
91  .to = Handle.fromName(sdsnewlen(_to->u.string.ptr, _to->u.string.length)),
92  .from = Coverage.parse(_from),
93  }));
94  }
95  return (otl_Subtable *)st;
96  } else {
98  glyphid_t n = _subtable->u.array.length;
99 
100  for (glyphid_t k = 0; k < n; k++) {
101  json_value *_from = _subtable->u.object.values[k].value;
102  if (!_from || _from->type != json_array) continue;
105  .to = Handle.fromName(sdsnewlen(_subtable->u.object.values[k].name,
106  _subtable->u.object.values[k].name_length)),
107  .from = Coverage.parse(_from),
108  }));
109  }
110  return (otl_Subtable *)st;
111  }
112  return NULL;
113 }
114 
115 typedef struct {
116  int gid;
120  return a->gid - b->gid;
121 }
122 
124  const subtable_gsub_ligature *subtable = &(_subtable->gsub_ligature);
125 
126  ligature_aggerator *h = NULL, *s, *tmp;
127  glyphid_t nLigatures = subtable->length;
128  for (glyphid_t j = 0; j < nLigatures; j++) {
129  int sgid = subtable->items[j].from->glyphs[0].index;
130  HASH_FIND_INT(h, &sgid, s);
131  if (!s) {
132  NEW(s);
133  s->gid = sgid;
134  HASH_ADD_INT(h, gid, s);
135  }
136  }
137  HASH_SORT(h, by_gid);
138 
139  otl_Coverage *startcov = Coverage.create();
140 
141  foreach_hash(s, h) {
142  Coverage.push(startcov, Handle.fromIndex(s->gid));
143  }
144 
145  bk_Block *root = bk_new_Block(b16, 1, // format
146  p16, bk_newBlockFromBuffer(Coverage.build(startcov)), // coverage
147  b16, startcov->numGlyphs, // LigSetCount
148  bkover);
149 
150  foreach_hash(s, h) {
151  glyphid_t nLigsHere = 0;
152  for (glyphid_t j = 0; j < nLigatures; j++)
153  if (subtable->items[j].from->glyphs[0].index == s->gid) nLigsHere++;
154  bk_Block *ligset = bk_new_Block(b16, nLigsHere, bkover);
155 
156  for (glyphid_t j = 0; j < nLigatures; j++) {
157  if (subtable->items[j].from->glyphs[0].index == s->gid) {
158  bk_Block *ligdef =
159  bk_new_Block(b16, subtable->items[j].to.index, // ligGlyph
160  b16, subtable->items[j].from->numGlyphs, // compCount
161  bkover);
162  for (glyphid_t m = 1; m < subtable->items[j].from->numGlyphs; m++) {
163  bk_push(ligdef, b16, subtable->items[j].from->glyphs[m].index, bkover);
164  }
165  bk_push(ligset, p16, ligdef, bkover);
166  }
167  }
168  bk_push(root, p16, ligset, bkover);
169  }
170 
171  Coverage.free(startcov);
172  HASH_ITER(hh, h, s, tmp) {
173  HASH_DEL(h, s);
174  FREE(s);
175  }
176  return bk_build_Block(root);
177 }
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
@ 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 n
Definition: t4ht.c:1290
#define b
Definition: jpegint.h:372
int h
Definition: dviconv.c:9
static void setOffset(char dir, char sign, int pos)
Definition: dvi2xx.c:758
long hh
Definition: dvi2xx.h:579
struct rect data
Definition: dvipdfm.c:64
#define s
Definition: afcover.h:80
#define a(n)
Definition: gpos-common.c:148
const unsigned char FREE
Definition: image.cpp:34
json_value * json_array_new(size_t length)
json_value * json_string_new_length(unsigned int length, const char *)
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_object_new(size_t length)
static json_value * preserialize(MOVE json_value *x)
Definition: json-funcs.h:187
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
#define NEW
Definition: gdkanji.c:77
unsigned int uint32_t
Definition: stdint.h:80
pdf_obj * entry
Definition: pdfdoc.c:64
static int ret
Definition: convert.c:72
#define root
Definition: ctangleboot.c:69
#define foreach_hash(id, range)
Definition: aliases.h:39
#define Handle
Definition: aliases.h:45
uint8_t * font_file_pointer
Definition: aliases.h:41
#define Coverage
Definition: aliases.h:58
#define DELETE(fn, ptr)
Definition: otfcc-alloc.h:76
iSubtable_gsub_ligature
Definition: otl.d:20769
otl_BuildHeuristics
Definition: otl.d:20979
int k
Definition: otp-parser.c:70
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_string
Definition: json.h:89
@ json_array
Definition: json.h:86
#define checkLength(offset)
Definition: common.h:13
static unsigned long int lc(mp_ptr rp, gmp_randstate_t rstate)
Definition: randlc2x.c:72
sds sdsnewlen(const void *init, size_t initlen)
static size_t sdslen(const sds s)
Definition: sds.h:91
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
char * ptr
Definition: json.h:124
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
struct _json_value::@1795::@1799 array
struct _json_value::@1795::@1797 string
UT_hash_handle hh
OWNING sds name
Definition: handle.h:21
glyphid_t index
Definition: handle.h:20
otfcc_GlyphHandle * glyphs
Definition: coverage.h:8
glyphid_t numGlyphs
Definition: coverage.h:6
OWNING otfcc_GlyphHandle to
Definition: otl.h:63
OWNING otl_Coverage * from
Definition: otl.h:62
Definition: stemdb.c:56
otl_GsubLigatureEntry * items
Definition: otl.d:20767
int j
Definition: t4ht.c:1589
static int by_gid(ligature_aggerator *a, ligature_aggerator *b)
caryll_Buffer * otfcc_build_gsub_ligature_subtable(const otl_Subtable *_subtable, otl_BuildHeuristics heuristics)
json_value * otl_gsub_dump_ligature(const otl_Subtable *_subtable)
Definition: gsub-ligature.c:61
otl_Subtable * otl_read_gsub_ligature(const font_file_pointer data, uint32_t tableLength, uint32_t offset, const glyphid_t maxGlyphs, const otfcc_Options *options)
Definition: gsub-ligature.c:13
caryll_standardVectorImpl(subtable_gsub_ligature, otl_GsubLigatureEntry, gss_typeinfo, iSubtable_gsub_ligature)
static void deleteGsubLigatureEntry(otl_GsubLigatureEntry *entry)
Definition: gsub-ligature.c:3
static caryll_ElementInterface(otl_GsubLigatureEntry)
Definition: gsub-ligature.c:7
otl_Subtable * otl_gsub_parse_ligature(const json_value *_subtable, const otfcc_Options *options)
Definition: gsub-ligature.c:77
m
Definition: tex4ht.c:3990
subtable_gsub_ligature gsub_ligature
Definition: otl.h:189
#define FAIL(ec)
#define HASH_DEL(head, delptr)
Definition: uthash.h:498
#define HASH_ITER(hh, head, el, tmp)
Definition: uthash.h:1131
#define HASH_SORT(head, cmpfcn)
Definition: uthash.h:960
#define HASH_FIND_INT(head, findint, out)
Definition: uthash.h:486
#define HASH_ADD_INT(head, intfield, add)
Definition: uthash.h:488