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)  

build.c
Go to the documentation of this file.
1 #include "../chaining.h"
2 #include "common.h"
3 
6  return false;
7  bool isContextual = true;
8  for (tableid_t j = 0; j < lookup->subtables.length; j++) {
9  const subtable_chaining *subtable = &(lookup->subtables.items[j]->chaining);
10  if (subtable->type == otl_chaining_classified) {
11  for (tableid_t k = 0; k < subtable->rulesCount; k++) {
12  otl_ChainingRule *rule = subtable->rules[k];
13  tableid_t nBacktrack = rule->inputBegins;
14  tableid_t nLookahead = rule->matchCount - rule->inputEnds;
15  isContextual = isContextual && !nBacktrack && !nLookahead;
16  }
17  } else {
18  const otl_ChainingRule *rule = (const otl_ChainingRule *)&(subtable->rule);
19  tableid_t nBacktrack = rule->inputBegins;
20  tableid_t nLookahead = rule->matchCount - rule->inputEnds;
21  isContextual = isContextual && !nBacktrack && !nLookahead;
22  }
23  }
24  return isContextual;
25 }
26 
27 ////// CHAINING
28 
30  const subtable_chaining *subtable = &(_subtable->chaining);
31  const otl_ChainingRule *rule = (const otl_ChainingRule *)&(subtable->rule);
32  tableid_t nBacktrack = rule->inputBegins;
33  tableid_t nInput = rule->inputEnds - rule->inputBegins;
34  tableid_t nLookahead = rule->matchCount - rule->inputEnds;
35  tableid_t nSubst = rule->applyCount;
37 
38  bk_Block *root = bk_new_Block(b16, 3, // format
39  bkover);
40 
41  bk_push(root, b16, nBacktrack, bkover);
42  for (tableid_t j = 0; j < rule->inputBegins; j++) {
44  }
45  bk_push(root, b16, nInput, bkover);
46  for (tableid_t j = rule->inputBegins; j < rule->inputEnds; j++) {
48  }
49  bk_push(root, b16, nLookahead, bkover);
50  for (tableid_t j = rule->inputEnds; j < rule->matchCount; j++) {
52  }
53  bk_push(root, b16, rule->applyCount, bkover);
54  for (tableid_t j = 0; j < nSubst; j++) {
55  bk_push(root, b16, rule->apply[j].index - nBacktrack, // position
56  b16, rule->apply[j].lookup.index, // lookup
57  bkover);
58  }
59 
60  return bk_build_Block(root);
61 }
62 
64  const subtable_chaining *subtable = &(_subtable->chaining);
65 
67  NEW(coverage);
68  coverage->numGlyphs = subtable->ic->numGlyphs;
69  coverage->glyphs = subtable->ic->glyphs;
70 
71  bk_Block *root =
72  bk_new_Block(b16, 2, // format
73  p16, bk_newBlockFromBuffer(Coverage.build(coverage)), // coverage
74  p16, bk_newBlockFromBuffer(ClassDef.build(subtable->bc)), // BacktrackClassDef
75  p16, bk_newBlockFromBuffer(ClassDef.build(subtable->ic)), // InputClassDef
76  p16, bk_newBlockFromBuffer(ClassDef.build(subtable->fc)), // LookaheadClassDef
77  b16, subtable->ic->maxclass + 1, // ChainSubClassSetCnt
78  bkover);
79 
80  glyphclass_t *rcpg;
81  NEW(rcpg, subtable->ic->maxclass + 1);
82  for (glyphclass_t j = 0; j <= subtable->ic->maxclass; j++) {
83  rcpg[j] = 0;
84  }
85  for (tableid_t j = 0; j < subtable->rulesCount; j++) {
86  tableid_t ib = subtable->rules[j]->inputBegins;
87  tableid_t startClass = subtable->rules[j]->match[ib]->glyphs[0].index;
88  if (startClass <= subtable->ic->maxclass) rcpg[startClass] += 1;
89  }
90 
91  for (glyphclass_t j = 0; j <= subtable->ic->maxclass; j++) {
92  if (rcpg[j]) {
93  bk_Block *cset = bk_new_Block(b16, rcpg[j], // ChainSubClassRuleCnt
94  bkover);
95  for (tableid_t k = 0; k < subtable->rulesCount; k++) {
96  otl_ChainingRule *rule = subtable->rules[k];
97  glyphclass_t startClass = rule->match[rule->inputBegins]->glyphs[0].index;
98  if (startClass != j) { continue; }
100  tableid_t nBacktrack = rule->inputBegins;
101  tableid_t nInput = rule->inputEnds - rule->inputBegins;
102  tableid_t nLookahead = rule->matchCount - rule->inputEnds;
103  tableid_t nSubst = rule->applyCount;
105  bk_push(r, b16, nBacktrack, bkover);
106  for (tableid_t m = 0; m < rule->inputBegins; m++) {
107  bk_push(r, b16, rule->match[m]->glyphs[0].index, bkover);
108  }
109  bk_push(r, b16, nInput, bkover);
110  for (tableid_t m = rule->inputBegins + 1; m < rule->inputEnds; m++) {
111  bk_push(r, b16, rule->match[m]->glyphs[0].index, bkover);
112  }
113  bk_push(r, b16, nLookahead, bkover);
114  for (tableid_t m = rule->inputEnds; m < rule->matchCount; m++) {
115  bk_push(r, b16, rule->match[m]->glyphs[0].index, bkover);
116  }
117  bk_push(r, b16, nSubst, bkover);
118  for (tableid_t m = 0; m < nSubst; m++) {
119  bk_push(r, b16, rule->apply[m].index - nBacktrack, // position
120  b16, rule->apply[m].lookup.index, // lookup index
121  bkover);
122  }
123  bk_push(cset, p16, r, bkover);
124  }
125  bk_push(root, p16, cset, bkover);
126  } else {
127  bk_push(root, p16, NULL, bkover);
128  }
129  }
130 
131  FREE(coverage);
132  FREE(rcpg);
133  return bk_build_Block(root);
134 }
135 
137  if (_subtable->chaining.type == otl_chaining_classified) {
138  return otfcc_build_chaining_classes(_subtable);
139  } else {
140  return otfcc_build_chaining_coverage(_subtable);
141  }
142 }
143 
144 ////// CONTEXTUAL
145 
147  const subtable_chaining *subtable = &(_subtable->chaining);
148  const otl_ChainingRule *rule = (const otl_ChainingRule *)&(subtable->rule);
149  tableid_t nInput = rule->inputEnds - rule->inputBegins;
150  tableid_t nSubst = rule->applyCount;
152 
153  bk_Block *root = bk_new_Block(b16, 3, // format
154  bkover);
155 
156  bk_push(root, b16, nInput, bkover);
157  bk_push(root, b16, nSubst, bkover);
158  for (tableid_t j = rule->inputBegins; j < rule->inputEnds; j++) {
160  }
161  for (tableid_t j = 0; j < nSubst; j++) {
162  bk_push(root, b16, rule->apply[j].index, // position
163  b16, rule->apply[j].lookup.index, // lookup
164  bkover);
165  }
166 
167  return bk_build_Block(root);
168 }
169 
171  const subtable_chaining *subtable = &(_subtable->chaining);
172 
174  NEW(coverage);
175  coverage->numGlyphs = subtable->ic->numGlyphs;
176  coverage->glyphs = subtable->ic->glyphs;
177 
178  bk_Block *root =
179  bk_new_Block(b16, 2, // format
180  p16, bk_newBlockFromBuffer(Coverage.build(coverage)), // coverage
181  p16, bk_newBlockFromBuffer(ClassDef.build(subtable->ic)), // InputClassDef
182  b16, subtable->ic->maxclass + 1, // ChainSubClassSetCnt
183  bkover);
184 
185  glyphclass_t *rcpg;
186  NEW(rcpg, subtable->ic->maxclass + 1);
187  for (glyphclass_t j = 0; j <= subtable->ic->maxclass; j++) {
188  rcpg[j] = 0;
189  }
190  for (tableid_t j = 0; j < subtable->rulesCount; j++) {
191  tableid_t ib = subtable->rules[j]->inputBegins;
192  tableid_t startClass = subtable->rules[j]->match[ib]->glyphs[0].index;
193  if (startClass <= subtable->ic->maxclass) rcpg[startClass] += 1;
194  }
195 
196  for (glyphclass_t j = 0; j <= subtable->ic->maxclass; j++) {
197  if (rcpg[j]) {
198  bk_Block *cset = bk_new_Block(b16, rcpg[j], // ChainSubClassRuleCnt
199  bkover);
200  for (tableid_t k = 0; k < subtable->rulesCount; k++) {
201  otl_ChainingRule *rule = subtable->rules[k];
202  glyphclass_t startClass = rule->match[rule->inputBegins]->glyphs[0].index;
203  if (startClass != j) { continue; }
205  tableid_t nInput = rule->inputEnds - rule->inputBegins;
206  tableid_t nSubst = rule->applyCount;
208 
209  bk_push(r, b16, nInput, bkover);
210  bk_push(r, b16, nSubst, bkover);
211  for (tableid_t m = rule->inputBegins + 1; m < rule->inputEnds; m++) {
212  bk_push(r, b16, rule->match[m]->glyphs[0].index, bkover);
213  }
214 
215  for (tableid_t m = 0; m < nSubst; m++) {
216  bk_push(r, b16, rule->apply[m].index, // position
217  b16, rule->apply[m].lookup.index, // lookup index
218  bkover);
219  }
220  bk_push(cset, p16, r, bkover);
221  }
222  bk_push(root, p16, cset, bkover);
223  } else {
224  bk_push(root, p16, NULL, bkover);
225  }
226  }
227 
228  FREE(coverage);
229  FREE(rcpg);
230  return bk_build_Block(root);
231 }
232 
234  if (_subtable->chaining.type == otl_chaining_classified) {
235  return otfcc_build_contextual_classes(_subtable);
236  } else {
237  return otfcc_build_contextual_coverage(_subtable);
238  }
239 }
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
const unsigned char FREE
Definition: image.cpp:34
@ otl_type_gsub_chaining
Definition: otl.h:18
@ otl_type_gpos_chaining
Definition: otl.h:30
@ otl_chaining_classified
Definition: otl.h:73
#define NULL
Definition: ftobjs.h:61
#define NEW
Definition: gdkanji.c:77
#define root
Definition: ctangleboot.c:69
#define ClassDef
Definition: aliases.h:55
#define Coverage
Definition: aliases.h:58
static caryll_Buffer * otfcc_build_chaining_classes(const otl_Subtable *_subtable)
Definition: build.c:63
bool otfcc_chainingLookupIsContextualLookup(const otl_Lookup *lookup)
Definition: build.c:4
static caryll_Buffer * otfcc_build_chaining_coverage(const otl_Subtable *_subtable)
Definition: build.c:29
static caryll_Buffer * otfcc_build_contextual_coverage(const otl_Subtable *_subtable)
Definition: build.c:146
caryll_Buffer * otfcc_build_contextual(const otl_Subtable *_subtable)
Definition: build.c:233
caryll_Buffer * otfcc_build_chaining(const otl_Subtable *_subtable)
Definition: build.c:136
static caryll_Buffer * otfcc_build_contextual_classes(const otl_Subtable *_subtable)
Definition: build.c:170
int k
Definition: otp-parser.c:70
int r
Definition: ppmqvga.c:68
uint16_t tableid_t
Definition: primitives.h:17
uint16_t glyphclass_t
Definition: primitives.h:15
static INLINE void reverseBacktracks(otl_ChainingRule *rule)
Definition: common.h:22
Definition: tfm.c:163
Definition: zic.c:306
uint16 type
Definition: parsettfatt.c:198
glyphid_t index
Definition: handle.h:20
OWNING otl_Coverage ** match
Definition: otl.h:86
tableid_t inputBegins
Definition: otl.h:84
glyphclass_t maxclass
Definition: classdef.h:9
glyphid_t numGlyphs
Definition: classdef.h:7
otfcc_GlyphHandle * glyphs
Definition: classdef.h:10
otfcc_GlyphHandle * glyphs
Definition: coverage.h:8
Definition: rule.h:21
otl_ChainingRule rule
Definition: otl.h:93
OWNING otl_ClassDef * ic
Definition: otl.h:98
otl_chaining_type type
Definition: otl.h:91
tableid_t rulesCount
Definition: otl.h:95
OWNING otl_ClassDef * fc
Definition: otl.h:99
OWNING otl_ClassDef * bc
Definition: otl.h:97
OWNING otl_ChainingRule ** rules
Definition: otl.h:96
int j
Definition: t4ht.c:1589
m
Definition: tex4ht.c:3990
subtable_chaining chaining
Definition: otl.h:190