| 1 |
--[[info----------------------------------------------------------------------- |
| 2 |
Luaotfload fontloader package |
| 3 |
build 2023-12-28 15:52:34 |
| 4 |
------------------------------------------------------------------------------- |
| 5 |
|
| 6 |
© 2023 PRAGMA ADE / ConTeXt Development Team |
| 7 |
|
| 8 |
The code in this file is provided under the GPL v2.0 license. See the |
| 9 |
file COPYING in the Luaotfload repository for details. |
| 10 |
|
| 11 |
Report bugs to https://github.com/latex3/luaotfload |
| 12 |
|
| 13 |
This file has been assembled from components taken from Context. See |
| 14 |
the Luaotfload documentation for details: |
| 15 |
|
| 16 |
$ texdoc luaotfload |
| 17 |
$ man 1 luaotfload-tool |
| 18 |
$ man 5 luaotfload.conf |
| 19 |
|
| 20 |
Included files: |
| 21 |
|
| 22 |
· fontloader-data-con.lua |
| 23 |
· fontloader-basics-nod.lua |
| 24 |
· fontloader-basics-chr.lua |
| 25 |
· fontloader-font-ini.lua |
| 26 |
· fontloader-fonts-mis.lua |
| 27 |
· fontloader-font-con.lua |
| 28 |
· fontloader-fonts-enc.lua |
| 29 |
· fontloader-font-cid.lua |
| 30 |
· fontloader-font-map.lua |
| 31 |
· fontloader-font-vfc.lua |
| 32 |
· fontloader-font-otr.lua |
| 33 |
· fontloader-font-oti.lua |
| 34 |
· fontloader-font-ott.lua |
| 35 |
· fontloader-font-cff.lua |
| 36 |
· fontloader-font-ttf.lua |
| 37 |
· fontloader-font-dsp.lua |
| 38 |
· fontloader-font-oup.lua |
| 39 |
· fontloader-font-otl.lua |
| 40 |
· fontloader-font-oto.lua |
| 41 |
· fontloader-font-otj.lua |
| 42 |
· fontloader-font-ota.lua |
| 43 |
· fontloader-font-ots.lua |
| 44 |
· fontloader-font-osd.lua |
| 45 |
· fontloader-font-ocl.lua |
| 46 |
· fontloader-font-otc.lua |
| 47 |
· fontloader-font-onr.lua |
| 48 |
· fontloader-font-one.lua |
| 49 |
· fontloader-font-afk.lua |
| 50 |
· fontloader-fonts-tfm.lua |
| 51 |
· fontloader-font-lua.lua |
| 52 |
· fontloader-font-def.lua |
| 53 |
· fontloader-font-shp.lua |
| 54 |
· fontloader-fonts-def.lua |
| 55 |
· fontloader-fonts-ext.lua |
| 56 |
· fontloader-font-imp-tex.lua |
| 57 |
· fontloader-font-imp-ligatures.lua |
| 58 |
· fontloader-font-imp-italics.lua |
| 59 |
· fontloader-font-imp-effects.lua |
| 60 |
· fontloader-fonts-lig.lua |
| 61 |
· fontloader-fonts-gbn.lua |
| 62 |
|
| 63 |
--info]]----------------------------------------------------------------------- |
| 64 |
|
| 65 |
|
| 66 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “data-con” b4ab51aaeab872d86d827f3e216bf05e] --- |
| 67 |
|
| 68 |
if not modules then modules={} end modules ['data-con']={ |
| 69 |
version=1.100, |
| 70 |
comment="companion to luat-lib.mkiv", |
| 71 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 72 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 73 |
license="see context related readme files" |
| 74 |
} |
| 75 |
local setmetatable=setmetatable |
| 76 |
local format,lower,gsub=string.format,string.lower,string.gsub |
| 77 |
local trace_cache=false trackers.register("resolvers.cache",function(v) trace_cache=v end) |
| 78 |
local trace_containers=false trackers.register("resolvers.containers",function(v) trace_containers=v end) |
| 79 |
local trace_storage=false trackers.register("resolvers.storage",function(v) trace_storage=v end) |
| 80 |
containers=containers or {} |
| 81 |
local containers=containers |
| 82 |
containers.usecache=true |
| 83 |
local getwritablepath=caches.getwritablepath |
| 84 |
local getreadablepaths=caches.getreadablepaths |
| 85 |
local cacheiswritable=caches.is_writable |
| 86 |
local loaddatafromcache=caches.loaddata |
| 87 |
local savedataincache=caches.savedata |
| 88 |
local report_containers=logs.reporter("resolvers","containers") |
| 89 |
local allocated={} |
| 90 |
local mt={ |
| 91 |
__index=function(t,k) |
| 92 |
if k=="writable" then |
| 93 |
local writable=getwritablepath(t.category,t.subcategory) or { "." } |
| 94 |
t.writable=writable |
| 95 |
return writable |
| 96 |
elseif k=="readables" then |
| 97 |
local readables=getreadablepaths(t.category,t.subcategory) or { "." } |
| 98 |
t.readables=readables |
| 99 |
return readables |
| 100 |
end |
| 101 |
end, |
| 102 |
__storage__=true |
| 103 |
} |
| 104 |
function containers.define(category,subcategory,version,enabled,reload) |
| 105 |
if category and subcategory then |
| 106 |
local c=allocated[category] |
| 107 |
if not c then |
| 108 |
c={} |
| 109 |
allocated[category]=c |
| 110 |
end |
| 111 |
local s=c[subcategory] |
| 112 |
if not s then |
| 113 |
s={ |
| 114 |
category=category, |
| 115 |
subcategory=subcategory, |
| 116 |
storage={}, |
| 117 |
enabled=enabled, |
| 118 |
reload=reload, |
| 119 |
version=version or math.pi, |
| 120 |
trace=false, |
| 121 |
} |
| 122 |
setmetatable(s,mt) |
| 123 |
c[subcategory]=s |
| 124 |
end |
| 125 |
return s |
| 126 |
end |
| 127 |
end |
| 128 |
function containers.is_usable(container,name) |
| 129 |
return container.enabled and caches and cacheiswritable(container.writable,name) |
| 130 |
end |
| 131 |
function containers.is_valid(container,name) |
| 132 |
if name and name~="" then |
| 133 |
local storage=container.storage[name] |
| 134 |
return storage and storage.cache_version==container.version |
| 135 |
else |
| 136 |
return false |
| 137 |
end |
| 138 |
end |
| 139 |
function containers.read(container,name) |
| 140 |
local storage=container.storage |
| 141 |
local reload=container.reload |
| 142 |
local stored=not reload and storage[name] |
| 143 |
if not stored and container.enabled and caches and containers.usecache then |
| 144 |
stored=loaddatafromcache(container.readables,name,container.writable) |
| 145 |
if stored and stored.cache_version==container.version then |
| 146 |
if trace_cache or trace_containers then |
| 147 |
report_containers("action %a, category %a, name %a","load",container.subcategory,name) |
| 148 |
end |
| 149 |
else |
| 150 |
stored=nil |
| 151 |
end |
| 152 |
storage[name]=stored |
| 153 |
elseif stored then |
| 154 |
if trace_cache or trace_containers then |
| 155 |
report_containers("action %a, category %a, name %a","reuse",container.subcategory,name) |
| 156 |
end |
| 157 |
end |
| 158 |
return stored |
| 159 |
end |
| 160 |
function containers.write(container,name,data,fast) |
| 161 |
if data then |
| 162 |
data.cache_version=container.version |
| 163 |
if container.enabled and caches then |
| 164 |
local unique=data.unique |
| 165 |
local shared=data.shared |
| 166 |
data.unique=nil |
| 167 |
data.shared=nil |
| 168 |
savedataincache(container.writable,name,data,fast) |
| 169 |
if trace_cache or trace_containers then |
| 170 |
report_containers("action %a, category %a, name %a","save",container.subcategory,name) |
| 171 |
end |
| 172 |
data.unique=unique |
| 173 |
data.shared=shared |
| 174 |
end |
| 175 |
if trace_cache or trace_containers then |
| 176 |
report_containers("action %a, category %a, name %a","store",container.subcategory,name) |
| 177 |
end |
| 178 |
container.storage[name]=data |
| 179 |
end |
| 180 |
return data |
| 181 |
end |
| 182 |
function containers.content(container,name) |
| 183 |
return container.storage[name] |
| 184 |
end |
| 185 |
function containers.cleanname(name) |
| 186 |
return (gsub(lower(name),"[^%w\128-\255]+","-")) |
| 187 |
end |
| 188 |
|
| 189 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “data-con”] --- |
| 190 |
|
| 191 |
|
| 192 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “basics-nod” 1750af43148def9e7a75c6900a96f9dc] --- |
| 193 |
|
| 194 |
if not modules then modules={} end modules ['luatex-fonts-nod']={ |
| 195 |
version=1.001, |
| 196 |
comment="companion to luatex-fonts.lua", |
| 197 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 198 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 199 |
license="see context related readme files" |
| 200 |
} |
| 201 |
if context then |
| 202 |
os.exit() |
| 203 |
end |
| 204 |
if tex.attribute[0]~=0 then |
| 205 |
texio.write_nl("log","!") |
| 206 |
texio.write_nl("log","! Attribute 0 is reserved for ConTeXt's font feature management and has to be") |
| 207 |
texio.write_nl("log","! set to zero. Also, some attributes in the range 1-255 are used for special") |
| 208 |
texio.write_nl("log","! purposes so setting them at the TeX end might break the font handler.") |
| 209 |
texio.write_nl("log","!") |
| 210 |
tex.attribute[0]=0 |
| 211 |
end |
| 212 |
attributes=attributes or {} |
| 213 |
attributes.unsetvalue=-0x7FFFFFFF |
| 214 |
local numbers,last={},127 |
| 215 |
attributes.private=attributes.private or function(name) |
| 216 |
local number=numbers[name] |
| 217 |
if not number then |
| 218 |
if last<255 then |
| 219 |
last=last+1 |
| 220 |
end |
| 221 |
number=last |
| 222 |
numbers[name]=number |
| 223 |
end |
| 224 |
return number |
| 225 |
end |
| 226 |
nodes={} |
| 227 |
nodes.handlers={} |
| 228 |
local nodecodes={} |
| 229 |
local glyphcodes=node.subtypes("glyph") |
| 230 |
local disccodes=node.subtypes("disc") |
| 231 |
for k,v in next,node.types() do |
| 232 |
v=string.gsub(v,"_","") |
| 233 |
nodecodes[k]=v |
| 234 |
nodecodes[v]=k |
| 235 |
end |
| 236 |
for k,v in next,glyphcodes do |
| 237 |
glyphcodes[v]=k |
| 238 |
end |
| 239 |
for k,v in next,disccodes do |
| 240 |
disccodes[v]=k |
| 241 |
end |
| 242 |
nodes.nodecodes=nodecodes |
| 243 |
nodes.glyphcodes=glyphcodes |
| 244 |
nodes.disccodes=disccodes |
| 245 |
nodes.dirvalues={ lefttoright=0,righttoleft=1 } |
| 246 |
nodes.handlers.protectglyphs=node.protectglyphs or node.protect_glyphs |
| 247 |
nodes.handlers.unprotectglyphs=node.unprotectglyphs or node.unprotect_glyphs |
| 248 |
local direct=node.direct |
| 249 |
local nuts={} |
| 250 |
nodes.nuts=nuts |
| 251 |
local tonode=direct.tonode |
| 252 |
local tonut=direct.todirect |
| 253 |
nodes.tonode=tonode |
| 254 |
nodes.tonut=tonut |
| 255 |
nuts.tonode=tonode |
| 256 |
nuts.tonut=tonut |
| 257 |
nuts.getattr=direct.get_attribute |
| 258 |
nuts.getboth=direct.getboth |
| 259 |
nuts.getchar=direct.getchar |
| 260 |
nuts.getdirection=direct.getdirection |
| 261 |
nuts.getdisc=direct.getdisc |
| 262 |
nuts.getreplace=direct.getreplace |
| 263 |
nuts.getfield=direct.getfield |
| 264 |
nuts.getfont=direct.getfont |
| 265 |
nuts.getid=direct.getid |
| 266 |
nuts.getkern=direct.getkern |
| 267 |
nuts.getlist=direct.getlist |
| 268 |
nuts.getnext=direct.getnext |
| 269 |
nuts.getoffsets=direct.getoffsets |
| 270 |
nuts.getoptions=direct.getoptions or function() return 0 end |
| 271 |
nuts.getprev=direct.getprev |
| 272 |
nuts.getsubtype=direct.getsubtype |
| 273 |
nuts.getwidth=direct.getwidth |
| 274 |
nuts.setattr=direct.setfield |
| 275 |
nuts.setboth=direct.setboth |
| 276 |
nuts.setchar=direct.setchar |
| 277 |
nuts.setcomponents=direct.setcomponents |
| 278 |
nuts.setdirection=direct.setdirection |
| 279 |
nuts.setdisc=direct.setdisc |
| 280 |
nuts.setreplace=direct.setreplace |
| 281 |
nuts.setfield=direct.setfield |
| 282 |
nuts.setkern=direct.setkern |
| 283 |
nuts.setlink=direct.setlink |
| 284 |
nuts.setlist=direct.setlist |
| 285 |
nuts.setnext=direct.setnext |
| 286 |
nuts.setoffsets=direct.setoffsets |
| 287 |
nuts.setprev=direct.setprev |
| 288 |
nuts.setsplit=direct.setsplit |
| 289 |
nuts.setsubtype=direct.setsubtype |
| 290 |
nuts.setwidth=direct.setwidth |
| 291 |
nuts.getglyphdata=nuts.getattribute or nuts.getattr |
| 292 |
nuts.setglyphdata=nuts.setattribute or nuts.setattr |
| 293 |
nuts.ischar=direct.ischar or direct.is_char |
| 294 |
nuts.isglyph=direct.isglyph or direct.is_glyph |
| 295 |
nuts.copy=direct.copy |
| 296 |
nuts.copynode=direct.copy |
| 297 |
nuts.copylist=direct.copylist or direct.copy_list |
| 298 |
nuts.endofmath=direct.endofmath or direct.end_of_math |
| 299 |
nuts.flush=direct.flush |
| 300 |
nuts.flushlist=direct.flushlist or direct.flush_list |
| 301 |
nuts.flushnode=direct.flushnode or direct.flush_node |
| 302 |
nuts.free=direct.free |
| 303 |
nuts.insertafter=direct.insertafter or direct.insert_after |
| 304 |
nuts.insertbefore=direct.insertbefore or direct.insert_before |
| 305 |
nuts.isnode=direct.isnode or direct.is_node |
| 306 |
nuts.isdirect=direct.isdirect or direct.is_direct |
| 307 |
nuts.isnut=direct.isdirect or direct.is_direct |
| 308 |
nuts.kerning=direct.kerning |
| 309 |
nuts.ligaturing=direct.ligaturing |
| 310 |
nuts.new=direct.new |
| 311 |
nuts.remove=direct.remove |
| 312 |
nuts.tail=direct.tail |
| 313 |
nuts.traverse=direct.traverse |
| 314 |
nuts.traversechar=direct.traversechar or direct.traverse_char |
| 315 |
nuts.traverseglyph=direct.traverseglyph or direct.traverse_glyph |
| 316 |
nuts.traverseid=direct.traverseid or direct.traverse_id |
| 317 |
local propertydata=(direct.getpropertiestable or direct.get_properties_table)() |
| 318 |
nodes.properties={ data=propertydata } |
| 319 |
if direct.set_properties_mode then |
| 320 |
direct.set_properties_mode(true,true) |
| 321 |
function direct.set_properties_mode() end |
| 322 |
end |
| 323 |
nuts.getprop=function(n,k) |
| 324 |
local p=propertydata[n] |
| 325 |
if p then |
| 326 |
return p[k] |
| 327 |
end |
| 328 |
end |
| 329 |
nuts.setprop=function(n,k,v) |
| 330 |
if v then |
| 331 |
local p=propertydata[n] |
| 332 |
if p then |
| 333 |
p[k]=v |
| 334 |
else |
| 335 |
propertydata[n]={ [k]=v } |
| 336 |
end |
| 337 |
end |
| 338 |
end |
| 339 |
nodes.setprop=nodes.setproperty |
| 340 |
nodes.getprop=nodes.getproperty |
| 341 |
local setprev=nuts.setprev |
| 342 |
local setnext=nuts.setnext |
| 343 |
local getnext=nuts.getnext |
| 344 |
local setlink=nuts.setlink |
| 345 |
local getfield=nuts.getfield |
| 346 |
local setfield=nuts.setfield |
| 347 |
local getsubtype=nuts.getsubtype |
| 348 |
local isglyph=nuts.isglyph |
| 349 |
local find_tail=nuts.tail |
| 350 |
local flushlist=nuts.flushlist |
| 351 |
local flushnode=nuts.flushnode |
| 352 |
local traverseid=nuts.traverseid |
| 353 |
local copynode=nuts.copynode |
| 354 |
local glyph_code=nodes.nodecodes.glyph |
| 355 |
local ligature_code=nodes.glyphcodes.ligature |
| 356 |
do |
| 357 |
local p=nodecodes.localpar or nodecodes.local_par |
| 358 |
if p then |
| 359 |
nodecodes.par=p |
| 360 |
nodecodes[p]="par" |
| 361 |
nodecodes.localpar=p |
| 362 |
nodecodes.local_par=p |
| 363 |
end |
| 364 |
end |
| 365 |
do |
| 366 |
local getcomponents=node.direct.getcomponents |
| 367 |
local setcomponents=node.direct.setcomponents |
| 368 |
local function copynocomponents(g,copyinjection) |
| 369 |
local components=getcomponents(g) |
| 370 |
if components then |
| 371 |
setcomponents(g) |
| 372 |
local n=copynode(g) |
| 373 |
if copyinjection then |
| 374 |
copyinjection(n,g) |
| 375 |
end |
| 376 |
setcomponents(g,components) |
| 377 |
return n |
| 378 |
else |
| 379 |
local n=copynode(g) |
| 380 |
if copyinjection then |
| 381 |
copyinjection(n,g) |
| 382 |
end |
| 383 |
return n |
| 384 |
end |
| 385 |
end |
| 386 |
local function copyonlyglyphs(current) |
| 387 |
local head=nil |
| 388 |
local previous=nil |
| 389 |
for n in traverseid(glyph_code,current) do |
| 390 |
n=copynode(n) |
| 391 |
if head then |
| 392 |
setlink(previous,n) |
| 393 |
else |
| 394 |
head=n |
| 395 |
end |
| 396 |
previous=n |
| 397 |
end |
| 398 |
return head |
| 399 |
end |
| 400 |
local function countcomponents(start,marks) |
| 401 |
local char=isglyph(start) |
| 402 |
if char then |
| 403 |
if getsubtype(start)==ligature_code then |
| 404 |
local n=0 |
| 405 |
local components=getcomponents(start) |
| 406 |
while components do |
| 407 |
n=n+countcomponents(components,marks) |
| 408 |
components=getnext(components) |
| 409 |
end |
| 410 |
return n |
| 411 |
elseif not marks[char] then |
| 412 |
return 1 |
| 413 |
end |
| 414 |
end |
| 415 |
return 0 |
| 416 |
end |
| 417 |
local function flushcomponents() |
| 418 |
end |
| 419 |
nuts.components={ |
| 420 |
set=setcomponents, |
| 421 |
get=getcomponents, |
| 422 |
copyonlyglyphs=copyonlyglyphs, |
| 423 |
copynocomponents=copynocomponents, |
| 424 |
count=countcomponents, |
| 425 |
flush=flushcomponents, |
| 426 |
} |
| 427 |
end |
| 428 |
nuts.usesfont=direct.usesfont or direct.uses_font |
| 429 |
do |
| 430 |
local dummy=tonut(node.new("glyph")) |
| 431 |
nuts.traversers={ |
| 432 |
glyph=nuts.traverseid(nodecodes.glyph,dummy), |
| 433 |
glue=nuts.traverseid(nodecodes.glue,dummy), |
| 434 |
disc=nuts.traverseid(nodecodes.disc,dummy), |
| 435 |
boundary=nuts.traverseid(nodecodes.boundary,dummy), |
| 436 |
char=nuts.traversechar(dummy), |
| 437 |
node=nuts.traverse(dummy), |
| 438 |
} |
| 439 |
end |
| 440 |
if not nuts.setreplace then |
| 441 |
local getdisc=nuts.getdisc |
| 442 |
local setfield=nuts.setfield |
| 443 |
function nuts.getreplace(n) |
| 444 |
local _,_,h,_,_,t=getdisc(n,true) |
| 445 |
return h,t |
| 446 |
end |
| 447 |
function nuts.setreplace(n,h) |
| 448 |
setfield(n,"replace",h) |
| 449 |
end |
| 450 |
end |
| 451 |
do |
| 452 |
local getsubtype=nuts.getsubtype |
| 453 |
function nuts.startofpar(n) |
| 454 |
local s=getsubtype(n) |
| 455 |
return s==0 or s==2 |
| 456 |
end |
| 457 |
end |
| 458 |
|
| 459 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “basics-nod”] --- |
| 460 |
|
| 461 |
|
| 462 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “basics-chr” ce4afac7ba19471f3c8f90800839f315] --- |
| 463 |
|
| 464 |
|
| 465 |
characters=characters or {} |
| 466 |
characters.blockrange={} |
| 467 |
characters.classifiers={ |
| 468 |
[768]=5, |
| 469 |
[769]=5, |
| 470 |
[770]=5, |
| 471 |
[771]=5, |
| 472 |
[772]=5, |
| 473 |
[773]=5, |
| 474 |
[774]=5, |
| 475 |
[775]=5, |
| 476 |
[776]=5, |
| 477 |
[777]=5, |
| 478 |
[778]=5, |
| 479 |
[779]=5, |
| 480 |
[780]=5, |
| 481 |
[781]=5, |
| 482 |
[782]=5, |
| 483 |
[783]=5, |
| 484 |
[784]=5, |
| 485 |
[785]=5, |
| 486 |
[786]=5, |
| 487 |
[787]=5, |
| 488 |
[788]=5, |
| 489 |
[789]=5, |
| 490 |
[790]=5, |
| 491 |
[791]=5, |
| 492 |
[792]=5, |
| 493 |
[793]=5, |
| 494 |
[794]=5, |
| 495 |
[795]=5, |
| 496 |
[796]=5, |
| 497 |
[797]=5, |
| 498 |
[798]=5, |
| 499 |
[799]=5, |
| 500 |
[800]=5, |
| 501 |
[801]=5, |
| 502 |
[802]=5, |
| 503 |
[803]=5, |
| 504 |
[804]=5, |
| 505 |
[805]=5, |
| 506 |
[806]=5, |
| 507 |
[807]=5, |
| 508 |
[808]=5, |
| 509 |
[809]=5, |
| 510 |
[810]=5, |
| 511 |
[811]=5, |
| 512 |
[812]=5, |
| 513 |
[813]=5, |
| 514 |
[814]=5, |
| 515 |
[815]=5, |
| 516 |
[816]=5, |
| 517 |
[817]=5, |
| 518 |
[818]=5, |
| 519 |
[819]=5, |
| 520 |
[820]=5, |
| 521 |
[821]=5, |
| 522 |
[822]=5, |
| 523 |
[823]=5, |
| 524 |
[824]=5, |
| 525 |
[825]=5, |
| 526 |
[826]=5, |
| 527 |
[827]=5, |
| 528 |
[828]=5, |
| 529 |
[829]=5, |
| 530 |
[830]=5, |
| 531 |
[831]=5, |
| 532 |
[832]=5, |
| 533 |
[833]=5, |
| 534 |
[834]=5, |
| 535 |
[835]=5, |
| 536 |
[836]=5, |
| 537 |
[837]=5, |
| 538 |
[838]=5, |
| 539 |
[839]=5, |
| 540 |
[840]=5, |
| 541 |
[841]=5, |
| 542 |
[842]=5, |
| 543 |
[843]=5, |
| 544 |
[844]=5, |
| 545 |
[845]=5, |
| 546 |
[846]=5, |
| 547 |
[847]=5, |
| 548 |
[848]=5, |
| 549 |
[849]=5, |
| 550 |
[850]=5, |
| 551 |
[851]=5, |
| 552 |
[852]=5, |
| 553 |
[853]=5, |
| 554 |
[854]=5, |
| 555 |
[855]=5, |
| 556 |
[856]=5, |
| 557 |
[857]=5, |
| 558 |
[858]=5, |
| 559 |
[859]=5, |
| 560 |
[860]=5, |
| 561 |
[861]=5, |
| 562 |
[862]=5, |
| 563 |
[863]=5, |
| 564 |
[864]=5, |
| 565 |
[865]=5, |
| 566 |
[866]=5, |
| 567 |
[867]=5, |
| 568 |
[868]=5, |
| 569 |
[869]=5, |
| 570 |
[870]=5, |
| 571 |
[871]=5, |
| 572 |
[872]=5, |
| 573 |
[873]=5, |
| 574 |
[874]=5, |
| 575 |
[875]=5, |
| 576 |
[876]=5, |
| 577 |
[877]=5, |
| 578 |
[878]=5, |
| 579 |
[879]=5, |
| 580 |
[1155]=5, |
| 581 |
[1156]=5, |
| 582 |
[1157]=5, |
| 583 |
[1158]=5, |
| 584 |
[1159]=5, |
| 585 |
[1425]=5, |
| 586 |
[1426]=5, |
| 587 |
[1427]=5, |
| 588 |
[1428]=5, |
| 589 |
[1429]=5, |
| 590 |
[1430]=5, |
| 591 |
[1431]=5, |
| 592 |
[1432]=5, |
| 593 |
[1433]=5, |
| 594 |
[1434]=5, |
| 595 |
[1435]=5, |
| 596 |
[1436]=5, |
| 597 |
[1437]=5, |
| 598 |
[1438]=5, |
| 599 |
[1439]=5, |
| 600 |
[1440]=5, |
| 601 |
[1441]=5, |
| 602 |
[1442]=5, |
| 603 |
[1443]=5, |
| 604 |
[1444]=5, |
| 605 |
[1445]=5, |
| 606 |
[1446]=5, |
| 607 |
[1447]=5, |
| 608 |
[1448]=5, |
| 609 |
[1449]=5, |
| 610 |
[1450]=5, |
| 611 |
[1451]=5, |
| 612 |
[1452]=5, |
| 613 |
[1453]=5, |
| 614 |
[1454]=5, |
| 615 |
[1455]=5, |
| 616 |
[1456]=5, |
| 617 |
[1457]=5, |
| 618 |
[1458]=5, |
| 619 |
[1459]=5, |
| 620 |
[1460]=5, |
| 621 |
[1461]=5, |
| 622 |
[1462]=5, |
| 623 |
[1463]=5, |
| 624 |
[1464]=5, |
| 625 |
[1465]=5, |
| 626 |
[1466]=5, |
| 627 |
[1467]=5, |
| 628 |
[1468]=5, |
| 629 |
[1469]=5, |
| 630 |
[1471]=5, |
| 631 |
[1473]=5, |
| 632 |
[1474]=5, |
| 633 |
[1476]=5, |
| 634 |
[1477]=5, |
| 635 |
[1479]=5, |
| 636 |
[1536]=4, |
| 637 |
[1537]=4, |
| 638 |
[1538]=4, |
| 639 |
[1539]=4, |
| 640 |
[1540]=4, |
| 641 |
[1541]=4, |
| 642 |
[1542]=6, |
| 643 |
[1543]=6, |
| 644 |
[1544]=4, |
| 645 |
[1545]=6, |
| 646 |
[1546]=6, |
| 647 |
[1547]=4, |
| 648 |
[1548]=6, |
| 649 |
[1549]=6, |
| 650 |
[1550]=6, |
| 651 |
[1551]=6, |
| 652 |
[1552]=5, |
| 653 |
[1553]=5, |
| 654 |
[1554]=5, |
| 655 |
[1555]=5, |
| 656 |
[1556]=5, |
| 657 |
[1557]=5, |
| 658 |
[1558]=5, |
| 659 |
[1559]=5, |
| 660 |
[1560]=5, |
| 661 |
[1561]=5, |
| 662 |
[1562]=5, |
| 663 |
[1563]=6, |
| 664 |
[1564]=6, |
| 665 |
[1565]=6, |
| 666 |
[1566]=6, |
| 667 |
[1567]=6, |
| 668 |
[1568]=2, |
| 669 |
[1569]=4, |
| 670 |
[1570]=3, |
| 671 |
[1571]=3, |
| 672 |
[1572]=3, |
| 673 |
[1573]=3, |
| 674 |
[1574]=2, |
| 675 |
[1575]=3, |
| 676 |
[1576]=2, |
| 677 |
[1577]=3, |
| 678 |
[1578]=2, |
| 679 |
[1579]=2, |
| 680 |
[1580]=2, |
| 681 |
[1581]=2, |
| 682 |
[1582]=2, |
| 683 |
[1583]=3, |
| 684 |
[1584]=3, |
| 685 |
[1585]=3, |
| 686 |
[1586]=3, |
| 687 |
[1587]=2, |
| 688 |
[1588]=2, |
| 689 |
[1589]=2, |
| 690 |
[1590]=2, |
| 691 |
[1591]=2, |
| 692 |
[1592]=2, |
| 693 |
[1593]=2, |
| 694 |
[1594]=2, |
| 695 |
[1595]=2, |
| 696 |
[1596]=2, |
| 697 |
[1597]=2, |
| 698 |
[1598]=2, |
| 699 |
[1599]=2, |
| 700 |
[1600]=2, |
| 701 |
[1601]=2, |
| 702 |
[1602]=2, |
| 703 |
[1603]=2, |
| 704 |
[1604]=2, |
| 705 |
[1605]=2, |
| 706 |
[1606]=2, |
| 707 |
[1607]=2, |
| 708 |
[1608]=3, |
| 709 |
[1609]=2, |
| 710 |
[1610]=2, |
| 711 |
[1611]=5, |
| 712 |
[1612]=5, |
| 713 |
[1613]=5, |
| 714 |
[1614]=5, |
| 715 |
[1615]=5, |
| 716 |
[1616]=5, |
| 717 |
[1617]=5, |
| 718 |
[1618]=5, |
| 719 |
[1619]=5, |
| 720 |
[1620]=5, |
| 721 |
[1621]=5, |
| 722 |
[1622]=5, |
| 723 |
[1623]=5, |
| 724 |
[1624]=5, |
| 725 |
[1625]=5, |
| 726 |
[1626]=5, |
| 727 |
[1627]=5, |
| 728 |
[1628]=5, |
| 729 |
[1629]=5, |
| 730 |
[1630]=5, |
| 731 |
[1631]=5, |
| 732 |
[1632]=6, |
| 733 |
[1633]=6, |
| 734 |
[1634]=6, |
| 735 |
[1635]=6, |
| 736 |
[1636]=6, |
| 737 |
[1637]=6, |
| 738 |
[1638]=6, |
| 739 |
[1639]=6, |
| 740 |
[1640]=6, |
| 741 |
[1641]=6, |
| 742 |
[1642]=6, |
| 743 |
[1643]=6, |
| 744 |
[1644]=6, |
| 745 |
[1645]=6, |
| 746 |
[1646]=2, |
| 747 |
[1647]=2, |
| 748 |
[1648]=5, |
| 749 |
[1649]=3, |
| 750 |
[1650]=3, |
| 751 |
[1651]=3, |
| 752 |
[1652]=4, |
| 753 |
[1653]=3, |
| 754 |
[1654]=3, |
| 755 |
[1655]=3, |
| 756 |
[1656]=2, |
| 757 |
[1657]=2, |
| 758 |
[1658]=2, |
| 759 |
[1659]=2, |
| 760 |
[1660]=2, |
| 761 |
[1661]=2, |
| 762 |
[1662]=2, |
| 763 |
[1663]=2, |
| 764 |
[1664]=2, |
| 765 |
[1665]=2, |
| 766 |
[1666]=2, |
| 767 |
[1667]=2, |
| 768 |
[1668]=2, |
| 769 |
[1669]=2, |
| 770 |
[1670]=2, |
| 771 |
[1671]=2, |
| 772 |
[1672]=3, |
| 773 |
[1673]=3, |
| 774 |
[1674]=3, |
| 775 |
[1675]=3, |
| 776 |
[1676]=3, |
| 777 |
[1677]=3, |
| 778 |
[1678]=3, |
| 779 |
[1679]=3, |
| 780 |
[1680]=3, |
| 781 |
[1681]=3, |
| 782 |
[1682]=3, |
| 783 |
[1683]=3, |
| 784 |
[1684]=3, |
| 785 |
[1685]=3, |
| 786 |
[1686]=3, |
| 787 |
[1687]=3, |
| 788 |
[1688]=3, |
| 789 |
[1689]=3, |
| 790 |
[1690]=2, |
| 791 |
[1691]=2, |
| 792 |
[1692]=2, |
| 793 |
[1693]=2, |
| 794 |
[1694]=2, |
| 795 |
[1695]=2, |
| 796 |
[1696]=2, |
| 797 |
[1697]=2, |
| 798 |
[1698]=2, |
| 799 |
[1699]=2, |
| 800 |
[1700]=2, |
| 801 |
[1701]=2, |
| 802 |
[1702]=2, |
| 803 |
[1703]=2, |
| 804 |
[1704]=2, |
| 805 |
[1705]=2, |
| 806 |
[1706]=2, |
| 807 |
[1707]=2, |
| 808 |
[1708]=2, |
| 809 |
[1709]=2, |
| 810 |
[1710]=2, |
| 811 |
[1711]=2, |
| 812 |
[1712]=2, |
| 813 |
[1713]=2, |
| 814 |
[1714]=2, |
| 815 |
[1715]=2, |
| 816 |
[1716]=2, |
| 817 |
[1717]=2, |
| 818 |
[1718]=2, |
| 819 |
[1719]=2, |
| 820 |
[1720]=2, |
| 821 |
[1721]=2, |
| 822 |
[1722]=2, |
| 823 |
[1723]=2, |
| 824 |
[1724]=2, |
| 825 |
[1725]=2, |
| 826 |
[1726]=2, |
| 827 |
[1727]=2, |
| 828 |
[1728]=3, |
| 829 |
[1729]=2, |
| 830 |
[1730]=2, |
| 831 |
[1731]=3, |
| 832 |
[1732]=3, |
| 833 |
[1733]=3, |
| 834 |
[1734]=3, |
| 835 |
[1735]=3, |
| 836 |
[1736]=3, |
| 837 |
[1737]=3, |
| 838 |
[1738]=3, |
| 839 |
[1739]=3, |
| 840 |
[1740]=2, |
| 841 |
[1741]=3, |
| 842 |
[1742]=2, |
| 843 |
[1743]=3, |
| 844 |
[1744]=2, |
| 845 |
[1745]=2, |
| 846 |
[1746]=3, |
| 847 |
[1747]=3, |
| 848 |
[1748]=6, |
| 849 |
[1749]=3, |
| 850 |
[1750]=5, |
| 851 |
[1751]=5, |
| 852 |
[1752]=5, |
| 853 |
[1753]=5, |
| 854 |
[1754]=5, |
| 855 |
[1755]=5, |
| 856 |
[1756]=5, |
| 857 |
[1757]=4, |
| 858 |
[1758]=6, |
| 859 |
[1759]=5, |
| 860 |
[1760]=5, |
| 861 |
[1761]=5, |
| 862 |
[1762]=5, |
| 863 |
[1763]=5, |
| 864 |
[1764]=5, |
| 865 |
[1765]=6, |
| 866 |
[1766]=6, |
| 867 |
[1767]=5, |
| 868 |
[1768]=5, |
| 869 |
[1769]=6, |
| 870 |
[1770]=5, |
| 871 |
[1771]=5, |
| 872 |
[1772]=5, |
| 873 |
[1773]=5, |
| 874 |
[1774]=3, |
| 875 |
[1775]=3, |
| 876 |
[1776]=6, |
| 877 |
[1777]=6, |
| 878 |
[1778]=6, |
| 879 |
[1779]=6, |
| 880 |
[1780]=6, |
| 881 |
[1781]=6, |
| 882 |
[1782]=6, |
| 883 |
[1783]=6, |
| 884 |
[1784]=6, |
| 885 |
[1785]=6, |
| 886 |
[1786]=2, |
| 887 |
[1787]=2, |
| 888 |
[1788]=2, |
| 889 |
[1789]=6, |
| 890 |
[1790]=6, |
| 891 |
[1791]=2, |
| 892 |
[1792]=6, |
| 893 |
[1793]=6, |
| 894 |
[1794]=6, |
| 895 |
[1795]=6, |
| 896 |
[1796]=6, |
| 897 |
[1797]=6, |
| 898 |
[1798]=6, |
| 899 |
[1799]=6, |
| 900 |
[1800]=6, |
| 901 |
[1801]=6, |
| 902 |
[1802]=6, |
| 903 |
[1803]=6, |
| 904 |
[1804]=6, |
| 905 |
[1805]=6, |
| 906 |
[1808]=3, |
| 907 |
[1809]=5, |
| 908 |
[1810]=2, |
| 909 |
[1811]=2, |
| 910 |
[1812]=2, |
| 911 |
[1813]=3, |
| 912 |
[1814]=3, |
| 913 |
[1815]=3, |
| 914 |
[1816]=3, |
| 915 |
[1817]=3, |
| 916 |
[1818]=2, |
| 917 |
[1819]=2, |
| 918 |
[1820]=2, |
| 919 |
[1821]=2, |
| 920 |
[1822]=3, |
| 921 |
[1823]=2, |
| 922 |
[1824]=2, |
| 923 |
[1825]=2, |
| 924 |
[1826]=2, |
| 925 |
[1827]=2, |
| 926 |
[1828]=2, |
| 927 |
[1829]=2, |
| 928 |
[1830]=2, |
| 929 |
[1831]=2, |
| 930 |
[1832]=3, |
| 931 |
[1833]=2, |
| 932 |
[1834]=3, |
| 933 |
[1835]=2, |
| 934 |
[1836]=3, |
| 935 |
[1837]=2, |
| 936 |
[1838]=2, |
| 937 |
[1839]=3, |
| 938 |
[1840]=5, |
| 939 |
[1841]=5, |
| 940 |
[1842]=5, |
| 941 |
[1843]=5, |
| 942 |
[1844]=5, |
| 943 |
[1845]=5, |
| 944 |
[1846]=5, |
| 945 |
[1847]=5, |
| 946 |
[1848]=5, |
| 947 |
[1849]=5, |
| 948 |
[1850]=5, |
| 949 |
[1851]=5, |
| 950 |
[1852]=5, |
| 951 |
[1853]=5, |
| 952 |
[1854]=5, |
| 953 |
[1855]=5, |
| 954 |
[1856]=5, |
| 955 |
[1857]=5, |
| 956 |
[1858]=5, |
| 957 |
[1859]=5, |
| 958 |
[1860]=5, |
| 959 |
[1861]=5, |
| 960 |
[1862]=5, |
| 961 |
[1863]=5, |
| 962 |
[1864]=5, |
| 963 |
[1865]=5, |
| 964 |
[1866]=5, |
| 965 |
[1869]=3, |
| 966 |
[1870]=2, |
| 967 |
[1871]=2, |
| 968 |
[1872]=2, |
| 969 |
[1873]=2, |
| 970 |
[1874]=2, |
| 971 |
[1875]=2, |
| 972 |
[1876]=2, |
| 973 |
[1877]=2, |
| 974 |
[1878]=2, |
| 975 |
[1879]=2, |
| 976 |
[1880]=2, |
| 977 |
[1881]=3, |
| 978 |
[1882]=3, |
| 979 |
[1883]=3, |
| 980 |
[1884]=2, |
| 981 |
[1885]=2, |
| 982 |
[1886]=2, |
| 983 |
[1887]=2, |
| 984 |
[1888]=2, |
| 985 |
[1889]=2, |
| 986 |
[1890]=2, |
| 987 |
[1891]=2, |
| 988 |
[1892]=2, |
| 989 |
[1893]=2, |
| 990 |
[1894]=2, |
| 991 |
[1895]=2, |
| 992 |
[1896]=2, |
| 993 |
[1897]=2, |
| 994 |
[1898]=2, |
| 995 |
[1899]=3, |
| 996 |
[1900]=3, |
| 997 |
[1901]=2, |
| 998 |
[1902]=2, |
| 999 |
[1903]=2, |
| 1000 |
[1904]=2, |
| 1001 |
[1905]=3, |
| 1002 |
[1906]=2, |
| 1003 |
[1907]=3, |
| 1004 |
[1908]=3, |
| 1005 |
[1909]=2, |
| 1006 |
[1910]=2, |
| 1007 |
[1911]=2, |
| 1008 |
[1912]=3, |
| 1009 |
[1913]=3, |
| 1010 |
[1914]=2, |
| 1011 |
[1915]=2, |
| 1012 |
[1916]=2, |
| 1013 |
[1917]=2, |
| 1014 |
[1918]=2, |
| 1015 |
[1919]=2, |
| 1016 |
[1958]=5, |
| 1017 |
[1959]=5, |
| 1018 |
[1960]=5, |
| 1019 |
[1961]=5, |
| 1020 |
[1962]=5, |
| 1021 |
[1963]=5, |
| 1022 |
[1964]=5, |
| 1023 |
[1965]=5, |
| 1024 |
[1966]=5, |
| 1025 |
[1967]=5, |
| 1026 |
[1968]=5, |
| 1027 |
[1984]=6, |
| 1028 |
[1985]=6, |
| 1029 |
[1986]=6, |
| 1030 |
[1987]=6, |
| 1031 |
[1988]=6, |
| 1032 |
[1989]=6, |
| 1033 |
[1990]=6, |
| 1034 |
[1991]=6, |
| 1035 |
[1992]=6, |
| 1036 |
[1993]=6, |
| 1037 |
[1994]=2, |
| 1038 |
[1995]=2, |
| 1039 |
[1996]=2, |
| 1040 |
[1997]=2, |
| 1041 |
[1998]=2, |
| 1042 |
[1999]=2, |
| 1043 |
[2000]=2, |
| 1044 |
[2001]=2, |
| 1045 |
[2002]=2, |
| 1046 |
[2003]=2, |
| 1047 |
[2004]=2, |
| 1048 |
[2005]=2, |
| 1049 |
[2006]=2, |
| 1050 |
[2007]=2, |
| 1051 |
[2008]=2, |
| 1052 |
[2009]=2, |
| 1053 |
[2010]=2, |
| 1054 |
[2011]=2, |
| 1055 |
[2012]=2, |
| 1056 |
[2013]=2, |
| 1057 |
[2014]=2, |
| 1058 |
[2015]=2, |
| 1059 |
[2016]=2, |
| 1060 |
[2017]=2, |
| 1061 |
[2018]=2, |
| 1062 |
[2019]=2, |
| 1063 |
[2020]=2, |
| 1064 |
[2021]=2, |
| 1065 |
[2022]=2, |
| 1066 |
[2023]=2, |
| 1067 |
[2024]=2, |
| 1068 |
[2025]=2, |
| 1069 |
[2026]=2, |
| 1070 |
[2027]=5, |
| 1071 |
[2028]=5, |
| 1072 |
[2029]=5, |
| 1073 |
[2030]=5, |
| 1074 |
[2031]=5, |
| 1075 |
[2032]=5, |
| 1076 |
[2033]=5, |
| 1077 |
[2034]=5, |
| 1078 |
[2035]=5, |
| 1079 |
[2036]=6, |
| 1080 |
[2037]=6, |
| 1081 |
[2038]=6, |
| 1082 |
[2039]=6, |
| 1083 |
[2040]=6, |
| 1084 |
[2041]=6, |
| 1085 |
[2042]=2, |
| 1086 |
[2045]=5, |
| 1087 |
[2046]=6, |
| 1088 |
[2047]=6, |
| 1089 |
[2070]=5, |
| 1090 |
[2071]=5, |
| 1091 |
[2072]=5, |
| 1092 |
[2073]=5, |
| 1093 |
[2075]=5, |
| 1094 |
[2076]=5, |
| 1095 |
[2077]=5, |
| 1096 |
[2078]=5, |
| 1097 |
[2079]=5, |
| 1098 |
[2080]=5, |
| 1099 |
[2081]=5, |
| 1100 |
[2082]=5, |
| 1101 |
[2083]=5, |
| 1102 |
[2085]=5, |
| 1103 |
[2086]=5, |
| 1104 |
[2087]=5, |
| 1105 |
[2089]=5, |
| 1106 |
[2090]=5, |
| 1107 |
[2091]=5, |
| 1108 |
[2092]=5, |
| 1109 |
[2093]=5, |
| 1110 |
[2112]=3, |
| 1111 |
[2113]=2, |
| 1112 |
[2114]=2, |
| 1113 |
[2115]=2, |
| 1114 |
[2116]=2, |
| 1115 |
[2117]=2, |
| 1116 |
[2118]=3, |
| 1117 |
[2119]=3, |
| 1118 |
[2120]=2, |
| 1119 |
[2121]=3, |
| 1120 |
[2122]=2, |
| 1121 |
[2123]=2, |
| 1122 |
[2124]=2, |
| 1123 |
[2125]=2, |
| 1124 |
[2126]=2, |
| 1125 |
[2127]=2, |
| 1126 |
[2128]=2, |
| 1127 |
[2129]=2, |
| 1128 |
[2130]=2, |
| 1129 |
[2131]=2, |
| 1130 |
[2132]=3, |
| 1131 |
[2133]=2, |
| 1132 |
[2134]=3, |
| 1133 |
[2135]=3, |
| 1134 |
[2136]=3, |
| 1135 |
[2137]=5, |
| 1136 |
[2138]=5, |
| 1137 |
[2139]=5, |
| 1138 |
[2144]=2, |
| 1139 |
[2145]=4, |
| 1140 |
[2146]=2, |
| 1141 |
[2147]=2, |
| 1142 |
[2148]=2, |
| 1143 |
[2149]=2, |
| 1144 |
[2150]=4, |
| 1145 |
[2151]=3, |
| 1146 |
[2152]=2, |
| 1147 |
[2153]=3, |
| 1148 |
[2154]=3, |
| 1149 |
[2160]=3, |
| 1150 |
[2161]=3, |
| 1151 |
[2162]=3, |
| 1152 |
[2163]=3, |
| 1153 |
[2164]=3, |
| 1154 |
[2165]=3, |
| 1155 |
[2166]=3, |
| 1156 |
[2167]=3, |
| 1157 |
[2168]=3, |
| 1158 |
[2169]=3, |
| 1159 |
[2170]=3, |
| 1160 |
[2171]=3, |
| 1161 |
[2172]=3, |
| 1162 |
[2173]=3, |
| 1163 |
[2174]=3, |
| 1164 |
[2175]=3, |
| 1165 |
[2176]=3, |
| 1166 |
[2177]=3, |
| 1167 |
[2178]=3, |
| 1168 |
[2179]=2, |
| 1169 |
[2180]=2, |
| 1170 |
[2181]=2, |
| 1171 |
[2182]=2, |
| 1172 |
[2183]=4, |
| 1173 |
[2184]=4, |
| 1174 |
[2185]=2, |
| 1175 |
[2186]=2, |
| 1176 |
[2187]=2, |
| 1177 |
[2188]=2, |
| 1178 |
[2189]=2, |
| 1179 |
[2190]=3, |
| 1180 |
[2192]=4, |
| 1181 |
[2193]=4, |
| 1182 |
[2200]=5, |
| 1183 |
[2201]=5, |
| 1184 |
[2202]=5, |
| 1185 |
[2203]=5, |
| 1186 |
[2204]=5, |
| 1187 |
[2205]=5, |
| 1188 |
[2206]=5, |
| 1189 |
[2207]=5, |
| 1190 |
[2208]=2, |
| 1191 |
[2209]=2, |
| 1192 |
[2210]=2, |
| 1193 |
[2211]=2, |
| 1194 |
[2212]=2, |
| 1195 |
[2213]=2, |
| 1196 |
[2214]=2, |
| 1197 |
[2215]=2, |
| 1198 |
[2216]=2, |
| 1199 |
[2217]=2, |
| 1200 |
[2218]=3, |
| 1201 |
[2219]=3, |
| 1202 |
[2220]=3, |
| 1203 |
[2221]=4, |
| 1204 |
[2222]=3, |
| 1205 |
[2223]=2, |
| 1206 |
[2224]=2, |
| 1207 |
[2225]=3, |
| 1208 |
[2226]=3, |
| 1209 |
[2227]=2, |
| 1210 |
[2228]=2, |
| 1211 |
[2229]=2, |
| 1212 |
[2230]=2, |
| 1213 |
[2231]=2, |
| 1214 |
[2232]=2, |
| 1215 |
[2233]=3, |
| 1216 |
[2234]=2, |
| 1217 |
[2235]=2, |
| 1218 |
[2236]=2, |
| 1219 |
[2237]=2, |
| 1220 |
[2238]=2, |
| 1221 |
[2239]=2, |
| 1222 |
[2240]=2, |
| 1223 |
[2241]=2, |
| 1224 |
[2242]=2, |
| 1225 |
[2243]=2, |
| 1226 |
[2244]=2, |
| 1227 |
[2245]=2, |
| 1228 |
[2246]=2, |
| 1229 |
[2247]=2, |
| 1230 |
[2248]=2, |
| 1231 |
[2250]=5, |
| 1232 |
[2251]=5, |
| 1233 |
[2252]=5, |
| 1234 |
[2253]=5, |
| 1235 |
[2254]=5, |
| 1236 |
[2255]=5, |
| 1237 |
[2256]=5, |
| 1238 |
[2257]=5, |
| 1239 |
[2258]=5, |
| 1240 |
[2259]=5, |
| 1241 |
[2260]=5, |
| 1242 |
[2261]=5, |
| 1243 |
[2262]=5, |
| 1244 |
[2263]=5, |
| 1245 |
[2264]=5, |
| 1246 |
[2265]=5, |
| 1247 |
[2266]=5, |
| 1248 |
[2267]=5, |
| 1249 |
[2268]=5, |
| 1250 |
[2269]=5, |
| 1251 |
[2270]=5, |
| 1252 |
[2271]=5, |
| 1253 |
[2272]=5, |
| 1254 |
[2273]=5, |
| 1255 |
[2274]=4, |
| 1256 |
[2275]=5, |
| 1257 |
[2276]=5, |
| 1258 |
[2277]=5, |
| 1259 |
[2278]=5, |
| 1260 |
[2279]=5, |
| 1261 |
[2280]=5, |
| 1262 |
[2281]=5, |
| 1263 |
[2282]=5, |
| 1264 |
[2283]=5, |
| 1265 |
[2284]=5, |
| 1266 |
[2285]=5, |
| 1267 |
[2286]=5, |
| 1268 |
[2287]=5, |
| 1269 |
[2288]=5, |
| 1270 |
[2289]=5, |
| 1271 |
[2290]=5, |
| 1272 |
[2291]=5, |
| 1273 |
[2292]=5, |
| 1274 |
[2293]=5, |
| 1275 |
[2294]=5, |
| 1276 |
[2295]=5, |
| 1277 |
[2296]=5, |
| 1278 |
[2297]=5, |
| 1279 |
[2298]=5, |
| 1280 |
[2299]=5, |
| 1281 |
[2300]=5, |
| 1282 |
[2301]=5, |
| 1283 |
[2302]=5, |
| 1284 |
[2303]=5, |
| 1285 |
[2304]=5, |
| 1286 |
[2305]=5, |
| 1287 |
[2306]=5, |
| 1288 |
[2362]=5, |
| 1289 |
[2364]=5, |
| 1290 |
[2369]=5, |
| 1291 |
[2370]=5, |
| 1292 |
[2371]=5, |
| 1293 |
[2372]=5, |
| 1294 |
[2373]=5, |
| 1295 |
[2374]=5, |
| 1296 |
[2375]=5, |
| 1297 |
[2376]=5, |
| 1298 |
[2381]=5, |
| 1299 |
[2385]=5, |
| 1300 |
[2386]=5, |
| 1301 |
[2387]=5, |
| 1302 |
[2388]=5, |
| 1303 |
[2389]=5, |
| 1304 |
[2390]=5, |
| 1305 |
[2391]=5, |
| 1306 |
[2402]=5, |
| 1307 |
[2403]=5, |
| 1308 |
[2433]=5, |
| 1309 |
[2492]=5, |
| 1310 |
[2497]=5, |
| 1311 |
[2498]=5, |
| 1312 |
[2499]=5, |
| 1313 |
[2500]=5, |
| 1314 |
[2509]=5, |
| 1315 |
[2530]=5, |
| 1316 |
[2531]=5, |
| 1317 |
[2558]=5, |
| 1318 |
[2561]=5, |
| 1319 |
[2562]=5, |
| 1320 |
[2620]=5, |
| 1321 |
[2625]=5, |
| 1322 |
[2626]=5, |
| 1323 |
[2631]=5, |
| 1324 |
[2632]=5, |
| 1325 |
[2635]=5, |
| 1326 |
[2636]=5, |
| 1327 |
[2637]=5, |
| 1328 |
[2641]=5, |
| 1329 |
[2672]=5, |
| 1330 |
[2673]=5, |
| 1331 |
[2677]=5, |
| 1332 |
[2689]=5, |
| 1333 |
[2690]=5, |
| 1334 |
[2748]=5, |
| 1335 |
[2753]=5, |
| 1336 |
[2754]=5, |
| 1337 |
[2755]=5, |
| 1338 |
[2756]=5, |
| 1339 |
[2757]=5, |
| 1340 |
[2759]=5, |
| 1341 |
[2760]=5, |
| 1342 |
[2765]=5, |
| 1343 |
[2786]=5, |
| 1344 |
[2787]=5, |
| 1345 |
[2810]=5, |
| 1346 |
[2811]=5, |
| 1347 |
[2812]=5, |
| 1348 |
[2813]=5, |
| 1349 |
[2814]=5, |
| 1350 |
[2815]=5, |
| 1351 |
[2817]=5, |
| 1352 |
[2876]=5, |
| 1353 |
[2879]=5, |
| 1354 |
[2881]=5, |
| 1355 |
[2882]=5, |
| 1356 |
[2883]=5, |
| 1357 |
[2884]=5, |
| 1358 |
[2893]=5, |
| 1359 |
[2901]=5, |
| 1360 |
[2902]=5, |
| 1361 |
[2914]=5, |
| 1362 |
[2915]=5, |
| 1363 |
[2946]=5, |
| 1364 |
[3008]=5, |
| 1365 |
[3021]=5, |
| 1366 |
[3072]=5, |
| 1367 |
[3076]=5, |
| 1368 |
[3132]=5, |
| 1369 |
[3134]=5, |
| 1370 |
[3135]=5, |
| 1371 |
[3136]=5, |
| 1372 |
[3142]=5, |
| 1373 |
[3143]=5, |
| 1374 |
[3144]=5, |
| 1375 |
[3146]=5, |
| 1376 |
[3147]=5, |
| 1377 |
[3148]=5, |
| 1378 |
[3149]=5, |
| 1379 |
[3157]=5, |
| 1380 |
[3158]=5, |
| 1381 |
[3170]=5, |
| 1382 |
[3171]=5, |
| 1383 |
[3201]=5, |
| 1384 |
[3260]=5, |
| 1385 |
[3263]=5, |
| 1386 |
[3270]=5, |
| 1387 |
[3276]=5, |
| 1388 |
[3277]=5, |
| 1389 |
[3298]=5, |
| 1390 |
[3299]=5, |
| 1391 |
[3328]=5, |
| 1392 |
[3329]=5, |
| 1393 |
[3387]=5, |
| 1394 |
[3388]=5, |
| 1395 |
[3393]=5, |
| 1396 |
[3394]=5, |
| 1397 |
[3395]=5, |
| 1398 |
[3396]=5, |
| 1399 |
[3405]=5, |
| 1400 |
[3426]=5, |
| 1401 |
[3427]=5, |
| 1402 |
[3457]=5, |
| 1403 |
[3530]=5, |
| 1404 |
[3538]=5, |
| 1405 |
[3539]=5, |
| 1406 |
[3540]=5, |
| 1407 |
[3542]=5, |
| 1408 |
[3633]=5, |
| 1409 |
[3636]=5, |
| 1410 |
[3637]=5, |
| 1411 |
[3638]=5, |
| 1412 |
[3639]=5, |
| 1413 |
[3640]=5, |
| 1414 |
[3641]=5, |
| 1415 |
[3642]=5, |
| 1416 |
[3655]=5, |
| 1417 |
[3656]=5, |
| 1418 |
[3657]=5, |
| 1419 |
[3658]=5, |
| 1420 |
[3659]=5, |
| 1421 |
[3660]=5, |
| 1422 |
[3661]=5, |
| 1423 |
[3662]=5, |
| 1424 |
[3761]=5, |
| 1425 |
[3764]=5, |
| 1426 |
[3765]=5, |
| 1427 |
[3766]=5, |
| 1428 |
[3767]=5, |
| 1429 |
[3768]=5, |
| 1430 |
[3769]=5, |
| 1431 |
[3770]=5, |
| 1432 |
[3771]=5, |
| 1433 |
[3772]=5, |
| 1434 |
[3784]=5, |
| 1435 |
[3785]=5, |
| 1436 |
[3786]=5, |
| 1437 |
[3787]=5, |
| 1438 |
[3788]=5, |
| 1439 |
[3789]=5, |
| 1440 |
[3864]=5, |
| 1441 |
[3865]=5, |
| 1442 |
[3893]=5, |
| 1443 |
[3895]=5, |
| 1444 |
[3897]=5, |
| 1445 |
[3953]=5, |
| 1446 |
[3954]=5, |
| 1447 |
[3955]=5, |
| 1448 |
[3956]=5, |
| 1449 |
[3957]=5, |
| 1450 |
[3958]=5, |
| 1451 |
[3959]=5, |
| 1452 |
[3960]=5, |
| 1453 |
[3961]=5, |
| 1454 |
[3962]=5, |
| 1455 |
[3963]=5, |
| 1456 |
[3964]=5, |
| 1457 |
[3965]=5, |
| 1458 |
[3966]=5, |
| 1459 |
[3968]=5, |
| 1460 |
[3969]=5, |
| 1461 |
[3970]=5, |
| 1462 |
[3971]=5, |
| 1463 |
[3972]=5, |
| 1464 |
[3974]=5, |
| 1465 |
[3975]=5, |
| 1466 |
[3981]=5, |
| 1467 |
[3982]=5, |
| 1468 |
[3983]=5, |
| 1469 |
[3984]=5, |
| 1470 |
[3985]=5, |
| 1471 |
[3986]=5, |
| 1472 |
[3987]=5, |
| 1473 |
[3988]=5, |
| 1474 |
[3989]=5, |
| 1475 |
[3990]=5, |
| 1476 |
[3991]=5, |
| 1477 |
[3993]=5, |
| 1478 |
[3994]=5, |
| 1479 |
[3995]=5, |
| 1480 |
[3996]=5, |
| 1481 |
[3997]=5, |
| 1482 |
[3998]=5, |
| 1483 |
[3999]=5, |
| 1484 |
[4000]=5, |
| 1485 |
[4001]=5, |
| 1486 |
[4002]=5, |
| 1487 |
[4003]=5, |
| 1488 |
[4004]=5, |
| 1489 |
[4005]=5, |
| 1490 |
[4006]=5, |
| 1491 |
[4007]=5, |
| 1492 |
[4008]=5, |
| 1493 |
[4009]=5, |
| 1494 |
[4010]=5, |
| 1495 |
[4011]=5, |
| 1496 |
[4012]=5, |
| 1497 |
[4013]=5, |
| 1498 |
[4014]=5, |
| 1499 |
[4015]=5, |
| 1500 |
[4016]=5, |
| 1501 |
[4017]=5, |
| 1502 |
[4018]=5, |
| 1503 |
[4019]=5, |
| 1504 |
[4020]=5, |
| 1505 |
[4021]=5, |
| 1506 |
[4022]=5, |
| 1507 |
[4023]=5, |
| 1508 |
[4024]=5, |
| 1509 |
[4025]=5, |
| 1510 |
[4026]=5, |
| 1511 |
[4027]=5, |
| 1512 |
[4028]=5, |
| 1513 |
[4038]=5, |
| 1514 |
[4141]=5, |
| 1515 |
[4142]=5, |
| 1516 |
[4143]=5, |
| 1517 |
[4144]=5, |
| 1518 |
[4146]=5, |
| 1519 |
[4147]=5, |
| 1520 |
[4148]=5, |
| 1521 |
[4149]=5, |
| 1522 |
[4150]=5, |
| 1523 |
[4151]=5, |
| 1524 |
[4153]=5, |
| 1525 |
[4154]=5, |
| 1526 |
[4157]=5, |
| 1527 |
[4158]=5, |
| 1528 |
[4184]=5, |
| 1529 |
[4185]=5, |
| 1530 |
[4190]=5, |
| 1531 |
[4191]=5, |
| 1532 |
[4192]=5, |
| 1533 |
[4209]=5, |
| 1534 |
[4210]=5, |
| 1535 |
[4211]=5, |
| 1536 |
[4212]=5, |
| 1537 |
[4226]=5, |
| 1538 |
[4229]=5, |
| 1539 |
[4230]=5, |
| 1540 |
[4237]=5, |
| 1541 |
[4253]=5, |
| 1542 |
[4957]=5, |
| 1543 |
[4958]=5, |
| 1544 |
[4959]=5, |
| 1545 |
[5906]=5, |
| 1546 |
[5907]=5, |
| 1547 |
[5908]=5, |
| 1548 |
[5938]=5, |
| 1549 |
[5939]=5, |
| 1550 |
[5940]=5, |
| 1551 |
[5970]=5, |
| 1552 |
[5971]=5, |
| 1553 |
[6002]=5, |
| 1554 |
[6003]=5, |
| 1555 |
[6071]=5, |
| 1556 |
[6072]=5, |
| 1557 |
[6073]=5, |
| 1558 |
[6074]=5, |
| 1559 |
[6075]=5, |
| 1560 |
[6076]=5, |
| 1561 |
[6077]=5, |
| 1562 |
[6086]=5, |
| 1563 |
[6089]=5, |
| 1564 |
[6090]=5, |
| 1565 |
[6091]=5, |
| 1566 |
[6092]=5, |
| 1567 |
[6093]=5, |
| 1568 |
[6094]=5, |
| 1569 |
[6095]=5, |
| 1570 |
[6096]=5, |
| 1571 |
[6097]=5, |
| 1572 |
[6098]=5, |
| 1573 |
[6099]=5, |
| 1574 |
[6109]=5, |
| 1575 |
[6150]=4, |
| 1576 |
[6151]=2, |
| 1577 |
[6154]=2, |
| 1578 |
[6155]=5, |
| 1579 |
[6156]=5, |
| 1580 |
[6157]=5, |
| 1581 |
[6158]=4, |
| 1582 |
[6159]=5, |
| 1583 |
[6176]=2, |
| 1584 |
[6177]=2, |
| 1585 |
[6178]=2, |
| 1586 |
[6179]=2, |
| 1587 |
[6180]=2, |
| 1588 |
[6181]=2, |
| 1589 |
[6182]=2, |
| 1590 |
[6183]=2, |
| 1591 |
[6184]=2, |
| 1592 |
[6185]=2, |
| 1593 |
[6186]=2, |
| 1594 |
[6187]=2, |
| 1595 |
[6188]=2, |
| 1596 |
[6189]=2, |
| 1597 |
[6190]=2, |
| 1598 |
[6191]=2, |
| 1599 |
[6192]=2, |
| 1600 |
[6193]=2, |
| 1601 |
[6194]=2, |
| 1602 |
[6195]=2, |
| 1603 |
[6196]=2, |
| 1604 |
[6197]=2, |
| 1605 |
[6198]=2, |
| 1606 |
[6199]=2, |
| 1607 |
[6200]=2, |
| 1608 |
[6201]=2, |
| 1609 |
[6202]=2, |
| 1610 |
[6203]=2, |
| 1611 |
[6204]=2, |
| 1612 |
[6205]=2, |
| 1613 |
[6206]=2, |
| 1614 |
[6207]=2, |
| 1615 |
[6208]=2, |
| 1616 |
[6209]=2, |
| 1617 |
[6210]=2, |
| 1618 |
[6211]=2, |
| 1619 |
[6212]=2, |
| 1620 |
[6213]=2, |
| 1621 |
[6214]=2, |
| 1622 |
[6215]=2, |
| 1623 |
[6216]=2, |
| 1624 |
[6217]=2, |
| 1625 |
[6218]=2, |
| 1626 |
[6219]=2, |
| 1627 |
[6220]=2, |
| 1628 |
[6221]=2, |
| 1629 |
[6222]=2, |
| 1630 |
[6223]=2, |
| 1631 |
[6224]=2, |
| 1632 |
[6225]=2, |
| 1633 |
[6226]=2, |
| 1634 |
[6227]=2, |
| 1635 |
[6228]=2, |
| 1636 |
[6229]=2, |
| 1637 |
[6230]=2, |
| 1638 |
[6231]=2, |
| 1639 |
[6232]=2, |
| 1640 |
[6233]=2, |
| 1641 |
[6234]=2, |
| 1642 |
[6235]=2, |
| 1643 |
[6236]=2, |
| 1644 |
[6237]=2, |
| 1645 |
[6238]=2, |
| 1646 |
[6239]=2, |
| 1647 |
[6240]=2, |
| 1648 |
[6241]=2, |
| 1649 |
[6242]=2, |
| 1650 |
[6243]=2, |
| 1651 |
[6244]=2, |
| 1652 |
[6245]=2, |
| 1653 |
[6246]=2, |
| 1654 |
[6247]=2, |
| 1655 |
[6248]=2, |
| 1656 |
[6249]=2, |
| 1657 |
[6250]=2, |
| 1658 |
[6251]=2, |
| 1659 |
[6252]=2, |
| 1660 |
[6253]=2, |
| 1661 |
[6254]=2, |
| 1662 |
[6255]=2, |
| 1663 |
[6256]=2, |
| 1664 |
[6257]=2, |
| 1665 |
[6258]=2, |
| 1666 |
[6259]=2, |
| 1667 |
[6260]=2, |
| 1668 |
[6261]=2, |
| 1669 |
[6262]=2, |
| 1670 |
[6263]=2, |
| 1671 |
[6264]=2, |
| 1672 |
[6272]=4, |
| 1673 |
[6273]=4, |
| 1674 |
[6274]=4, |
| 1675 |
[6275]=4, |
| 1676 |
[6276]=4, |
| 1677 |
[6279]=2, |
| 1678 |
[6280]=2, |
| 1679 |
[6281]=2, |
| 1680 |
[6282]=2, |
| 1681 |
[6283]=2, |
| 1682 |
[6284]=2, |
| 1683 |
[6285]=2, |
| 1684 |
[6286]=2, |
| 1685 |
[6287]=2, |
| 1686 |
[6288]=2, |
| 1687 |
[6289]=2, |
| 1688 |
[6290]=2, |
| 1689 |
[6291]=2, |
| 1690 |
[6292]=2, |
| 1691 |
[6293]=2, |
| 1692 |
[6294]=2, |
| 1693 |
[6295]=2, |
| 1694 |
[6296]=2, |
| 1695 |
[6297]=2, |
| 1696 |
[6298]=2, |
| 1697 |
[6299]=2, |
| 1698 |
[6300]=2, |
| 1699 |
[6301]=2, |
| 1700 |
[6302]=2, |
| 1701 |
[6303]=2, |
| 1702 |
[6304]=2, |
| 1703 |
[6305]=2, |
| 1704 |
[6306]=2, |
| 1705 |
[6307]=2, |
| 1706 |
[6308]=2, |
| 1707 |
[6309]=2, |
| 1708 |
[6310]=2, |
| 1709 |
[6311]=2, |
| 1710 |
[6312]=2, |
| 1711 |
[6313]=5, |
| 1712 |
[6314]=2, |
| 1713 |
[6432]=5, |
| 1714 |
[6433]=5, |
| 1715 |
[6434]=5, |
| 1716 |
[6439]=5, |
| 1717 |
[6440]=5, |
| 1718 |
[6450]=5, |
| 1719 |
[6457]=5, |
| 1720 |
[6458]=5, |
| 1721 |
[6459]=5, |
| 1722 |
[6679]=5, |
| 1723 |
[6680]=5, |
| 1724 |
[6742]=5, |
| 1725 |
[6744]=5, |
| 1726 |
[6745]=5, |
| 1727 |
[6746]=5, |
| 1728 |
[6747]=5, |
| 1729 |
[6748]=5, |
| 1730 |
[6749]=5, |
| 1731 |
[6750]=5, |
| 1732 |
[6752]=5, |
| 1733 |
[6754]=5, |
| 1734 |
[6757]=5, |
| 1735 |
[6758]=5, |
| 1736 |
[6759]=5, |
| 1737 |
[6760]=5, |
| 1738 |
[6761]=5, |
| 1739 |
[6762]=5, |
| 1740 |
[6763]=5, |
| 1741 |
[6764]=5, |
| 1742 |
[6771]=5, |
| 1743 |
[6772]=5, |
| 1744 |
[6773]=5, |
| 1745 |
[6774]=5, |
| 1746 |
[6775]=5, |
| 1747 |
[6776]=5, |
| 1748 |
[6777]=5, |
| 1749 |
[6778]=5, |
| 1750 |
[6779]=5, |
| 1751 |
[6780]=5, |
| 1752 |
[6783]=5, |
| 1753 |
[6832]=5, |
| 1754 |
[6833]=5, |
| 1755 |
[6834]=5, |
| 1756 |
[6835]=5, |
| 1757 |
[6836]=5, |
| 1758 |
[6837]=5, |
| 1759 |
[6838]=5, |
| 1760 |
[6839]=5, |
| 1761 |
[6840]=5, |
| 1762 |
[6841]=5, |
| 1763 |
[6842]=5, |
| 1764 |
[6843]=5, |
| 1765 |
[6844]=5, |
| 1766 |
[6845]=5, |
| 1767 |
[6847]=5, |
| 1768 |
[6848]=5, |
| 1769 |
[6849]=5, |
| 1770 |
[6850]=5, |
| 1771 |
[6851]=5, |
| 1772 |
[6852]=5, |
| 1773 |
[6853]=5, |
| 1774 |
[6854]=5, |
| 1775 |
[6855]=5, |
| 1776 |
[6856]=5, |
| 1777 |
[6857]=5, |
| 1778 |
[6858]=5, |
| 1779 |
[6859]=5, |
| 1780 |
[6860]=5, |
| 1781 |
[6861]=5, |
| 1782 |
[6862]=5, |
| 1783 |
[6912]=5, |
| 1784 |
[6913]=5, |
| 1785 |
[6914]=5, |
| 1786 |
[6915]=5, |
| 1787 |
[6964]=5, |
| 1788 |
[6966]=5, |
| 1789 |
[6967]=5, |
| 1790 |
[6968]=5, |
| 1791 |
[6969]=5, |
| 1792 |
[6970]=5, |
| 1793 |
[6972]=5, |
| 1794 |
[6978]=5, |
| 1795 |
[7019]=5, |
| 1796 |
[7020]=5, |
| 1797 |
[7021]=5, |
| 1798 |
[7022]=5, |
| 1799 |
[7023]=5, |
| 1800 |
[7024]=5, |
| 1801 |
[7025]=5, |
| 1802 |
[7026]=5, |
| 1803 |
[7027]=5, |
| 1804 |
[7040]=5, |
| 1805 |
[7041]=5, |
| 1806 |
[7074]=5, |
| 1807 |
[7075]=5, |
| 1808 |
[7076]=5, |
| 1809 |
[7077]=5, |
| 1810 |
[7080]=5, |
| 1811 |
[7081]=5, |
| 1812 |
[7083]=5, |
| 1813 |
[7142]=5, |
| 1814 |
[7144]=5, |
| 1815 |
[7145]=5, |
| 1816 |
[7149]=5, |
| 1817 |
[7151]=5, |
| 1818 |
[7152]=5, |
| 1819 |
[7153]=5, |
| 1820 |
[7212]=5, |
| 1821 |
[7213]=5, |
| 1822 |
[7214]=5, |
| 1823 |
[7215]=5, |
| 1824 |
[7216]=5, |
| 1825 |
[7217]=5, |
| 1826 |
[7218]=5, |
| 1827 |
[7219]=5, |
| 1828 |
[7222]=5, |
| 1829 |
[7223]=5, |
| 1830 |
[7376]=5, |
| 1831 |
[7377]=5, |
| 1832 |
[7378]=5, |
| 1833 |
[7380]=5, |
| 1834 |
[7381]=5, |
| 1835 |
[7382]=5, |
| 1836 |
[7383]=5, |
| 1837 |
[7384]=5, |
| 1838 |
[7385]=5, |
| 1839 |
[7386]=5, |
| 1840 |
[7387]=5, |
| 1841 |
[7388]=5, |
| 1842 |
[7389]=5, |
| 1843 |
[7390]=5, |
| 1844 |
[7391]=5, |
| 1845 |
[7392]=5, |
| 1846 |
[7394]=5, |
| 1847 |
[7395]=5, |
| 1848 |
[7396]=5, |
| 1849 |
[7397]=5, |
| 1850 |
[7398]=5, |
| 1851 |
[7399]=5, |
| 1852 |
[7400]=5, |
| 1853 |
[7405]=5, |
| 1854 |
[7412]=5, |
| 1855 |
[7416]=5, |
| 1856 |
[7417]=5, |
| 1857 |
[7616]=5, |
| 1858 |
[7617]=5, |
| 1859 |
[7618]=5, |
| 1860 |
[7619]=5, |
| 1861 |
[7620]=5, |
| 1862 |
[7621]=5, |
| 1863 |
[7622]=5, |
| 1864 |
[7623]=5, |
| 1865 |
[7624]=5, |
| 1866 |
[7625]=5, |
| 1867 |
[7626]=5, |
| 1868 |
[7627]=5, |
| 1869 |
[7628]=5, |
| 1870 |
[7629]=5, |
| 1871 |
[7630]=5, |
| 1872 |
[7631]=5, |
| 1873 |
[7632]=5, |
| 1874 |
[7633]=5, |
| 1875 |
[7634]=5, |
| 1876 |
[7635]=5, |
| 1877 |
[7636]=5, |
| 1878 |
[7637]=5, |
| 1879 |
[7638]=5, |
| 1880 |
[7639]=5, |
| 1881 |
[7640]=5, |
| 1882 |
[7641]=5, |
| 1883 |
[7642]=5, |
| 1884 |
[7643]=5, |
| 1885 |
[7644]=5, |
| 1886 |
[7645]=5, |
| 1887 |
[7646]=5, |
| 1888 |
[7647]=5, |
| 1889 |
[7648]=5, |
| 1890 |
[7649]=5, |
| 1891 |
[7650]=5, |
| 1892 |
[7651]=5, |
| 1893 |
[7652]=5, |
| 1894 |
[7653]=5, |
| 1895 |
[7654]=5, |
| 1896 |
[7655]=5, |
| 1897 |
[7656]=5, |
| 1898 |
[7657]=5, |
| 1899 |
[7658]=5, |
| 1900 |
[7659]=5, |
| 1901 |
[7660]=5, |
| 1902 |
[7661]=5, |
| 1903 |
[7662]=5, |
| 1904 |
[7663]=5, |
| 1905 |
[7664]=5, |
| 1906 |
[7665]=5, |
| 1907 |
[7666]=5, |
| 1908 |
[7667]=5, |
| 1909 |
[7668]=5, |
| 1910 |
[7669]=5, |
| 1911 |
[7670]=5, |
| 1912 |
[7671]=5, |
| 1913 |
[7672]=5, |
| 1914 |
[7673]=5, |
| 1915 |
[7674]=5, |
| 1916 |
[7675]=5, |
| 1917 |
[7676]=5, |
| 1918 |
[7677]=5, |
| 1919 |
[7678]=5, |
| 1920 |
[7679]=5, |
| 1921 |
[8204]=4, |
| 1922 |
[8205]=2, |
| 1923 |
[8239]=4, |
| 1924 |
[8294]=4, |
| 1925 |
[8295]=4, |
| 1926 |
[8296]=4, |
| 1927 |
[8297]=4, |
| 1928 |
[8400]=5, |
| 1929 |
[8401]=5, |
| 1930 |
[8402]=5, |
| 1931 |
[8403]=5, |
| 1932 |
[8404]=5, |
| 1933 |
[8405]=5, |
| 1934 |
[8406]=5, |
| 1935 |
[8407]=5, |
| 1936 |
[8408]=5, |
| 1937 |
[8409]=5, |
| 1938 |
[8410]=5, |
| 1939 |
[8411]=5, |
| 1940 |
[8412]=5, |
| 1941 |
[8417]=5, |
| 1942 |
[8421]=5, |
| 1943 |
[8422]=5, |
| 1944 |
[8423]=5, |
| 1945 |
[8424]=5, |
| 1946 |
[8425]=5, |
| 1947 |
[8426]=5, |
| 1948 |
[8427]=5, |
| 1949 |
[8428]=5, |
| 1950 |
[8429]=5, |
| 1951 |
[8430]=5, |
| 1952 |
[8431]=5, |
| 1953 |
[8432]=5, |
| 1954 |
[11503]=5, |
| 1955 |
[11504]=5, |
| 1956 |
[11505]=5, |
| 1957 |
[11647]=5, |
| 1958 |
[11744]=5, |
| 1959 |
[11745]=5, |
| 1960 |
[11746]=5, |
| 1961 |
[11747]=5, |
| 1962 |
[11748]=5, |
| 1963 |
[11749]=5, |
| 1964 |
[11750]=5, |
| 1965 |
[11751]=5, |
| 1966 |
[11752]=5, |
| 1967 |
[11753]=5, |
| 1968 |
[11754]=5, |
| 1969 |
[11755]=5, |
| 1970 |
[11756]=5, |
| 1971 |
[11757]=5, |
| 1972 |
[11758]=5, |
| 1973 |
[11759]=5, |
| 1974 |
[11760]=5, |
| 1975 |
[11761]=5, |
| 1976 |
[11762]=5, |
| 1977 |
[11763]=5, |
| 1978 |
[11764]=5, |
| 1979 |
[11765]=5, |
| 1980 |
[11766]=5, |
| 1981 |
[11767]=5, |
| 1982 |
[11768]=5, |
| 1983 |
[11769]=5, |
| 1984 |
[11770]=5, |
| 1985 |
[11771]=5, |
| 1986 |
[11772]=5, |
| 1987 |
[11773]=5, |
| 1988 |
[11774]=5, |
| 1989 |
[11775]=5, |
| 1990 |
[12330]=5, |
| 1991 |
[12331]=5, |
| 1992 |
[12332]=5, |
| 1993 |
[12333]=5, |
| 1994 |
[12334]=5, |
| 1995 |
[12335]=5, |
| 1996 |
[12441]=5, |
| 1997 |
[12442]=5, |
| 1998 |
[42607]=5, |
| 1999 |
[42612]=5, |
| 2000 |
[42613]=5, |
| 2001 |
[42614]=5, |
| 2002 |
[42615]=5, |
| 2003 |
[42616]=5, |
| 2004 |
[42617]=5, |
| 2005 |
[42618]=5, |
| 2006 |
[42619]=5, |
| 2007 |
[42620]=5, |
| 2008 |
[42621]=5, |
| 2009 |
[42654]=5, |
| 2010 |
[42655]=5, |
| 2011 |
[42736]=5, |
| 2012 |
[42737]=5, |
| 2013 |
[43014]=5, |
| 2014 |
[43019]=5, |
| 2015 |
[43045]=5, |
| 2016 |
[43046]=5, |
| 2017 |
[43052]=5, |
| 2018 |
[43072]=2, |
| 2019 |
[43073]=2, |
| 2020 |
[43074]=2, |
| 2021 |
[43075]=2, |
| 2022 |
[43076]=2, |
| 2023 |
[43077]=2, |
| 2024 |
[43078]=2, |
| 2025 |
[43079]=2, |
| 2026 |
[43080]=2, |
| 2027 |
[43081]=2, |
| 2028 |
[43082]=2, |
| 2029 |
[43083]=2, |
| 2030 |
[43084]=2, |
| 2031 |
[43085]=2, |
| 2032 |
[43086]=2, |
| 2033 |
[43087]=2, |
| 2034 |
[43088]=2, |
| 2035 |
[43089]=2, |
| 2036 |
[43090]=2, |
| 2037 |
[43091]=2, |
| 2038 |
[43092]=2, |
| 2039 |
[43093]=2, |
| 2040 |
[43094]=2, |
| 2041 |
[43095]=2, |
| 2042 |
[43096]=2, |
| 2043 |
[43097]=2, |
| 2044 |
[43098]=2, |
| 2045 |
[43099]=2, |
| 2046 |
[43100]=2, |
| 2047 |
[43101]=2, |
| 2048 |
[43102]=2, |
| 2049 |
[43103]=2, |
| 2050 |
[43104]=2, |
| 2051 |
[43105]=2, |
| 2052 |
[43106]=2, |
| 2053 |
[43107]=2, |
| 2054 |
[43108]=2, |
| 2055 |
[43109]=2, |
| 2056 |
[43110]=2, |
| 2057 |
[43111]=2, |
| 2058 |
[43112]=2, |
| 2059 |
[43113]=2, |
| 2060 |
[43114]=2, |
| 2061 |
[43115]=2, |
| 2062 |
[43116]=2, |
| 2063 |
[43117]=2, |
| 2064 |
[43118]=2, |
| 2065 |
[43119]=2, |
| 2066 |
[43120]=2, |
| 2067 |
[43121]=2, |
| 2068 |
[43122]=1, |
| 2069 |
[43123]=4, |
| 2070 |
[43204]=5, |
| 2071 |
[43205]=5, |
| 2072 |
[43232]=5, |
| 2073 |
[43233]=5, |
| 2074 |
[43234]=5, |
| 2075 |
[43235]=5, |
| 2076 |
[43236]=5, |
| 2077 |
[43237]=5, |
| 2078 |
[43238]=5, |
| 2079 |
[43239]=5, |
| 2080 |
[43240]=5, |
| 2081 |
[43241]=5, |
| 2082 |
[43242]=5, |
| 2083 |
[43243]=5, |
| 2084 |
[43244]=5, |
| 2085 |
[43245]=5, |
| 2086 |
[43246]=5, |
| 2087 |
[43247]=5, |
| 2088 |
[43248]=5, |
| 2089 |
[43249]=5, |
| 2090 |
[43263]=5, |
| 2091 |
[43302]=5, |
| 2092 |
[43303]=5, |
| 2093 |
[43304]=5, |
| 2094 |
[43305]=5, |
| 2095 |
[43306]=5, |
| 2096 |
[43307]=5, |
| 2097 |
[43308]=5, |
| 2098 |
[43309]=5, |
| 2099 |
[43335]=5, |
| 2100 |
[43336]=5, |
| 2101 |
[43337]=5, |
| 2102 |
[43338]=5, |
| 2103 |
[43339]=5, |
| 2104 |
[43340]=5, |
| 2105 |
[43341]=5, |
| 2106 |
[43342]=5, |
| 2107 |
[43343]=5, |
| 2108 |
[43344]=5, |
| 2109 |
[43345]=5, |
| 2110 |
[43392]=5, |
| 2111 |
[43393]=5, |
| 2112 |
[43394]=5, |
| 2113 |
[43443]=5, |
| 2114 |
[43446]=5, |
| 2115 |
[43447]=5, |
| 2116 |
[43448]=5, |
| 2117 |
[43449]=5, |
| 2118 |
[43452]=5, |
| 2119 |
[43493]=5, |
| 2120 |
[43561]=5, |
| 2121 |
[43562]=5, |
| 2122 |
[43563]=5, |
| 2123 |
[43564]=5, |
| 2124 |
[43565]=5, |
| 2125 |
[43566]=5, |
| 2126 |
[43569]=5, |
| 2127 |
[43570]=5, |
| 2128 |
[43573]=5, |
| 2129 |
[43574]=5, |
| 2130 |
[43587]=5, |
| 2131 |
[43596]=5, |
| 2132 |
[43644]=5, |
| 2133 |
[43696]=5, |
| 2134 |
[43698]=5, |
| 2135 |
[43699]=5, |
| 2136 |
[43700]=5, |
| 2137 |
[43703]=5, |
| 2138 |
[43704]=5, |
| 2139 |
[43710]=5, |
| 2140 |
[43711]=5, |
| 2141 |
[43713]=5, |
| 2142 |
[43756]=5, |
| 2143 |
[43757]=5, |
| 2144 |
[43766]=5, |
| 2145 |
[44005]=5, |
| 2146 |
[44008]=5, |
| 2147 |
[44013]=5, |
| 2148 |
[64286]=5, |
| 2149 |
[65056]=5, |
| 2150 |
[65057]=5, |
| 2151 |
[65058]=5, |
| 2152 |
[65059]=5, |
| 2153 |
[65060]=5, |
| 2154 |
[65061]=5, |
| 2155 |
[65062]=5, |
| 2156 |
[65063]=5, |
| 2157 |
[65064]=5, |
| 2158 |
[65065]=5, |
| 2159 |
[65066]=5, |
| 2160 |
[65067]=5, |
| 2161 |
[65068]=5, |
| 2162 |
[65069]=5, |
| 2163 |
[65070]=5, |
| 2164 |
[65071]=5, |
| 2165 |
[66045]=5, |
| 2166 |
[66272]=5, |
| 2167 |
[66422]=5, |
| 2168 |
[66423]=5, |
| 2169 |
[66424]=5, |
| 2170 |
[66425]=5, |
| 2171 |
[66426]=5, |
| 2172 |
[68097]=5, |
| 2173 |
[68098]=5, |
| 2174 |
[68099]=5, |
| 2175 |
[68101]=5, |
| 2176 |
[68102]=5, |
| 2177 |
[68108]=5, |
| 2178 |
[68109]=5, |
| 2179 |
[68110]=5, |
| 2180 |
[68111]=5, |
| 2181 |
[68152]=5, |
| 2182 |
[68153]=5, |
| 2183 |
[68154]=5, |
| 2184 |
[68159]=5, |
| 2185 |
[68288]=2, |
| 2186 |
[68289]=2, |
| 2187 |
[68290]=2, |
| 2188 |
[68291]=2, |
| 2189 |
[68292]=2, |
| 2190 |
[68293]=3, |
| 2191 |
[68294]=4, |
| 2192 |
[68295]=3, |
| 2193 |
[68296]=4, |
| 2194 |
[68297]=3, |
| 2195 |
[68298]=3, |
| 2196 |
[68299]=4, |
| 2197 |
[68300]=4, |
| 2198 |
[68301]=1, |
| 2199 |
[68302]=3, |
| 2200 |
[68303]=3, |
| 2201 |
[68304]=3, |
| 2202 |
[68305]=3, |
| 2203 |
[68306]=3, |
| 2204 |
[68307]=2, |
| 2205 |
[68308]=2, |
| 2206 |
[68309]=2, |
| 2207 |
[68310]=2, |
| 2208 |
[68311]=1, |
| 2209 |
[68312]=2, |
| 2210 |
[68313]=2, |
| 2211 |
[68314]=2, |
| 2212 |
[68315]=2, |
| 2213 |
[68316]=2, |
| 2214 |
[68317]=3, |
| 2215 |
[68318]=2, |
| 2216 |
[68319]=2, |
| 2217 |
[68320]=2, |
| 2218 |
[68321]=3, |
| 2219 |
[68322]=4, |
| 2220 |
[68323]=4, |
| 2221 |
[68324]=3, |
| 2222 |
[68325]=5, |
| 2223 |
[68326]=5, |
| 2224 |
[68331]=2, |
| 2225 |
[68332]=2, |
| 2226 |
[68333]=2, |
| 2227 |
[68334]=2, |
| 2228 |
[68335]=3, |
| 2229 |
[68480]=2, |
| 2230 |
[68481]=3, |
| 2231 |
[68482]=2, |
| 2232 |
[68483]=3, |
| 2233 |
[68484]=3, |
| 2234 |
[68485]=3, |
| 2235 |
[68486]=2, |
| 2236 |
[68487]=2, |
| 2237 |
[68488]=2, |
| 2238 |
[68489]=3, |
| 2239 |
[68490]=2, |
| 2240 |
[68491]=2, |
| 2241 |
[68492]=3, |
| 2242 |
[68493]=2, |
| 2243 |
[68494]=3, |
| 2244 |
[68495]=3, |
| 2245 |
[68496]=2, |
| 2246 |
[68497]=3, |
| 2247 |
[68521]=3, |
| 2248 |
[68522]=3, |
| 2249 |
[68523]=3, |
| 2250 |
[68524]=3, |
| 2251 |
[68525]=2, |
| 2252 |
[68526]=2, |
| 2253 |
[68527]=4, |
| 2254 |
[68864]=1, |
| 2255 |
[68865]=2, |
| 2256 |
[68866]=2, |
| 2257 |
[68867]=2, |
| 2258 |
[68868]=2, |
| 2259 |
[68869]=2, |
| 2260 |
[68870]=2, |
| 2261 |
[68871]=2, |
| 2262 |
[68872]=2, |
| 2263 |
[68873]=2, |
| 2264 |
[68874]=2, |
| 2265 |
[68875]=2, |
| 2266 |
[68876]=2, |
| 2267 |
[68877]=2, |
| 2268 |
[68878]=2, |
| 2269 |
[68879]=2, |
| 2270 |
[68880]=2, |
| 2271 |
[68881]=2, |
| 2272 |
[68882]=2, |
| 2273 |
[68883]=2, |
| 2274 |
[68884]=2, |
| 2275 |
[68885]=2, |
| 2276 |
[68886]=2, |
| 2277 |
[68887]=2, |
| 2278 |
[68888]=2, |
| 2279 |
[68889]=2, |
| 2280 |
[68890]=2, |
| 2281 |
[68891]=2, |
| 2282 |
[68892]=2, |
| 2283 |
[68893]=2, |
| 2284 |
[68894]=2, |
| 2285 |
[68895]=2, |
| 2286 |
[68896]=2, |
| 2287 |
[68897]=2, |
| 2288 |
[68898]=3, |
| 2289 |
[68899]=2, |
| 2290 |
[68900]=5, |
| 2291 |
[68901]=5, |
| 2292 |
[68902]=5, |
| 2293 |
[68903]=5, |
| 2294 |
[69291]=5, |
| 2295 |
[69292]=5, |
| 2296 |
[69424]=2, |
| 2297 |
[69425]=2, |
| 2298 |
[69426]=2, |
| 2299 |
[69427]=3, |
| 2300 |
[69428]=2, |
| 2301 |
[69429]=2, |
| 2302 |
[69430]=2, |
| 2303 |
[69431]=2, |
| 2304 |
[69432]=2, |
| 2305 |
[69433]=2, |
| 2306 |
[69434]=2, |
| 2307 |
[69435]=2, |
| 2308 |
[69436]=2, |
| 2309 |
[69437]=2, |
| 2310 |
[69438]=2, |
| 2311 |
[69439]=2, |
| 2312 |
[69440]=2, |
| 2313 |
[69441]=2, |
| 2314 |
[69442]=2, |
| 2315 |
[69443]=2, |
| 2316 |
[69444]=2, |
| 2317 |
[69445]=4, |
| 2318 |
[69446]=5, |
| 2319 |
[69447]=5, |
| 2320 |
[69448]=5, |
| 2321 |
[69449]=5, |
| 2322 |
[69450]=5, |
| 2323 |
[69451]=5, |
| 2324 |
[69452]=5, |
| 2325 |
[69453]=5, |
| 2326 |
[69454]=5, |
| 2327 |
[69455]=5, |
| 2328 |
[69456]=5, |
| 2329 |
[69457]=2, |
| 2330 |
[69458]=2, |
| 2331 |
[69459]=2, |
| 2332 |
[69460]=3, |
| 2333 |
[69488]=2, |
| 2334 |
[69489]=2, |
| 2335 |
[69490]=2, |
| 2336 |
[69491]=2, |
| 2337 |
[69492]=3, |
| 2338 |
[69493]=3, |
| 2339 |
[69494]=2, |
| 2340 |
[69495]=2, |
| 2341 |
[69496]=2, |
| 2342 |
[69497]=2, |
| 2343 |
[69498]=2, |
| 2344 |
[69499]=2, |
| 2345 |
[69500]=2, |
| 2346 |
[69501]=2, |
| 2347 |
[69502]=2, |
| 2348 |
[69503]=2, |
| 2349 |
[69504]=2, |
| 2350 |
[69505]=2, |
| 2351 |
[69506]=5, |
| 2352 |
[69507]=5, |
| 2353 |
[69508]=5, |
| 2354 |
[69509]=5, |
| 2355 |
[69552]=2, |
| 2356 |
[69553]=4, |
| 2357 |
[69554]=2, |
| 2358 |
[69555]=2, |
| 2359 |
[69556]=3, |
| 2360 |
[69557]=3, |
| 2361 |
[69558]=3, |
| 2362 |
[69559]=4, |
| 2363 |
[69560]=2, |
| 2364 |
[69561]=3, |
| 2365 |
[69562]=3, |
| 2366 |
[69563]=2, |
| 2367 |
[69564]=2, |
| 2368 |
[69565]=3, |
| 2369 |
[69566]=2, |
| 2370 |
[69567]=2, |
| 2371 |
[69568]=4, |
| 2372 |
[69569]=2, |
| 2373 |
[69570]=3, |
| 2374 |
[69571]=3, |
| 2375 |
[69572]=2, |
| 2376 |
[69573]=4, |
| 2377 |
[69574]=4, |
| 2378 |
[69575]=4, |
| 2379 |
[69576]=4, |
| 2380 |
[69577]=3, |
| 2381 |
[69578]=2, |
| 2382 |
[69579]=1, |
| 2383 |
[69633]=5, |
| 2384 |
[69688]=5, |
| 2385 |
[69689]=5, |
| 2386 |
[69690]=5, |
| 2387 |
[69691]=5, |
| 2388 |
[69692]=5, |
| 2389 |
[69693]=5, |
| 2390 |
[69694]=5, |
| 2391 |
[69695]=5, |
| 2392 |
[69696]=5, |
| 2393 |
[69697]=5, |
| 2394 |
[69698]=5, |
| 2395 |
[69699]=5, |
| 2396 |
[69700]=5, |
| 2397 |
[69701]=5, |
| 2398 |
[69702]=5, |
| 2399 |
[69744]=5, |
| 2400 |
[69747]=5, |
| 2401 |
[69748]=5, |
| 2402 |
[69759]=5, |
| 2403 |
[69760]=5, |
| 2404 |
[69761]=5, |
| 2405 |
[69811]=5, |
| 2406 |
[69812]=5, |
| 2407 |
[69813]=5, |
| 2408 |
[69814]=5, |
| 2409 |
[69817]=5, |
| 2410 |
[69818]=5, |
| 2411 |
[69821]=4, |
| 2412 |
[69826]=5, |
| 2413 |
[69837]=4, |
| 2414 |
[69888]=5, |
| 2415 |
[69889]=5, |
| 2416 |
[69890]=5, |
| 2417 |
[69927]=5, |
| 2418 |
[69928]=5, |
| 2419 |
[69929]=5, |
| 2420 |
[69930]=5, |
| 2421 |
[69931]=5, |
| 2422 |
[69933]=5, |
| 2423 |
[69934]=5, |
| 2424 |
[69935]=5, |
| 2425 |
[69936]=5, |
| 2426 |
[69937]=5, |
| 2427 |
[69938]=5, |
| 2428 |
[69939]=5, |
| 2429 |
[69940]=5, |
| 2430 |
[70003]=5, |
| 2431 |
[70016]=5, |
| 2432 |
[70017]=5, |
| 2433 |
[70070]=5, |
| 2434 |
[70071]=5, |
| 2435 |
[70072]=5, |
| 2436 |
[70073]=5, |
| 2437 |
[70074]=5, |
| 2438 |
[70075]=5, |
| 2439 |
[70076]=5, |
| 2440 |
[70077]=5, |
| 2441 |
[70078]=5, |
| 2442 |
[70090]=5, |
| 2443 |
[70091]=5, |
| 2444 |
[70092]=5, |
| 2445 |
[70095]=5, |
| 2446 |
[70191]=5, |
| 2447 |
[70192]=5, |
| 2448 |
[70193]=5, |
| 2449 |
[70196]=5, |
| 2450 |
[70198]=5, |
| 2451 |
[70199]=5, |
| 2452 |
[70206]=5, |
| 2453 |
[70367]=5, |
| 2454 |
[70371]=5, |
| 2455 |
[70372]=5, |
| 2456 |
[70373]=5, |
| 2457 |
[70374]=5, |
| 2458 |
[70375]=5, |
| 2459 |
[70376]=5, |
| 2460 |
[70377]=5, |
| 2461 |
[70378]=5, |
| 2462 |
[70400]=5, |
| 2463 |
[70401]=5, |
| 2464 |
[70459]=5, |
| 2465 |
[70460]=5, |
| 2466 |
[70464]=5, |
| 2467 |
[70502]=5, |
| 2468 |
[70503]=5, |
| 2469 |
[70504]=5, |
| 2470 |
[70505]=5, |
| 2471 |
[70506]=5, |
| 2472 |
[70507]=5, |
| 2473 |
[70508]=5, |
| 2474 |
[70512]=5, |
| 2475 |
[70513]=5, |
| 2476 |
[70514]=5, |
| 2477 |
[70515]=5, |
| 2478 |
[70516]=5, |
| 2479 |
[70712]=5, |
| 2480 |
[70713]=5, |
| 2481 |
[70714]=5, |
| 2482 |
[70715]=5, |
| 2483 |
[70716]=5, |
| 2484 |
[70717]=5, |
| 2485 |
[70718]=5, |
| 2486 |
[70719]=5, |
| 2487 |
[70722]=5, |
| 2488 |
[70723]=5, |
| 2489 |
[70724]=5, |
| 2490 |
[70726]=5, |
| 2491 |
[70750]=5, |
| 2492 |
[70835]=5, |
| 2493 |
[70836]=5, |
| 2494 |
[70837]=5, |
| 2495 |
[70838]=5, |
| 2496 |
[70839]=5, |
| 2497 |
[70840]=5, |
| 2498 |
[70842]=5, |
| 2499 |
[70847]=5, |
| 2500 |
[70848]=5, |
| 2501 |
[70850]=5, |
| 2502 |
[70851]=5, |
| 2503 |
[71090]=5, |
| 2504 |
[71091]=5, |
| 2505 |
[71092]=5, |
| 2506 |
[71093]=5, |
| 2507 |
[71100]=5, |
| 2508 |
[71101]=5, |
| 2509 |
[71103]=5, |
| 2510 |
[71104]=5, |
| 2511 |
[71132]=5, |
| 2512 |
[71133]=5, |
| 2513 |
[71219]=5, |
| 2514 |
[71220]=5, |
| 2515 |
[71221]=5, |
| 2516 |
[71222]=5, |
| 2517 |
[71223]=5, |
| 2518 |
[71224]=5, |
| 2519 |
[71225]=5, |
| 2520 |
[71226]=5, |
| 2521 |
[71229]=5, |
| 2522 |
[71231]=5, |
| 2523 |
[71232]=5, |
| 2524 |
[71339]=5, |
| 2525 |
[71341]=5, |
| 2526 |
[71344]=5, |
| 2527 |
[71345]=5, |
| 2528 |
[71346]=5, |
| 2529 |
[71347]=5, |
| 2530 |
[71348]=5, |
| 2531 |
[71349]=5, |
| 2532 |
[71351]=5, |
| 2533 |
[71453]=5, |
| 2534 |
[71454]=5, |
| 2535 |
[71455]=5, |
| 2536 |
[71458]=5, |
| 2537 |
[71459]=5, |
| 2538 |
[71460]=5, |
| 2539 |
[71461]=5, |
| 2540 |
[71463]=5, |
| 2541 |
[71464]=5, |
| 2542 |
[71465]=5, |
| 2543 |
[71466]=5, |
| 2544 |
[71467]=5, |
| 2545 |
[71727]=5, |
| 2546 |
[71728]=5, |
| 2547 |
[71729]=5, |
| 2548 |
[71730]=5, |
| 2549 |
[71731]=5, |
| 2550 |
[71732]=5, |
| 2551 |
[71733]=5, |
| 2552 |
[71734]=5, |
| 2553 |
[71735]=5, |
| 2554 |
[71737]=5, |
| 2555 |
[71738]=5, |
| 2556 |
[71995]=5, |
| 2557 |
[71996]=5, |
| 2558 |
[71998]=5, |
| 2559 |
[72003]=5, |
| 2560 |
[72148]=5, |
| 2561 |
[72149]=5, |
| 2562 |
[72150]=5, |
| 2563 |
[72151]=5, |
| 2564 |
[72154]=5, |
| 2565 |
[72155]=5, |
| 2566 |
[72160]=5, |
| 2567 |
[72193]=5, |
| 2568 |
[72194]=5, |
| 2569 |
[72195]=5, |
| 2570 |
[72196]=5, |
| 2571 |
[72197]=5, |
| 2572 |
[72198]=5, |
| 2573 |
[72201]=5, |
| 2574 |
[72202]=5, |
| 2575 |
[72243]=5, |
| 2576 |
[72244]=5, |
| 2577 |
[72245]=5, |
| 2578 |
[72246]=5, |
| 2579 |
[72247]=5, |
| 2580 |
[72248]=5, |
| 2581 |
[72251]=5, |
| 2582 |
[72252]=5, |
| 2583 |
[72253]=5, |
| 2584 |
[72254]=5, |
| 2585 |
[72263]=5, |
| 2586 |
[72273]=5, |
| 2587 |
[72274]=5, |
| 2588 |
[72275]=5, |
| 2589 |
[72276]=5, |
| 2590 |
[72277]=5, |
| 2591 |
[72278]=5, |
| 2592 |
[72281]=5, |
| 2593 |
[72282]=5, |
| 2594 |
[72283]=5, |
| 2595 |
[72330]=5, |
| 2596 |
[72331]=5, |
| 2597 |
[72332]=5, |
| 2598 |
[72333]=5, |
| 2599 |
[72334]=5, |
| 2600 |
[72335]=5, |
| 2601 |
[72336]=5, |
| 2602 |
[72337]=5, |
| 2603 |
[72338]=5, |
| 2604 |
[72339]=5, |
| 2605 |
[72340]=5, |
| 2606 |
[72341]=5, |
| 2607 |
[72342]=5, |
| 2608 |
[72344]=5, |
| 2609 |
[72345]=5, |
| 2610 |
[72752]=5, |
| 2611 |
[72753]=5, |
| 2612 |
[72754]=5, |
| 2613 |
[72755]=5, |
| 2614 |
[72756]=5, |
| 2615 |
[72757]=5, |
| 2616 |
[72758]=5, |
| 2617 |
[72760]=5, |
| 2618 |
[72761]=5, |
| 2619 |
[72762]=5, |
| 2620 |
[72763]=5, |
| 2621 |
[72764]=5, |
| 2622 |
[72765]=5, |
| 2623 |
[72767]=5, |
| 2624 |
[72850]=5, |
| 2625 |
[72851]=5, |
| 2626 |
[72852]=5, |
| 2627 |
[72853]=5, |
| 2628 |
[72854]=5, |
| 2629 |
[72855]=5, |
| 2630 |
[72856]=5, |
| 2631 |
[72857]=5, |
| 2632 |
[72858]=5, |
| 2633 |
[72859]=5, |
| 2634 |
[72860]=5, |
| 2635 |
[72861]=5, |
| 2636 |
[72862]=5, |
| 2637 |
[72863]=5, |
| 2638 |
[72864]=5, |
| 2639 |
[72865]=5, |
| 2640 |
[72866]=5, |
| 2641 |
[72867]=5, |
| 2642 |
[72868]=5, |
| 2643 |
[72869]=5, |
| 2644 |
[72870]=5, |
| 2645 |
[72871]=5, |
| 2646 |
[72874]=5, |
| 2647 |
[72875]=5, |
| 2648 |
[72876]=5, |
| 2649 |
[72877]=5, |
| 2650 |
[72878]=5, |
| 2651 |
[72879]=5, |
| 2652 |
[72880]=5, |
| 2653 |
[72882]=5, |
| 2654 |
[72883]=5, |
| 2655 |
[72885]=5, |
| 2656 |
[72886]=5, |
| 2657 |
[73009]=5, |
| 2658 |
[73010]=5, |
| 2659 |
[73011]=5, |
| 2660 |
[73012]=5, |
| 2661 |
[73013]=5, |
| 2662 |
[73014]=5, |
| 2663 |
[73018]=5, |
| 2664 |
[73020]=5, |
| 2665 |
[73021]=5, |
| 2666 |
[73023]=5, |
| 2667 |
[73024]=5, |
| 2668 |
[73025]=5, |
| 2669 |
[73026]=5, |
| 2670 |
[73027]=5, |
| 2671 |
[73028]=5, |
| 2672 |
[73029]=5, |
| 2673 |
[73031]=5, |
| 2674 |
[73104]=5, |
| 2675 |
[73105]=5, |
| 2676 |
[73109]=5, |
| 2677 |
[73111]=5, |
| 2678 |
[73459]=5, |
| 2679 |
[73460]=5, |
| 2680 |
[92912]=5, |
| 2681 |
[92913]=5, |
| 2682 |
[92914]=5, |
| 2683 |
[92915]=5, |
| 2684 |
[92916]=5, |
| 2685 |
[92976]=5, |
| 2686 |
[92977]=5, |
| 2687 |
[92978]=5, |
| 2688 |
[92979]=5, |
| 2689 |
[92980]=5, |
| 2690 |
[92981]=5, |
| 2691 |
[92982]=5, |
| 2692 |
[94031]=5, |
| 2693 |
[94095]=5, |
| 2694 |
[94096]=5, |
| 2695 |
[94097]=5, |
| 2696 |
[94098]=5, |
| 2697 |
[94180]=5, |
| 2698 |
[113821]=5, |
| 2699 |
[113822]=5, |
| 2700 |
[118528]=5, |
| 2701 |
[118529]=5, |
| 2702 |
[118530]=5, |
| 2703 |
[118531]=5, |
| 2704 |
[118532]=5, |
| 2705 |
[118533]=5, |
| 2706 |
[118534]=5, |
| 2707 |
[118535]=5, |
| 2708 |
[118536]=5, |
| 2709 |
[118537]=5, |
| 2710 |
[118538]=5, |
| 2711 |
[118539]=5, |
| 2712 |
[118540]=5, |
| 2713 |
[118541]=5, |
| 2714 |
[118542]=5, |
| 2715 |
[118543]=5, |
| 2716 |
[118544]=5, |
| 2717 |
[118545]=5, |
| 2718 |
[118546]=5, |
| 2719 |
[118547]=5, |
| 2720 |
[118548]=5, |
| 2721 |
[118549]=5, |
| 2722 |
[118550]=5, |
| 2723 |
[118551]=5, |
| 2724 |
[118552]=5, |
| 2725 |
[118553]=5, |
| 2726 |
[118554]=5, |
| 2727 |
[118555]=5, |
| 2728 |
[118556]=5, |
| 2729 |
[118557]=5, |
| 2730 |
[118558]=5, |
| 2731 |
[118559]=5, |
| 2732 |
[118560]=5, |
| 2733 |
[118561]=5, |
| 2734 |
[118562]=5, |
| 2735 |
[118563]=5, |
| 2736 |
[118564]=5, |
| 2737 |
[118565]=5, |
| 2738 |
[118566]=5, |
| 2739 |
[118567]=5, |
| 2740 |
[118568]=5, |
| 2741 |
[118569]=5, |
| 2742 |
[118570]=5, |
| 2743 |
[118571]=5, |
| 2744 |
[118572]=5, |
| 2745 |
[118573]=5, |
| 2746 |
[118576]=5, |
| 2747 |
[118577]=5, |
| 2748 |
[118578]=5, |
| 2749 |
[118579]=5, |
| 2750 |
[118580]=5, |
| 2751 |
[118581]=5, |
| 2752 |
[118582]=5, |
| 2753 |
[118583]=5, |
| 2754 |
[118584]=5, |
| 2755 |
[118585]=5, |
| 2756 |
[118586]=5, |
| 2757 |
[118587]=5, |
| 2758 |
[118588]=5, |
| 2759 |
[118589]=5, |
| 2760 |
[118590]=5, |
| 2761 |
[118591]=5, |
| 2762 |
[118592]=5, |
| 2763 |
[118593]=5, |
| 2764 |
[118594]=5, |
| 2765 |
[118595]=5, |
| 2766 |
[118596]=5, |
| 2767 |
[118597]=5, |
| 2768 |
[118598]=5, |
| 2769 |
[119143]=5, |
| 2770 |
[119144]=5, |
| 2771 |
[119145]=5, |
| 2772 |
[119163]=5, |
| 2773 |
[119164]=5, |
| 2774 |
[119165]=5, |
| 2775 |
[119166]=5, |
| 2776 |
[119167]=5, |
| 2777 |
[119168]=5, |
| 2778 |
[119169]=5, |
| 2779 |
[119170]=5, |
| 2780 |
[119173]=5, |
| 2781 |
[119174]=5, |
| 2782 |
[119175]=5, |
| 2783 |
[119176]=5, |
| 2784 |
[119177]=5, |
| 2785 |
[119178]=5, |
| 2786 |
[119179]=5, |
| 2787 |
[119210]=5, |
| 2788 |
[119211]=5, |
| 2789 |
[119212]=5, |
| 2790 |
[119213]=5, |
| 2791 |
[119362]=5, |
| 2792 |
[119363]=5, |
| 2793 |
[119364]=5, |
| 2794 |
[121344]=5, |
| 2795 |
[121345]=5, |
| 2796 |
[121346]=5, |
| 2797 |
[121347]=5, |
| 2798 |
[121348]=5, |
| 2799 |
[121349]=5, |
| 2800 |
[121350]=5, |
| 2801 |
[121351]=5, |
| 2802 |
[121352]=5, |
| 2803 |
[121353]=5, |
| 2804 |
[121354]=5, |
| 2805 |
[121355]=5, |
| 2806 |
[121356]=5, |
| 2807 |
[121357]=5, |
| 2808 |
[121358]=5, |
| 2809 |
[121359]=5, |
| 2810 |
[121360]=5, |
| 2811 |
[121361]=5, |
| 2812 |
[121362]=5, |
| 2813 |
[121363]=5, |
| 2814 |
[121364]=5, |
| 2815 |
[121365]=5, |
| 2816 |
[121366]=5, |
| 2817 |
[121367]=5, |
| 2818 |
[121368]=5, |
| 2819 |
[121369]=5, |
| 2820 |
[121370]=5, |
| 2821 |
[121371]=5, |
| 2822 |
[121372]=5, |
| 2823 |
[121373]=5, |
| 2824 |
[121374]=5, |
| 2825 |
[121375]=5, |
| 2826 |
[121376]=5, |
| 2827 |
[121377]=5, |
| 2828 |
[121378]=5, |
| 2829 |
[121379]=5, |
| 2830 |
[121380]=5, |
| 2831 |
[121381]=5, |
| 2832 |
[121382]=5, |
| 2833 |
[121383]=5, |
| 2834 |
[121384]=5, |
| 2835 |
[121385]=5, |
| 2836 |
[121386]=5, |
| 2837 |
[121387]=5, |
| 2838 |
[121388]=5, |
| 2839 |
[121389]=5, |
| 2840 |
[121390]=5, |
| 2841 |
[121391]=5, |
| 2842 |
[121392]=5, |
| 2843 |
[121393]=5, |
| 2844 |
[121394]=5, |
| 2845 |
[121395]=5, |
| 2846 |
[121396]=5, |
| 2847 |
[121397]=5, |
| 2848 |
[121398]=5, |
| 2849 |
[121403]=5, |
| 2850 |
[121404]=5, |
| 2851 |
[121405]=5, |
| 2852 |
[121406]=5, |
| 2853 |
[121407]=5, |
| 2854 |
[121408]=5, |
| 2855 |
[121409]=5, |
| 2856 |
[121410]=5, |
| 2857 |
[121411]=5, |
| 2858 |
[121412]=5, |
| 2859 |
[121413]=5, |
| 2860 |
[121414]=5, |
| 2861 |
[121415]=5, |
| 2862 |
[121416]=5, |
| 2863 |
[121417]=5, |
| 2864 |
[121418]=5, |
| 2865 |
[121419]=5, |
| 2866 |
[121420]=5, |
| 2867 |
[121421]=5, |
| 2868 |
[121422]=5, |
| 2869 |
[121423]=5, |
| 2870 |
[121424]=5, |
| 2871 |
[121425]=5, |
| 2872 |
[121426]=5, |
| 2873 |
[121427]=5, |
| 2874 |
[121428]=5, |
| 2875 |
[121429]=5, |
| 2876 |
[121430]=5, |
| 2877 |
[121431]=5, |
| 2878 |
[121432]=5, |
| 2879 |
[121433]=5, |
| 2880 |
[121434]=5, |
| 2881 |
[121435]=5, |
| 2882 |
[121436]=5, |
| 2883 |
[121437]=5, |
| 2884 |
[121438]=5, |
| 2885 |
[121439]=5, |
| 2886 |
[121440]=5, |
| 2887 |
[121441]=5, |
| 2888 |
[121442]=5, |
| 2889 |
[121443]=5, |
| 2890 |
[121444]=5, |
| 2891 |
[121445]=5, |
| 2892 |
[121446]=5, |
| 2893 |
[121447]=5, |
| 2894 |
[121448]=5, |
| 2895 |
[121449]=5, |
| 2896 |
[121450]=5, |
| 2897 |
[121451]=5, |
| 2898 |
[121452]=5, |
| 2899 |
[121461]=5, |
| 2900 |
[121476]=5, |
| 2901 |
[121499]=5, |
| 2902 |
[121500]=5, |
| 2903 |
[121501]=5, |
| 2904 |
[121502]=5, |
| 2905 |
[121503]=5, |
| 2906 |
[121505]=5, |
| 2907 |
[121506]=5, |
| 2908 |
[121507]=5, |
| 2909 |
[121508]=5, |
| 2910 |
[121509]=5, |
| 2911 |
[121510]=5, |
| 2912 |
[121511]=5, |
| 2913 |
[121512]=5, |
| 2914 |
[121513]=5, |
| 2915 |
[121514]=5, |
| 2916 |
[121515]=5, |
| 2917 |
[121516]=5, |
| 2918 |
[121517]=5, |
| 2919 |
[121518]=5, |
| 2920 |
[121519]=5, |
| 2921 |
[122880]=5, |
| 2922 |
[122881]=5, |
| 2923 |
[122882]=5, |
| 2924 |
[122883]=5, |
| 2925 |
[122884]=5, |
| 2926 |
[122885]=5, |
| 2927 |
[122886]=5, |
| 2928 |
[122888]=5, |
| 2929 |
[122889]=5, |
| 2930 |
[122890]=5, |
| 2931 |
[122891]=5, |
| 2932 |
[122892]=5, |
| 2933 |
[122893]=5, |
| 2934 |
[122894]=5, |
| 2935 |
[122895]=5, |
| 2936 |
[122896]=5, |
| 2937 |
[122897]=5, |
| 2938 |
[122898]=5, |
| 2939 |
[122899]=5, |
| 2940 |
[122900]=5, |
| 2941 |
[122901]=5, |
| 2942 |
[122902]=5, |
| 2943 |
[122903]=5, |
| 2944 |
[122904]=5, |
| 2945 |
[122907]=5, |
| 2946 |
[122908]=5, |
| 2947 |
[122909]=5, |
| 2948 |
[122910]=5, |
| 2949 |
[122911]=5, |
| 2950 |
[122912]=5, |
| 2951 |
[122913]=5, |
| 2952 |
[122915]=5, |
| 2953 |
[122916]=5, |
| 2954 |
[122918]=5, |
| 2955 |
[122919]=5, |
| 2956 |
[122920]=5, |
| 2957 |
[122921]=5, |
| 2958 |
[122922]=5, |
| 2959 |
[123184]=5, |
| 2960 |
[123185]=5, |
| 2961 |
[123186]=5, |
| 2962 |
[123187]=5, |
| 2963 |
[123188]=5, |
| 2964 |
[123189]=5, |
| 2965 |
[123190]=5, |
| 2966 |
[123566]=5, |
| 2967 |
[123628]=5, |
| 2968 |
[123629]=5, |
| 2969 |
[123630]=5, |
| 2970 |
[123631]=5, |
| 2971 |
[125136]=5, |
| 2972 |
[125137]=5, |
| 2973 |
[125138]=5, |
| 2974 |
[125139]=5, |
| 2975 |
[125140]=5, |
| 2976 |
[125141]=5, |
| 2977 |
[125142]=5, |
| 2978 |
[125184]=2, |
| 2979 |
[125185]=2, |
| 2980 |
[125186]=2, |
| 2981 |
[125187]=2, |
| 2982 |
[125188]=2, |
| 2983 |
[125189]=2, |
| 2984 |
[125190]=2, |
| 2985 |
[125191]=2, |
| 2986 |
[125192]=2, |
| 2987 |
[125193]=2, |
| 2988 |
[125194]=2, |
| 2989 |
[125195]=2, |
| 2990 |
[125196]=2, |
| 2991 |
[125197]=2, |
| 2992 |
[125198]=2, |
| 2993 |
[125199]=2, |
| 2994 |
[125200]=2, |
| 2995 |
[125201]=2, |
| 2996 |
[125202]=2, |
| 2997 |
[125203]=2, |
| 2998 |
[125204]=2, |
| 2999 |
[125205]=2, |
| 3000 |
[125206]=2, |
| 3001 |
[125207]=2, |
| 3002 |
[125208]=2, |
| 3003 |
[125209]=2, |
| 3004 |
[125210]=2, |
| 3005 |
[125211]=2, |
| 3006 |
[125212]=2, |
| 3007 |
[125213]=2, |
| 3008 |
[125214]=2, |
| 3009 |
[125215]=2, |
| 3010 |
[125216]=2, |
| 3011 |
[125217]=2, |
| 3012 |
[125218]=2, |
| 3013 |
[125219]=2, |
| 3014 |
[125220]=2, |
| 3015 |
[125221]=2, |
| 3016 |
[125222]=2, |
| 3017 |
[125223]=2, |
| 3018 |
[125224]=2, |
| 3019 |
[125225]=2, |
| 3020 |
[125226]=2, |
| 3021 |
[125227]=2, |
| 3022 |
[125228]=2, |
| 3023 |
[125229]=2, |
| 3024 |
[125230]=2, |
| 3025 |
[125231]=2, |
| 3026 |
[125232]=2, |
| 3027 |
[125233]=2, |
| 3028 |
[125234]=2, |
| 3029 |
[125235]=2, |
| 3030 |
[125236]=2, |
| 3031 |
[125237]=2, |
| 3032 |
[125238]=2, |
| 3033 |
[125239]=2, |
| 3034 |
[125240]=2, |
| 3035 |
[125241]=2, |
| 3036 |
[125242]=2, |
| 3037 |
[125243]=2, |
| 3038 |
[125244]=2, |
| 3039 |
[125245]=2, |
| 3040 |
[125246]=2, |
| 3041 |
[125247]=2, |
| 3042 |
[125248]=2, |
| 3043 |
[125249]=2, |
| 3044 |
[125250]=2, |
| 3045 |
[125251]=2, |
| 3046 |
[125252]=5, |
| 3047 |
[125253]=5, |
| 3048 |
[125254]=5, |
| 3049 |
[125255]=5, |
| 3050 |
[125256]=5, |
| 3051 |
[125257]=5, |
| 3052 |
[125258]=5, |
| 3053 |
[1042752]=5, |
| 3054 |
} |
| 3055 |
characters.indicgroups={ |
| 3056 |
["above_mark"]={ |
| 3057 |
[2304]=true, |
| 3058 |
[2305]=true, |
| 3059 |
[2306]=true, |
| 3060 |
[2362]=true, |
| 3061 |
[2373]=true, |
| 3062 |
[2374]=true, |
| 3063 |
[2375]=true, |
| 3064 |
[2376]=true, |
| 3065 |
[2385]=true, |
| 3066 |
[2387]=true, |
| 3067 |
[2388]=true, |
| 3068 |
[2389]=true, |
| 3069 |
[2631]=true, |
| 3070 |
[2632]=true, |
| 3071 |
[2635]=true, |
| 3072 |
[2636]=true, |
| 3073 |
[2690]=true, |
| 3074 |
[2757]=true, |
| 3075 |
[2759]=true, |
| 3076 |
[2760]=true, |
| 3077 |
[2879]=true, |
| 3078 |
[3008]=true, |
| 3079 |
[3021]=true, |
| 3080 |
[3134]=true, |
| 3081 |
[3135]=true, |
| 3082 |
[3136]=true, |
| 3083 |
[3142]=true, |
| 3084 |
[3143]=true, |
| 3085 |
[3146]=true, |
| 3086 |
[3147]=true, |
| 3087 |
[3148]=true, |
| 3088 |
[3149]=true, |
| 3089 |
[3263]=true, |
| 3090 |
[3270]=true, |
| 3091 |
[3406]=true, |
| 3092 |
[4141]=true, |
| 3093 |
[4142]=true, |
| 3094 |
[4146]=true, |
| 3095 |
[4147]=true, |
| 3096 |
[4148]=true, |
| 3097 |
[4149]=true, |
| 3098 |
[4150]=true, |
| 3099 |
[4154]=true, |
| 3100 |
[4209]=true, |
| 3101 |
[4210]=true, |
| 3102 |
[4211]=true, |
| 3103 |
[4212]=true, |
| 3104 |
[4229]=true, |
| 3105 |
[4230]=true, |
| 3106 |
[4253]=true, |
| 3107 |
[43232]=true, |
| 3108 |
[43233]=true, |
| 3109 |
[43234]=true, |
| 3110 |
[43235]=true, |
| 3111 |
[43236]=true, |
| 3112 |
[43237]=true, |
| 3113 |
[43238]=true, |
| 3114 |
[43239]=true, |
| 3115 |
[43240]=true, |
| 3116 |
[43241]=true, |
| 3117 |
[43242]=true, |
| 3118 |
[43243]=true, |
| 3119 |
[43244]=true, |
| 3120 |
[43245]=true, |
| 3121 |
[43246]=true, |
| 3122 |
[43247]=true, |
| 3123 |
[43248]=true, |
| 3124 |
[43249]=true, |
| 3125 |
[43493]=true, |
| 3126 |
[43644]=true, |
| 3127 |
}, |
| 3128 |
["after_half"]={}, |
| 3129 |
["after_main"]={ |
| 3130 |
[2864]=true, |
| 3131 |
[2879]=true, |
| 3132 |
[2902]=true, |
| 3133 |
[3376]=true, |
| 3134 |
[5901]=true, |
| 3135 |
}, |
| 3136 |
["after_postscript"]={ |
| 3137 |
[2433]=true, |
| 3138 |
[2494]=true, |
| 3139 |
[2496]=true, |
| 3140 |
[2519]=true, |
| 3141 |
[2561]=true, |
| 3142 |
[2562]=true, |
| 3143 |
[2622]=true, |
| 3144 |
[2624]=true, |
| 3145 |
[2625]=true, |
| 3146 |
[2626]=true, |
| 3147 |
[2672]=true, |
| 3148 |
[2673]=true, |
| 3149 |
[2735]=true, |
| 3150 |
[2750]=true, |
| 3151 |
[2752]=true, |
| 3152 |
[2753]=true, |
| 3153 |
[2754]=true, |
| 3154 |
[2755]=true, |
| 3155 |
[2756]=true, |
| 3156 |
[2761]=true, |
| 3157 |
[2763]=true, |
| 3158 |
[2764]=true, |
| 3159 |
[2786]=true, |
| 3160 |
[2787]=true, |
| 3161 |
[2878]=true, |
| 3162 |
[2880]=true, |
| 3163 |
[2903]=true, |
| 3164 |
[2992]=true, |
| 3165 |
[3006]=true, |
| 3166 |
[3007]=true, |
| 3167 |
[3009]=true, |
| 3168 |
[3010]=true, |
| 3169 |
[3031]=true, |
| 3170 |
[3120]=true, |
| 3171 |
[3248]=true, |
| 3172 |
[3390]=true, |
| 3173 |
[3391]=true, |
| 3174 |
[3392]=true, |
| 3175 |
[3393]=true, |
| 3176 |
[3394]=true, |
| 3177 |
[3395]=true, |
| 3178 |
[3415]=true, |
| 3179 |
}, |
| 3180 |
["after_subscript"]={ |
| 3181 |
[2366]=true, |
| 3182 |
[2368]=true, |
| 3183 |
[2369]=true, |
| 3184 |
[2370]=true, |
| 3185 |
[2371]=true, |
| 3186 |
[2372]=true, |
| 3187 |
[2373]=true, |
| 3188 |
[2374]=true, |
| 3189 |
[2375]=true, |
| 3190 |
[2376]=true, |
| 3191 |
[2377]=true, |
| 3192 |
[2378]=true, |
| 3193 |
[2379]=true, |
| 3194 |
[2380]=true, |
| 3195 |
[2402]=true, |
| 3196 |
[2403]=true, |
| 3197 |
[2480]=true, |
| 3198 |
[2497]=true, |
| 3199 |
[2498]=true, |
| 3200 |
[2499]=true, |
| 3201 |
[2500]=true, |
| 3202 |
[2530]=true, |
| 3203 |
[2531]=true, |
| 3204 |
[2544]=true, |
| 3205 |
[2631]=true, |
| 3206 |
[2632]=true, |
| 3207 |
[2635]=true, |
| 3208 |
[2636]=true, |
| 3209 |
[2757]=true, |
| 3210 |
[2759]=true, |
| 3211 |
[2760]=true, |
| 3212 |
[2881]=true, |
| 3213 |
[2882]=true, |
| 3214 |
[2883]=true, |
| 3215 |
[3008]=true, |
| 3216 |
[3139]=true, |
| 3217 |
[3140]=true, |
| 3218 |
[3267]=true, |
| 3219 |
[3268]=true, |
| 3220 |
[3285]=true, |
| 3221 |
[3286]=true, |
| 3222 |
}, |
| 3223 |
["anudatta"]={ |
| 3224 |
[2386]=true, |
| 3225 |
}, |
| 3226 |
["before_half"]={ |
| 3227 |
[2367]=true, |
| 3228 |
[2382]=true, |
| 3229 |
[2495]=true, |
| 3230 |
[2503]=true, |
| 3231 |
[2504]=true, |
| 3232 |
[2623]=true, |
| 3233 |
[2751]=true, |
| 3234 |
[2887]=true, |
| 3235 |
}, |
| 3236 |
["before_main"]={ |
| 3237 |
[3014]=true, |
| 3238 |
[3015]=true, |
| 3239 |
[3016]=true, |
| 3240 |
[3398]=true, |
| 3241 |
[3399]=true, |
| 3242 |
[3400]=true, |
| 3243 |
}, |
| 3244 |
["before_postscript"]={ |
| 3245 |
[2352]=true, |
| 3246 |
[2736]=true, |
| 3247 |
}, |
| 3248 |
["before_subscript"]={ |
| 3249 |
[2608]=true, |
| 3250 |
[2817]=true, |
| 3251 |
[3134]=true, |
| 3252 |
[3135]=true, |
| 3253 |
[3136]=true, |
| 3254 |
[3137]=true, |
| 3255 |
[3138]=true, |
| 3256 |
[3142]=true, |
| 3257 |
[3143]=true, |
| 3258 |
[3146]=true, |
| 3259 |
[3147]=true, |
| 3260 |
[3148]=true, |
| 3261 |
[3157]=true, |
| 3262 |
[3158]=true, |
| 3263 |
[3262]=true, |
| 3264 |
[3263]=true, |
| 3265 |
[3265]=true, |
| 3266 |
[3266]=true, |
| 3267 |
[3270]=true, |
| 3268 |
[3276]=true, |
| 3269 |
[3298]=true, |
| 3270 |
[3299]=true, |
| 3271 |
}, |
| 3272 |
["below_mark"]={ |
| 3273 |
[2364]=true, |
| 3274 |
[2369]=true, |
| 3275 |
[2370]=true, |
| 3276 |
[2371]=true, |
| 3277 |
[2372]=true, |
| 3278 |
[2381]=true, |
| 3279 |
[2386]=true, |
| 3280 |
[2390]=true, |
| 3281 |
[2391]=true, |
| 3282 |
[2402]=true, |
| 3283 |
[2403]=true, |
| 3284 |
[2492]=true, |
| 3285 |
[2497]=true, |
| 3286 |
[2498]=true, |
| 3287 |
[2499]=true, |
| 3288 |
[2500]=true, |
| 3289 |
[2509]=true, |
| 3290 |
[2620]=true, |
| 3291 |
[2625]=true, |
| 3292 |
[2626]=true, |
| 3293 |
[2637]=true, |
| 3294 |
[2748]=true, |
| 3295 |
[2753]=true, |
| 3296 |
[2754]=true, |
| 3297 |
[2755]=true, |
| 3298 |
[2756]=true, |
| 3299 |
[2765]=true, |
| 3300 |
[2876]=true, |
| 3301 |
[2881]=true, |
| 3302 |
[2882]=true, |
| 3303 |
[2883]=true, |
| 3304 |
[2884]=true, |
| 3305 |
[2893]=true, |
| 3306 |
[2914]=true, |
| 3307 |
[2915]=true, |
| 3308 |
[3009]=true, |
| 3309 |
[3010]=true, |
| 3310 |
[3132]=true, |
| 3311 |
[3170]=true, |
| 3312 |
[3171]=true, |
| 3313 |
[3260]=true, |
| 3314 |
[3286]=true, |
| 3315 |
[3298]=true, |
| 3316 |
[3299]=true, |
| 3317 |
[3426]=true, |
| 3318 |
[3427]=true, |
| 3319 |
[4143]=true, |
| 3320 |
[4144]=true, |
| 3321 |
[4151]=true, |
| 3322 |
[4153]=true, |
| 3323 |
[4157]=true, |
| 3324 |
[4158]=true, |
| 3325 |
[4184]=true, |
| 3326 |
[4185]=true, |
| 3327 |
[4190]=true, |
| 3328 |
[4191]=true, |
| 3329 |
[4192]=true, |
| 3330 |
[4226]=true, |
| 3331 |
[4237]=true, |
| 3332 |
}, |
| 3333 |
["consonant"]={ |
| 3334 |
[2325]=true, |
| 3335 |
[2326]=true, |
| 3336 |
[2327]=true, |
| 3337 |
[2328]=true, |
| 3338 |
[2329]=true, |
| 3339 |
[2330]=true, |
| 3340 |
[2331]=true, |
| 3341 |
[2332]=true, |
| 3342 |
[2333]=true, |
| 3343 |
[2334]=true, |
| 3344 |
[2335]=true, |
| 3345 |
[2336]=true, |
| 3346 |
[2337]=true, |
| 3347 |
[2338]=true, |
| 3348 |
[2339]=true, |
| 3349 |
[2340]=true, |
| 3350 |
[2341]=true, |
| 3351 |
[2342]=true, |
| 3352 |
[2343]=true, |
| 3353 |
[2344]=true, |
| 3354 |
[2345]=true, |
| 3355 |
[2346]=true, |
| 3356 |
[2347]=true, |
| 3357 |
[2348]=true, |
| 3358 |
[2349]=true, |
| 3359 |
[2350]=true, |
| 3360 |
[2351]=true, |
| 3361 |
[2352]=true, |
| 3362 |
[2353]=true, |
| 3363 |
[2354]=true, |
| 3364 |
[2355]=true, |
| 3365 |
[2356]=true, |
| 3366 |
[2357]=true, |
| 3367 |
[2358]=true, |
| 3368 |
[2359]=true, |
| 3369 |
[2360]=true, |
| 3370 |
[2361]=true, |
| 3371 |
[2392]=true, |
| 3372 |
[2393]=true, |
| 3373 |
[2394]=true, |
| 3374 |
[2395]=true, |
| 3375 |
[2396]=true, |
| 3376 |
[2397]=true, |
| 3377 |
[2398]=true, |
| 3378 |
[2399]=true, |
| 3379 |
[2424]=true, |
| 3380 |
[2425]=true, |
| 3381 |
[2426]=true, |
| 3382 |
[2453]=true, |
| 3383 |
[2454]=true, |
| 3384 |
[2455]=true, |
| 3385 |
[2456]=true, |
| 3386 |
[2457]=true, |
| 3387 |
[2458]=true, |
| 3388 |
[2459]=true, |
| 3389 |
[2460]=true, |
| 3390 |
[2461]=true, |
| 3391 |
[2462]=true, |
| 3392 |
[2463]=true, |
| 3393 |
[2464]=true, |
| 3394 |
[2465]=true, |
| 3395 |
[2466]=true, |
| 3396 |
[2467]=true, |
| 3397 |
[2468]=true, |
| 3398 |
[2469]=true, |
| 3399 |
[2470]=true, |
| 3400 |
[2471]=true, |
| 3401 |
[2472]=true, |
| 3402 |
[2474]=true, |
| 3403 |
[2475]=true, |
| 3404 |
[2476]=true, |
| 3405 |
[2477]=true, |
| 3406 |
[2478]=true, |
| 3407 |
[2479]=true, |
| 3408 |
[2480]=true, |
| 3409 |
[2482]=true, |
| 3410 |
[2486]=true, |
| 3411 |
[2487]=true, |
| 3412 |
[2488]=true, |
| 3413 |
[2489]=true, |
| 3414 |
[2510]=true, |
| 3415 |
[2524]=true, |
| 3416 |
[2525]=true, |
| 3417 |
[2527]=true, |
| 3418 |
[2581]=true, |
| 3419 |
[2582]=true, |
| 3420 |
[2583]=true, |
| 3421 |
[2584]=true, |
| 3422 |
[2585]=true, |
| 3423 |
[2586]=true, |
| 3424 |
[2587]=true, |
| 3425 |
[2588]=true, |
| 3426 |
[2589]=true, |
| 3427 |
[2590]=true, |
| 3428 |
[2591]=true, |
| 3429 |
[2592]=true, |
| 3430 |
[2593]=true, |
| 3431 |
[2594]=true, |
| 3432 |
[2595]=true, |
| 3433 |
[2596]=true, |
| 3434 |
[2597]=true, |
| 3435 |
[2598]=true, |
| 3436 |
[2599]=true, |
| 3437 |
[2600]=true, |
| 3438 |
[2602]=true, |
| 3439 |
[2603]=true, |
| 3440 |
[2604]=true, |
| 3441 |
[2605]=true, |
| 3442 |
[2606]=true, |
| 3443 |
[2607]=true, |
| 3444 |
[2608]=true, |
| 3445 |
[2610]=true, |
| 3446 |
[2611]=true, |
| 3447 |
[2613]=true, |
| 3448 |
[2614]=true, |
| 3449 |
[2616]=true, |
| 3450 |
[2617]=true, |
| 3451 |
[2649]=true, |
| 3452 |
[2650]=true, |
| 3453 |
[2651]=true, |
| 3454 |
[2652]=true, |
| 3455 |
[2654]=true, |
| 3456 |
[2709]=true, |
| 3457 |
[2710]=true, |
| 3458 |
[2711]=true, |
| 3459 |
[2712]=true, |
| 3460 |
[2713]=true, |
| 3461 |
[2714]=true, |
| 3462 |
[2715]=true, |
| 3463 |
[2716]=true, |
| 3464 |
[2717]=true, |
| 3465 |
[2718]=true, |
| 3466 |
[2719]=true, |
| 3467 |
[2720]=true, |
| 3468 |
[2721]=true, |
| 3469 |
[2722]=true, |
| 3470 |
[2723]=true, |
| 3471 |
[2724]=true, |
| 3472 |
[2725]=true, |
| 3473 |
[2726]=true, |
| 3474 |
[2727]=true, |
| 3475 |
[2728]=true, |
| 3476 |
[2730]=true, |
| 3477 |
[2731]=true, |
| 3478 |
[2732]=true, |
| 3479 |
[2733]=true, |
| 3480 |
[2734]=true, |
| 3481 |
[2735]=true, |
| 3482 |
[2736]=true, |
| 3483 |
[2738]=true, |
| 3484 |
[2739]=true, |
| 3485 |
[2741]=true, |
| 3486 |
[2742]=true, |
| 3487 |
[2743]=true, |
| 3488 |
[2744]=true, |
| 3489 |
[2745]=true, |
| 3490 |
[2837]=true, |
| 3491 |
[2838]=true, |
| 3492 |
[2839]=true, |
| 3493 |
[2840]=true, |
| 3494 |
[2841]=true, |
| 3495 |
[2842]=true, |
| 3496 |
[2843]=true, |
| 3497 |
[2844]=true, |
| 3498 |
[2845]=true, |
| 3499 |
[2846]=true, |
| 3500 |
[2847]=true, |
| 3501 |
[2848]=true, |
| 3502 |
[2849]=true, |
| 3503 |
[2850]=true, |
| 3504 |
[2851]=true, |
| 3505 |
[2852]=true, |
| 3506 |
[2853]=true, |
| 3507 |
[2854]=true, |
| 3508 |
[2855]=true, |
| 3509 |
[2856]=true, |
| 3510 |
[2858]=true, |
| 3511 |
[2859]=true, |
| 3512 |
[2860]=true, |
| 3513 |
[2861]=true, |
| 3514 |
[2862]=true, |
| 3515 |
[2863]=true, |
| 3516 |
[2864]=true, |
| 3517 |
[2866]=true, |
| 3518 |
[2867]=true, |
| 3519 |
[2869]=true, |
| 3520 |
[2870]=true, |
| 3521 |
[2871]=true, |
| 3522 |
[2872]=true, |
| 3523 |
[2873]=true, |
| 3524 |
[2908]=true, |
| 3525 |
[2909]=true, |
| 3526 |
[2929]=true, |
| 3527 |
[2965]=true, |
| 3528 |
[2969]=true, |
| 3529 |
[2970]=true, |
| 3530 |
[2972]=true, |
| 3531 |
[2974]=true, |
| 3532 |
[2975]=true, |
| 3533 |
[2979]=true, |
| 3534 |
[2980]=true, |
| 3535 |
[2984]=true, |
| 3536 |
[2985]=true, |
| 3537 |
[2986]=true, |
| 3538 |
[2990]=true, |
| 3539 |
[2991]=true, |
| 3540 |
[2992]=true, |
| 3541 |
[2993]=true, |
| 3542 |
[2994]=true, |
| 3543 |
[2995]=true, |
| 3544 |
[2996]=true, |
| 3545 |
[2997]=true, |
| 3546 |
[2998]=true, |
| 3547 |
[2999]=true, |
| 3548 |
[3000]=true, |
| 3549 |
[3001]=true, |
| 3550 |
[3093]=true, |
| 3551 |
[3094]=true, |
| 3552 |
[3095]=true, |
| 3553 |
[3096]=true, |
| 3554 |
[3097]=true, |
| 3555 |
[3098]=true, |
| 3556 |
[3099]=true, |
| 3557 |
[3100]=true, |
| 3558 |
[3101]=true, |
| 3559 |
[3102]=true, |
| 3560 |
[3103]=true, |
| 3561 |
[3104]=true, |
| 3562 |
[3105]=true, |
| 3563 |
[3106]=true, |
| 3564 |
[3107]=true, |
| 3565 |
[3108]=true, |
| 3566 |
[3109]=true, |
| 3567 |
[3110]=true, |
| 3568 |
[3111]=true, |
| 3569 |
[3112]=true, |
| 3570 |
[3114]=true, |
| 3571 |
[3115]=true, |
| 3572 |
[3116]=true, |
| 3573 |
[3117]=true, |
| 3574 |
[3118]=true, |
| 3575 |
[3119]=true, |
| 3576 |
[3120]=true, |
| 3577 |
[3121]=true, |
| 3578 |
[3122]=true, |
| 3579 |
[3123]=true, |
| 3580 |
[3124]=true, |
| 3581 |
[3125]=true, |
| 3582 |
[3126]=true, |
| 3583 |
[3127]=true, |
| 3584 |
[3128]=true, |
| 3585 |
[3129]=true, |
| 3586 |
[3133]=true, |
| 3587 |
[3221]=true, |
| 3588 |
[3222]=true, |
| 3589 |
[3223]=true, |
| 3590 |
[3224]=true, |
| 3591 |
[3225]=true, |
| 3592 |
[3226]=true, |
| 3593 |
[3227]=true, |
| 3594 |
[3228]=true, |
| 3595 |
[3229]=true, |
| 3596 |
[3230]=true, |
| 3597 |
[3231]=true, |
| 3598 |
[3232]=true, |
| 3599 |
[3233]=true, |
| 3600 |
[3234]=true, |
| 3601 |
[3235]=true, |
| 3602 |
[3236]=true, |
| 3603 |
[3237]=true, |
| 3604 |
[3238]=true, |
| 3605 |
[3239]=true, |
| 3606 |
[3240]=true, |
| 3607 |
[3242]=true, |
| 3608 |
[3243]=true, |
| 3609 |
[3244]=true, |
| 3610 |
[3245]=true, |
| 3611 |
[3246]=true, |
| 3612 |
[3247]=true, |
| 3613 |
[3248]=true, |
| 3614 |
[3249]=true, |
| 3615 |
[3250]=true, |
| 3616 |
[3251]=true, |
| 3617 |
[3253]=true, |
| 3618 |
[3254]=true, |
| 3619 |
[3255]=true, |
| 3620 |
[3256]=true, |
| 3621 |
[3257]=true, |
| 3622 |
[3294]=true, |
| 3623 |
[3349]=true, |
| 3624 |
[3350]=true, |
| 3625 |
[3351]=true, |
| 3626 |
[3352]=true, |
| 3627 |
[3353]=true, |
| 3628 |
[3354]=true, |
| 3629 |
[3355]=true, |
| 3630 |
[3356]=true, |
| 3631 |
[3357]=true, |
| 3632 |
[3358]=true, |
| 3633 |
[3359]=true, |
| 3634 |
[3360]=true, |
| 3635 |
[3361]=true, |
| 3636 |
[3362]=true, |
| 3637 |
[3363]=true, |
| 3638 |
[3364]=true, |
| 3639 |
[3365]=true, |
| 3640 |
[3366]=true, |
| 3641 |
[3367]=true, |
| 3642 |
[3368]=true, |
| 3643 |
[3369]=true, |
| 3644 |
[3370]=true, |
| 3645 |
[3371]=true, |
| 3646 |
[3372]=true, |
| 3647 |
[3373]=true, |
| 3648 |
[3374]=true, |
| 3649 |
[3375]=true, |
| 3650 |
[3376]=true, |
| 3651 |
[3377]=true, |
| 3652 |
[3378]=true, |
| 3653 |
[3379]=true, |
| 3654 |
[3380]=true, |
| 3655 |
[3381]=true, |
| 3656 |
[3382]=true, |
| 3657 |
[3383]=true, |
| 3658 |
[3384]=true, |
| 3659 |
[3385]=true, |
| 3660 |
[3386]=true, |
| 3661 |
[4096]=true, |
| 3662 |
[4097]=true, |
| 3663 |
[4098]=true, |
| 3664 |
[4099]=true, |
| 3665 |
[4100]=true, |
| 3666 |
[4101]=true, |
| 3667 |
[4102]=true, |
| 3668 |
[4103]=true, |
| 3669 |
[4104]=true, |
| 3670 |
[4105]=true, |
| 3671 |
[4106]=true, |
| 3672 |
[4107]=true, |
| 3673 |
[4108]=true, |
| 3674 |
[4109]=true, |
| 3675 |
[4110]=true, |
| 3676 |
[4111]=true, |
| 3677 |
[4112]=true, |
| 3678 |
[4113]=true, |
| 3679 |
[4114]=true, |
| 3680 |
[4115]=true, |
| 3681 |
[4116]=true, |
| 3682 |
[4117]=true, |
| 3683 |
[4118]=true, |
| 3684 |
[4119]=true, |
| 3685 |
[4120]=true, |
| 3686 |
[4121]=true, |
| 3687 |
[4122]=true, |
| 3688 |
[4123]=true, |
| 3689 |
[4124]=true, |
| 3690 |
[4125]=true, |
| 3691 |
[4126]=true, |
| 3692 |
[4127]=true, |
| 3693 |
[4128]=true, |
| 3694 |
[4155]=true, |
| 3695 |
[4156]=true, |
| 3696 |
[4157]=true, |
| 3697 |
[4158]=true, |
| 3698 |
[4159]=true, |
| 3699 |
[4176]=true, |
| 3700 |
[4177]=true, |
| 3701 |
[4186]=true, |
| 3702 |
[4187]=true, |
| 3703 |
[4188]=true, |
| 3704 |
[4189]=true, |
| 3705 |
[4190]=true, |
| 3706 |
[4191]=true, |
| 3707 |
[4192]=true, |
| 3708 |
[4193]=true, |
| 3709 |
[4197]=true, |
| 3710 |
[4198]=true, |
| 3711 |
[4206]=true, |
| 3712 |
[4207]=true, |
| 3713 |
[4208]=true, |
| 3714 |
[4213]=true, |
| 3715 |
[4214]=true, |
| 3716 |
[4215]=true, |
| 3717 |
[4216]=true, |
| 3718 |
[4217]=true, |
| 3719 |
[4218]=true, |
| 3720 |
[4219]=true, |
| 3721 |
[4220]=true, |
| 3722 |
[4221]=true, |
| 3723 |
[4222]=true, |
| 3724 |
[4223]=true, |
| 3725 |
[4224]=true, |
| 3726 |
[4225]=true, |
| 3727 |
[4226]=true, |
| 3728 |
[4238]=true, |
| 3729 |
[5901]=true, |
| 3730 |
[43488]=true, |
| 3731 |
[43489]=true, |
| 3732 |
[43490]=true, |
| 3733 |
[43491]=true, |
| 3734 |
[43492]=true, |
| 3735 |
[43495]=true, |
| 3736 |
[43496]=true, |
| 3737 |
[43497]=true, |
| 3738 |
[43498]=true, |
| 3739 |
[43499]=true, |
| 3740 |
[43500]=true, |
| 3741 |
[43501]=true, |
| 3742 |
[43502]=true, |
| 3743 |
[43503]=true, |
| 3744 |
[43514]=true, |
| 3745 |
[43515]=true, |
| 3746 |
[43516]=true, |
| 3747 |
[43517]=true, |
| 3748 |
[43518]=true, |
| 3749 |
[43616]=true, |
| 3750 |
[43617]=true, |
| 3751 |
[43618]=true, |
| 3752 |
[43619]=true, |
| 3753 |
[43620]=true, |
| 3754 |
[43621]=true, |
| 3755 |
[43622]=true, |
| 3756 |
[43623]=true, |
| 3757 |
[43624]=true, |
| 3758 |
[43625]=true, |
| 3759 |
[43626]=true, |
| 3760 |
[43628]=true, |
| 3761 |
[43629]=true, |
| 3762 |
[43630]=true, |
| 3763 |
[43631]=true, |
| 3764 |
[43633]=true, |
| 3765 |
[43634]=true, |
| 3766 |
[43635]=true, |
| 3767 |
[43636]=true, |
| 3768 |
[43637]=true, |
| 3769 |
[43638]=true, |
| 3770 |
[43642]=true, |
| 3771 |
[43646]=true, |
| 3772 |
[43647]=true, |
| 3773 |
}, |
| 3774 |
["dependent_vowel"]={ |
| 3775 |
[2362]=true, |
| 3776 |
[2363]=true, |
| 3777 |
[2366]=true, |
| 3778 |
[2367]=true, |
| 3779 |
[2368]=true, |
| 3780 |
[2369]=true, |
| 3781 |
[2370]=true, |
| 3782 |
[2371]=true, |
| 3783 |
[2372]=true, |
| 3784 |
[2373]=true, |
| 3785 |
[2374]=true, |
| 3786 |
[2375]=true, |
| 3787 |
[2376]=true, |
| 3788 |
[2377]=true, |
| 3789 |
[2378]=true, |
| 3790 |
[2379]=true, |
| 3791 |
[2380]=true, |
| 3792 |
[2382]=true, |
| 3793 |
[2383]=true, |
| 3794 |
[2389]=true, |
| 3795 |
[2390]=true, |
| 3796 |
[2391]=true, |
| 3797 |
[2402]=true, |
| 3798 |
[2403]=true, |
| 3799 |
[2494]=true, |
| 3800 |
[2495]=true, |
| 3801 |
[2497]=true, |
| 3802 |
[2498]=true, |
| 3803 |
[2499]=true, |
| 3804 |
[2500]=true, |
| 3805 |
[2503]=true, |
| 3806 |
[2504]=true, |
| 3807 |
[2507]=true, |
| 3808 |
[2508]=true, |
| 3809 |
[2622]=true, |
| 3810 |
[2623]=true, |
| 3811 |
[2624]=true, |
| 3812 |
[2625]=true, |
| 3813 |
[2626]=true, |
| 3814 |
[2631]=true, |
| 3815 |
[2632]=true, |
| 3816 |
[2635]=true, |
| 3817 |
[2636]=true, |
| 3818 |
[2750]=true, |
| 3819 |
[2751]=true, |
| 3820 |
[2752]=true, |
| 3821 |
[2753]=true, |
| 3822 |
[2754]=true, |
| 3823 |
[2755]=true, |
| 3824 |
[2756]=true, |
| 3825 |
[2757]=true, |
| 3826 |
[2759]=true, |
| 3827 |
[2760]=true, |
| 3828 |
[2761]=true, |
| 3829 |
[2763]=true, |
| 3830 |
[2764]=true, |
| 3831 |
[2878]=true, |
| 3832 |
[2879]=true, |
| 3833 |
[2880]=true, |
| 3834 |
[2881]=true, |
| 3835 |
[2882]=true, |
| 3836 |
[2883]=true, |
| 3837 |
[2884]=true, |
| 3838 |
[2887]=true, |
| 3839 |
[2888]=true, |
| 3840 |
[2891]=true, |
| 3841 |
[2892]=true, |
| 3842 |
[2914]=true, |
| 3843 |
[2915]=true, |
| 3844 |
[3006]=true, |
| 3845 |
[3007]=true, |
| 3846 |
[3008]=true, |
| 3847 |
[3009]=true, |
| 3848 |
[3010]=true, |
| 3849 |
[3014]=true, |
| 3850 |
[3015]=true, |
| 3851 |
[3016]=true, |
| 3852 |
[3018]=true, |
| 3853 |
[3019]=true, |
| 3854 |
[3020]=true, |
| 3855 |
[3134]=true, |
| 3856 |
[3135]=true, |
| 3857 |
[3136]=true, |
| 3858 |
[3137]=true, |
| 3859 |
[3138]=true, |
| 3860 |
[3139]=true, |
| 3861 |
[3140]=true, |
| 3862 |
[3142]=true, |
| 3863 |
[3143]=true, |
| 3864 |
[3144]=true, |
| 3865 |
[3146]=true, |
| 3866 |
[3147]=true, |
| 3867 |
[3148]=true, |
| 3868 |
[3170]=true, |
| 3869 |
[3171]=true, |
| 3870 |
[3262]=true, |
| 3871 |
[3263]=true, |
| 3872 |
[3264]=true, |
| 3873 |
[3265]=true, |
| 3874 |
[3266]=true, |
| 3875 |
[3267]=true, |
| 3876 |
[3268]=true, |
| 3877 |
[3270]=true, |
| 3878 |
[3271]=true, |
| 3879 |
[3272]=true, |
| 3880 |
[3274]=true, |
| 3881 |
[3275]=true, |
| 3882 |
[3276]=true, |
| 3883 |
[3285]=true, |
| 3884 |
[3286]=true, |
| 3885 |
[3298]=true, |
| 3886 |
[3299]=true, |
| 3887 |
[3390]=true, |
| 3888 |
[3391]=true, |
| 3889 |
[3392]=true, |
| 3890 |
[3393]=true, |
| 3891 |
[3394]=true, |
| 3892 |
[3395]=true, |
| 3893 |
[3396]=true, |
| 3894 |
[3398]=true, |
| 3895 |
[3399]=true, |
| 3896 |
[3400]=true, |
| 3897 |
[3402]=true, |
| 3898 |
[3403]=true, |
| 3899 |
[3404]=true, |
| 3900 |
[3415]=true, |
| 3901 |
[3426]=true, |
| 3902 |
[3427]=true, |
| 3903 |
[4139]=true, |
| 3904 |
[4140]=true, |
| 3905 |
[4141]=true, |
| 3906 |
[4142]=true, |
| 3907 |
[4143]=true, |
| 3908 |
[4144]=true, |
| 3909 |
[4145]=true, |
| 3910 |
[4146]=true, |
| 3911 |
[4147]=true, |
| 3912 |
[4148]=true, |
| 3913 |
[4149]=true, |
| 3914 |
[4182]=true, |
| 3915 |
[4183]=true, |
| 3916 |
[4184]=true, |
| 3917 |
[4185]=true, |
| 3918 |
[4194]=true, |
| 3919 |
[4199]=true, |
| 3920 |
[4200]=true, |
| 3921 |
[4209]=true, |
| 3922 |
[4210]=true, |
| 3923 |
[4211]=true, |
| 3924 |
[4212]=true, |
| 3925 |
[4227]=true, |
| 3926 |
[4228]=true, |
| 3927 |
[4229]=true, |
| 3928 |
[4230]=true, |
| 3929 |
[4252]=true, |
| 3930 |
[4253]=true, |
| 3931 |
[43493]=true, |
| 3932 |
}, |
| 3933 |
["halant"]={ |
| 3934 |
[2381]=true, |
| 3935 |
[2509]=true, |
| 3936 |
[2637]=true, |
| 3937 |
[2765]=true, |
| 3938 |
[2893]=true, |
| 3939 |
[3021]=true, |
| 3940 |
[3149]=true, |
| 3941 |
[3277]=true, |
| 3942 |
[3405]=true, |
| 3943 |
}, |
| 3944 |
["independent_vowel"]={ |
| 3945 |
[2308]=true, |
| 3946 |
[2309]=true, |
| 3947 |
[2310]=true, |
| 3948 |
[2311]=true, |
| 3949 |
[2312]=true, |
| 3950 |
[2313]=true, |
| 3951 |
[2314]=true, |
| 3952 |
[2315]=true, |
| 3953 |
[2316]=true, |
| 3954 |
[2317]=true, |
| 3955 |
[2318]=true, |
| 3956 |
[2319]=true, |
| 3957 |
[2320]=true, |
| 3958 |
[2321]=true, |
| 3959 |
[2322]=true, |
| 3960 |
[2323]=true, |
| 3961 |
[2324]=true, |
| 3962 |
[2400]=true, |
| 3963 |
[2401]=true, |
| 3964 |
[2418]=true, |
| 3965 |
[2419]=true, |
| 3966 |
[2420]=true, |
| 3967 |
[2421]=true, |
| 3968 |
[2422]=true, |
| 3969 |
[2423]=true, |
| 3970 |
[2437]=true, |
| 3971 |
[2438]=true, |
| 3972 |
[2439]=true, |
| 3973 |
[2440]=true, |
| 3974 |
[2441]=true, |
| 3975 |
[2442]=true, |
| 3976 |
[2443]=true, |
| 3977 |
[2444]=true, |
| 3978 |
[2447]=true, |
| 3979 |
[2448]=true, |
| 3980 |
[2451]=true, |
| 3981 |
[2452]=true, |
| 3982 |
[2528]=true, |
| 3983 |
[2529]=true, |
| 3984 |
[2530]=true, |
| 3985 |
[2531]=true, |
| 3986 |
[2565]=true, |
| 3987 |
[2566]=true, |
| 3988 |
[2567]=true, |
| 3989 |
[2568]=true, |
| 3990 |
[2569]=true, |
| 3991 |
[2570]=true, |
| 3992 |
[2575]=true, |
| 3993 |
[2576]=true, |
| 3994 |
[2579]=true, |
| 3995 |
[2580]=true, |
| 3996 |
[2693]=true, |
| 3997 |
[2694]=true, |
| 3998 |
[2695]=true, |
| 3999 |
[2696]=true, |
| 4000 |
[2697]=true, |
| 4001 |
[2698]=true, |
| 4002 |
[2699]=true, |
| 4003 |
[2700]=true, |
| 4004 |
[2701]=true, |
| 4005 |
[2703]=true, |
| 4006 |
[2704]=true, |
| 4007 |
[2705]=true, |
| 4008 |
[2707]=true, |
| 4009 |
[2708]=true, |
| 4010 |
[2784]=true, |
| 4011 |
[2785]=true, |
| 4012 |
[2786]=true, |
| 4013 |
[2787]=true, |
| 4014 |
[2821]=true, |
| 4015 |
[2822]=true, |
| 4016 |
[2823]=true, |
| 4017 |
[2824]=true, |
| 4018 |
[2825]=true, |
| 4019 |
[2826]=true, |
| 4020 |
[2827]=true, |
| 4021 |
[2828]=true, |
| 4022 |
[2831]=true, |
| 4023 |
[2832]=true, |
| 4024 |
[2835]=true, |
| 4025 |
[2836]=true, |
| 4026 |
[2912]=true, |
| 4027 |
[2913]=true, |
| 4028 |
[2949]=true, |
| 4029 |
[2950]=true, |
| 4030 |
[2951]=true, |
| 4031 |
[2952]=true, |
| 4032 |
[2953]=true, |
| 4033 |
[2954]=true, |
| 4034 |
[2958]=true, |
| 4035 |
[2959]=true, |
| 4036 |
[2960]=true, |
| 4037 |
[2962]=true, |
| 4038 |
[2963]=true, |
| 4039 |
[2964]=true, |
| 4040 |
[3077]=true, |
| 4041 |
[3078]=true, |
| 4042 |
[3079]=true, |
| 4043 |
[3080]=true, |
| 4044 |
[3081]=true, |
| 4045 |
[3082]=true, |
| 4046 |
[3083]=true, |
| 4047 |
[3084]=true, |
| 4048 |
[3086]=true, |
| 4049 |
[3087]=true, |
| 4050 |
[3088]=true, |
| 4051 |
[3090]=true, |
| 4052 |
[3091]=true, |
| 4053 |
[3092]=true, |
| 4054 |
[3165]=true, |
| 4055 |
[3168]=true, |
| 4056 |
[3169]=true, |
| 4057 |
[3205]=true, |
| 4058 |
[3206]=true, |
| 4059 |
[3207]=true, |
| 4060 |
[3208]=true, |
| 4061 |
[3209]=true, |
| 4062 |
[3210]=true, |
| 4063 |
[3211]=true, |
| 4064 |
[3212]=true, |
| 4065 |
[3214]=true, |
| 4066 |
[3215]=true, |
| 4067 |
[3216]=true, |
| 4068 |
[3218]=true, |
| 4069 |
[3219]=true, |
| 4070 |
[3220]=true, |
| 4071 |
[3293]=true, |
| 4072 |
[3296]=true, |
| 4073 |
[3297]=true, |
| 4074 |
[3333]=true, |
| 4075 |
[3334]=true, |
| 4076 |
[3335]=true, |
| 4077 |
[3336]=true, |
| 4078 |
[3337]=true, |
| 4079 |
[3338]=true, |
| 4080 |
[3339]=true, |
| 4081 |
[3340]=true, |
| 4082 |
[3342]=true, |
| 4083 |
[3343]=true, |
| 4084 |
[3344]=true, |
| 4085 |
[3346]=true, |
| 4086 |
[3347]=true, |
| 4087 |
[3348]=true, |
| 4088 |
[3423]=true, |
| 4089 |
[3424]=true, |
| 4090 |
[3425]=true, |
| 4091 |
[4129]=true, |
| 4092 |
[4130]=true, |
| 4093 |
[4131]=true, |
| 4094 |
[4132]=true, |
| 4095 |
[4133]=true, |
| 4096 |
[4134]=true, |
| 4097 |
[4135]=true, |
| 4098 |
[4136]=true, |
| 4099 |
[4137]=true, |
| 4100 |
[4138]=true, |
| 4101 |
[4178]=true, |
| 4102 |
[4179]=true, |
| 4103 |
[4180]=true, |
| 4104 |
[4181]=true, |
| 4105 |
}, |
| 4106 |
["nukta"]={ |
| 4107 |
[2364]=true, |
| 4108 |
[2492]=true, |
| 4109 |
[2620]=true, |
| 4110 |
[2748]=true, |
| 4111 |
[2876]=true, |
| 4112 |
[3132]=true, |
| 4113 |
[3260]=true, |
| 4114 |
}, |
| 4115 |
["post_mark"]={ |
| 4116 |
[2307]=true, |
| 4117 |
[2363]=true, |
| 4118 |
[2366]=true, |
| 4119 |
[2368]=true, |
| 4120 |
[2377]=true, |
| 4121 |
[2378]=true, |
| 4122 |
[2379]=true, |
| 4123 |
[2380]=true, |
| 4124 |
[2383]=true, |
| 4125 |
[2494]=true, |
| 4126 |
[2496]=true, |
| 4127 |
[2622]=true, |
| 4128 |
[2624]=true, |
| 4129 |
[2750]=true, |
| 4130 |
[2752]=true, |
| 4131 |
[2761]=true, |
| 4132 |
[2763]=true, |
| 4133 |
[2764]=true, |
| 4134 |
[2878]=true, |
| 4135 |
[2880]=true, |
| 4136 |
[3006]=true, |
| 4137 |
[3007]=true, |
| 4138 |
[3137]=true, |
| 4139 |
[3138]=true, |
| 4140 |
[3139]=true, |
| 4141 |
[3140]=true, |
| 4142 |
[3262]=true, |
| 4143 |
[3265]=true, |
| 4144 |
[3266]=true, |
| 4145 |
[3267]=true, |
| 4146 |
[3268]=true, |
| 4147 |
[3276]=true, |
| 4148 |
[3285]=true, |
| 4149 |
[3390]=true, |
| 4150 |
[3391]=true, |
| 4151 |
[3392]=true, |
| 4152 |
[3393]=true, |
| 4153 |
[3394]=true, |
| 4154 |
[3395]=true, |
| 4155 |
[3396]=true, |
| 4156 |
[3415]=true, |
| 4157 |
[4139]=true, |
| 4158 |
[4140]=true, |
| 4159 |
[4152]=true, |
| 4160 |
[4155]=true, |
| 4161 |
[4182]=true, |
| 4162 |
[4183]=true, |
| 4163 |
[4194]=true, |
| 4164 |
[4195]=true, |
| 4165 |
[4196]=true, |
| 4166 |
[4199]=true, |
| 4167 |
[4200]=true, |
| 4168 |
[4201]=true, |
| 4169 |
[4202]=true, |
| 4170 |
[4203]=true, |
| 4171 |
[4204]=true, |
| 4172 |
[4205]=true, |
| 4173 |
[4227]=true, |
| 4174 |
[4231]=true, |
| 4175 |
[4232]=true, |
| 4176 |
[4233]=true, |
| 4177 |
[4234]=true, |
| 4178 |
[4235]=true, |
| 4179 |
[4236]=true, |
| 4180 |
[4239]=true, |
| 4181 |
[4250]=true, |
| 4182 |
[4251]=true, |
| 4183 |
[4252]=true, |
| 4184 |
[43643]=true, |
| 4185 |
[43645]=true, |
| 4186 |
}, |
| 4187 |
["pre_mark"]={ |
| 4188 |
[2367]=true, |
| 4189 |
[2382]=true, |
| 4190 |
[2495]=true, |
| 4191 |
[2503]=true, |
| 4192 |
[2504]=true, |
| 4193 |
[2623]=true, |
| 4194 |
[2751]=true, |
| 4195 |
[2887]=true, |
| 4196 |
[3014]=true, |
| 4197 |
[3015]=true, |
| 4198 |
[3016]=true, |
| 4199 |
[3398]=true, |
| 4200 |
[3399]=true, |
| 4201 |
[3400]=true, |
| 4202 |
[4145]=true, |
| 4203 |
[4228]=true, |
| 4204 |
}, |
| 4205 |
["ra"]={ |
| 4206 |
[2352]=true, |
| 4207 |
[2480]=true, |
| 4208 |
[2544]=true, |
| 4209 |
[2608]=true, |
| 4210 |
[2736]=true, |
| 4211 |
[2864]=true, |
| 4212 |
[2992]=true, |
| 4213 |
[3120]=true, |
| 4214 |
[3248]=true, |
| 4215 |
[3376]=true, |
| 4216 |
[5901]=true, |
| 4217 |
}, |
| 4218 |
["stress_tone_mark"]={ |
| 4219 |
[2385]=true, |
| 4220 |
[2386]=true, |
| 4221 |
[2387]=true, |
| 4222 |
[2388]=true, |
| 4223 |
[4151]=true, |
| 4224 |
[4195]=true, |
| 4225 |
[4196]=true, |
| 4226 |
[4201]=true, |
| 4227 |
[4202]=true, |
| 4228 |
[4203]=true, |
| 4229 |
[4204]=true, |
| 4230 |
[4205]=true, |
| 4231 |
[4231]=true, |
| 4232 |
[4232]=true, |
| 4233 |
[4233]=true, |
| 4234 |
[4234]=true, |
| 4235 |
[4235]=true, |
| 4236 |
[4236]=true, |
| 4237 |
[4237]=true, |
| 4238 |
[4239]=true, |
| 4239 |
[4250]=true, |
| 4240 |
[4251]=true, |
| 4241 |
[43643]=true, |
| 4242 |
[43644]=true, |
| 4243 |
[43645]=true, |
| 4244 |
}, |
| 4245 |
["twopart_mark"]={ |
| 4246 |
[2507]={ 2503,2494 }, |
| 4247 |
[2508]={ 2503,2519 }, |
| 4248 |
[2888]={ 2887,2902 }, |
| 4249 |
[2891]={ 2887,2878 }, |
| 4250 |
[2892]={ 2887,2903 }, |
| 4251 |
[3018]={ 3014,3006 }, |
| 4252 |
[3019]={ 3015,3006 }, |
| 4253 |
[3020]={ 3014,3031 }, |
| 4254 |
[3144]={ 3142,3158 }, |
| 4255 |
[3264]={ 3263,3285 }, |
| 4256 |
[3271]={ 3270,3285 }, |
| 4257 |
[3272]={ 3270,3286 }, |
| 4258 |
[3274]={ 3270,3266 }, |
| 4259 |
[3275]={ 3274,3285 }, |
| 4260 |
[3402]={ 3398,3390 }, |
| 4261 |
[3403]={ 3399,3390 }, |
| 4262 |
[3404]={ 3398,3415 }, |
| 4263 |
}, |
| 4264 |
["vowel_modifier"]={ |
| 4265 |
[2304]=true, |
| 4266 |
[2305]=true, |
| 4267 |
[2306]=true, |
| 4268 |
[2307]=true, |
| 4269 |
[2433]=true, |
| 4270 |
[3330]=true, |
| 4271 |
[3331]=true, |
| 4272 |
[4150]=true, |
| 4273 |
[4152]=true, |
| 4274 |
[4153]=true, |
| 4275 |
[4154]=true, |
| 4276 |
[43232]=true, |
| 4277 |
[43233]=true, |
| 4278 |
[43234]=true, |
| 4279 |
[43235]=true, |
| 4280 |
[43236]=true, |
| 4281 |
[43237]=true, |
| 4282 |
[43238]=true, |
| 4283 |
[43239]=true, |
| 4284 |
[43240]=true, |
| 4285 |
[43241]=true, |
| 4286 |
[43242]=true, |
| 4287 |
[43243]=true, |
| 4288 |
[43244]=true, |
| 4289 |
[43245]=true, |
| 4290 |
[43246]=true, |
| 4291 |
[43247]=true, |
| 4292 |
[43249]=true, |
| 4293 |
}, |
| 4294 |
} |
| 4295 |
|
| 4296 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “basics-chr”] --- |
| 4297 |
|
| 4298 |
|
| 4299 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ini” 16b855c98602e4a3e9df39512916a427] --- |
| 4300 |
|
| 4301 |
if not modules then modules={} end modules ['font-ini']={ |
| 4302 |
version=1.001, |
| 4303 |
comment="companion to font-ini.mkiv", |
| 4304 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 4305 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 4306 |
license="see context related readme files" |
| 4307 |
} |
| 4308 |
local allocate=utilities.storage.allocate |
| 4309 |
local sortedhash=table.sortedhash |
| 4310 |
fonts=fonts or {} |
| 4311 |
local fonts=fonts |
| 4312 |
local identifiers=allocate() |
| 4313 |
fonts.hashes=fonts.hashes or { identifiers=identifiers } |
| 4314 |
fonts.tables=fonts.tables or {} |
| 4315 |
fonts.helpers=fonts.helpers or {} |
| 4316 |
fonts.tracers=fonts.tracers or {} |
| 4317 |
fonts.specifiers=fonts.specifiers or {} |
| 4318 |
fonts.analyzers={} |
| 4319 |
fonts.readers={} |
| 4320 |
fonts.definers={ methods={} } |
| 4321 |
fonts.loggers={ register=function() end } |
| 4322 |
if context then |
| 4323 |
font.originaleach=font.each |
| 4324 |
function font.each() |
| 4325 |
return sortedhash(identifiers) |
| 4326 |
end |
| 4327 |
fontloader=nil |
| 4328 |
end |
| 4329 |
fonts.privateoffsets={ |
| 4330 |
textbase=0xF0000, |
| 4331 |
textextrabase=0xFD000, |
| 4332 |
mathextrabase=0xFE000, |
| 4333 |
mathbase=0xFF000, |
| 4334 |
keepnames=false, |
| 4335 |
} |
| 4336 |
if node and not tex.getfontoffamily then |
| 4337 |
tex.getfontoffamily=node.family_font |
| 4338 |
end |
| 4339 |
|
| 4340 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ini”] --- |
| 4341 |
|
| 4342 |
|
| 4343 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-mis” 17e967c9ec4d001deefd43ddf25e98f7] --- |
| 4344 |
|
| 4345 |
if not modules then modules={} end modules ['luatex-font-mis']={ |
| 4346 |
version=1.001, |
| 4347 |
comment="companion to luatex-*.tex", |
| 4348 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 4349 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 4350 |
license="see context related readme files" |
| 4351 |
} |
| 4352 |
if context then |
| 4353 |
os.exit() |
| 4354 |
end |
| 4355 |
local currentfont=font.current |
| 4356 |
local hashes=fonts.hashes |
| 4357 |
local identifiers=hashes.identifiers or {} |
| 4358 |
local marks=hashes.marks or {} |
| 4359 |
hashes.identifiers=identifiers |
| 4360 |
hashes.marks=marks |
| 4361 |
table.setmetatableindex(marks,function(t,k) |
| 4362 |
if k==true then |
| 4363 |
return marks[currentfont()] |
| 4364 |
else |
| 4365 |
local resources=identifiers[k].resources or {} |
| 4366 |
local marks=resources.marks or {} |
| 4367 |
t[k]=marks |
| 4368 |
return marks |
| 4369 |
end |
| 4370 |
end) |
| 4371 |
function font.each() |
| 4372 |
return table.sortedhash(fonts.hashes.identifiers) |
| 4373 |
end |
| 4374 |
|
| 4375 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-mis”] --- |
| 4376 |
|
| 4377 |
|
| 4378 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-con” ebdd0ca857deafdc0152c7a4f1ed2490] --- |
| 4379 |
|
| 4380 |
if not modules then modules={} end modules ['font-con']={ |
| 4381 |
version=1.001, |
| 4382 |
comment="companion to font-ini.mkiv", |
| 4383 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 4384 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 4385 |
license="see context related readme files" |
| 4386 |
} |
| 4387 |
local next,tostring,tonumber,rawget=next,tostring,tonumber,rawget |
| 4388 |
local format,match,lower,gsub,find=string.format,string.match,string.lower,string.gsub,string.find |
| 4389 |
local sort,insert,concat=table.sort,table.insert,table.concat |
| 4390 |
local sortedkeys,sortedhash,serialize,fastcopy=table.sortedkeys,table.sortedhash,table.serialize,table.fastcopy |
| 4391 |
local derivetable=table.derive |
| 4392 |
local ioflush=io.flush |
| 4393 |
local round=math.round |
| 4394 |
local setmetatable,getmetatable,rawget,rawset=setmetatable,getmetatable,rawget,rawset |
| 4395 |
local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) |
| 4396 |
local trace_scaling=false trackers.register("fonts.scaling",function(v) trace_scaling=v end) |
| 4397 |
local report_defining=logs.reporter("fonts","defining") |
| 4398 |
local fonts=fonts |
| 4399 |
local constructors=fonts.constructors or {} |
| 4400 |
fonts.constructors=constructors |
| 4401 |
local handlers=fonts.handlers or {} |
| 4402 |
fonts.handlers=handlers |
| 4403 |
local allocate=utilities.storage.allocate |
| 4404 |
local setmetatableindex=table.setmetatableindex |
| 4405 |
constructors.dontembed=allocate() |
| 4406 |
constructors.namemode="fullpath" |
| 4407 |
constructors.version=1.01 |
| 4408 |
constructors.cache=containers.define("fonts","constructors",constructors.version,false) |
| 4409 |
constructors.privateoffset=fonts.privateoffsets.textbase or 0xF0000 |
| 4410 |
constructors.cacheintex=true |
| 4411 |
constructors.addtounicode=true |
| 4412 |
constructors.fixprotrusion=true |
| 4413 |
local designsizes=allocate() |
| 4414 |
constructors.designsizes=designsizes |
| 4415 |
local loadedfonts=allocate() |
| 4416 |
constructors.loadedfonts=loadedfonts |
| 4417 |
local factors={ |
| 4418 |
pt=65536.0, |
| 4419 |
bp=65781.8, |
| 4420 |
} |
| 4421 |
function constructors.setfactor(f) |
| 4422 |
constructors.factor=factors[f or 'pt'] or factors.pt |
| 4423 |
end |
| 4424 |
constructors.setfactor() |
| 4425 |
function constructors.scaled(scaledpoints,designsize) |
| 4426 |
if scaledpoints<0 then |
| 4427 |
local factor=constructors.factor |
| 4428 |
if designsize then |
| 4429 |
if designsize>factor then |
| 4430 |
return (- scaledpoints/1000)*designsize |
| 4431 |
else |
| 4432 |
return (- scaledpoints/1000)*designsize*factor |
| 4433 |
end |
| 4434 |
else |
| 4435 |
return (- scaledpoints/1000)*10*factor |
| 4436 |
end |
| 4437 |
else |
| 4438 |
return scaledpoints |
| 4439 |
end |
| 4440 |
end |
| 4441 |
function constructors.getprivate(tfmdata) |
| 4442 |
local properties=tfmdata.properties |
| 4443 |
local private=properties.private |
| 4444 |
properties.private=private+1 |
| 4445 |
return private |
| 4446 |
end |
| 4447 |
function constructors.setmathparameter(tfmdata,name,value) |
| 4448 |
local m=tfmdata.mathparameters |
| 4449 |
local c=tfmdata.MathConstants |
| 4450 |
if m then |
| 4451 |
m[name]=value |
| 4452 |
end |
| 4453 |
if c and c~=m then |
| 4454 |
c[name]=value |
| 4455 |
end |
| 4456 |
end |
| 4457 |
function constructors.getmathparameter(tfmdata,name) |
| 4458 |
local p=tfmdata.mathparameters or tfmdata.MathConstants |
| 4459 |
if p then |
| 4460 |
return p[name] |
| 4461 |
end |
| 4462 |
end |
| 4463 |
function constructors.cleanuptable(tfmdata) |
| 4464 |
end |
| 4465 |
function constructors.calculatescale(tfmdata,scaledpoints) |
| 4466 |
local parameters=tfmdata.parameters |
| 4467 |
if scaledpoints<0 then |
| 4468 |
scaledpoints=(- scaledpoints/1000)*(tfmdata.designsize or parameters.designsize) |
| 4469 |
end |
| 4470 |
return scaledpoints,scaledpoints/(parameters.units or 1000) |
| 4471 |
end |
| 4472 |
local unscaled={ |
| 4473 |
ScriptPercentScaleDown=true, |
| 4474 |
ScriptScriptPercentScaleDown=true, |
| 4475 |
RadicalDegreeBottomRaisePercent=true, |
| 4476 |
NoLimitSupFactor=true, |
| 4477 |
NoLimitSubFactor=true, |
| 4478 |
} |
| 4479 |
function constructors.assignmathparameters(target,original) |
| 4480 |
local mathparameters=original.mathparameters |
| 4481 |
if mathparameters and next(mathparameters) then |
| 4482 |
local targetparameters=target.parameters |
| 4483 |
local targetproperties=target.properties |
| 4484 |
local targetmathparameters={} |
| 4485 |
local factor=targetproperties.math_is_scaled and 1 or targetparameters.factor |
| 4486 |
for name,value in next,mathparameters do |
| 4487 |
if unscaled[name] then |
| 4488 |
targetmathparameters[name]=value |
| 4489 |
else |
| 4490 |
targetmathparameters[name]=value*factor |
| 4491 |
end |
| 4492 |
end |
| 4493 |
if not targetmathparameters.FractionDelimiterSize then |
| 4494 |
targetmathparameters.FractionDelimiterSize=1.01*targetparameters.size |
| 4495 |
end |
| 4496 |
if not mathparameters.FractionDelimiterDisplayStyleSize then |
| 4497 |
targetmathparameters.FractionDelimiterDisplayStyleSize=2.40*targetparameters.size |
| 4498 |
end |
| 4499 |
if not targetmathparameters.SpaceBeforeScript then |
| 4500 |
targetmathparameters.SpaceBeforeScript=targetmathparameters.SpaceAfterScript |
| 4501 |
end |
| 4502 |
target.mathparameters=targetmathparameters |
| 4503 |
end |
| 4504 |
end |
| 4505 |
function constructors.beforecopyingcharacters(target,original) |
| 4506 |
end |
| 4507 |
function constructors.aftercopyingcharacters(target,original) |
| 4508 |
end |
| 4509 |
local nofinstances=0 |
| 4510 |
local instances=setmetatableindex(function(t,k) |
| 4511 |
nofinstances=nofinstances+1 |
| 4512 |
t[k]=nofinstances |
| 4513 |
return nofinstances |
| 4514 |
end) |
| 4515 |
function constructors.trytosharefont(target,tfmdata) |
| 4516 |
local properties=target.properties |
| 4517 |
local instance=properties.instance |
| 4518 |
if instance then |
| 4519 |
local fullname=target.fullname |
| 4520 |
local fontname=target.fontname |
| 4521 |
local psname=target.psname |
| 4522 |
local format=tfmdata.properties.format |
| 4523 |
if format=="opentype" then |
| 4524 |
target.streamprovider=1 |
| 4525 |
elseif format=="truetype" then |
| 4526 |
target.streamprovider=2 |
| 4527 |
else |
| 4528 |
target.streamprovider=0 |
| 4529 |
end |
| 4530 |
if target.streamprovider>0 then |
| 4531 |
if fullname then |
| 4532 |
fullname=fullname..":"..instances[instance] |
| 4533 |
target.fullname=fullname |
| 4534 |
end |
| 4535 |
if fontname then |
| 4536 |
fontname=fontname..":"..instances[instance] |
| 4537 |
target.fontname=fontname |
| 4538 |
end |
| 4539 |
if psname then |
| 4540 |
psname=psname..":"..instances[instance] |
| 4541 |
target.psname=psname |
| 4542 |
end |
| 4543 |
end |
| 4544 |
end |
| 4545 |
end |
| 4546 |
local synonyms={ |
| 4547 |
exheight="x_height", |
| 4548 |
xheight="x_height", |
| 4549 |
ex="x_height", |
| 4550 |
emwidth="quad", |
| 4551 |
em="quad", |
| 4552 |
spacestretch="space_stretch", |
| 4553 |
stretch="space_stretch", |
| 4554 |
spaceshrink="space_shrink", |
| 4555 |
shrink="space_shrink", |
| 4556 |
extraspace="extra_space", |
| 4557 |
xspace="extra_space", |
| 4558 |
slantperpoint="slant", |
| 4559 |
} |
| 4560 |
function constructors.enhanceparameters(parameters) |
| 4561 |
local mt=getmetatable(parameters) |
| 4562 |
local getter=function(t,k) |
| 4563 |
if not k then |
| 4564 |
return nil |
| 4565 |
end |
| 4566 |
local s=synonyms[k] |
| 4567 |
if s then |
| 4568 |
return rawget(t,s) or (mt and mt[s]) or nil |
| 4569 |
end |
| 4570 |
if k=="spacing" then |
| 4571 |
return { |
| 4572 |
width=t.space, |
| 4573 |
stretch=t.space_stretch, |
| 4574 |
shrink=t.space_shrink, |
| 4575 |
extra=t.extra_space, |
| 4576 |
} |
| 4577 |
end |
| 4578 |
return mt and mt[k] or nil |
| 4579 |
end |
| 4580 |
local setter=function(t,k,v) |
| 4581 |
if not k then |
| 4582 |
return 0 |
| 4583 |
end |
| 4584 |
local s=synonyms[k] |
| 4585 |
if s then |
| 4586 |
rawset(t,s,v) |
| 4587 |
elseif k=="spacing" then |
| 4588 |
if type(v)=="table" then |
| 4589 |
rawset(t,"space",v.width or 0) |
| 4590 |
rawset(t,"space_stretch",v.stretch or 0) |
| 4591 |
rawset(t,"space_shrink",v.shrink or 0) |
| 4592 |
rawset(t,"extra_space",v.extra or 0) |
| 4593 |
end |
| 4594 |
else |
| 4595 |
rawset(t,k,v) |
| 4596 |
end |
| 4597 |
end |
| 4598 |
setmetatable(parameters,{ |
| 4599 |
__index=getter, |
| 4600 |
__newindex=setter, |
| 4601 |
}) |
| 4602 |
end |
| 4603 |
local function mathkerns(v,vdelta) |
| 4604 |
local k={} |
| 4605 |
for i=1,#v do |
| 4606 |
local entry=v[i] |
| 4607 |
local height=entry.height |
| 4608 |
local kern=entry.kern |
| 4609 |
k[i]={ |
| 4610 |
height=height and vdelta*height or 0, |
| 4611 |
kern=kern and vdelta*kern or 0, |
| 4612 |
} |
| 4613 |
end |
| 4614 |
return k |
| 4615 |
end |
| 4616 |
local psfake=0 |
| 4617 |
local function fixedpsname(psname,fallback) |
| 4618 |
local usedname=psname |
| 4619 |
if psname and psname~="" then |
| 4620 |
if find(psname," ",1,true) then |
| 4621 |
usedname=gsub(psname,"[%s]+","-") |
| 4622 |
else |
| 4623 |
end |
| 4624 |
elseif not fallback or fallback=="" then |
| 4625 |
psfake=psfake+1 |
| 4626 |
psname="fakename-"..psfake |
| 4627 |
else |
| 4628 |
psname=fallback |
| 4629 |
usedname=gsub(psname,"[^a-zA-Z0-9]+","-") |
| 4630 |
end |
| 4631 |
return usedname,psname~=usedname |
| 4632 |
end |
| 4633 |
function constructors.scale(tfmdata,specification) |
| 4634 |
local target={} |
| 4635 |
if tonumber(specification) then |
| 4636 |
specification={ size=specification } |
| 4637 |
end |
| 4638 |
target.specification=specification |
| 4639 |
local scaledpoints=specification.size |
| 4640 |
local relativeid=specification.relativeid |
| 4641 |
local properties=tfmdata.properties or {} |
| 4642 |
local goodies=tfmdata.goodies or {} |
| 4643 |
local resources=tfmdata.resources or {} |
| 4644 |
local descriptions=tfmdata.descriptions or {} |
| 4645 |
local characters=tfmdata.characters or {} |
| 4646 |
local changed=tfmdata.changed or {} |
| 4647 |
local shared=tfmdata.shared or {} |
| 4648 |
local parameters=tfmdata.parameters or {} |
| 4649 |
local mathparameters=tfmdata.mathparameters or {} |
| 4650 |
local targetcharacters={} |
| 4651 |
local targetdescriptions=derivetable(descriptions) |
| 4652 |
local targetparameters=derivetable(parameters) |
| 4653 |
local targetproperties=derivetable(properties) |
| 4654 |
local targetgoodies=goodies |
| 4655 |
target.characters=targetcharacters |
| 4656 |
target.descriptions=targetdescriptions |
| 4657 |
target.parameters=targetparameters |
| 4658 |
target.properties=targetproperties |
| 4659 |
target.goodies=targetgoodies |
| 4660 |
target.shared=shared |
| 4661 |
target.resources=resources |
| 4662 |
target.unscaled=tfmdata |
| 4663 |
local mathsize=tonumber(specification.mathsize) or 0 |
| 4664 |
local textsize=tonumber(specification.textsize) or scaledpoints |
| 4665 |
local extrafactor=tonumber(specification.factor ) or 1 |
| 4666 |
targetparameters.mathsize=mathsize |
| 4667 |
targetparameters.textsize=textsize |
| 4668 |
targetparameters.extrafactor=extrafactor |
| 4669 |
local addtounicode=constructors.addtounicode |
| 4670 |
local tounicode=fonts.mappings.tounicode |
| 4671 |
local unknowncode=tounicode(0xFFFD) |
| 4672 |
local defaultwidth=resources.defaultwidth or 0 |
| 4673 |
local defaultheight=resources.defaultheight or 0 |
| 4674 |
local defaultdepth=resources.defaultdepth or 0 |
| 4675 |
local units=parameters.units or 1000 |
| 4676 |
targetproperties.language=properties.language or "dflt" |
| 4677 |
targetproperties.script=properties.script or "dflt" |
| 4678 |
targetproperties.mode=properties.mode or "base" |
| 4679 |
targetproperties.method=properties.method |
| 4680 |
local askedscaledpoints=scaledpoints |
| 4681 |
local scaledpoints,delta=constructors.calculatescale(tfmdata,scaledpoints,nil,specification) |
| 4682 |
local hdelta=delta |
| 4683 |
local vdelta=delta |
| 4684 |
target.designsize=parameters.designsize |
| 4685 |
target.units=units |
| 4686 |
target.units_per_em=units |
| 4687 |
local direction=properties.direction or tfmdata.direction or 0 |
| 4688 |
target.direction=direction |
| 4689 |
properties.direction=direction |
| 4690 |
target.size=scaledpoints |
| 4691 |
target.encodingbytes=properties.encodingbytes or 1 |
| 4692 |
target.subfont=properties.subfont |
| 4693 |
target.embedding=properties.embedding or "subset" |
| 4694 |
target.tounicode=1 |
| 4695 |
target.cidinfo=properties.cidinfo |
| 4696 |
target.format=properties.format |
| 4697 |
target.cache=constructors.cacheintex and "yes" or "renew" |
| 4698 |
local original=properties.original or tfmdata.original |
| 4699 |
local fontname=properties.fontname or tfmdata.fontname |
| 4700 |
local fullname=properties.fullname or tfmdata.fullname |
| 4701 |
local filename=properties.filename or tfmdata.filename |
| 4702 |
local psname=properties.psname or tfmdata.psname |
| 4703 |
local name=properties.name or tfmdata.name |
| 4704 |
local psname,psfixed=fixedpsname(psname,fontname or fullname or file.nameonly(filename)) |
| 4705 |
target.original=original |
| 4706 |
target.fontname=fontname |
| 4707 |
target.fullname=fullname |
| 4708 |
target.filename=filename |
| 4709 |
target.psname=psname |
| 4710 |
target.name=name |
| 4711 |
properties.fontname=fontname |
| 4712 |
properties.fullname=fullname |
| 4713 |
properties.filename=filename |
| 4714 |
properties.psname=psname |
| 4715 |
properties.name=name |
| 4716 |
local expansion=parameters.expansion |
| 4717 |
if expansion then |
| 4718 |
target.stretch=expansion.stretch |
| 4719 |
target.shrink=expansion.shrink |
| 4720 |
target.step=expansion.step |
| 4721 |
end |
| 4722 |
local slantfactor=parameters.slantfactor or 0 |
| 4723 |
if slantfactor~=0 then |
| 4724 |
target.slant=slantfactor*1000 |
| 4725 |
else |
| 4726 |
target.slant=0 |
| 4727 |
end |
| 4728 |
local extendfactor=parameters.extendfactor or 0 |
| 4729 |
if extendfactor~=0 and extendfactor~=1 then |
| 4730 |
hdelta=hdelta*extendfactor |
| 4731 |
target.extend=extendfactor*1000 |
| 4732 |
else |
| 4733 |
target.extend=1000 |
| 4734 |
end |
| 4735 |
local squeezefactor=parameters.squeezefactor or 0 |
| 4736 |
if squeezefactor~=0 and squeezefactor~=1 then |
| 4737 |
vdelta=vdelta*squeezefactor |
| 4738 |
target.squeeze=squeezefactor*1000 |
| 4739 |
else |
| 4740 |
target.squeeze=1000 |
| 4741 |
end |
| 4742 |
local mode=parameters.mode or 0 |
| 4743 |
if mode~=0 then |
| 4744 |
target.mode=mode |
| 4745 |
end |
| 4746 |
local width=parameters.width or 0 |
| 4747 |
if width~=0 then |
| 4748 |
target.width=width*delta*1000/655360 |
| 4749 |
end |
| 4750 |
targetparameters.factor=delta |
| 4751 |
targetparameters.hfactor=hdelta |
| 4752 |
targetparameters.vfactor=vdelta |
| 4753 |
targetparameters.size=scaledpoints |
| 4754 |
targetparameters.units=units |
| 4755 |
targetparameters.scaledpoints=askedscaledpoints |
| 4756 |
targetparameters.mode=mode |
| 4757 |
targetparameters.width=width |
| 4758 |
local isvirtual=properties.virtualized or tfmdata.type=="virtual" |
| 4759 |
local hasquality=parameters.expansion or parameters.protrusion |
| 4760 |
local hasitalics=properties.hasitalics |
| 4761 |
local autoitalicamount=properties.autoitalicamount |
| 4762 |
local stackmath=not properties.nostackmath |
| 4763 |
local haskerns=properties.haskerns or properties.mode=="base" |
| 4764 |
local hasligatures=properties.hasligatures or properties.mode=="base" |
| 4765 |
local realdimensions=properties.realdimensions |
| 4766 |
local writingmode=properties.writingmode or "horizontal" |
| 4767 |
local identity=properties.identity or "horizontal" |
| 4768 |
local vfonts=target.fonts |
| 4769 |
if vfonts and #vfonts>0 then |
| 4770 |
target.fonts=fastcopy(vfonts) |
| 4771 |
elseif isvirtual then |
| 4772 |
target.fonts={ { id=0 } } |
| 4773 |
end |
| 4774 |
if changed and not next(changed) then |
| 4775 |
changed=false |
| 4776 |
end |
| 4777 |
target.type=isvirtual and "virtual" or "real" |
| 4778 |
target.writingmode=writingmode=="vertical" and "vertical" or "horizontal" |
| 4779 |
target.identity=identity=="vertical" and "vertical" or "horizontal" |
| 4780 |
target.postprocessors=tfmdata.postprocessors |
| 4781 |
local targetslant=(parameters.slant or parameters[1] or 0)*factors.pt |
| 4782 |
local targetspace=(parameters.space or parameters[2] or 0)*hdelta |
| 4783 |
local targetspace_stretch=(parameters.space_stretch or parameters[3] or 0)*hdelta |
| 4784 |
local targetspace_shrink=(parameters.space_shrink or parameters[4] or 0)*hdelta |
| 4785 |
local targetx_height=(parameters.x_height or parameters[5] or 0)*vdelta |
| 4786 |
local targetquad=(parameters.quad or parameters[6] or 0)*hdelta |
| 4787 |
local targetextra_space=(parameters.extra_space or parameters[7] or 0)*hdelta |
| 4788 |
targetparameters.slant=targetslant |
| 4789 |
targetparameters.space=targetspace |
| 4790 |
targetparameters.space_stretch=targetspace_stretch |
| 4791 |
targetparameters.space_shrink=targetspace_shrink |
| 4792 |
targetparameters.x_height=targetx_height |
| 4793 |
targetparameters.quad=targetquad |
| 4794 |
targetparameters.extra_space=targetextra_space |
| 4795 |
local hshift=parameters.hshift |
| 4796 |
if hshift then |
| 4797 |
targetparameters.hshift=delta*hshift |
| 4798 |
end |
| 4799 |
local vshift=parameters.vshift |
| 4800 |
if vshift then |
| 4801 |
targetparameters.vshift=delta*vshift |
| 4802 |
end |
| 4803 |
local ascender=parameters.ascender |
| 4804 |
if ascender then |
| 4805 |
targetparameters.ascender=delta*ascender |
| 4806 |
end |
| 4807 |
local descender=parameters.descender |
| 4808 |
if descender then |
| 4809 |
targetparameters.descender=delta*descender |
| 4810 |
end |
| 4811 |
constructors.enhanceparameters(targetparameters) |
| 4812 |
local protrusionfactor=constructors.fixprotrusion and ((targetquad~=0 and 1000/targetquad) or 1) or 1 |
| 4813 |
local scaledwidth=defaultwidth*hdelta |
| 4814 |
local scaledheight=defaultheight*vdelta |
| 4815 |
local scaleddepth=defaultdepth*vdelta |
| 4816 |
local hasmath=(properties.hasmath or next(mathparameters)) and true |
| 4817 |
if hasmath then |
| 4818 |
constructors.assignmathparameters(target,tfmdata) |
| 4819 |
properties.hasmath=true |
| 4820 |
target.nomath=false |
| 4821 |
target.MathConstants=target.mathparameters |
| 4822 |
local oldmath=properties.oldmath |
| 4823 |
targetproperties.oldmath=oldmath |
| 4824 |
target.oldmath=oldmath |
| 4825 |
else |
| 4826 |
properties.hasmath=false |
| 4827 |
target.nomath=true |
| 4828 |
target.mathparameters=nil |
| 4829 |
end |
| 4830 |
if hasmath then |
| 4831 |
local mathitalics=properties.mathitalics |
| 4832 |
if mathitalics==false then |
| 4833 |
if trace_defining then |
| 4834 |
report_defining("%s italics %s for font %a, fullname %a, filename %a","math",hasitalics and "ignored" or "disabled",name,fullname,filename) |
| 4835 |
end |
| 4836 |
hasitalics=false |
| 4837 |
autoitalicamount=false |
| 4838 |
end |
| 4839 |
else |
| 4840 |
local textitalics=properties.textitalics |
| 4841 |
if textitalics==false then |
| 4842 |
if trace_defining then |
| 4843 |
report_defining("%s italics %s for font %a, fullname %a, filename %a","text",hasitalics and "ignored" or "disabled",name,fullname,filename) |
| 4844 |
end |
| 4845 |
hasitalics=false |
| 4846 |
autoitalicamount=false |
| 4847 |
end |
| 4848 |
end |
| 4849 |
if trace_defining then |
| 4850 |
report_defining("defining tfm, name %a, fullname %a, filename %a, %spsname %a, hscale %a, vscale %a, math %a, italics %a", |
| 4851 |
name,fullname,filename,psfixed and "(fixed) " or "",psname,hdelta,vdelta, |
| 4852 |
hasmath and "enabled" or "disabled",hasitalics and "enabled" or "disabled") |
| 4853 |
end |
| 4854 |
constructors.beforecopyingcharacters(target,tfmdata) |
| 4855 |
local sharedkerns={} |
| 4856 |
for unicode,character in next,characters do |
| 4857 |
local chr,description,index |
| 4858 |
if changed then |
| 4859 |
local c=changed[unicode] |
| 4860 |
if c and c~=unicode then |
| 4861 |
local cc=changed[c] |
| 4862 |
if cc then |
| 4863 |
while cc do |
| 4864 |
c=cc |
| 4865 |
cc=changed[c] |
| 4866 |
end |
| 4867 |
end |
| 4868 |
if c then |
| 4869 |
description=descriptions[c] or descriptions[unicode] or character |
| 4870 |
character=characters[c] or character |
| 4871 |
index=description.index or c |
| 4872 |
else |
| 4873 |
description=descriptions[unicode] or character |
| 4874 |
index=description.index or unicode |
| 4875 |
end |
| 4876 |
else |
| 4877 |
description=descriptions[unicode] or character |
| 4878 |
index=description.index or unicode |
| 4879 |
end |
| 4880 |
else |
| 4881 |
description=descriptions[unicode] or character |
| 4882 |
index=description.index or unicode |
| 4883 |
end |
| 4884 |
local width=description.width |
| 4885 |
local height=description.height |
| 4886 |
local depth=description.depth |
| 4887 |
local isunicode=description.unicode |
| 4888 |
if realdimensions then |
| 4889 |
if not height or height==0 then |
| 4890 |
local bb=description.boundingbox |
| 4891 |
local ht=bb[4] |
| 4892 |
if ht~=0 then |
| 4893 |
height=ht |
| 4894 |
end |
| 4895 |
if not depth or depth==0 then |
| 4896 |
local dp=-bb[2] |
| 4897 |
if dp~=0 then |
| 4898 |
depth=dp |
| 4899 |
end |
| 4900 |
end |
| 4901 |
elseif not depth or depth==0 then |
| 4902 |
local dp=-description.boundingbox[2] |
| 4903 |
if dp~=0 then |
| 4904 |
depth=dp |
| 4905 |
end |
| 4906 |
end |
| 4907 |
end |
| 4908 |
if width then width=hdelta*width else width=scaledwidth end |
| 4909 |
if height then height=vdelta*height else height=scaledheight end |
| 4910 |
if depth and depth~=0 then |
| 4911 |
depth=delta*depth |
| 4912 |
if isunicode then |
| 4913 |
chr={ |
| 4914 |
index=index, |
| 4915 |
height=height, |
| 4916 |
depth=depth, |
| 4917 |
width=width, |
| 4918 |
unicode=isunicode, |
| 4919 |
} |
| 4920 |
else |
| 4921 |
chr={ |
| 4922 |
index=index, |
| 4923 |
height=height, |
| 4924 |
depth=depth, |
| 4925 |
width=width, |
| 4926 |
} |
| 4927 |
end |
| 4928 |
else |
| 4929 |
if isunicode then |
| 4930 |
chr={ |
| 4931 |
index=index, |
| 4932 |
height=height, |
| 4933 |
width=width, |
| 4934 |
unicode=isunicode, |
| 4935 |
} |
| 4936 |
else |
| 4937 |
chr={ |
| 4938 |
index=index, |
| 4939 |
height=height, |
| 4940 |
width=width, |
| 4941 |
} |
| 4942 |
end |
| 4943 |
end |
| 4944 |
if addtounicode then |
| 4945 |
chr.tounicode=isunicode and tounicode(isunicode) or unknowncode |
| 4946 |
end |
| 4947 |
if hasquality then |
| 4948 |
local ve=character.expansion_factor |
| 4949 |
if ve then |
| 4950 |
chr.expansion_factor=ve*1000 |
| 4951 |
end |
| 4952 |
local vl=character.left_protruding |
| 4953 |
if vl then |
| 4954 |
chr.left_protruding=protrusionfactor*width*vl |
| 4955 |
end |
| 4956 |
local vr=character.right_protruding |
| 4957 |
if vr then |
| 4958 |
chr.right_protruding=protrusionfactor*width*vr |
| 4959 |
end |
| 4960 |
end |
| 4961 |
if hasmath then |
| 4962 |
local vn=character.next |
| 4963 |
if vn then |
| 4964 |
chr.next=vn |
| 4965 |
else |
| 4966 |
local vv=character.vert_variants |
| 4967 |
if vv then |
| 4968 |
local t={} |
| 4969 |
for i=1,#vv do |
| 4970 |
local vvi=vv[i] |
| 4971 |
local s=vvi["start"] or 0 |
| 4972 |
local e=vvi["end"] or 0 |
| 4973 |
local a=vvi["advance"] or 0 |
| 4974 |
t[i]={ |
| 4975 |
["start"]=s==0 and 0 or s*vdelta, |
| 4976 |
["end"]=e==0 and 0 or e*vdelta, |
| 4977 |
["advance"]=a==0 and 0 or a*vdelta, |
| 4978 |
["extender"]=vvi["extender"], |
| 4979 |
["glyph"]=vvi["glyph"], |
| 4980 |
} |
| 4981 |
end |
| 4982 |
chr.vert_variants=t |
| 4983 |
else |
| 4984 |
local hv=character.horiz_variants |
| 4985 |
if hv then |
| 4986 |
local t={} |
| 4987 |
for i=1,#hv do |
| 4988 |
local hvi=hv[i] |
| 4989 |
local s=hvi["start"] or 0 |
| 4990 |
local e=hvi["end"] or 0 |
| 4991 |
local a=hvi["advance"] or 0 |
| 4992 |
t[i]={ |
| 4993 |
["start"]=s==0 and 0 or s*hdelta, |
| 4994 |
["end"]=e==0 and 0 or e*hdelta, |
| 4995 |
["advance"]=a==0 and 0 or a*hdelta, |
| 4996 |
["extender"]=hvi["extender"], |
| 4997 |
["glyph"]=hvi["glyph"], |
| 4998 |
} |
| 4999 |
end |
| 5000 |
chr.horiz_variants=t |
| 5001 |
end |
| 5002 |
end |
| 5003 |
end |
| 5004 |
local vi=character.vert_italic |
| 5005 |
if vi and vi~=0 then |
| 5006 |
chr.vert_italic=vi*hdelta |
| 5007 |
end |
| 5008 |
local va=character.accent |
| 5009 |
if va then |
| 5010 |
chr.top_accent=vdelta*va |
| 5011 |
end |
| 5012 |
if stackmath then |
| 5013 |
local mk=character.mathkerns |
| 5014 |
if mk then |
| 5015 |
local tr=mk.topright |
| 5016 |
local tl=mk.topleft |
| 5017 |
local br=mk.bottomright |
| 5018 |
local bl=mk.bottomleft |
| 5019 |
chr.mathkern={ |
| 5020 |
top_right=tr and mathkerns(tr,vdelta) or nil, |
| 5021 |
top_left=tl and mathkerns(tl,vdelta) or nil, |
| 5022 |
bottom_right=br and mathkerns(br,vdelta) or nil, |
| 5023 |
bottom_left=bl and mathkerns(bl,vdelta) or nil, |
| 5024 |
} |
| 5025 |
end |
| 5026 |
end |
| 5027 |
if hasitalics then |
| 5028 |
local vi=character.italic |
| 5029 |
if vi and vi~=0 then |
| 5030 |
chr.italic=vi*hdelta |
| 5031 |
end |
| 5032 |
end |
| 5033 |
elseif autoitalicamount then |
| 5034 |
local vi=description.italic |
| 5035 |
if not vi then |
| 5036 |
local bb=description.boundingbox |
| 5037 |
if bb then |
| 5038 |
local vi=bb[3]-description.width+autoitalicamount |
| 5039 |
if vi>0 then |
| 5040 |
chr.italic=vi*hdelta |
| 5041 |
end |
| 5042 |
else |
| 5043 |
end |
| 5044 |
elseif vi~=0 then |
| 5045 |
chr.italic=vi*hdelta |
| 5046 |
end |
| 5047 |
elseif hasitalics then |
| 5048 |
local vi=character.italic |
| 5049 |
if vi and vi~=0 then |
| 5050 |
chr.italic=vi*hdelta |
| 5051 |
end |
| 5052 |
end |
| 5053 |
if haskerns then |
| 5054 |
local vk=character.kerns |
| 5055 |
if vk then |
| 5056 |
local s=sharedkerns[vk] |
| 5057 |
if not s then |
| 5058 |
s={} |
| 5059 |
for k,v in next,vk do s[k]=v*hdelta end |
| 5060 |
sharedkerns[vk]=s |
| 5061 |
end |
| 5062 |
chr.kerns=s |
| 5063 |
end |
| 5064 |
end |
| 5065 |
if hasligatures then |
| 5066 |
local vl=character.ligatures |
| 5067 |
if vl then |
| 5068 |
if true then |
| 5069 |
chr.ligatures=vl |
| 5070 |
else |
| 5071 |
local tt={} |
| 5072 |
for i,l in next,vl do |
| 5073 |
tt[i]=l |
| 5074 |
end |
| 5075 |
chr.ligatures=tt |
| 5076 |
end |
| 5077 |
end |
| 5078 |
end |
| 5079 |
if isvirtual then |
| 5080 |
local vc=character.commands |
| 5081 |
if vc then |
| 5082 |
local ok=false |
| 5083 |
for i=1,#vc do |
| 5084 |
local key=vc[i][1] |
| 5085 |
if key=="right" or key=="down" or key=="rule" then |
| 5086 |
ok=true |
| 5087 |
break |
| 5088 |
end |
| 5089 |
end |
| 5090 |
if ok then |
| 5091 |
local tt={} |
| 5092 |
for i=1,#vc do |
| 5093 |
local ivc=vc[i] |
| 5094 |
local key=ivc[1] |
| 5095 |
if key=="right" then |
| 5096 |
tt[i]={ key,ivc[2]*hdelta } |
| 5097 |
elseif key=="down" then |
| 5098 |
tt[i]={ key,ivc[2]*vdelta } |
| 5099 |
elseif key=="rule" then |
| 5100 |
tt[i]={ key,ivc[2]*vdelta,ivc[3]*hdelta } |
| 5101 |
else |
| 5102 |
tt[i]=ivc |
| 5103 |
end |
| 5104 |
end |
| 5105 |
chr.commands=tt |
| 5106 |
else |
| 5107 |
chr.commands=vc |
| 5108 |
end |
| 5109 |
end |
| 5110 |
end |
| 5111 |
targetcharacters[unicode]=chr |
| 5112 |
end |
| 5113 |
properties.setitalics=hasitalics |
| 5114 |
constructors.aftercopyingcharacters(target,tfmdata) |
| 5115 |
constructors.trytosharefont(target,tfmdata) |
| 5116 |
local vfonts=target.fonts |
| 5117 |
if isvirtual or target.type=="virtual" or properties.virtualized then |
| 5118 |
properties.virtualized=true |
| 5119 |
target.type="virtual" |
| 5120 |
if not vfonts or #vfonts==0 then |
| 5121 |
target.fonts={ { id=0 } } |
| 5122 |
end |
| 5123 |
elseif vfonts then |
| 5124 |
properties.virtualized=true |
| 5125 |
target.type="virtual" |
| 5126 |
if #vfonts==0 then |
| 5127 |
target.fonts={ { id=0 } } |
| 5128 |
end |
| 5129 |
end |
| 5130 |
return target |
| 5131 |
end |
| 5132 |
function constructors.finalize(tfmdata) |
| 5133 |
if tfmdata.properties and tfmdata.properties.finalized then |
| 5134 |
return |
| 5135 |
end |
| 5136 |
if not tfmdata.characters then |
| 5137 |
return nil |
| 5138 |
end |
| 5139 |
if not tfmdata.goodies then |
| 5140 |
tfmdata.goodies={} |
| 5141 |
end |
| 5142 |
local parameters=tfmdata.parameters |
| 5143 |
if not parameters then |
| 5144 |
return nil |
| 5145 |
end |
| 5146 |
if not parameters.expansion then |
| 5147 |
parameters.expansion={ |
| 5148 |
stretch=tfmdata.stretch or 0, |
| 5149 |
shrink=tfmdata.shrink or 0, |
| 5150 |
step=tfmdata.step or 0, |
| 5151 |
} |
| 5152 |
end |
| 5153 |
if not parameters.size then |
| 5154 |
parameters.size=tfmdata.size |
| 5155 |
end |
| 5156 |
if not parameters.mode then |
| 5157 |
parameters.mode=0 |
| 5158 |
end |
| 5159 |
if not parameters.width then |
| 5160 |
parameters.width=0 |
| 5161 |
end |
| 5162 |
if not parameters.slantfactor then |
| 5163 |
parameters.slantfactor=(tfmdata.slant or 0)/1000 |
| 5164 |
end |
| 5165 |
if not parameters.extendfactor then |
| 5166 |
parameters.extendfactor=(tfmdata.extend or 1000)/1000 |
| 5167 |
end |
| 5168 |
if not parameters.squeezefactor then |
| 5169 |
parameters.squeezefactor=(tfmdata.squeeze or 1000)/1000 |
| 5170 |
end |
| 5171 |
local designsize=parameters.designsize |
| 5172 |
if designsize then |
| 5173 |
parameters.minsize=tfmdata.minsize or designsize |
| 5174 |
parameters.maxsize=tfmdata.maxsize or designsize |
| 5175 |
else |
| 5176 |
designsize=factors.pt*10 |
| 5177 |
parameters.designsize=designsize |
| 5178 |
parameters.minsize=designsize |
| 5179 |
parameters.maxsize=designsize |
| 5180 |
end |
| 5181 |
parameters.minsize=tfmdata.minsize or parameters.designsize |
| 5182 |
parameters.maxsize=tfmdata.maxsize or parameters.designsize |
| 5183 |
if not parameters.units then |
| 5184 |
parameters.units=tfmdata.units or tfmdata.units_per_em or 1000 |
| 5185 |
end |
| 5186 |
if not tfmdata.descriptions then |
| 5187 |
local descriptions={} |
| 5188 |
setmetatableindex(descriptions,function(t,k) local v={} t[k]=v return v end) |
| 5189 |
tfmdata.descriptions=descriptions |
| 5190 |
end |
| 5191 |
local properties=tfmdata.properties |
| 5192 |
if not properties then |
| 5193 |
properties={} |
| 5194 |
tfmdata.properties=properties |
| 5195 |
end |
| 5196 |
if not properties.virtualized then |
| 5197 |
properties.virtualized=tfmdata.type=="virtual" |
| 5198 |
end |
| 5199 |
properties.fontname=properties.fontname or tfmdata.fontname |
| 5200 |
properties.filename=properties.filename or tfmdata.filename |
| 5201 |
properties.fullname=properties.fullname or tfmdata.fullname |
| 5202 |
properties.name=properties.name or tfmdata.name |
| 5203 |
properties.psname=properties.psname or tfmdata.psname |
| 5204 |
properties.encodingbytes=tfmdata.encodingbytes or 1 |
| 5205 |
properties.subfont=tfmdata.subfont or nil |
| 5206 |
properties.embedding=tfmdata.embedding or "subset" |
| 5207 |
properties.tounicode=tfmdata.tounicode or 1 |
| 5208 |
properties.cidinfo=tfmdata.cidinfo or nil |
| 5209 |
properties.format=tfmdata.format or "type1" |
| 5210 |
properties.direction=tfmdata.direction or 0 |
| 5211 |
properties.writingmode=tfmdata.writingmode or "horizontal" |
| 5212 |
properties.identity=tfmdata.identity or "horizontal" |
| 5213 |
properties.usedbitmap=tfmdata.usedbitmap |
| 5214 |
if not tfmdata.resources then |
| 5215 |
tfmdata.resources={} |
| 5216 |
end |
| 5217 |
if not tfmdata.shared then |
| 5218 |
tfmdata.shared={} |
| 5219 |
end |
| 5220 |
if not properties.hasmath then |
| 5221 |
properties.hasmath=not tfmdata.nomath |
| 5222 |
end |
| 5223 |
tfmdata.MathConstants=nil |
| 5224 |
tfmdata.postprocessors=nil |
| 5225 |
tfmdata.fontname=nil |
| 5226 |
tfmdata.filename=nil |
| 5227 |
tfmdata.fullname=nil |
| 5228 |
tfmdata.name=nil |
| 5229 |
tfmdata.psname=nil |
| 5230 |
tfmdata.encodingbytes=nil |
| 5231 |
tfmdata.subfont=nil |
| 5232 |
tfmdata.embedding=nil |
| 5233 |
tfmdata.tounicode=nil |
| 5234 |
tfmdata.cidinfo=nil |
| 5235 |
tfmdata.format=nil |
| 5236 |
tfmdata.direction=nil |
| 5237 |
tfmdata.type=nil |
| 5238 |
tfmdata.nomath=nil |
| 5239 |
tfmdata.designsize=nil |
| 5240 |
tfmdata.size=nil |
| 5241 |
tfmdata.stretch=nil |
| 5242 |
tfmdata.shrink=nil |
| 5243 |
tfmdata.step=nil |
| 5244 |
tfmdata.slant=nil |
| 5245 |
tfmdata.extend=nil |
| 5246 |
tfmdata.squeeze=nil |
| 5247 |
tfmdata.mode=nil |
| 5248 |
tfmdata.width=nil |
| 5249 |
tfmdata.units=nil |
| 5250 |
tfmdata.units_per_em=nil |
| 5251 |
tfmdata.cache=nil |
| 5252 |
properties.finalized=true |
| 5253 |
return tfmdata |
| 5254 |
end |
| 5255 |
local hashmethods={} |
| 5256 |
constructors.hashmethods=hashmethods |
| 5257 |
function constructors.hashfeatures(specification) |
| 5258 |
local features=specification.features |
| 5259 |
if features then |
| 5260 |
local t,n={},0 |
| 5261 |
for category,list in sortedhash(features) do |
| 5262 |
if next(list) then |
| 5263 |
local hasher=hashmethods[category] |
| 5264 |
if hasher then |
| 5265 |
local hash=hasher(list) |
| 5266 |
if hash then |
| 5267 |
n=n+1 |
| 5268 |
t[n]=category..":"..hash |
| 5269 |
end |
| 5270 |
end |
| 5271 |
end |
| 5272 |
end |
| 5273 |
if n>0 then |
| 5274 |
return concat(t," & ") |
| 5275 |
end |
| 5276 |
end |
| 5277 |
return "unknown" |
| 5278 |
end |
| 5279 |
hashmethods.normal=function(list) |
| 5280 |
local s={} |
| 5281 |
local n=0 |
| 5282 |
for k,v in next,list do |
| 5283 |
if not k then |
| 5284 |
elseif k=="number" or k=="features" then |
| 5285 |
else |
| 5286 |
n=n+1 |
| 5287 |
if type(v)=="table" then |
| 5288 |
local t={} |
| 5289 |
local m=0 |
| 5290 |
for k,v in next,v do |
| 5291 |
m=m+1 |
| 5292 |
t[m]=k..'='..tostring(v) |
| 5293 |
end |
| 5294 |
sort(t) |
| 5295 |
s[n]=k..'={'..concat(t,",").."}" |
| 5296 |
else |
| 5297 |
s[n]=k..'='..tostring(v) |
| 5298 |
end |
| 5299 |
end |
| 5300 |
end |
| 5301 |
if n>0 then |
| 5302 |
sort(s) |
| 5303 |
return concat(s,"+") |
| 5304 |
end |
| 5305 |
end |
| 5306 |
function constructors.hashinstance(specification,force) |
| 5307 |
local hash=specification.hash |
| 5308 |
local size=specification.size |
| 5309 |
local fallbacks=specification.fallbacks |
| 5310 |
if force or not hash then |
| 5311 |
hash=constructors.hashfeatures(specification) |
| 5312 |
specification.hash=hash |
| 5313 |
end |
| 5314 |
if size<1000 and designsizes[hash] then |
| 5315 |
size=round(constructors.scaled(size,designsizes[hash])) |
| 5316 |
else |
| 5317 |
size=round(size) |
| 5318 |
end |
| 5319 |
specification.size=size |
| 5320 |
if fallbacks then |
| 5321 |
return hash..' @ '..size..' @ '..fallbacks |
| 5322 |
else |
| 5323 |
return hash..' @ '..size |
| 5324 |
end |
| 5325 |
end |
| 5326 |
function constructors.setname(tfmdata,specification) |
| 5327 |
if constructors.namemode=="specification" then |
| 5328 |
local specname=specification.specification |
| 5329 |
if specname then |
| 5330 |
tfmdata.properties.name=specname |
| 5331 |
if trace_defining then |
| 5332 |
report_otf("overloaded fontname %a",specname) |
| 5333 |
end |
| 5334 |
end |
| 5335 |
end |
| 5336 |
end |
| 5337 |
function constructors.checkedfilename(data) |
| 5338 |
local foundfilename=data.foundfilename |
| 5339 |
if not foundfilename then |
| 5340 |
local askedfilename=data.filename or "" |
| 5341 |
if askedfilename~="" then |
| 5342 |
askedfilename=resolvers.resolve(askedfilename) |
| 5343 |
foundfilename=resolvers.findbinfile(askedfilename,"") or "" |
| 5344 |
if foundfilename=="" then |
| 5345 |
report_defining("source file %a is not found",askedfilename) |
| 5346 |
foundfilename=resolvers.findbinfile(file.basename(askedfilename),"") or "" |
| 5347 |
if foundfilename~="" then |
| 5348 |
report_defining("using source file %a due to cache mismatch",foundfilename) |
| 5349 |
end |
| 5350 |
end |
| 5351 |
end |
| 5352 |
data.foundfilename=foundfilename |
| 5353 |
end |
| 5354 |
return foundfilename |
| 5355 |
end |
| 5356 |
local formats=allocate() |
| 5357 |
fonts.formats=formats |
| 5358 |
setmetatableindex(formats,function(t,k) |
| 5359 |
local l=lower(k) |
| 5360 |
if rawget(t,k) then |
| 5361 |
t[k]=l |
| 5362 |
return l |
| 5363 |
end |
| 5364 |
return rawget(t,file.suffix(l)) |
| 5365 |
end) |
| 5366 |
do |
| 5367 |
local function setindeed(mode,source,target,group,name,position) |
| 5368 |
local action=source[mode] |
| 5369 |
if not action then |
| 5370 |
return |
| 5371 |
end |
| 5372 |
local t=target[mode] |
| 5373 |
if not t then |
| 5374 |
report_defining("fatal error in setting feature %a, group %a, mode %a",name,group,mode) |
| 5375 |
os.exit() |
| 5376 |
elseif position then |
| 5377 |
insert(t,position,{ name=name,action=action }) |
| 5378 |
else |
| 5379 |
for i=1,#t do |
| 5380 |
local ti=t[i] |
| 5381 |
if ti.name==name then |
| 5382 |
ti.action=action |
| 5383 |
return |
| 5384 |
end |
| 5385 |
end |
| 5386 |
insert(t,{ name=name,action=action }) |
| 5387 |
end |
| 5388 |
end |
| 5389 |
local function set(group,name,target,source) |
| 5390 |
target=target[group] |
| 5391 |
if not target then |
| 5392 |
report_defining("fatal target error in setting feature %a, group %a",name,group) |
| 5393 |
os.exit() |
| 5394 |
end |
| 5395 |
local source=source[group] |
| 5396 |
if not source then |
| 5397 |
report_defining("fatal source error in setting feature %a, group %a",name,group) |
| 5398 |
os.exit() |
| 5399 |
end |
| 5400 |
local position=source.position |
| 5401 |
setindeed("node",source,target,group,name,position) |
| 5402 |
setindeed("base",source,target,group,name,position) |
| 5403 |
setindeed("plug",source,target,group,name,position) |
| 5404 |
end |
| 5405 |
local function register(where,specification) |
| 5406 |
local name=specification.name |
| 5407 |
if name and name~="" then |
| 5408 |
local default=specification.default |
| 5409 |
local description=specification.description |
| 5410 |
local initializers=specification.initializers |
| 5411 |
local processors=specification.processors |
| 5412 |
local manipulators=specification.manipulators |
| 5413 |
local modechecker=specification.modechecker |
| 5414 |
if default then |
| 5415 |
where.defaults[name]=default |
| 5416 |
end |
| 5417 |
if description and description~="" then |
| 5418 |
where.descriptions[name]=description |
| 5419 |
end |
| 5420 |
if initializers then |
| 5421 |
set('initializers',name,where,specification) |
| 5422 |
end |
| 5423 |
if processors then |
| 5424 |
set('processors',name,where,specification) |
| 5425 |
end |
| 5426 |
if manipulators then |
| 5427 |
set('manipulators',name,where,specification) |
| 5428 |
end |
| 5429 |
if modechecker then |
| 5430 |
where.modechecker=modechecker |
| 5431 |
end |
| 5432 |
end |
| 5433 |
end |
| 5434 |
constructors.registerfeature=register |
| 5435 |
function constructors.getfeatureaction(what,where,mode,name) |
| 5436 |
what=handlers[what].features |
| 5437 |
if what then |
| 5438 |
where=what[where] |
| 5439 |
if where then |
| 5440 |
mode=where[mode] |
| 5441 |
if mode then |
| 5442 |
for i=1,#mode do |
| 5443 |
local m=mode[i] |
| 5444 |
if m.name==name then |
| 5445 |
return m.action |
| 5446 |
end |
| 5447 |
end |
| 5448 |
end |
| 5449 |
end |
| 5450 |
end |
| 5451 |
end |
| 5452 |
local newfeatures={} |
| 5453 |
constructors.newfeatures=newfeatures |
| 5454 |
constructors.features=newfeatures |
| 5455 |
local function setnewfeatures(what) |
| 5456 |
local handler=handlers[what] |
| 5457 |
local features=handler.features |
| 5458 |
if not features then |
| 5459 |
local tables=handler.tables |
| 5460 |
local statistics=handler.statistics |
| 5461 |
features=allocate { |
| 5462 |
defaults={}, |
| 5463 |
descriptions=tables and tables.features or {}, |
| 5464 |
used=statistics and statistics.usedfeatures or {}, |
| 5465 |
initializers={ base={},node={},plug={} }, |
| 5466 |
processors={ base={},node={},plug={} }, |
| 5467 |
manipulators={ base={},node={},plug={} }, |
| 5468 |
} |
| 5469 |
features.register=function(specification) return register(features,specification) end |
| 5470 |
handler.features=features |
| 5471 |
end |
| 5472 |
return features |
| 5473 |
end |
| 5474 |
setmetatable(newfeatures,{ |
| 5475 |
__call=function(t,k) local v=t[k] return v end, |
| 5476 |
__index=function(t,k) local v=setnewfeatures(k) t[k]=v return v end, |
| 5477 |
}) |
| 5478 |
end |
| 5479 |
do |
| 5480 |
local newhandler={} |
| 5481 |
constructors.handlers=newhandler |
| 5482 |
constructors.newhandler=newhandler |
| 5483 |
local function setnewhandler(what) |
| 5484 |
local handler=handlers[what] |
| 5485 |
if not handler then |
| 5486 |
handler={} |
| 5487 |
handlers[what]=handler |
| 5488 |
end |
| 5489 |
return handler |
| 5490 |
end |
| 5491 |
setmetatable(newhandler,{ |
| 5492 |
__call=function(t,k) local v=t[k] return v end, |
| 5493 |
__index=function(t,k) local v=setnewhandler(k) t[k]=v return v end, |
| 5494 |
}) |
| 5495 |
end |
| 5496 |
do |
| 5497 |
local newenhancer={} |
| 5498 |
constructors.enhancers=newenhancer |
| 5499 |
constructors.newenhancer=newenhancer |
| 5500 |
local function setnewenhancer(format) |
| 5501 |
local handler=handlers[format] |
| 5502 |
local enhancers=handler.enhancers |
| 5503 |
if not enhancers then |
| 5504 |
local actions=allocate() |
| 5505 |
local before=allocate() |
| 5506 |
local after=allocate() |
| 5507 |
local order=allocate() |
| 5508 |
local known={} |
| 5509 |
local nofsteps=0 |
| 5510 |
local patches={ before=before,after=after } |
| 5511 |
local trace=false |
| 5512 |
local report=logs.reporter("fonts",format.." enhancing") |
| 5513 |
trackers.register(format..".loading",function(v) trace=v end) |
| 5514 |
local function enhance(name,data,filename,raw) |
| 5515 |
local enhancer=actions[name] |
| 5516 |
if enhancer then |
| 5517 |
if trace then |
| 5518 |
report("apply enhancement %a to file %a",name,filename) |
| 5519 |
ioflush() |
| 5520 |
end |
| 5521 |
enhancer(data,filename,raw) |
| 5522 |
else |
| 5523 |
end |
| 5524 |
end |
| 5525 |
local function apply(data,filename,raw) |
| 5526 |
local basename=file.basename(lower(filename)) |
| 5527 |
if trace then |
| 5528 |
report("%s enhancing file %a","start",filename) |
| 5529 |
end |
| 5530 |
ioflush() |
| 5531 |
for e=1,nofsteps do |
| 5532 |
local enhancer=order[e] |
| 5533 |
local b=before[enhancer] |
| 5534 |
if b then |
| 5535 |
for pattern,action in next,b do |
| 5536 |
if find(basename,pattern) then |
| 5537 |
action(data,filename,raw) |
| 5538 |
end |
| 5539 |
end |
| 5540 |
end |
| 5541 |
enhance(enhancer,data,filename,raw) |
| 5542 |
local a=after[enhancer] |
| 5543 |
if a then |
| 5544 |
for pattern,action in next,a do |
| 5545 |
if find(basename,pattern) then |
| 5546 |
action(data,filename,raw) |
| 5547 |
end |
| 5548 |
end |
| 5549 |
end |
| 5550 |
ioflush() |
| 5551 |
end |
| 5552 |
if trace then |
| 5553 |
report("%s enhancing file %a","stop",filename) |
| 5554 |
end |
| 5555 |
ioflush() |
| 5556 |
end |
| 5557 |
local function register(what,action) |
| 5558 |
if action then |
| 5559 |
if actions[what] then |
| 5560 |
else |
| 5561 |
nofsteps=nofsteps+1 |
| 5562 |
order[nofsteps]=what |
| 5563 |
known[what]=nofsteps |
| 5564 |
end |
| 5565 |
actions[what]=action |
| 5566 |
else |
| 5567 |
report("bad enhancer %a",what) |
| 5568 |
end |
| 5569 |
end |
| 5570 |
local function patch(what,where,pattern,action) |
| 5571 |
local pw=patches[what] |
| 5572 |
if pw then |
| 5573 |
local ww=pw[where] |
| 5574 |
if ww then |
| 5575 |
ww[pattern]=action |
| 5576 |
else |
| 5577 |
pw[where]={ [pattern]=action } |
| 5578 |
if not known[where] then |
| 5579 |
nofsteps=nofsteps+1 |
| 5580 |
order[nofsteps]=where |
| 5581 |
known[where]=nofsteps |
| 5582 |
end |
| 5583 |
end |
| 5584 |
end |
| 5585 |
end |
| 5586 |
enhancers={ |
| 5587 |
register=register, |
| 5588 |
apply=apply, |
| 5589 |
patch=patch, |
| 5590 |
report=report, |
| 5591 |
patches={ |
| 5592 |
register=patch, |
| 5593 |
report=report, |
| 5594 |
}, |
| 5595 |
} |
| 5596 |
handler.enhancers=enhancers |
| 5597 |
end |
| 5598 |
return enhancers |
| 5599 |
end |
| 5600 |
setmetatable(newenhancer,{ |
| 5601 |
__call=function(t,k) local v=t[k] return v end, |
| 5602 |
__index=function(t,k) local v=setnewenhancer(k) t[k]=v return v end, |
| 5603 |
}) |
| 5604 |
end |
| 5605 |
function constructors.checkedfeatures(what,features) |
| 5606 |
local defaults=handlers[what].features.defaults |
| 5607 |
if features and next(features) then |
| 5608 |
features=fastcopy(features) |
| 5609 |
for key,value in next,defaults do |
| 5610 |
if features[key]==nil then |
| 5611 |
features[key]=value |
| 5612 |
end |
| 5613 |
end |
| 5614 |
return features |
| 5615 |
else |
| 5616 |
return fastcopy(defaults) |
| 5617 |
end |
| 5618 |
end |
| 5619 |
function constructors.initializefeatures(what,tfmdata,features,trace,report) |
| 5620 |
if features and next(features) then |
| 5621 |
local properties=tfmdata.properties or {} |
| 5622 |
local whathandler=handlers[what] |
| 5623 |
local whatfeatures=whathandler.features |
| 5624 |
local whatmodechecker=whatfeatures.modechecker |
| 5625 |
local mode=properties.mode or (whatmodechecker and whatmodechecker(tfmdata,features,features.mode)) or features.mode or "base" |
| 5626 |
properties.mode=mode |
| 5627 |
features.mode=mode |
| 5628 |
local done={} |
| 5629 |
while true do |
| 5630 |
local redo=false |
| 5631 |
local initializers=whatfeatures.initializers[mode] |
| 5632 |
if initializers then |
| 5633 |
for i=1,#initializers do |
| 5634 |
local step=initializers[i] |
| 5635 |
local feature=step.name |
| 5636 |
local value=features[feature] |
| 5637 |
if not value then |
| 5638 |
elseif done[feature] then |
| 5639 |
else |
| 5640 |
local action=step.action |
| 5641 |
if trace then |
| 5642 |
report("initializing feature %a to %a for mode %a for font %a",feature, |
| 5643 |
value,mode,tfmdata.properties.fullname) |
| 5644 |
end |
| 5645 |
action(tfmdata,value,features) |
| 5646 |
if mode~=properties.mode or mode~=features.mode then |
| 5647 |
if whatmodechecker then |
| 5648 |
properties.mode=whatmodechecker(tfmdata,features,properties.mode) |
| 5649 |
features.mode=properties.mode |
| 5650 |
end |
| 5651 |
if mode~=properties.mode then |
| 5652 |
mode=properties.mode |
| 5653 |
redo=true |
| 5654 |
end |
| 5655 |
end |
| 5656 |
done[feature]=true |
| 5657 |
end |
| 5658 |
if redo then |
| 5659 |
break |
| 5660 |
end |
| 5661 |
end |
| 5662 |
if not redo then |
| 5663 |
break |
| 5664 |
end |
| 5665 |
else |
| 5666 |
break |
| 5667 |
end |
| 5668 |
end |
| 5669 |
properties.mode=mode |
| 5670 |
return true |
| 5671 |
else |
| 5672 |
return false |
| 5673 |
end |
| 5674 |
end |
| 5675 |
function constructors.collectprocessors(what,tfmdata,features,trace,report) |
| 5676 |
local processes={} |
| 5677 |
local nofprocesses=0 |
| 5678 |
if features and next(features) then |
| 5679 |
local properties=tfmdata.properties |
| 5680 |
local whathandler=handlers[what] |
| 5681 |
local whatfeatures=whathandler.features |
| 5682 |
local whatprocessors=whatfeatures.processors |
| 5683 |
local mode=properties.mode |
| 5684 |
local processors=whatprocessors[mode] |
| 5685 |
if processors then |
| 5686 |
for i=1,#processors do |
| 5687 |
local step=processors[i] |
| 5688 |
local feature=step.name |
| 5689 |
if features[feature] then |
| 5690 |
local action=step.action |
| 5691 |
if trace then |
| 5692 |
report("installing feature processor %a for mode %a for font %a",feature,mode,tfmdata.properties.fullname) |
| 5693 |
end |
| 5694 |
if action then |
| 5695 |
nofprocesses=nofprocesses+1 |
| 5696 |
processes[nofprocesses]=action |
| 5697 |
end |
| 5698 |
end |
| 5699 |
end |
| 5700 |
elseif trace then |
| 5701 |
report("no feature processors for mode %a for font %a",mode,properties.fullname) |
| 5702 |
end |
| 5703 |
end |
| 5704 |
return processes |
| 5705 |
end |
| 5706 |
function constructors.applymanipulators(what,tfmdata,features,trace,report) |
| 5707 |
if features and next(features) then |
| 5708 |
local properties=tfmdata.properties |
| 5709 |
local whathandler=handlers[what] |
| 5710 |
local whatfeatures=whathandler.features |
| 5711 |
local whatmanipulators=whatfeatures.manipulators |
| 5712 |
local mode=properties.mode |
| 5713 |
local manipulators=whatmanipulators[mode] |
| 5714 |
if manipulators then |
| 5715 |
for i=1,#manipulators do |
| 5716 |
local step=manipulators[i] |
| 5717 |
local feature=step.name |
| 5718 |
local value=features[feature] |
| 5719 |
if value then |
| 5720 |
local action=step.action |
| 5721 |
if trace then |
| 5722 |
report("applying feature manipulator %a for mode %a for font %a",feature,mode,properties.fullname) |
| 5723 |
end |
| 5724 |
if action then |
| 5725 |
action(tfmdata,feature,value) |
| 5726 |
end |
| 5727 |
end |
| 5728 |
end |
| 5729 |
end |
| 5730 |
end |
| 5731 |
end |
| 5732 |
function constructors.addcoreunicodes(unicodes) |
| 5733 |
if not unicodes then |
| 5734 |
unicodes={} |
| 5735 |
end |
| 5736 |
unicodes.space=0x0020 |
| 5737 |
unicodes.hyphen=0x002D |
| 5738 |
unicodes.zwj=0x200D |
| 5739 |
unicodes.zwnj=0x200C |
| 5740 |
return unicodes |
| 5741 |
end |
| 5742 |
|
| 5743 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-con”] --- |
| 5744 |
|
| 5745 |
|
| 5746 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-enc” c24fd6b4f34f87b9c4ff5e6193ce2656] --- |
| 5747 |
|
| 5748 |
if not modules then modules={} end modules ['luatex-font-enc']={ |
| 5749 |
version=1.001, |
| 5750 |
comment="companion to luatex-*.tex", |
| 5751 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 5752 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 5753 |
license="see context related readme files" |
| 5754 |
} |
| 5755 |
if context then |
| 5756 |
os.exit() |
| 5757 |
end |
| 5758 |
local fonts=fonts |
| 5759 |
local encodings={} |
| 5760 |
fonts.encodings=encodings |
| 5761 |
encodings.agl={} |
| 5762 |
encodings.known={} |
| 5763 |
encodings.glyphlistfilename="font-age.lua" |
| 5764 |
setmetatable(encodings.agl,{ __index=function(t,k) |
| 5765 |
if k=="unicodes" then |
| 5766 |
logs.report("fonts","loading (extended) adobe glyph list") |
| 5767 |
local foundname=resolvers.findfile(encodings.glyphlistfilename) or "" |
| 5768 |
local unicodes=foundname~="" and dofile(foundname) |
| 5769 |
if type(unicodes)~="table" then |
| 5770 |
logs.report("fonts","missing or invalid (extended) adobe glyph list") |
| 5771 |
unicodes={} |
| 5772 |
end |
| 5773 |
encodings.agl={ unicodes=unicodes } |
| 5774 |
return unicodes |
| 5775 |
else |
| 5776 |
return nil |
| 5777 |
end |
| 5778 |
end }) |
| 5779 |
encodings.cache=containers.define("fonts","enc",encodings.version,true) |
| 5780 |
function encodings.load(filename) |
| 5781 |
local name=file.removesuffix(filename) |
| 5782 |
local data=containers.read(encodings.cache,name) |
| 5783 |
if data then |
| 5784 |
return data |
| 5785 |
end |
| 5786 |
local vector,tag,hash,unicodes={},"",{},{} |
| 5787 |
local foundname=resolvers.findfile(filename,'enc') |
| 5788 |
if foundname and foundname~="" then |
| 5789 |
local ok,encoding,size=resolvers.loadbinfile(foundname) |
| 5790 |
if ok and encoding then |
| 5791 |
encoding=string.gsub(encoding,"%%(.-)\n","") |
| 5792 |
local unicoding=encodings.agl.unicodes |
| 5793 |
local tag,vec=string.match(encoding,"/(%w+)%s*%[(.*)%]%s*def") |
| 5794 |
local i=0 |
| 5795 |
for ch in string.gmatch(vec,"/([%a%d%.]+)") do |
| 5796 |
if ch~=".notdef" then |
| 5797 |
vector[i]=ch |
| 5798 |
if not hash[ch] then |
| 5799 |
hash[ch]=i |
| 5800 |
else |
| 5801 |
end |
| 5802 |
local u=unicoding[ch] |
| 5803 |
if u then |
| 5804 |
unicodes[u]=i |
| 5805 |
end |
| 5806 |
end |
| 5807 |
i=i+1 |
| 5808 |
end |
| 5809 |
end |
| 5810 |
end |
| 5811 |
local data={ |
| 5812 |
name=name, |
| 5813 |
tag=tag, |
| 5814 |
vector=vector, |
| 5815 |
hash=hash, |
| 5816 |
unicodes=unicodes |
| 5817 |
} |
| 5818 |
return containers.write(encodings.cache,name,data) |
| 5819 |
end |
| 5820 |
|
| 5821 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-enc”] --- |
| 5822 |
|
| 5823 |
|
| 5824 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-cid” 22b0367742fb253deef84ef7ccf5e8de] --- |
| 5825 |
|
| 5826 |
if not modules then modules={} end modules ['font-cid']={ |
| 5827 |
version=1.001, |
| 5828 |
comment="companion to font-ini.mkiv", |
| 5829 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 5830 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 5831 |
license="see context related readme files" |
| 5832 |
} |
| 5833 |
local format,match,lower=string.format,string.match,string.lower |
| 5834 |
local tonumber=tonumber |
| 5835 |
local P,S,R,C,V,lpegmatch=lpeg.P,lpeg.S,lpeg.R,lpeg.C,lpeg.V,lpeg.match |
| 5836 |
local fonts,logs,trackers=fonts,logs,trackers |
| 5837 |
local trace_loading=false trackers.register("otf.loading",function(v) trace_loading=v end) |
| 5838 |
local report_otf=logs.reporter("fonts","otf loading") |
| 5839 |
local cid={} |
| 5840 |
fonts.cid=cid |
| 5841 |
local cidmap={} |
| 5842 |
local cidmax=10 |
| 5843 |
local number=C(R("09","af","AF")^1) |
| 5844 |
local space=S(" \n\r\t") |
| 5845 |
local spaces=space^0 |
| 5846 |
local period=P(".") |
| 5847 |
local periods=period*period |
| 5848 |
local name=P("/")*C((1-space)^1) |
| 5849 |
local unicodes,names={},{} |
| 5850 |
local function do_one(a,b) |
| 5851 |
unicodes[tonumber(a)]=tonumber(b,16) |
| 5852 |
end |
| 5853 |
local function do_range(a,b,c) |
| 5854 |
c=tonumber(c,16) |
| 5855 |
for i=tonumber(a),tonumber(b) do |
| 5856 |
unicodes[i]=c |
| 5857 |
c=c+1 |
| 5858 |
end |
| 5859 |
end |
| 5860 |
local function do_name(a,b) |
| 5861 |
names[tonumber(a)]=b |
| 5862 |
end |
| 5863 |
local grammar=P { "start", |
| 5864 |
start=number*spaces*number*V("series"), |
| 5865 |
series=(spaces*(V("one")+V("range")+V("named")))^1, |
| 5866 |
one=(number*spaces*number)/do_one, |
| 5867 |
range=(number*periods*number*spaces*number)/do_range, |
| 5868 |
named=(number*spaces*name)/do_name |
| 5869 |
} |
| 5870 |
local function loadcidfile(filename) |
| 5871 |
local data=io.loaddata(filename) |
| 5872 |
if data then |
| 5873 |
unicodes,names={},{} |
| 5874 |
lpegmatch(grammar,data) |
| 5875 |
local supplement,registry,ordering=match(filename,"^(.-)%-(.-)%-()%.(.-)$") |
| 5876 |
return { |
| 5877 |
supplement=supplement, |
| 5878 |
registry=registry, |
| 5879 |
ordering=ordering, |
| 5880 |
filename=filename, |
| 5881 |
unicodes=unicodes, |
| 5882 |
names=names, |
| 5883 |
} |
| 5884 |
end |
| 5885 |
end |
| 5886 |
cid.loadfile=loadcidfile |
| 5887 |
local template="%s-%s-%s.cidmap" |
| 5888 |
local function locate(registry,ordering,supplement) |
| 5889 |
local filename=format(template,registry,ordering,supplement) |
| 5890 |
local hashname=lower(filename) |
| 5891 |
local found=cidmap[hashname] |
| 5892 |
if not found then |
| 5893 |
if trace_loading then |
| 5894 |
report_otf("checking cidmap, registry %a, ordering %a, supplement %a, filename %a",registry,ordering,supplement,filename) |
| 5895 |
end |
| 5896 |
local fullname=resolvers.findfile(filename,'cid') or "" |
| 5897 |
if fullname~="" then |
| 5898 |
found=loadcidfile(fullname) |
| 5899 |
if found then |
| 5900 |
if trace_loading then |
| 5901 |
report_otf("using cidmap file %a",filename) |
| 5902 |
end |
| 5903 |
cidmap[hashname]=found |
| 5904 |
found.usedname=file.basename(filename) |
| 5905 |
end |
| 5906 |
end |
| 5907 |
end |
| 5908 |
return found |
| 5909 |
end |
| 5910 |
function cid.getmap(specification) |
| 5911 |
if not specification then |
| 5912 |
report_otf("invalid cidinfo specification, table expected") |
| 5913 |
return |
| 5914 |
end |
| 5915 |
local registry=specification.registry |
| 5916 |
local ordering=specification.ordering |
| 5917 |
local supplement=specification.supplement |
| 5918 |
local filename=format(registry,ordering,supplement) |
| 5919 |
local lowername=lower(filename) |
| 5920 |
local found=cidmap[lowername] |
| 5921 |
if found then |
| 5922 |
return found |
| 5923 |
end |
| 5924 |
if ordering=="Identity" then |
| 5925 |
local found={ |
| 5926 |
supplement=supplement, |
| 5927 |
registry=registry, |
| 5928 |
ordering=ordering, |
| 5929 |
filename=filename, |
| 5930 |
unicodes={}, |
| 5931 |
names={}, |
| 5932 |
} |
| 5933 |
cidmap[lowername]=found |
| 5934 |
return found |
| 5935 |
end |
| 5936 |
if trace_loading then |
| 5937 |
report_otf("cidmap needed, registry %a, ordering %a, supplement %a",registry,ordering,supplement) |
| 5938 |
end |
| 5939 |
found=locate(registry,ordering,supplement) |
| 5940 |
if not found then |
| 5941 |
local supnum=tonumber(supplement) |
| 5942 |
local cidnum=nil |
| 5943 |
if supnum<cidmax then |
| 5944 |
for s=supnum+1,cidmax do |
| 5945 |
local c=locate(registry,ordering,s) |
| 5946 |
if c then |
| 5947 |
found,cidnum=c,s |
| 5948 |
break |
| 5949 |
end |
| 5950 |
end |
| 5951 |
end |
| 5952 |
if not found and supnum>0 then |
| 5953 |
for s=supnum-1,0,-1 do |
| 5954 |
local c=locate(registry,ordering,s) |
| 5955 |
if c then |
| 5956 |
found,cidnum=c,s |
| 5957 |
break |
| 5958 |
end |
| 5959 |
end |
| 5960 |
end |
| 5961 |
registry=lower(registry) |
| 5962 |
ordering=lower(ordering) |
| 5963 |
if found and cidnum>0 then |
| 5964 |
for s=0,cidnum-1 do |
| 5965 |
local filename=format(template,registry,ordering,s) |
| 5966 |
if not cidmap[filename] then |
| 5967 |
cidmap[filename]=found |
| 5968 |
end |
| 5969 |
end |
| 5970 |
end |
| 5971 |
end |
| 5972 |
return found |
| 5973 |
end |
| 5974 |
|
| 5975 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-cid”] --- |
| 5976 |
|
| 5977 |
|
| 5978 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-map” b1444428c238a17d2a998ff1a4769183] --- |
| 5979 |
|
| 5980 |
if not modules then modules={} end modules ['font-map']={ |
| 5981 |
version=1.001, |
| 5982 |
optimize=true, |
| 5983 |
comment="companion to font-ini.mkiv", |
| 5984 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 5985 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 5986 |
license="see context related readme files" |
| 5987 |
} |
| 5988 |
local tonumber,next,type=tonumber,next,type |
| 5989 |
local match,format,find,concat,gsub,lower=string.match,string.format,string.find,table.concat,string.gsub,string.lower |
| 5990 |
local P,R,S,C,Ct,Cc,lpegmatch=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Ct,lpeg.Cc,lpeg.match |
| 5991 |
local formatters=string.formatters |
| 5992 |
local sortedhash,sortedkeys=table.sortedhash,table.sortedkeys |
| 5993 |
local idiv=number.idiv |
| 5994 |
local trace_loading=false trackers.register("fonts.loading",function(v) trace_loading=v end) |
| 5995 |
local trace_mapping=false trackers.register("fonts.mapping",function(v) trace_mapping=v end) |
| 5996 |
local report_fonts=logs.reporter("fonts","loading") |
| 5997 |
local force_ligatures=false directives.register("fonts.mapping.forceligatures",function(v) force_ligatures=v end) |
| 5998 |
local fonts=fonts or {} |
| 5999 |
local mappings=fonts.mappings or {} |
| 6000 |
fonts.mappings=mappings |
| 6001 |
local allocate=utilities.storage.allocate |
| 6002 |
local hex=R("AF","af","09") |
| 6003 |
local hexfour=(hex*hex*hex^-2)/function(s) return tonumber(s,16) end |
| 6004 |
local hexsix=(hex*hex*hex^-4)/function(s) return tonumber(s,16) end |
| 6005 |
local dec=(R("09")^1)/tonumber |
| 6006 |
local period=P(".") |
| 6007 |
local unicode=(P("uni")+P("UNI"))*(hexfour*(period+P(-1))*Cc(false)+Ct(hexfour^1)*Cc(true)) |
| 6008 |
local ucode=(P("u")+P("U") )*(hexsix*(period+P(-1))*Cc(false)+Ct(hexsix^1)*Cc(true)) |
| 6009 |
local index=P("index")*dec*Cc(false) |
| 6010 |
local parser=unicode+ucode+index |
| 6011 |
local parsers={} |
| 6012 |
local function makenameparser(str) |
| 6013 |
if not str or str=="" then |
| 6014 |
return parser |
| 6015 |
else |
| 6016 |
local p=parsers[str] |
| 6017 |
if not p then |
| 6018 |
p=P(str)*period*dec*Cc(false) |
| 6019 |
parsers[str]=p |
| 6020 |
end |
| 6021 |
return p |
| 6022 |
end |
| 6023 |
end |
| 6024 |
local f_single=formatters["%04X"] |
| 6025 |
local f_double=formatters["%04X%04X"] |
| 6026 |
local s_unknown="FFFD" |
| 6027 |
local function tounicode16(unicode) |
| 6028 |
if unicode<0xD7FF or (unicode>0xDFFF and unicode<=0xFFFF) then |
| 6029 |
return f_single(unicode) |
| 6030 |
elseif unicode>=0x00E000 and unicode<=0x00F8FF then |
| 6031 |
return s_unknown |
| 6032 |
elseif unicode>=0x0F0000 and unicode<=0x0FFFFF then |
| 6033 |
return s_unknown |
| 6034 |
elseif unicode>=0x100000 and unicode<=0x10FFFF then |
| 6035 |
return s_unknown |
| 6036 |
elseif unicode>=0x00D800 and unicode<=0x00DFFF then |
| 6037 |
return s_unknown |
| 6038 |
else |
| 6039 |
unicode=unicode-0x10000 |
| 6040 |
return f_double(idiv(unicode,0x400)+0xD800,unicode%0x400+0xDC00) |
| 6041 |
end |
| 6042 |
end |
| 6043 |
local function tounicode16sequence(unicodes) |
| 6044 |
local t={} |
| 6045 |
for l=1,#unicodes do |
| 6046 |
local u=unicodes[l] |
| 6047 |
if u<0xD7FF or (u>0xDFFF and u<=0xFFFF) then |
| 6048 |
t[l]=f_single(u) |
| 6049 |
elseif unicode>=0x00E000 and unicode<=0x00F8FF then |
| 6050 |
t[l]=s_unknown |
| 6051 |
elseif unicode>=0x0F0000 and unicode<=0x0FFFFF then |
| 6052 |
t[l]=s_unknown |
| 6053 |
elseif unicode>=0x100000 and unicode<=0x10FFFF then |
| 6054 |
t[l]=s_unknown |
| 6055 |
elseif unicode>=0x00D7FF and unicode<=0x00DFFF then |
| 6056 |
t[l]=s_unknown |
| 6057 |
else |
| 6058 |
u=u-0x10000 |
| 6059 |
t[l]=f_double(idiv(u,0x400)+0xD800,u%0x400+0xDC00) |
| 6060 |
end |
| 6061 |
end |
| 6062 |
return concat(t) |
| 6063 |
end |
| 6064 |
local hash={} |
| 6065 |
local conc={} |
| 6066 |
table.setmetatableindex(hash,function(t,k) |
| 6067 |
local v |
| 6068 |
if k<0xD7FF or (k>0xDFFF and k<=0xFFFF) then |
| 6069 |
v=f_single(k) |
| 6070 |
else |
| 6071 |
local k=k-0x10000 |
| 6072 |
v=f_double(idiv(k,0x400)+0xD800,k%0x400+0xDC00) |
| 6073 |
end |
| 6074 |
t[k]=v |
| 6075 |
return v |
| 6076 |
end) |
| 6077 |
local function tounicode(k) |
| 6078 |
if type(k)=="table" then |
| 6079 |
local n=#k |
| 6080 |
for l=1,n do |
| 6081 |
conc[l]=hash[k[l]] |
| 6082 |
end |
| 6083 |
return concat(conc,"",1,n) |
| 6084 |
elseif k>=0x00E000 and k<=0x00F8FF then |
| 6085 |
return s_unknown |
| 6086 |
elseif k>=0x0F0000 and k<=0x0FFFFF then |
| 6087 |
return s_unknown |
| 6088 |
elseif k>=0x100000 and k<=0x10FFFF then |
| 6089 |
return s_unknown |
| 6090 |
elseif k>=0x00D7FF and k<=0x00DFFF then |
| 6091 |
return s_unknown |
| 6092 |
else |
| 6093 |
return hash[k] |
| 6094 |
end |
| 6095 |
end |
| 6096 |
local function fromunicode16(str) |
| 6097 |
if #str==4 then |
| 6098 |
return tonumber(str,16) |
| 6099 |
else |
| 6100 |
local l,r=match(str,"(....)(....)") |
| 6101 |
return 0x10000+(tonumber(l,16)-0xD800)*0x400+tonumber(r,16)-0xDC00 |
| 6102 |
end |
| 6103 |
end |
| 6104 |
mappings.makenameparser=makenameparser |
| 6105 |
mappings.tounicode=tounicode |
| 6106 |
mappings.tounicode16=tounicode16 |
| 6107 |
mappings.tounicode16sequence=tounicode16sequence |
| 6108 |
mappings.fromunicode16=fromunicode16 |
| 6109 |
local ligseparator=P("_") |
| 6110 |
local varseparator=P(".") |
| 6111 |
local namesplitter=Ct(C((1-ligseparator-varseparator)^1)*(ligseparator*C((1-ligseparator-varseparator)^1))^0) |
| 6112 |
do |
| 6113 |
local overloads={ |
| 6114 |
IJ={ name="I_J",unicode={ 0x49,0x4A },mess=0x0132 }, |
| 6115 |
ij={ name="i_j",unicode={ 0x69,0x6A },mess=0x0133 }, |
| 6116 |
ff={ name="f_f",unicode={ 0x66,0x66 },mess=0xFB00 }, |
| 6117 |
fi={ name="f_i",unicode={ 0x66,0x69 },mess=0xFB01 }, |
| 6118 |
fl={ name="f_l",unicode={ 0x66,0x6C },mess=0xFB02 }, |
| 6119 |
ffi={ name="f_f_i",unicode={ 0x66,0x66,0x69 },mess=0xFB03 }, |
| 6120 |
ffl={ name="f_f_l",unicode={ 0x66,0x66,0x6C },mess=0xFB04 }, |
| 6121 |
fj={ name="f_j",unicode={ 0x66,0x6A } }, |
| 6122 |
fk={ name="f_k",unicode={ 0x66,0x6B } }, |
| 6123 |
} |
| 6124 |
local o=allocate {} |
| 6125 |
for k,v in next,overloads do |
| 6126 |
local name=v.name |
| 6127 |
local mess=v.mess |
| 6128 |
if name then |
| 6129 |
o[name]=v |
| 6130 |
end |
| 6131 |
if mess then |
| 6132 |
o[mess]=v |
| 6133 |
end |
| 6134 |
o[k]=v |
| 6135 |
end |
| 6136 |
mappings.overloads=o |
| 6137 |
end |
| 6138 |
function mappings.addtounicode(data,filename,checklookups,forceligatures) |
| 6139 |
local resources=data.resources |
| 6140 |
local unicodes=resources.unicodes |
| 6141 |
if not unicodes then |
| 6142 |
if trace_mapping then |
| 6143 |
report_fonts("no unicode list, quitting tounicode for %a",filename) |
| 6144 |
end |
| 6145 |
return |
| 6146 |
end |
| 6147 |
local properties=data.properties |
| 6148 |
local descriptions=data.descriptions |
| 6149 |
local overloads=mappings.overloads |
| 6150 |
unicodes['space']=unicodes['space'] or 32 |
| 6151 |
unicodes['hyphen']=unicodes['hyphen'] or 45 |
| 6152 |
unicodes['zwj']=unicodes['zwj'] or 0x200D |
| 6153 |
unicodes['zwnj']=unicodes['zwnj'] or 0x200C |
| 6154 |
local private=fonts.constructors and fonts.constructors.privateoffset or 0xF0000 |
| 6155 |
local unicodevector=fonts.encodings.agl.unicodes or {} |
| 6156 |
local contextvector=fonts.encodings.agl.ctxcodes or {} |
| 6157 |
local missing={} |
| 6158 |
local nofmissing=0 |
| 6159 |
local oparser=nil |
| 6160 |
local cidnames=nil |
| 6161 |
local cidcodes=nil |
| 6162 |
local cidinfo=properties.cidinfo |
| 6163 |
local usedmap=cidinfo and fonts.cid.getmap(cidinfo) |
| 6164 |
local uparser=makenameparser() |
| 6165 |
if usedmap then |
| 6166 |
oparser=usedmap and makenameparser(cidinfo.ordering) |
| 6167 |
cidnames=usedmap.names |
| 6168 |
cidcodes=usedmap.unicodes |
| 6169 |
end |
| 6170 |
local ns=0 |
| 6171 |
local nl=0 |
| 6172 |
local dlist=sortedkeys(descriptions) |
| 6173 |
for i=1,#dlist do |
| 6174 |
local du=dlist[i] |
| 6175 |
local glyph=descriptions[du] |
| 6176 |
local name=glyph.name |
| 6177 |
if name then |
| 6178 |
local overload=overloads[name] or overloads[du] |
| 6179 |
if overload then |
| 6180 |
glyph.unicode=overload.unicode |
| 6181 |
else |
| 6182 |
local gu=glyph.unicode |
| 6183 |
if not gu or gu==-1 or du>=private or (du>=0xE000 and du<=0xF8FF) or du==0xFFFE or du==0xFFFF then |
| 6184 |
local unicode=unicodevector[name] or contextvector[name] |
| 6185 |
if unicode then |
| 6186 |
glyph.unicode=unicode |
| 6187 |
ns=ns+1 |
| 6188 |
end |
| 6189 |
if (not unicode) and usedmap then |
| 6190 |
local foundindex=lpegmatch(oparser,name) |
| 6191 |
if foundindex then |
| 6192 |
unicode=cidcodes[foundindex] |
| 6193 |
if unicode then |
| 6194 |
glyph.unicode=unicode |
| 6195 |
ns=ns+1 |
| 6196 |
else |
| 6197 |
local reference=cidnames[foundindex] |
| 6198 |
if reference then |
| 6199 |
local foundindex=lpegmatch(oparser,reference) |
| 6200 |
if foundindex then |
| 6201 |
unicode=cidcodes[foundindex] |
| 6202 |
if unicode then |
| 6203 |
glyph.unicode=unicode |
| 6204 |
ns=ns+1 |
| 6205 |
end |
| 6206 |
end |
| 6207 |
if not unicode or unicode=="" then |
| 6208 |
local foundcodes,multiple=lpegmatch(uparser,reference) |
| 6209 |
if foundcodes then |
| 6210 |
glyph.unicode=foundcodes |
| 6211 |
if multiple then |
| 6212 |
nl=nl+1 |
| 6213 |
unicode=true |
| 6214 |
else |
| 6215 |
ns=ns+1 |
| 6216 |
unicode=foundcodes |
| 6217 |
end |
| 6218 |
end |
| 6219 |
end |
| 6220 |
end |
| 6221 |
end |
| 6222 |
end |
| 6223 |
end |
| 6224 |
if not unicode or unicode=="" then |
| 6225 |
local split=lpegmatch(namesplitter,name) |
| 6226 |
local nsplit=split and #split or 0 |
| 6227 |
if nsplit==0 then |
| 6228 |
elseif nsplit==1 then |
| 6229 |
local base=split[1] |
| 6230 |
local u=unicodes[base] or unicodevector[base] or contextvector[name] |
| 6231 |
if not u then |
| 6232 |
elseif type(u)=="table" then |
| 6233 |
if u[1]<private then |
| 6234 |
unicode=u |
| 6235 |
glyph.unicode=unicode |
| 6236 |
end |
| 6237 |
elseif u<private then |
| 6238 |
unicode=u |
| 6239 |
glyph.unicode=unicode |
| 6240 |
end |
| 6241 |
else |
| 6242 |
local t={} |
| 6243 |
local n=0 |
| 6244 |
for l=1,nsplit do |
| 6245 |
local base=split[l] |
| 6246 |
local u=unicodes[base] or unicodevector[base] or contextvector[name] |
| 6247 |
if not u then |
| 6248 |
break |
| 6249 |
elseif type(u)=="table" then |
| 6250 |
if u[1]>=private then |
| 6251 |
break |
| 6252 |
end |
| 6253 |
n=n+1 |
| 6254 |
t[n]=u[1] |
| 6255 |
else |
| 6256 |
if u>=private then |
| 6257 |
break |
| 6258 |
end |
| 6259 |
n=n+1 |
| 6260 |
t[n]=u |
| 6261 |
end |
| 6262 |
end |
| 6263 |
if n>0 then |
| 6264 |
if n==1 then |
| 6265 |
unicode=t[1] |
| 6266 |
else |
| 6267 |
unicode=t |
| 6268 |
end |
| 6269 |
glyph.unicode=unicode |
| 6270 |
end |
| 6271 |
end |
| 6272 |
nl=nl+1 |
| 6273 |
end |
| 6274 |
if not unicode or unicode=="" then |
| 6275 |
local foundcodes,multiple=lpegmatch(uparser,name) |
| 6276 |
if foundcodes then |
| 6277 |
glyph.unicode=foundcodes |
| 6278 |
if multiple then |
| 6279 |
nl=nl+1 |
| 6280 |
unicode=true |
| 6281 |
else |
| 6282 |
ns=ns+1 |
| 6283 |
unicode=foundcodes |
| 6284 |
end |
| 6285 |
end |
| 6286 |
end |
| 6287 |
local r=overloads[unicode] |
| 6288 |
if r then |
| 6289 |
unicode=r.unicode |
| 6290 |
glyph.unicode=unicode |
| 6291 |
end |
| 6292 |
if not unicode then |
| 6293 |
missing[du]=true |
| 6294 |
nofmissing=nofmissing+1 |
| 6295 |
end |
| 6296 |
else |
| 6297 |
end |
| 6298 |
end |
| 6299 |
else |
| 6300 |
local overload=overloads[du] |
| 6301 |
if overload then |
| 6302 |
glyph.unicode=overload.unicode |
| 6303 |
elseif not glyph.unicode then |
| 6304 |
missing[du]=true |
| 6305 |
nofmissing=nofmissing+1 |
| 6306 |
end |
| 6307 |
end |
| 6308 |
end |
| 6309 |
if type(checklookups)=="function" then |
| 6310 |
checklookups(data,missing,nofmissing) |
| 6311 |
end |
| 6312 |
local unicoded=0 |
| 6313 |
local collected=fonts.handlers.otf.readers.getcomponents(data) |
| 6314 |
local function resolve(glyph,u) |
| 6315 |
local n=#u |
| 6316 |
for i=1,n do |
| 6317 |
if u[i]>private then |
| 6318 |
n=0 |
| 6319 |
break |
| 6320 |
end |
| 6321 |
end |
| 6322 |
if n>0 then |
| 6323 |
if n>1 then |
| 6324 |
glyph.unicode=u |
| 6325 |
else |
| 6326 |
glyph.unicode=u[1] |
| 6327 |
end |
| 6328 |
unicoded=unicoded+1 |
| 6329 |
end |
| 6330 |
end |
| 6331 |
if not collected then |
| 6332 |
elseif forceligatures or force_ligatures then |
| 6333 |
for i=1,#dlist do |
| 6334 |
local du=dlist[i] |
| 6335 |
if du>=private or (du>=0xE000 and du<=0xF8FF) then |
| 6336 |
local u=collected[du] |
| 6337 |
if u then |
| 6338 |
resolve(descriptions[du],u) |
| 6339 |
end |
| 6340 |
end |
| 6341 |
end |
| 6342 |
else |
| 6343 |
for i=1,#dlist do |
| 6344 |
local du=dlist[i] |
| 6345 |
if du>=private or (du>=0xE000 and du<=0xF8FF) then |
| 6346 |
local glyph=descriptions[du] |
| 6347 |
if glyph.class=="ligature" and not glyph.unicode then |
| 6348 |
local u=collected[du] |
| 6349 |
if u then |
| 6350 |
resolve(glyph,u) |
| 6351 |
end |
| 6352 |
end |
| 6353 |
end |
| 6354 |
end |
| 6355 |
end |
| 6356 |
if trace_mapping and unicoded>0 then |
| 6357 |
report_fonts("%n ligature tounicode mappings deduced from gsub ligature features",unicoded) |
| 6358 |
end |
| 6359 |
if trace_mapping then |
| 6360 |
for i=1,#dlist do |
| 6361 |
local du=dlist[i] |
| 6362 |
local glyph=descriptions[du] |
| 6363 |
local name=glyph.name or "-" |
| 6364 |
local index=glyph.index or 0 |
| 6365 |
local unicode=glyph.unicode |
| 6366 |
if unicode then |
| 6367 |
if type(unicode)=="table" then |
| 6368 |
local unicodes={} |
| 6369 |
for i=1,#unicode do |
| 6370 |
unicodes[i]=formatters("%U",unicode[i]) |
| 6371 |
end |
| 6372 |
report_fonts("internal slot %U, name %a, unicode %U, tounicode % t",index,name,du,unicodes) |
| 6373 |
else |
| 6374 |
report_fonts("internal slot %U, name %a, unicode %U, tounicode %U",index,name,du,unicode) |
| 6375 |
end |
| 6376 |
else |
| 6377 |
report_fonts("internal slot %U, name %a, unicode %U",index,name,du) |
| 6378 |
end |
| 6379 |
end |
| 6380 |
end |
| 6381 |
if trace_loading and (ns>0 or nl>0) then |
| 6382 |
report_fonts("%s tounicode entries added, ligatures %s",nl+ns,ns) |
| 6383 |
end |
| 6384 |
end |
| 6385 |
|
| 6386 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-map”] --- |
| 6387 |
|
| 6388 |
|
| 6389 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-vfc” a81c29eda98cd62cbebdb6c93544b50d] --- |
| 6390 |
|
| 6391 |
if not modules then modules={} end modules ['font-vfc']={ |
| 6392 |
version=1.001, |
| 6393 |
comment="companion to font-ini.mkiv and hand-ini.mkiv", |
| 6394 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 6395 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 6396 |
license="see context related readme files" |
| 6397 |
} |
| 6398 |
local select,type=select,type |
| 6399 |
local insert=table.insert |
| 6400 |
local fonts=fonts |
| 6401 |
local helpers=fonts.helpers |
| 6402 |
local setmetatableindex=table.setmetatableindex |
| 6403 |
local push={ "push" } |
| 6404 |
local pop={ "pop" } |
| 6405 |
local dummy={ "comment" } |
| 6406 |
function helpers.prependcommands(commands,...) |
| 6407 |
insert(commands,1,push) |
| 6408 |
for i=select("#",...),1,-1 do |
| 6409 |
local s=(select(i,...)) |
| 6410 |
if s then |
| 6411 |
insert(commands,1,s) |
| 6412 |
end |
| 6413 |
end |
| 6414 |
insert(commands,pop) |
| 6415 |
return commands |
| 6416 |
end |
| 6417 |
function helpers.appendcommands(commands,...) |
| 6418 |
insert(commands,1,push) |
| 6419 |
insert(commands,pop) |
| 6420 |
for i=1,select("#",...) do |
| 6421 |
local s=(select(i,...)) |
| 6422 |
if s then |
| 6423 |
insert(commands,s) |
| 6424 |
end |
| 6425 |
end |
| 6426 |
return commands |
| 6427 |
end |
| 6428 |
function helpers.prependcommandtable(commands,t) |
| 6429 |
insert(commands,1,push) |
| 6430 |
for i=#t,1,-1 do |
| 6431 |
local s=t[i] |
| 6432 |
if s then |
| 6433 |
insert(commands,1,s) |
| 6434 |
end |
| 6435 |
end |
| 6436 |
insert(commands,pop) |
| 6437 |
return commands |
| 6438 |
end |
| 6439 |
function helpers.appendcommandtable(commands,t) |
| 6440 |
insert(commands,1,push) |
| 6441 |
insert(commands,pop) |
| 6442 |
for i=1,#t do |
| 6443 |
local s=t[i] |
| 6444 |
if s then |
| 6445 |
insert(commands,s) |
| 6446 |
end |
| 6447 |
end |
| 6448 |
return commands |
| 6449 |
end |
| 6450 |
local char=setmetatableindex(function(t,k) |
| 6451 |
local v={ "slot",0,k } |
| 6452 |
t[k]=v |
| 6453 |
return v |
| 6454 |
end) |
| 6455 |
local right=setmetatableindex(function(t,k) |
| 6456 |
local v={ "right",k } |
| 6457 |
t[k]=v |
| 6458 |
return v |
| 6459 |
end) |
| 6460 |
local left=setmetatableindex(function(t,k) |
| 6461 |
local v={ "right",-k } |
| 6462 |
t[k]=v |
| 6463 |
return v |
| 6464 |
end) |
| 6465 |
local down=setmetatableindex(function(t,k) |
| 6466 |
local v={ "down",k } |
| 6467 |
t[k]=v |
| 6468 |
return v |
| 6469 |
end) |
| 6470 |
local up=setmetatableindex(function(t,k) |
| 6471 |
local v={ "down",-k } |
| 6472 |
t[k]=v |
| 6473 |
return v |
| 6474 |
end) |
| 6475 |
helpers.commands=utilities.storage.allocate { |
| 6476 |
char=char, |
| 6477 |
right=right, |
| 6478 |
left=left, |
| 6479 |
down=down, |
| 6480 |
up=up, |
| 6481 |
push=push, |
| 6482 |
pop=pop, |
| 6483 |
dummy=dummy, |
| 6484 |
} |
| 6485 |
|
| 6486 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-vfc”] --- |
| 6487 |
|
| 6488 |
|
| 6489 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-otr” 2958a21bebcf0579f4e11f0646d1b402] --- |
| 6490 |
|
| 6491 |
if not modules then modules={} end modules ['font-otr']={ |
| 6492 |
version=1.001, |
| 6493 |
optimize=true, |
| 6494 |
comment="companion to font-ini.mkiv", |
| 6495 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 6496 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 6497 |
license="see context related readme files" |
| 6498 |
} |
| 6499 |
local number=number |
| 6500 |
local next,type,tonumber,rawget=next,type,tonumber,rawget |
| 6501 |
local byte,lower,char,gsub=string.byte,string.lower,string.char,string.gsub |
| 6502 |
local fullstrip=string.fullstrip |
| 6503 |
local floor,round=math.floor,math.round |
| 6504 |
local P,R,S,C,Cs,Cc,Ct,Carg,Cmt=lpeg.P,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Cc,lpeg.Ct,lpeg.Carg,lpeg.Cmt |
| 6505 |
local lpegmatch=lpeg.match |
| 6506 |
local rshift=bit32.rshift |
| 6507 |
local setmetatableindex=table.setmetatableindex |
| 6508 |
local sortedkeys=table.sortedkeys |
| 6509 |
local sortedhash=table.sortedhash |
| 6510 |
local stripstring=string.nospaces |
| 6511 |
local utf16_to_utf8_be=utf.utf16_to_utf8_be |
| 6512 |
local report=logs.reporter("otf reader") |
| 6513 |
local report_cmap=logs.reporter("otf reader","cmap") |
| 6514 |
local trace_cmap=false trackers.register("otf.cmap",function(v) trace_cmap=v end) |
| 6515 |
local trace_cmap_details=false trackers.register("otf.cmap.details",function(v) trace_cmap_details=v end) |
| 6516 |
fonts=fonts or {} |
| 6517 |
local handlers=fonts.handlers or {} |
| 6518 |
fonts.handlers=handlers |
| 6519 |
local otf=handlers.otf or {} |
| 6520 |
handlers.otf=otf |
| 6521 |
local readers=otf.readers or {} |
| 6522 |
otf.readers=readers |
| 6523 |
local streamreader=utilities.files |
| 6524 |
local streamwriter=utilities.files |
| 6525 |
readers.streamreader=streamreader |
| 6526 |
readers.streamwriter=streamwriter |
| 6527 |
local openfile=streamreader.open |
| 6528 |
local closefile=streamreader.close |
| 6529 |
local setposition=streamreader.setposition |
| 6530 |
local skipshort=streamreader.skipshort |
| 6531 |
local readbytes=streamreader.readbytes |
| 6532 |
local readstring=streamreader.readstring |
| 6533 |
local readbyte=streamreader.readcardinal1 |
| 6534 |
local readushort=streamreader.readcardinal2 |
| 6535 |
local readuint=streamreader.readcardinal3 |
| 6536 |
local readulong=streamreader.readcardinal4 |
| 6537 |
local readshort=streamreader.readinteger2 |
| 6538 |
local readlong=streamreader.readinteger4 |
| 6539 |
local readfixed=streamreader.readfixed4 |
| 6540 |
local read2dot14=streamreader.read2dot14 |
| 6541 |
local readfword=readshort |
| 6542 |
local readufword=readushort |
| 6543 |
local readoffset=readushort |
| 6544 |
local readcardinaltable=streamreader.readcardinaltable |
| 6545 |
local readintegertable=streamreader.readintegertable |
| 6546 |
function streamreader.readtag(f) |
| 6547 |
return lower(stripstring(readstring(f,4))) |
| 6548 |
end |
| 6549 |
local short=2 |
| 6550 |
local ushort=2 |
| 6551 |
local ulong=4 |
| 6552 |
directives.register("fonts.streamreader",function() |
| 6553 |
streamreader=utilities.streams |
| 6554 |
openfile=streamreader.open |
| 6555 |
closefile=streamreader.close |
| 6556 |
setposition=streamreader.setposition |
| 6557 |
skipshort=streamreader.skipshort |
| 6558 |
readbytes=streamreader.readbytes |
| 6559 |
readstring=streamreader.readstring |
| 6560 |
readbyte=streamreader.readcardinal1 |
| 6561 |
readushort=streamreader.readcardinal2 |
| 6562 |
readuint=streamreader.readcardinal3 |
| 6563 |
readulong=streamreader.readcardinal4 |
| 6564 |
readshort=streamreader.readinteger2 |
| 6565 |
readlong=streamreader.readinteger4 |
| 6566 |
readfixed=streamreader.readfixed4 |
| 6567 |
read2dot14=streamreader.read2dot14 |
| 6568 |
readfword=readshort |
| 6569 |
readufword=readushort |
| 6570 |
readoffset=readushort |
| 6571 |
readcardinaltable=streamreader.readcardinaltable |
| 6572 |
readintegertable=streamreader.readintegertable |
| 6573 |
function streamreader.readtag(f) |
| 6574 |
return lower(stripstring(readstring(f,4))) |
| 6575 |
end |
| 6576 |
end) |
| 6577 |
local function readlongdatetime(f) |
| 6578 |
local a,b,c,d,e,f,g,h=readbytes(f,8) |
| 6579 |
return 0x100000000*d+0x1000000*e+0x10000*f+0x100*g+h |
| 6580 |
end |
| 6581 |
local tableversion=0.004 |
| 6582 |
readers.tableversion=tableversion |
| 6583 |
local privateoffset=fonts.constructors and fonts.constructors.privateoffset or 0xF0000 |
| 6584 |
local reservednames={ [0]="copyright", |
| 6585 |
"family", |
| 6586 |
"subfamily", |
| 6587 |
"uniqueid", |
| 6588 |
"fullname", |
| 6589 |
"version", |
| 6590 |
"postscriptname", |
| 6591 |
"trademark", |
| 6592 |
"manufacturer", |
| 6593 |
"designer", |
| 6594 |
"description", |
| 6595 |
"vendorurl", |
| 6596 |
"designerurl", |
| 6597 |
"license", |
| 6598 |
"licenseurl", |
| 6599 |
"reserved", |
| 6600 |
"typographicfamily", |
| 6601 |
"typographicsubfamily", |
| 6602 |
"compatiblefullname", |
| 6603 |
"sampletext", |
| 6604 |
"cidfindfontname", |
| 6605 |
"wwsfamily", |
| 6606 |
"wwssubfamily", |
| 6607 |
"lightbackgroundpalette", |
| 6608 |
"darkbackgroundpalette", |
| 6609 |
"variationspostscriptnameprefix", |
| 6610 |
} |
| 6611 |
local platforms={ [0]="unicode", |
| 6612 |
"macintosh", |
| 6613 |
"iso", |
| 6614 |
"windows", |
| 6615 |
"custom", |
| 6616 |
} |
| 6617 |
local encodings={ |
| 6618 |
unicode={ [0]="unicode 1.0 semantics", |
| 6619 |
"unicode 1.1 semantics", |
| 6620 |
"iso/iec 10646", |
| 6621 |
"unicode 2.0 bmp", |
| 6622 |
"unicode 2.0 full", |
| 6623 |
"unicode variation sequences", |
| 6624 |
"unicode full repertoire", |
| 6625 |
}, |
| 6626 |
macintosh={ [0]="roman","japanese","chinese (traditional)","korean","arabic","hebrew","greek","russian", |
| 6627 |
"rsymbol","devanagari","gurmukhi","gujarati","oriya","bengali","tamil","telugu","kannada", |
| 6628 |
"malayalam","sinhalese","burmese","khmer","thai","laotian","georgian","armenian", |
| 6629 |
"chinese (simplified)","tibetan","mongolian","geez","slavic","vietnamese","sindhi", |
| 6630 |
"uninterpreted", |
| 6631 |
}, |
| 6632 |
iso={ [0]="7-bit ascii", |
| 6633 |
"iso 10646", |
| 6634 |
"iso 8859-1", |
| 6635 |
}, |
| 6636 |
windows={ [0]="symbol", |
| 6637 |
"unicode bmp", |
| 6638 |
"shiftjis", |
| 6639 |
"prc", |
| 6640 |
"big5", |
| 6641 |
"wansung", |
| 6642 |
"johab", |
| 6643 |
"reserved 7", |
| 6644 |
"reserved 8", |
| 6645 |
"reserved 9", |
| 6646 |
"unicode ucs-4", |
| 6647 |
}, |
| 6648 |
custom={ |
| 6649 |
} |
| 6650 |
} |
| 6651 |
local decoders={ |
| 6652 |
unicode={}, |
| 6653 |
macintosh={}, |
| 6654 |
iso={}, |
| 6655 |
windows={ |
| 6656 |
["unicode semantics"]=utf16_to_utf8_be, |
| 6657 |
["unicode bmp"]=utf16_to_utf8_be, |
| 6658 |
["unicode full"]=utf16_to_utf8_be, |
| 6659 |
["unicode 1.0 semantics"]=utf16_to_utf8_be, |
| 6660 |
["unicode 1.1 semantics"]=utf16_to_utf8_be, |
| 6661 |
["unicode 2.0 bmp"]=utf16_to_utf8_be, |
| 6662 |
["unicode 2.0 full"]=utf16_to_utf8_be, |
| 6663 |
["unicode variation sequences"]=utf16_to_utf8_be, |
| 6664 |
["unicode full repertoire"]=utf16_to_utf8_be, |
| 6665 |
}, |
| 6666 |
custom={}, |
| 6667 |
} |
| 6668 |
local languages={ |
| 6669 |
unicode={ |
| 6670 |
[ 0]="english", |
| 6671 |
}, |
| 6672 |
macintosh={ |
| 6673 |
[ 0]="english", |
| 6674 |
}, |
| 6675 |
iso={}, |
| 6676 |
windows={ |
| 6677 |
[0x0409]="english - united states", |
| 6678 |
}, |
| 6679 |
custom={}, |
| 6680 |
} |
| 6681 |
local standardromanencoding={ [0]= |
| 6682 |
"notdef",".null","nonmarkingreturn","space","exclam","quotedbl", |
| 6683 |
"numbersign","dollar","percent","ampersand","quotesingle","parenleft", |
| 6684 |
"parenright","asterisk","plus","comma","hyphen","period","slash", |
| 6685 |
"zero","one","two","three","four","five","six","seven","eight", |
| 6686 |
"nine","colon","semicolon","less","equal","greater","question","at", |
| 6687 |
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O", |
| 6688 |
"P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft", |
| 6689 |
"backslash","bracketright","asciicircum","underscore","grave","a","b", |
| 6690 |
"c","d","e","f","g","h","i","j","k","l","m","n","o","p","q", |
| 6691 |
"r","s","t","u","v","w","x","y","z","braceleft","bar", |
| 6692 |
"braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute", |
| 6693 |
"Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex", |
| 6694 |
"adieresis","atilde","aring","ccedilla","eacute","egrave", |
| 6695 |
"ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis", |
| 6696 |
"ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute", |
| 6697 |
"ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling", |
| 6698 |
"section","bullet","paragraph","germandbls","registered","copyright", |
| 6699 |
"trademark","acute","dieresis","notequal","AE","Oslash","infinity", |
| 6700 |
"plusminus","lessequal","greaterequal","yen","mu","partialdiff", |
| 6701 |
"summation","product","pi","integral","ordfeminine","ordmasculine", |
| 6702 |
"Omega","ae","oslash","questiondown","exclamdown","logicalnot", |
| 6703 |
"radical","florin","approxequal","Delta","guillemotleft", |
| 6704 |
"guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde", |
| 6705 |
"Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright", |
| 6706 |
"quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis", |
| 6707 |
"fraction","currency","guilsinglleft","guilsinglright","fi","fl", |
| 6708 |
"daggerdbl","periodcentered","quotesinglbase","quotedblbase", |
| 6709 |
"perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave", |
| 6710 |
"Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex", |
| 6711 |
"apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi", |
| 6712 |
"circumflex","tilde","macron","breve","dotaccent","ring","cedilla", |
| 6713 |
"hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron", |
| 6714 |
"Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn", |
| 6715 |
"thorn","minus","multiply","onesuperior","twosuperior","threesuperior", |
| 6716 |
"onehalf","onequarter","threequarters","franc","Gbreve","gbreve", |
| 6717 |
"Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron", |
| 6718 |
"dcroat", |
| 6719 |
} |
| 6720 |
local weights={ |
| 6721 |
[100]="thin", |
| 6722 |
[200]="extralight", |
| 6723 |
[300]="light", |
| 6724 |
[400]="normal", |
| 6725 |
[500]="medium", |
| 6726 |
[600]="semibold", |
| 6727 |
[700]="bold", |
| 6728 |
[800]="extrabold", |
| 6729 |
[900]="black", |
| 6730 |
} |
| 6731 |
local widths={ |
| 6732 |
"ultracondensed", |
| 6733 |
"extracondensed", |
| 6734 |
"condensed", |
| 6735 |
"semicondensed", |
| 6736 |
"normal", |
| 6737 |
"semiexpanded", |
| 6738 |
"expanded", |
| 6739 |
"extraexpanded", |
| 6740 |
"ultraexpanded", |
| 6741 |
} |
| 6742 |
setmetatableindex(weights,function(t,k) |
| 6743 |
local r=floor((k+50)/100)*100 |
| 6744 |
local v=(r>900 and "black") or rawget(t,r) or "normal" |
| 6745 |
return v |
| 6746 |
end) |
| 6747 |
setmetatableindex(widths,function(t,k) |
| 6748 |
return "normal" |
| 6749 |
end) |
| 6750 |
local panoseweights={ [0]="normal", |
| 6751 |
"normal", |
| 6752 |
"verylight", |
| 6753 |
"light", |
| 6754 |
"thin", |
| 6755 |
"book", |
| 6756 |
"medium", |
| 6757 |
"demi", |
| 6758 |
"bold", |
| 6759 |
"heavy", |
| 6760 |
"black", |
| 6761 |
} |
| 6762 |
local panosewidths={ [0]="normal", |
| 6763 |
"normal", |
| 6764 |
"normal", |
| 6765 |
"normal", |
| 6766 |
"normal", |
| 6767 |
"expanded", |
| 6768 |
"condensed", |
| 6769 |
"veryexpanded", |
| 6770 |
"verycondensed", |
| 6771 |
"monospaced", |
| 6772 |
} |
| 6773 |
local helpers={} |
| 6774 |
readers.helpers=helpers |
| 6775 |
local function gotodatatable(f,fontdata,tag,criterium) |
| 6776 |
if criterium and f then |
| 6777 |
local tables=fontdata.tables |
| 6778 |
if tables then |
| 6779 |
local datatable=tables[tag] |
| 6780 |
if datatable then |
| 6781 |
local tableoffset=datatable.offset |
| 6782 |
setposition(f,tableoffset) |
| 6783 |
return tableoffset |
| 6784 |
end |
| 6785 |
else |
| 6786 |
report("no tables") |
| 6787 |
end |
| 6788 |
end |
| 6789 |
end |
| 6790 |
local function reportskippedtable(f,fontdata,tag,criterium) |
| 6791 |
if criterium and f then |
| 6792 |
local tables=fontdata.tables |
| 6793 |
if tables then |
| 6794 |
local datatable=tables[tag] |
| 6795 |
if datatable then |
| 6796 |
report("loading of table %a skipped",tag) |
| 6797 |
end |
| 6798 |
else |
| 6799 |
report("no tables") |
| 6800 |
end |
| 6801 |
end |
| 6802 |
end |
| 6803 |
local function setvariabledata(fontdata,tag,data) |
| 6804 |
local variabledata=fontdata.variabledata |
| 6805 |
if variabledata then |
| 6806 |
variabledata[tag]=data |
| 6807 |
else |
| 6808 |
fontdata.variabledata={ [tag]=data } |
| 6809 |
end |
| 6810 |
end |
| 6811 |
helpers.gotodatatable=gotodatatable |
| 6812 |
helpers.setvariabledata=setvariabledata |
| 6813 |
helpers.reportskippedtable=reportskippedtable |
| 6814 |
local platformnames={ |
| 6815 |
postscriptname=true, |
| 6816 |
fullname=true, |
| 6817 |
family=true, |
| 6818 |
subfamily=true, |
| 6819 |
typographicfamily=true, |
| 6820 |
typographicsubfamily=true, |
| 6821 |
compatiblefullname=true, |
| 6822 |
} |
| 6823 |
local platformextras={ |
| 6824 |
uniqueid=true, |
| 6825 |
version=true, |
| 6826 |
copyright=true, |
| 6827 |
license=true, |
| 6828 |
licenseurl=true, |
| 6829 |
manufacturer=true, |
| 6830 |
vendorurl=true, |
| 6831 |
} |
| 6832 |
function readers.name(f,fontdata,specification) |
| 6833 |
local tableoffset=gotodatatable(f,fontdata,"name",true) |
| 6834 |
if tableoffset then |
| 6835 |
local format=readushort(f) |
| 6836 |
local nofnames=readushort(f) |
| 6837 |
local offset=readushort(f) |
| 6838 |
local start=tableoffset+offset |
| 6839 |
local namelists={ |
| 6840 |
unicode={}, |
| 6841 |
windows={}, |
| 6842 |
macintosh={}, |
| 6843 |
} |
| 6844 |
for i=1,nofnames do |
| 6845 |
local platform=platforms[readushort(f)] |
| 6846 |
if platform then |
| 6847 |
local namelist=namelists[platform] |
| 6848 |
if namelist then |
| 6849 |
local encoding=readushort(f) |
| 6850 |
local language=readushort(f) |
| 6851 |
local encodings=encodings[platform] |
| 6852 |
local languages=languages[platform] |
| 6853 |
if encodings and languages then |
| 6854 |
local encoding=encodings[encoding] |
| 6855 |
local language=languages[language] |
| 6856 |
if encoding and language then |
| 6857 |
local index=readushort(f) |
| 6858 |
local name=reservednames[index] |
| 6859 |
namelist[#namelist+1]={ |
| 6860 |
platform=platform, |
| 6861 |
encoding=encoding, |
| 6862 |
language=language, |
| 6863 |
name=name, |
| 6864 |
index=index, |
| 6865 |
length=readushort(f), |
| 6866 |
offset=start+readushort(f), |
| 6867 |
} |
| 6868 |
else |
| 6869 |
skipshort(f,3) |
| 6870 |
end |
| 6871 |
else |
| 6872 |
skipshort(f,3) |
| 6873 |
end |
| 6874 |
else |
| 6875 |
skipshort(f,5) |
| 6876 |
end |
| 6877 |
else |
| 6878 |
skipshort(f,5) |
| 6879 |
end |
| 6880 |
end |
| 6881 |
local names={} |
| 6882 |
local done={} |
| 6883 |
local extras={} |
| 6884 |
local function decoded(platform,encoding,content) |
| 6885 |
local decoder=decoders[platform] |
| 6886 |
if decoder then |
| 6887 |
decoder=decoder[encoding] |
| 6888 |
end |
| 6889 |
if decoder then |
| 6890 |
return decoder(content) |
| 6891 |
else |
| 6892 |
return content |
| 6893 |
end |
| 6894 |
end |
| 6895 |
local function filter(platform,e,l) |
| 6896 |
local namelist=namelists[platform] |
| 6897 |
for i=1,#namelist do |
| 6898 |
local name=namelist[i] |
| 6899 |
local nametag=name.name |
| 6900 |
local index=name.index |
| 6901 |
if not done[nametag or i] then |
| 6902 |
local encoding=name.encoding |
| 6903 |
local language=name.language |
| 6904 |
if (not e or encoding==e) and (not l or language==l) then |
| 6905 |
setposition(f,name.offset) |
| 6906 |
local content=decoded(platform,encoding,readstring(f,name.length)) |
| 6907 |
if nametag then |
| 6908 |
names[nametag]={ |
| 6909 |
content=content, |
| 6910 |
platform=platform, |
| 6911 |
encoding=encoding, |
| 6912 |
language=language, |
| 6913 |
} |
| 6914 |
end |
| 6915 |
extras[index]=content |
| 6916 |
done[nametag or i]=true |
| 6917 |
end |
| 6918 |
end |
| 6919 |
end |
| 6920 |
end |
| 6921 |
filter("windows","unicode bmp","english - united states") |
| 6922 |
filter("macintosh","roman","english") |
| 6923 |
filter("windows") |
| 6924 |
filter("macintosh") |
| 6925 |
filter("unicode") |
| 6926 |
fontdata.names=names |
| 6927 |
fontdata.extras=extras |
| 6928 |
if specification.platformnames then |
| 6929 |
local collected={} |
| 6930 |
local platformextras=specification.platformextras and platformextras |
| 6931 |
for platform,namelist in next,namelists do |
| 6932 |
local filtered=false |
| 6933 |
for i=1,#namelist do |
| 6934 |
local entry=namelist[i] |
| 6935 |
local name=entry.name |
| 6936 |
if platformnames[name] or (platformextras and platformextras[name]) then |
| 6937 |
setposition(f,entry.offset) |
| 6938 |
local content=decoded(platform,entry.encoding,readstring(f,entry.length)) |
| 6939 |
if filtered then |
| 6940 |
filtered[name]=content |
| 6941 |
else |
| 6942 |
filtered={ [name]=content } |
| 6943 |
end |
| 6944 |
end |
| 6945 |
end |
| 6946 |
if filtered then |
| 6947 |
collected[platform]=filtered |
| 6948 |
end |
| 6949 |
end |
| 6950 |
fontdata.platformnames=collected |
| 6951 |
end |
| 6952 |
else |
| 6953 |
fontdata.names={} |
| 6954 |
end |
| 6955 |
end |
| 6956 |
local validutf=lpeg.patterns.validutf8 |
| 6957 |
local function getname(fontdata,key) |
| 6958 |
local names=fontdata.names |
| 6959 |
if names then |
| 6960 |
local value=names[key] |
| 6961 |
if value then |
| 6962 |
local content=value.content |
| 6963 |
return lpegmatch(validutf,content) and content or nil |
| 6964 |
end |
| 6965 |
end |
| 6966 |
end |
| 6967 |
readers["os/2"]=function(f,fontdata) |
| 6968 |
local tableoffset=gotodatatable(f,fontdata,"os/2",true) |
| 6969 |
if tableoffset then |
| 6970 |
local version=readushort(f) |
| 6971 |
local windowsmetrics={ |
| 6972 |
version=version, |
| 6973 |
averagewidth=readshort(f), |
| 6974 |
weightclass=readushort(f), |
| 6975 |
widthclass=readushort(f), |
| 6976 |
fstype=readushort(f), |
| 6977 |
subscriptxsize=readshort(f), |
| 6978 |
subscriptysize=readshort(f), |
| 6979 |
subscriptxoffset=readshort(f), |
| 6980 |
subscriptyoffset=readshort(f), |
| 6981 |
superscriptxsize=readshort(f), |
| 6982 |
superscriptysize=readshort(f), |
| 6983 |
superscriptxoffset=readshort(f), |
| 6984 |
superscriptyoffset=readshort(f), |
| 6985 |
strikeoutsize=readshort(f), |
| 6986 |
strikeoutpos=readshort(f), |
| 6987 |
familyclass=readshort(f), |
| 6988 |
panose={ readbytes(f,10) }, |
| 6989 |
unicoderanges={ readulong(f),readulong(f),readulong(f),readulong(f) }, |
| 6990 |
vendor=readstring(f,4), |
| 6991 |
fsselection=readushort(f), |
| 6992 |
firstcharindex=readushort(f), |
| 6993 |
lastcharindex=readushort(f), |
| 6994 |
typoascender=readshort(f), |
| 6995 |
typodescender=readshort(f), |
| 6996 |
typolinegap=readshort(f), |
| 6997 |
winascent=readushort(f), |
| 6998 |
windescent=readushort(f), |
| 6999 |
} |
| 7000 |
if version>=1 then |
| 7001 |
windowsmetrics.codepageranges={ readulong(f),readulong(f) } |
| 7002 |
end |
| 7003 |
if version>=2 then |
| 7004 |
windowsmetrics.xheight=readshort(f) |
| 7005 |
windowsmetrics.capheight=readshort(f) |
| 7006 |
windowsmetrics.defaultchar=readushort(f) |
| 7007 |
windowsmetrics.breakchar=readushort(f) |
| 7008 |
end |
| 7009 |
windowsmetrics.weight=windowsmetrics.weightclass and weights[windowsmetrics.weightclass] |
| 7010 |
windowsmetrics.width=windowsmetrics.widthclass and widths [windowsmetrics.widthclass] |
| 7011 |
windowsmetrics.panoseweight=panoseweights[windowsmetrics.panose[3]] |
| 7012 |
windowsmetrics.panosewidth=panosewidths [windowsmetrics.panose[4]] |
| 7013 |
fontdata.windowsmetrics=windowsmetrics |
| 7014 |
else |
| 7015 |
fontdata.windowsmetrics={} |
| 7016 |
end |
| 7017 |
end |
| 7018 |
readers.head=function(f,fontdata) |
| 7019 |
local tableoffset=gotodatatable(f,fontdata,"head",true) |
| 7020 |
if tableoffset then |
| 7021 |
local version=readulong(f) |
| 7022 |
local fontversion=readulong(f) |
| 7023 |
local fontheader={ |
| 7024 |
version=version, |
| 7025 |
fontversion=number.to16dot16(fontversion), |
| 7026 |
fontversionnumber=fontversion, |
| 7027 |
checksum=readushort(f)*0x10000+readushort(f), |
| 7028 |
magic=readulong(f), |
| 7029 |
flags=readushort(f), |
| 7030 |
units=readushort(f), |
| 7031 |
created=readlongdatetime(f), |
| 7032 |
modified=readlongdatetime(f), |
| 7033 |
xmin=readshort(f), |
| 7034 |
ymin=readshort(f), |
| 7035 |
xmax=readshort(f), |
| 7036 |
ymax=readshort(f), |
| 7037 |
macstyle=readushort(f), |
| 7038 |
smallpixels=readushort(f), |
| 7039 |
directionhint=readshort(f), |
| 7040 |
indextolocformat=readshort(f), |
| 7041 |
glyphformat=readshort(f), |
| 7042 |
} |
| 7043 |
fontdata.fontheader=fontheader |
| 7044 |
else |
| 7045 |
fontdata.fontheader={} |
| 7046 |
end |
| 7047 |
fontdata.nofglyphs=0 |
| 7048 |
end |
| 7049 |
readers.hhea=function(f,fontdata,specification) |
| 7050 |
local tableoffset=gotodatatable(f,fontdata,"hhea",specification.details) |
| 7051 |
if tableoffset then |
| 7052 |
fontdata.horizontalheader={ |
| 7053 |
version=readulong(f), |
| 7054 |
ascender=readfword(f), |
| 7055 |
descender=readfword(f), |
| 7056 |
linegap=readfword(f), |
| 7057 |
maxadvancewidth=readufword(f), |
| 7058 |
minleftsidebearing=readfword(f), |
| 7059 |
minrightsidebearing=readfword(f), |
| 7060 |
maxextent=readfword(f), |
| 7061 |
caretsloperise=readshort(f), |
| 7062 |
caretsloperun=readshort(f), |
| 7063 |
caretoffset=readshort(f), |
| 7064 |
reserved_1=readshort(f), |
| 7065 |
reserved_2=readshort(f), |
| 7066 |
reserved_3=readshort(f), |
| 7067 |
reserved_4=readshort(f), |
| 7068 |
metricdataformat=readshort(f), |
| 7069 |
nofmetrics=readushort(f), |
| 7070 |
} |
| 7071 |
else |
| 7072 |
fontdata.horizontalheader={ |
| 7073 |
nofmetrics=0, |
| 7074 |
} |
| 7075 |
end |
| 7076 |
end |
| 7077 |
readers.vhea=function(f,fontdata,specification) |
| 7078 |
local tableoffset=gotodatatable(f,fontdata,"vhea",specification.details) |
| 7079 |
if tableoffset then |
| 7080 |
fontdata.verticalheader={ |
| 7081 |
version=readulong(f), |
| 7082 |
ascender=readfword(f), |
| 7083 |
descender=readfword(f), |
| 7084 |
linegap=readfword(f), |
| 7085 |
maxadvanceheight=readufword(f), |
| 7086 |
mintopsidebearing=readfword(f), |
| 7087 |
minbottomsidebearing=readfword(f), |
| 7088 |
maxextent=readfword(f), |
| 7089 |
caretsloperise=readshort(f), |
| 7090 |
caretsloperun=readshort(f), |
| 7091 |
caretoffset=readshort(f), |
| 7092 |
reserved_1=readshort(f), |
| 7093 |
reserved_2=readshort(f), |
| 7094 |
reserved_3=readshort(f), |
| 7095 |
reserved_4=readshort(f), |
| 7096 |
metricdataformat=readshort(f), |
| 7097 |
nofmetrics=readushort(f), |
| 7098 |
} |
| 7099 |
else |
| 7100 |
fontdata.verticalheader={ |
| 7101 |
nofmetrics=0, |
| 7102 |
} |
| 7103 |
end |
| 7104 |
end |
| 7105 |
readers.maxp=function(f,fontdata,specification) |
| 7106 |
local tableoffset=gotodatatable(f,fontdata,"maxp",specification.details) |
| 7107 |
if tableoffset then |
| 7108 |
local version=readulong(f) |
| 7109 |
local nofglyphs=readushort(f) |
| 7110 |
fontdata.nofglyphs=nofglyphs |
| 7111 |
if version==0x00005000 then |
| 7112 |
fontdata.maximumprofile={ |
| 7113 |
version=version, |
| 7114 |
nofglyphs=nofglyphs, |
| 7115 |
} |
| 7116 |
elseif version==0x00010000 then |
| 7117 |
fontdata.maximumprofile={ |
| 7118 |
version=version, |
| 7119 |
nofglyphs=nofglyphs, |
| 7120 |
points=readushort(f), |
| 7121 |
contours=readushort(f), |
| 7122 |
compositepoints=readushort(f), |
| 7123 |
compositecontours=readushort(f), |
| 7124 |
zones=readushort(f), |
| 7125 |
twilightpoints=readushort(f), |
| 7126 |
storage=readushort(f), |
| 7127 |
functiondefs=readushort(f), |
| 7128 |
instructiondefs=readushort(f), |
| 7129 |
stackelements=readushort(f), |
| 7130 |
sizeofinstructions=readushort(f), |
| 7131 |
componentelements=readushort(f), |
| 7132 |
componentdepth=readushort(f), |
| 7133 |
} |
| 7134 |
else |
| 7135 |
fontdata.maximumprofile={ |
| 7136 |
version=version, |
| 7137 |
nofglyphs=0, |
| 7138 |
} |
| 7139 |
end |
| 7140 |
end |
| 7141 |
end |
| 7142 |
readers.hmtx=function(f,fontdata,specification) |
| 7143 |
local tableoffset=gotodatatable(f,fontdata,"hmtx",specification.glyphs) |
| 7144 |
if tableoffset then |
| 7145 |
local horizontalheader=fontdata.horizontalheader |
| 7146 |
local nofmetrics=horizontalheader.nofmetrics |
| 7147 |
local glyphs=fontdata.glyphs |
| 7148 |
local nofglyphs=fontdata.nofglyphs |
| 7149 |
local width=0 |
| 7150 |
local leftsidebearing=0 |
| 7151 |
for i=0,nofmetrics-1 do |
| 7152 |
local glyph=glyphs[i] |
| 7153 |
width=readshort(f) |
| 7154 |
leftsidebearing=readshort(f) |
| 7155 |
if width~=0 then |
| 7156 |
glyph.width=width |
| 7157 |
end |
| 7158 |
end |
| 7159 |
for i=nofmetrics,nofglyphs-1 do |
| 7160 |
local glyph=glyphs[i] |
| 7161 |
if width~=0 then |
| 7162 |
glyph.width=width |
| 7163 |
end |
| 7164 |
end |
| 7165 |
end |
| 7166 |
end |
| 7167 |
readers.vmtx=function(f,fontdata,specification) |
| 7168 |
local tableoffset=gotodatatable(f,fontdata,"vmtx",specification.glyphs) |
| 7169 |
if tableoffset then |
| 7170 |
local verticalheader=fontdata.verticalheader |
| 7171 |
local nofmetrics=verticalheader.nofmetrics |
| 7172 |
local glyphs=fontdata.glyphs |
| 7173 |
local nofglyphs=fontdata.nofglyphs |
| 7174 |
local vheight=0 |
| 7175 |
local vdefault=verticalheader.ascender-verticalheader.descender |
| 7176 |
local topsidebearing=0 |
| 7177 |
for i=0,nofmetrics-1 do |
| 7178 |
local glyph=glyphs[i] |
| 7179 |
vheight=readushort(f) |
| 7180 |
topsidebearing=readshort(f) |
| 7181 |
if vheight~=0 and vheight~=vdefault then |
| 7182 |
glyph.vheight=vheight |
| 7183 |
end |
| 7184 |
if topsidebearing~=0 then |
| 7185 |
glyph.tsb=topsidebearing |
| 7186 |
end |
| 7187 |
end |
| 7188 |
for i=nofmetrics,nofglyphs-1 do |
| 7189 |
local glyph=glyphs[i] |
| 7190 |
if vheight~=0 and vheight~=vdefault then |
| 7191 |
glyph.vheight=vheight |
| 7192 |
end |
| 7193 |
end |
| 7194 |
end |
| 7195 |
end |
| 7196 |
readers.vorg=function(f,fontdata,specification) |
| 7197 |
reportskippedtable(f,fontdata,"vorg",specification.glyphs) |
| 7198 |
end |
| 7199 |
readers.post=function(f,fontdata,specification) |
| 7200 |
local tableoffset=gotodatatable(f,fontdata,"post",true) |
| 7201 |
if tableoffset then |
| 7202 |
local version=readulong(f) |
| 7203 |
fontdata.postscript={ |
| 7204 |
version=version, |
| 7205 |
italicangle=readfixed(f), |
| 7206 |
underlineposition=readfword(f), |
| 7207 |
underlinethickness=readfword(f), |
| 7208 |
monospaced=readulong(f), |
| 7209 |
minmemtype42=readulong(f), |
| 7210 |
maxmemtype42=readulong(f), |
| 7211 |
minmemtype1=readulong(f), |
| 7212 |
maxmemtype1=readulong(f), |
| 7213 |
} |
| 7214 |
if not specification.glyphs then |
| 7215 |
elseif version==0x00010000 then |
| 7216 |
for index=0,#standardromanencoding do |
| 7217 |
glyphs[index].name=standardromanencoding[index] |
| 7218 |
end |
| 7219 |
elseif version==0x00020000 then |
| 7220 |
local glyphs=fontdata.glyphs |
| 7221 |
local nofglyphs=readushort(f) |
| 7222 |
local indices={} |
| 7223 |
local names={} |
| 7224 |
local maxnames=0 |
| 7225 |
for i=0,nofglyphs-1 do |
| 7226 |
local nameindex=readushort(f) |
| 7227 |
if nameindex>=258 then |
| 7228 |
maxnames=maxnames+1 |
| 7229 |
nameindex=nameindex-257 |
| 7230 |
indices[nameindex]=i |
| 7231 |
else |
| 7232 |
glyphs[i].name=standardromanencoding[nameindex] |
| 7233 |
end |
| 7234 |
end |
| 7235 |
for i=1,maxnames do |
| 7236 |
local mapping=indices[i] |
| 7237 |
if not mapping then |
| 7238 |
report("quit post name fetching at %a of %a: %s",i,maxnames,"no index") |
| 7239 |
break |
| 7240 |
else |
| 7241 |
local length=readbyte(f) |
| 7242 |
if length>0 then |
| 7243 |
glyphs[mapping].name=readstring(f,length) |
| 7244 |
else |
| 7245 |
end |
| 7246 |
end |
| 7247 |
end |
| 7248 |
end |
| 7249 |
else |
| 7250 |
fontdata.postscript={} |
| 7251 |
end |
| 7252 |
end |
| 7253 |
readers.cff=function(f,fontdata,specification) |
| 7254 |
reportskippedtable(f,fontdata,"cff",specification.glyphs) |
| 7255 |
end |
| 7256 |
local formatreaders={} |
| 7257 |
local duplicatestoo=true |
| 7258 |
local sequence={ |
| 7259 |
{ 3,1,4 }, |
| 7260 |
{ 3,10,12 }, |
| 7261 |
{ 0,3,4 }, |
| 7262 |
{ 0,3,12 }, |
| 7263 |
{ 0,1,4 }, |
| 7264 |
{ 0,1,12 }, |
| 7265 |
{ 0,0,6 }, |
| 7266 |
{ 3,0,6 }, |
| 7267 |
{ 3,0,4 }, |
| 7268 |
{ 0,5,14 }, |
| 7269 |
{ 0,4,12 }, |
| 7270 |
{ 3,10,13 }, |
| 7271 |
} |
| 7272 |
local supported={} |
| 7273 |
for i=1,#sequence do |
| 7274 |
local si=sequence[i] |
| 7275 |
local sp,se,sf=si[1],si[2],si[3] |
| 7276 |
local p=supported[sp] |
| 7277 |
if not p then |
| 7278 |
p={} |
| 7279 |
supported[sp]=p |
| 7280 |
end |
| 7281 |
local e=p[se] |
| 7282 |
if not e then |
| 7283 |
e={} |
| 7284 |
p[se]=e |
| 7285 |
end |
| 7286 |
e[sf]=true |
| 7287 |
end |
| 7288 |
formatreaders[4]=function(f,fontdata,offset) |
| 7289 |
setposition(f,offset+2) |
| 7290 |
local length=readushort(f) |
| 7291 |
local language=readushort(f) |
| 7292 |
local nofsegments=readushort(f)/2 |
| 7293 |
skipshort(f,3) |
| 7294 |
local mapping=fontdata.mapping |
| 7295 |
local glyphs=fontdata.glyphs |
| 7296 |
local duplicates=fontdata.duplicates |
| 7297 |
local nofdone=0 |
| 7298 |
local endchars=readcardinaltable(f,nofsegments,ushort) |
| 7299 |
local reserved=readushort(f) |
| 7300 |
local startchars=readcardinaltable(f,nofsegments,ushort) |
| 7301 |
local deltas=readcardinaltable(f,nofsegments,ushort) |
| 7302 |
local offsets=readcardinaltable(f,nofsegments,ushort) |
| 7303 |
local size=(length-2*2-5*2-4*2*nofsegments)/2 |
| 7304 |
local indices=readcardinaltable(f,size-1,ushort) |
| 7305 |
for segment=1,nofsegments do |
| 7306 |
local startchar=startchars[segment] |
| 7307 |
local endchar=endchars[segment] |
| 7308 |
local offset=offsets[segment] |
| 7309 |
local delta=deltas[segment] |
| 7310 |
if startchar==0xFFFF and endchar==0xFFFF then |
| 7311 |
elseif startchar==0xFFFF and offset==0 then |
| 7312 |
elseif offset==0xFFFF then |
| 7313 |
elseif offset==0 then |
| 7314 |
if trace_cmap_details then |
| 7315 |
report("format 4.%i segment %2i from %C upto %C at index %H",1,segment,startchar,endchar,(startchar+delta)%65536) |
| 7316 |
end |
| 7317 |
for unicode=startchar,endchar do |
| 7318 |
local index=(unicode+delta)%65536 |
| 7319 |
if index and index>0 then |
| 7320 |
local glyph=glyphs[index] |
| 7321 |
if glyph then |
| 7322 |
local gu=glyph.unicode |
| 7323 |
if not gu then |
| 7324 |
glyph.unicode=unicode |
| 7325 |
nofdone=nofdone+1 |
| 7326 |
elseif gu~=unicode then |
| 7327 |
if duplicatestoo then |
| 7328 |
local d=duplicates[gu] |
| 7329 |
if d then |
| 7330 |
d[unicode]=true |
| 7331 |
else |
| 7332 |
duplicates[gu]={ [unicode]=true } |
| 7333 |
end |
| 7334 |
else |
| 7335 |
report("duplicate case 1: %C %04i %s",unicode,index,glyphs[index].name) |
| 7336 |
end |
| 7337 |
end |
| 7338 |
if not mapping[index] then |
| 7339 |
mapping[index]=unicode |
| 7340 |
end |
| 7341 |
end |
| 7342 |
end |
| 7343 |
end |
| 7344 |
else |
| 7345 |
local shift=(segment-nofsegments+offset/2)-startchar |
| 7346 |
if trace_cmap_details then |
| 7347 |
report_cmap("format 4.%i segment %2i from %C upto %C at index %H",0,segment,startchar,endchar,(startchar+delta)%65536) |
| 7348 |
end |
| 7349 |
for unicode=startchar,endchar do |
| 7350 |
local slot=shift+unicode |
| 7351 |
local index=indices[slot] |
| 7352 |
if index and index>0 then |
| 7353 |
index=(index+delta)%65536 |
| 7354 |
local glyph=glyphs[index] |
| 7355 |
if glyph then |
| 7356 |
local gu=glyph.unicode |
| 7357 |
if not gu then |
| 7358 |
glyph.unicode=unicode |
| 7359 |
nofdone=nofdone+1 |
| 7360 |
elseif gu~=unicode then |
| 7361 |
if duplicatestoo then |
| 7362 |
local d=duplicates[gu] |
| 7363 |
if d then |
| 7364 |
d[unicode]=true |
| 7365 |
else |
| 7366 |
duplicates[gu]={ [unicode]=true } |
| 7367 |
end |
| 7368 |
else |
| 7369 |
report("duplicate case 2: %C %04i %s",unicode,index,glyphs[index].name) |
| 7370 |
end |
| 7371 |
end |
| 7372 |
if not mapping[index] then |
| 7373 |
mapping[index]=unicode |
| 7374 |
end |
| 7375 |
end |
| 7376 |
end |
| 7377 |
end |
| 7378 |
end |
| 7379 |
end |
| 7380 |
return nofdone |
| 7381 |
end |
| 7382 |
formatreaders[6]=function(f,fontdata,offset) |
| 7383 |
setposition(f,offset) |
| 7384 |
local format=readushort(f) |
| 7385 |
local length=readushort(f) |
| 7386 |
local language=readushort(f) |
| 7387 |
local mapping=fontdata.mapping |
| 7388 |
local glyphs=fontdata.glyphs |
| 7389 |
local duplicates=fontdata.duplicates |
| 7390 |
local start=readushort(f) |
| 7391 |
local count=readushort(f) |
| 7392 |
local stop=start+count-1 |
| 7393 |
local nofdone=0 |
| 7394 |
if trace_cmap_details then |
| 7395 |
report_cmap("format 6 from %C to %C",2,start,stop) |
| 7396 |
end |
| 7397 |
for unicode=start,stop do |
| 7398 |
local index=readushort(f) |
| 7399 |
if index>0 then |
| 7400 |
local glyph=glyphs[index] |
| 7401 |
if glyph then |
| 7402 |
local gu=glyph.unicode |
| 7403 |
if not gu then |
| 7404 |
glyph.unicode=unicode |
| 7405 |
nofdone=nofdone+1 |
| 7406 |
elseif gu~=unicode then |
| 7407 |
end |
| 7408 |
if not mapping[index] then |
| 7409 |
mapping[index]=unicode |
| 7410 |
end |
| 7411 |
end |
| 7412 |
end |
| 7413 |
end |
| 7414 |
return nofdone |
| 7415 |
end |
| 7416 |
formatreaders[12]=function(f,fontdata,offset) |
| 7417 |
setposition(f,offset+2+2+4+4) |
| 7418 |
local mapping=fontdata.mapping |
| 7419 |
local glyphs=fontdata.glyphs |
| 7420 |
local duplicates=fontdata.duplicates |
| 7421 |
local nofgroups=readulong(f) |
| 7422 |
local nofdone=0 |
| 7423 |
for i=1,nofgroups do |
| 7424 |
local first=readulong(f) |
| 7425 |
local last=readulong(f) |
| 7426 |
local index=readulong(f) |
| 7427 |
if trace_cmap_details then |
| 7428 |
report_cmap("format 12 from %C to %C starts at index %i",first,last,index) |
| 7429 |
end |
| 7430 |
for unicode=first,last do |
| 7431 |
local glyph=glyphs[index] |
| 7432 |
if glyph then |
| 7433 |
local gu=glyph.unicode |
| 7434 |
if not gu then |
| 7435 |
glyph.unicode=unicode |
| 7436 |
nofdone=nofdone+1 |
| 7437 |
elseif gu~=unicode then |
| 7438 |
local d=duplicates[gu] |
| 7439 |
if d then |
| 7440 |
d[unicode]=true |
| 7441 |
else |
| 7442 |
duplicates[gu]={ [unicode]=true } |
| 7443 |
end |
| 7444 |
end |
| 7445 |
if not mapping[index] then |
| 7446 |
mapping[index]=unicode |
| 7447 |
end |
| 7448 |
end |
| 7449 |
index=index+1 |
| 7450 |
end |
| 7451 |
end |
| 7452 |
return nofdone |
| 7453 |
end |
| 7454 |
formatreaders[13]=function(f,fontdata,offset) |
| 7455 |
setposition(f,offset+2+2+4+4) |
| 7456 |
local mapping=fontdata.mapping |
| 7457 |
local glyphs=fontdata.glyphs |
| 7458 |
local duplicates=fontdata.duplicates |
| 7459 |
local nofgroups=readulong(f) |
| 7460 |
local nofdone=0 |
| 7461 |
for i=1,nofgroups do |
| 7462 |
local first=readulong(f) |
| 7463 |
local last=readulong(f) |
| 7464 |
local index=readulong(f) |
| 7465 |
if first<privateoffset then |
| 7466 |
if trace_cmap_details then |
| 7467 |
report_cmap("format 13 from %C to %C get index %i",first,last,index) |
| 7468 |
end |
| 7469 |
local glyph=glyphs[index] |
| 7470 |
local unicode=glyph.unicode |
| 7471 |
if not unicode then |
| 7472 |
unicode=first |
| 7473 |
glyph.unicode=unicode |
| 7474 |
first=first+1 |
| 7475 |
end |
| 7476 |
local list=duplicates[unicode] |
| 7477 |
mapping[index]=unicode |
| 7478 |
if not list then |
| 7479 |
list={} |
| 7480 |
duplicates[unicode]=list |
| 7481 |
end |
| 7482 |
if last>=privateoffset then |
| 7483 |
local limit=privateoffset-1 |
| 7484 |
report("format 13 from %C to %C pruned to %C",first,last,limit) |
| 7485 |
last=limit |
| 7486 |
end |
| 7487 |
for unicode=first,last do |
| 7488 |
list[unicode]=true |
| 7489 |
end |
| 7490 |
nofdone=nofdone+last-first+1 |
| 7491 |
else |
| 7492 |
report("format 13 from %C to %C ignored",first,last) |
| 7493 |
end |
| 7494 |
end |
| 7495 |
return nofdone |
| 7496 |
end |
| 7497 |
formatreaders[14]=function(f,fontdata,offset) |
| 7498 |
if offset and offset~=0 then |
| 7499 |
setposition(f,offset) |
| 7500 |
local format=readushort(f) |
| 7501 |
local length=readulong(f) |
| 7502 |
local nofrecords=readulong(f) |
| 7503 |
local records={} |
| 7504 |
local variants={} |
| 7505 |
local nofdone=0 |
| 7506 |
fontdata.variants=variants |
| 7507 |
for i=1,nofrecords do |
| 7508 |
records[i]={ |
| 7509 |
selector=readuint(f), |
| 7510 |
default=readulong(f), |
| 7511 |
other=readulong(f), |
| 7512 |
} |
| 7513 |
end |
| 7514 |
for i=1,nofrecords do |
| 7515 |
local record=records[i] |
| 7516 |
local selector=record.selector |
| 7517 |
local default=record.default |
| 7518 |
local other=record.other |
| 7519 |
local other=record.other |
| 7520 |
if other~=0 then |
| 7521 |
setposition(f,offset+other) |
| 7522 |
local mapping={} |
| 7523 |
local count=readulong(f) |
| 7524 |
for i=1,count do |
| 7525 |
mapping[readuint(f)]=readushort(f) |
| 7526 |
end |
| 7527 |
nofdone=nofdone+count |
| 7528 |
variants[selector]=mapping |
| 7529 |
end |
| 7530 |
end |
| 7531 |
return nofdone |
| 7532 |
else |
| 7533 |
return 0 |
| 7534 |
end |
| 7535 |
end |
| 7536 |
local function checkcmap(f,fontdata,records,platform,encoding,format) |
| 7537 |
local pdata=records[platform] |
| 7538 |
if not pdata then |
| 7539 |
if trace_cmap_details then |
| 7540 |
report_cmap("skipped, %s, p=%i e=%i f=%i","no platform",platform,encoding,format) |
| 7541 |
end |
| 7542 |
return 0 |
| 7543 |
end |
| 7544 |
local edata=pdata[encoding] |
| 7545 |
if not edata then |
| 7546 |
if trace_cmap_details then |
| 7547 |
report_cmap("skipped, %s, p=%i e=%i f=%i","no encoding",platform,encoding,format) |
| 7548 |
end |
| 7549 |
return 0 |
| 7550 |
end |
| 7551 |
local fdata=edata[format] |
| 7552 |
if not fdata then |
| 7553 |
if trace_cmap_details then |
| 7554 |
report_cmap("skipped, %s, p=%i e=%i f=%i","no format",platform,encoding,format) |
| 7555 |
end |
| 7556 |
return 0 |
| 7557 |
elseif type(fdata)~="number" then |
| 7558 |
if trace_cmap_details then |
| 7559 |
report_cmap("skipped, %s, p=%i e=%i f=%i","already done",platform,encoding,format) |
| 7560 |
end |
| 7561 |
return 0 |
| 7562 |
end |
| 7563 |
edata[format]=true |
| 7564 |
local reader=formatreaders[format] |
| 7565 |
if not reader then |
| 7566 |
if trace_cmap_details then |
| 7567 |
report_cmap("skipped, %s, p=%i e=%i f=%i","unsupported format",platform,encoding,format) |
| 7568 |
end |
| 7569 |
return 0 |
| 7570 |
end |
| 7571 |
local n=reader(f,fontdata,fdata) or 0 |
| 7572 |
if trace_cmap_details or trace_cmap then |
| 7573 |
local p=platforms[platform] |
| 7574 |
local e=encodings[p] |
| 7575 |
report_cmap("checked, platform %i (%s), encoding %i (%s), format %i, new unicodes %i", |
| 7576 |
platform,p,encoding,e and e[encoding] or "?",format,n) |
| 7577 |
end |
| 7578 |
return n |
| 7579 |
end |
| 7580 |
function readers.cmap(f,fontdata,specification) |
| 7581 |
local tableoffset=gotodatatable(f,fontdata,"cmap",specification.glyphs) |
| 7582 |
if tableoffset then |
| 7583 |
local version=readushort(f) |
| 7584 |
local noftables=readushort(f) |
| 7585 |
local records={} |
| 7586 |
local unicodecid=false |
| 7587 |
local variantcid=false |
| 7588 |
local variants={} |
| 7589 |
local duplicates=fontdata.duplicates or {} |
| 7590 |
fontdata.duplicates=duplicates |
| 7591 |
for i=1,noftables do |
| 7592 |
local platform=readushort(f) |
| 7593 |
local encoding=readushort(f) |
| 7594 |
local offset=readulong(f) |
| 7595 |
local record=records[platform] |
| 7596 |
if not record then |
| 7597 |
records[platform]={ |
| 7598 |
[encoding]={ |
| 7599 |
offsets={ offset }, |
| 7600 |
formats={}, |
| 7601 |
} |
| 7602 |
} |
| 7603 |
else |
| 7604 |
local subtables=record[encoding] |
| 7605 |
if not subtables then |
| 7606 |
record[encoding]={ |
| 7607 |
offsets={ offset }, |
| 7608 |
formats={}, |
| 7609 |
} |
| 7610 |
else |
| 7611 |
local offsets=subtables.offsets |
| 7612 |
offsets[#offsets+1]=offset |
| 7613 |
end |
| 7614 |
end |
| 7615 |
end |
| 7616 |
if trace_cmap then |
| 7617 |
report("found cmaps:") |
| 7618 |
end |
| 7619 |
for platform,record in sortedhash(records) do |
| 7620 |
local p=platforms[platform] |
| 7621 |
local e=encodings[p] |
| 7622 |
local sp=supported[platform] |
| 7623 |
local ps=p or "?" |
| 7624 |
if trace_cmap then |
| 7625 |
if sp then |
| 7626 |
report(" platform %i: %s",platform,ps) |
| 7627 |
else |
| 7628 |
report(" platform %i: %s (unsupported)",platform,ps) |
| 7629 |
end |
| 7630 |
end |
| 7631 |
for encoding,subtables in sortedhash(record) do |
| 7632 |
local se=sp and sp[encoding] |
| 7633 |
local es=e and e[encoding] or "?" |
| 7634 |
if trace_cmap then |
| 7635 |
if se then |
| 7636 |
report(" encoding %i: %s",encoding,es) |
| 7637 |
else |
| 7638 |
report(" encoding %i: %s (unsupported)",encoding,es) |
| 7639 |
end |
| 7640 |
end |
| 7641 |
local offsets=subtables.offsets |
| 7642 |
local formats=subtables.formats |
| 7643 |
for i=1,#offsets do |
| 7644 |
local offset=tableoffset+offsets[i] |
| 7645 |
setposition(f,offset) |
| 7646 |
formats[readushort(f)]=offset |
| 7647 |
end |
| 7648 |
record[encoding]=formats |
| 7649 |
if trace_cmap then |
| 7650 |
local list=sortedkeys(formats) |
| 7651 |
for i=1,#list do |
| 7652 |
if not (se and se[list[i]]) then |
| 7653 |
list[i]=list[i].." (unsupported)" |
| 7654 |
end |
| 7655 |
end |
| 7656 |
report(" formats: % t",list) |
| 7657 |
end |
| 7658 |
end |
| 7659 |
end |
| 7660 |
local ok=false |
| 7661 |
for i=1,#sequence do |
| 7662 |
local si=sequence[i] |
| 7663 |
local sp,se,sf=si[1],si[2],si[3] |
| 7664 |
if checkcmap(f,fontdata,records,sp,se,sf)>0 then |
| 7665 |
ok=true |
| 7666 |
end |
| 7667 |
end |
| 7668 |
if not ok then |
| 7669 |
report("no useable unicode cmap found") |
| 7670 |
end |
| 7671 |
fontdata.cidmaps={ |
| 7672 |
version=version, |
| 7673 |
noftables=noftables, |
| 7674 |
records=records, |
| 7675 |
} |
| 7676 |
else |
| 7677 |
fontdata.cidmaps={} |
| 7678 |
end |
| 7679 |
end |
| 7680 |
function readers.loca(f,fontdata,specification) |
| 7681 |
reportskippedtable(f,fontdata,"loca",specification.glyphs) |
| 7682 |
end |
| 7683 |
function readers.glyf(f,fontdata,specification) |
| 7684 |
reportskippedtable(f,fontdata,"glyf",specification.glyphs) |
| 7685 |
end |
| 7686 |
function readers.colr(f,fontdata,specification) |
| 7687 |
reportskippedtable(f,fontdata,"colr",specification.glyphs) |
| 7688 |
end |
| 7689 |
function readers.cpal(f,fontdata,specification) |
| 7690 |
reportskippedtable(f,fontdata,"cpal",specification.glyphs) |
| 7691 |
end |
| 7692 |
function readers.svg(f,fontdata,specification) |
| 7693 |
reportskippedtable(f,fontdata,"svg",specification.glyphs) |
| 7694 |
end |
| 7695 |
function readers.sbix(f,fontdata,specification) |
| 7696 |
reportskippedtable(f,fontdata,"sbix",specification.glyphs) |
| 7697 |
end |
| 7698 |
function readers.cbdt(f,fontdata,specification) |
| 7699 |
reportskippedtable(f,fontdata,"cbdt",specification.glyphs) |
| 7700 |
end |
| 7701 |
function readers.cblc(f,fontdata,specification) |
| 7702 |
reportskippedtable(f,fontdata,"cblc",specification.glyphs) |
| 7703 |
end |
| 7704 |
function readers.ebdt(f,fontdata,specification) |
| 7705 |
reportskippedtable(f,fontdata,"ebdt",specification.glyphs) |
| 7706 |
end |
| 7707 |
function readers.ebsc(f,fontdata,specification) |
| 7708 |
reportskippedtable(f,fontdata,"ebsc",specification.glyphs) |
| 7709 |
end |
| 7710 |
function readers.eblc(f,fontdata,specification) |
| 7711 |
reportskippedtable(f,fontdata,"eblc",specification.glyphs) |
| 7712 |
end |
| 7713 |
function readers.kern(f,fontdata,specification) |
| 7714 |
local tableoffset=gotodatatable(f,fontdata,"kern",specification.kerns) |
| 7715 |
if tableoffset then |
| 7716 |
local version=readushort(f) |
| 7717 |
local noftables=readushort(f) |
| 7718 |
for i=1,noftables do |
| 7719 |
local version=readushort(f) |
| 7720 |
local length=readushort(f) |
| 7721 |
local coverage=readushort(f) |
| 7722 |
local format=rshift(coverage,8) |
| 7723 |
if format==0 then |
| 7724 |
local nofpairs=readushort(f) |
| 7725 |
local searchrange=readushort(f) |
| 7726 |
local entryselector=readushort(f) |
| 7727 |
local rangeshift=readushort(f) |
| 7728 |
local kerns={} |
| 7729 |
local glyphs=fontdata.glyphs |
| 7730 |
for i=1,nofpairs do |
| 7731 |
local left=readushort(f) |
| 7732 |
local right=readushort(f) |
| 7733 |
local kern=readfword(f) |
| 7734 |
local glyph=glyphs[left] |
| 7735 |
local kerns=glyph.kerns |
| 7736 |
if kerns then |
| 7737 |
kerns[right]=kern |
| 7738 |
else |
| 7739 |
glyph.kerns={ [right]=kern } |
| 7740 |
end |
| 7741 |
end |
| 7742 |
elseif format==2 then |
| 7743 |
report("todo: kern classes") |
| 7744 |
else |
| 7745 |
report("todo: kerns") |
| 7746 |
end |
| 7747 |
end |
| 7748 |
end |
| 7749 |
end |
| 7750 |
function readers.gdef(f,fontdata,specification) |
| 7751 |
reportskippedtable(f,fontdata,"gdef",specification.details) |
| 7752 |
end |
| 7753 |
function readers.gsub(f,fontdata,specification) |
| 7754 |
reportskippedtable(f,fontdata,"gsub",specification.details) |
| 7755 |
end |
| 7756 |
function readers.gpos(f,fontdata,specification) |
| 7757 |
reportskippedtable(f,fontdata,"gpos",specification.details) |
| 7758 |
end |
| 7759 |
function readers.math(f,fontdata,specification) |
| 7760 |
reportskippedtable(f,fontdata,"math",specification.details) |
| 7761 |
end |
| 7762 |
local function getinfo(maindata,sub,platformnames,rawfamilynames,metricstoo,instancenames) |
| 7763 |
local fontdata=sub and maindata.subfonts and maindata.subfonts[sub] or maindata |
| 7764 |
local names=fontdata.names |
| 7765 |
local info=nil |
| 7766 |
if names then |
| 7767 |
local metrics=fontdata.windowsmetrics or {} |
| 7768 |
local postscript=fontdata.postscript or {} |
| 7769 |
local fontheader=fontdata.fontheader or {} |
| 7770 |
local cffinfo=fontdata.cffinfo or {} |
| 7771 |
local verticalheader=fontdata.verticalheader or {} |
| 7772 |
local filename=fontdata.filename |
| 7773 |
local weight=getname(fontdata,"weight") or (cffinfo and cffinfo.weight) or (metrics and metrics.weight) |
| 7774 |
local width=getname(fontdata,"width") or (cffinfo and cffinfo.width ) or (metrics and metrics.width ) |
| 7775 |
local fontname=getname(fontdata,"postscriptname") |
| 7776 |
local fullname=getname(fontdata,"fullname") |
| 7777 |
local family=getname(fontdata,"family") |
| 7778 |
local subfamily=getname(fontdata,"subfamily") |
| 7779 |
local familyname=getname(fontdata,"typographicfamily") |
| 7780 |
local subfamilyname=getname(fontdata,"typographicsubfamily") |
| 7781 |
local compatiblename=getname(fontdata,"compatiblefullname") |
| 7782 |
if rawfamilynames then |
| 7783 |
else |
| 7784 |
if not familyname then familyname=family end |
| 7785 |
if not subfamilyname then subfamilyname=subfamily end |
| 7786 |
end |
| 7787 |
if platformnames then |
| 7788 |
platformnames=fontdata.platformnames |
| 7789 |
end |
| 7790 |
if instancenames then |
| 7791 |
local variabledata=fontdata.variabledata |
| 7792 |
if variabledata then |
| 7793 |
local instances=variabledata and variabledata.instances |
| 7794 |
if instances then |
| 7795 |
instancenames={} |
| 7796 |
for i=1,#instances do |
| 7797 |
instancenames[i]=lower(stripstring(instances[i].subfamily)) |
| 7798 |
end |
| 7799 |
else |
| 7800 |
instancenames=nil |
| 7801 |
end |
| 7802 |
else |
| 7803 |
instancenames=nil |
| 7804 |
end |
| 7805 |
end |
| 7806 |
info={ |
| 7807 |
subfontindex=fontdata.subfontindex or sub or 0, |
| 7808 |
version=getname(fontdata,"version"), |
| 7809 |
fontname=fontname, |
| 7810 |
fullname=fullname, |
| 7811 |
family=family, |
| 7812 |
subfamily=subfamily, |
| 7813 |
familyname=familyname, |
| 7814 |
subfamilyname=subfamilyname, |
| 7815 |
compatiblename=compatiblename, |
| 7816 |
weight=weight and lower(weight), |
| 7817 |
width=width and lower(width), |
| 7818 |
pfmweight=metrics.weightclass or 400, |
| 7819 |
pfmwidth=metrics.widthclass or 5, |
| 7820 |
panosewidth=metrics.panosewidth, |
| 7821 |
panoseweight=metrics.panoseweight, |
| 7822 |
fstype=metrics.fstype or 0, |
| 7823 |
italicangle=postscript.italicangle or 0, |
| 7824 |
units=fontheader.units or 0, |
| 7825 |
designsize=fontdata.designsize, |
| 7826 |
minsize=fontdata.minsize, |
| 7827 |
maxsize=fontdata.maxsize, |
| 7828 |
boundingbox=fontheader and { fontheader.xmin or 0,fontheader.ymin or 0,fontheader.xmax or 0,fontheader.ymax or 0 } or nil, |
| 7829 |
monospaced=(tonumber(postscript.monospaced or 0)>0) or metrics.panosewidth=="monospaced", |
| 7830 |
averagewidth=metrics.averagewidth, |
| 7831 |
xheight=metrics.xheight, |
| 7832 |
capheight=metrics.capheight or fontdata.maxy, |
| 7833 |
ascender=metrics.typoascender, |
| 7834 |
descender=metrics.typodescender, |
| 7835 |
platformnames=platformnames or nil, |
| 7836 |
instancenames=instancenames or nil, |
| 7837 |
tableoffsets=fontdata.tableoffsets, |
| 7838 |
defaultvheight=(verticalheader.ascender or 0)-(verticalheader.descender or 0) |
| 7839 |
} |
| 7840 |
if metricstoo then |
| 7841 |
local keys={ |
| 7842 |
"version", |
| 7843 |
"ascender","descender","linegap", |
| 7844 |
"maxadvancewidth","maxadvanceheight","maxextent", |
| 7845 |
"minbottomsidebearing","mintopsidebearing", |
| 7846 |
} |
| 7847 |
local h=fontdata.horizontalheader or {} |
| 7848 |
local v=fontdata.verticalheader or {} |
| 7849 |
if h then |
| 7850 |
local th={} |
| 7851 |
local tv={} |
| 7852 |
for i=1,#keys do |
| 7853 |
local key=keys[i] |
| 7854 |
th[key]=h[key] or 0 |
| 7855 |
tv[key]=v[key] or 0 |
| 7856 |
end |
| 7857 |
info.horizontalmetrics=th |
| 7858 |
info.verticalmetrics=tv |
| 7859 |
end |
| 7860 |
end |
| 7861 |
elseif n then |
| 7862 |
info={ |
| 7863 |
filename=fontdata.filename, |
| 7864 |
comment="there is no info for subfont "..n, |
| 7865 |
} |
| 7866 |
else |
| 7867 |
info={ |
| 7868 |
filename=fontdata.filename, |
| 7869 |
comment="there is no info", |
| 7870 |
} |
| 7871 |
end |
| 7872 |
return info |
| 7873 |
end |
| 7874 |
local function loadtables(f,specification,offset) |
| 7875 |
if offset then |
| 7876 |
setposition(f,offset) |
| 7877 |
end |
| 7878 |
local tables={} |
| 7879 |
local basename=file.basename(specification.filename) |
| 7880 |
local filesize=specification.filesize |
| 7881 |
local filetime=specification.filetime |
| 7882 |
local fontdata={ |
| 7883 |
filename=basename, |
| 7884 |
filesize=filesize, |
| 7885 |
filetime=filetime, |
| 7886 |
version=readstring(f,4), |
| 7887 |
noftables=readushort(f), |
| 7888 |
searchrange=readushort(f), |
| 7889 |
entryselector=readushort(f), |
| 7890 |
rangeshift=readushort(f), |
| 7891 |
tables=tables, |
| 7892 |
foundtables=false, |
| 7893 |
} |
| 7894 |
for i=1,fontdata.noftables do |
| 7895 |
local tag=lower(stripstring(readstring(f,4))) |
| 7896 |
local checksum=readushort(f)*0x10000+readushort(f) |
| 7897 |
local offset=readulong(f) |
| 7898 |
local length=readulong(f) |
| 7899 |
if offset+length>filesize then |
| 7900 |
report("bad %a table in file %a",tag,basename) |
| 7901 |
end |
| 7902 |
tables[tag]={ |
| 7903 |
checksum=checksum, |
| 7904 |
offset=offset, |
| 7905 |
length=length, |
| 7906 |
} |
| 7907 |
end |
| 7908 |
fontdata.foundtables=sortedkeys(tables) |
| 7909 |
if tables.cff or tables.cff2 then |
| 7910 |
fontdata.format="opentype" |
| 7911 |
else |
| 7912 |
fontdata.format="truetype" |
| 7913 |
end |
| 7914 |
return fontdata,tables |
| 7915 |
end |
| 7916 |
local function prepareglyps(fontdata) |
| 7917 |
local glyphs=setmetatableindex(function(t,k) |
| 7918 |
local v={ |
| 7919 |
index=k, |
| 7920 |
} |
| 7921 |
t[k]=v |
| 7922 |
return v |
| 7923 |
end) |
| 7924 |
fontdata.glyphs=glyphs |
| 7925 |
fontdata.mapping={} |
| 7926 |
end |
| 7927 |
local function readtable(tag,f,fontdata,specification,...) |
| 7928 |
local reader=readers[tag] |
| 7929 |
if reader then |
| 7930 |
reader(f,fontdata,specification,...) |
| 7931 |
end |
| 7932 |
end |
| 7933 |
local function readdata(f,offset,specification) |
| 7934 |
local fontdata,tables=loadtables(f,specification,offset) |
| 7935 |
if specification.glyphs then |
| 7936 |
prepareglyps(fontdata) |
| 7937 |
end |
| 7938 |
fontdata.temporary={} |
| 7939 |
readtable("name",f,fontdata,specification) |
| 7940 |
local askedname=specification.askedname |
| 7941 |
if askedname then |
| 7942 |
local fullname=getname(fontdata,"fullname") or "" |
| 7943 |
local cleanname=gsub(askedname,"[^a-zA-Z0-9]","") |
| 7944 |
local foundname=gsub(fullname,"[^a-zA-Z0-9]","") |
| 7945 |
if lower(cleanname)~=lower(foundname) then |
| 7946 |
return |
| 7947 |
end |
| 7948 |
end |
| 7949 |
readtable("stat",f,fontdata,specification) |
| 7950 |
readtable("avar",f,fontdata,specification) |
| 7951 |
readtable("fvar",f,fontdata,specification) |
| 7952 |
local variabledata=fontdata.variabledata |
| 7953 |
if variabledata then |
| 7954 |
local instances=variabledata.instances |
| 7955 |
local axis=variabledata.axis |
| 7956 |
if axis and (not instances or #instances==0) then |
| 7957 |
instances={} |
| 7958 |
variabledata.instances=instances |
| 7959 |
local function add(n,subfamily,value) |
| 7960 |
local values={} |
| 7961 |
for i=1,#axis do |
| 7962 |
local a=axis[i] |
| 7963 |
values[i]={ |
| 7964 |
axis=a.tag, |
| 7965 |
value=i==n and value or a.default, |
| 7966 |
} |
| 7967 |
end |
| 7968 |
instances[#instances+1]={ |
| 7969 |
subfamily=subfamily, |
| 7970 |
values=values, |
| 7971 |
} |
| 7972 |
end |
| 7973 |
for i=1,#axis do |
| 7974 |
local a=axis[i] |
| 7975 |
local tag=a.tag |
| 7976 |
add(i,"default"..tag,a.default) |
| 7977 |
add(i,"minimum"..tag,a.minimum) |
| 7978 |
add(i,"maximum"..tag,a.maximum) |
| 7979 |
end |
| 7980 |
end |
| 7981 |
end |
| 7982 |
if not specification.factors then |
| 7983 |
local instance=specification.instance |
| 7984 |
if type(instance)=="string" then |
| 7985 |
local factors=helpers.getfactors(fontdata,instance) |
| 7986 |
if factors then |
| 7987 |
specification.factors=factors |
| 7988 |
fontdata.factors=factors |
| 7989 |
fontdata.instance=instance |
| 7990 |
report("user instance: %s, factors: % t",instance,factors) |
| 7991 |
else |
| 7992 |
report("user instance: %s, bad factors",instance) |
| 7993 |
end |
| 7994 |
end |
| 7995 |
end |
| 7996 |
if not fontdata.factors then |
| 7997 |
if fontdata.variabledata then |
| 7998 |
local factors=helpers.getfactors(fontdata,true) |
| 7999 |
if factors then |
| 8000 |
specification.factors=factors |
| 8001 |
fontdata.factors=factors |
| 8002 |
end |
| 8003 |
else |
| 8004 |
end |
| 8005 |
end |
| 8006 |
readtable("os/2",f,fontdata,specification) |
| 8007 |
readtable("head",f,fontdata,specification) |
| 8008 |
readtable("maxp",f,fontdata,specification) |
| 8009 |
readtable("hhea",f,fontdata,specification) |
| 8010 |
readtable("vhea",f,fontdata,specification) |
| 8011 |
readtable("hmtx",f,fontdata,specification) |
| 8012 |
readtable("vmtx",f,fontdata,specification) |
| 8013 |
readtable("vorg",f,fontdata,specification) |
| 8014 |
readtable("post",f,fontdata,specification) |
| 8015 |
readtable("mvar",f,fontdata,specification) |
| 8016 |
readtable("hvar",f,fontdata,specification) |
| 8017 |
readtable("vvar",f,fontdata,specification) |
| 8018 |
readtable("gdef",f,fontdata,specification) |
| 8019 |
readtable("cff",f,fontdata,specification) |
| 8020 |
readtable("cff2",f,fontdata,specification) |
| 8021 |
readtable("cmap",f,fontdata,specification) |
| 8022 |
readtable("loca",f,fontdata,specification) |
| 8023 |
readtable("glyf",f,fontdata,specification) |
| 8024 |
readtable("colr",f,fontdata,specification) |
| 8025 |
readtable("cpal",f,fontdata,specification) |
| 8026 |
readtable("svg",f,fontdata,specification) |
| 8027 |
readtable("sbix",f,fontdata,specification) |
| 8028 |
readtable("cbdt",f,fontdata,specification) |
| 8029 |
readtable("cblc",f,fontdata,specification) |
| 8030 |
readtable("ebdt",f,fontdata,specification) |
| 8031 |
readtable("eblc",f,fontdata,specification) |
| 8032 |
readtable("kern",f,fontdata,specification) |
| 8033 |
readtable("gsub",f,fontdata,specification) |
| 8034 |
readtable("gpos",f,fontdata,specification) |
| 8035 |
readtable("math",f,fontdata,specification) |
| 8036 |
fontdata.locations=nil |
| 8037 |
fontdata.cidmaps=nil |
| 8038 |
fontdata.dictionaries=nil |
| 8039 |
if specification.tableoffsets then |
| 8040 |
fontdata.tableoffsets=tables |
| 8041 |
setmetatableindex(tables,{ |
| 8042 |
version=fontdata.version, |
| 8043 |
noftables=fontdata.noftables, |
| 8044 |
searchrange=fontdata.searchrange, |
| 8045 |
entryselector=fontdata.entryselector, |
| 8046 |
rangeshift=fontdata.rangeshift, |
| 8047 |
}) |
| 8048 |
end |
| 8049 |
return fontdata |
| 8050 |
end |
| 8051 |
local function loadfontdata(specification) |
| 8052 |
local filename=specification.filename |
| 8053 |
local fileattr=lfs.attributes(filename) |
| 8054 |
local filesize=fileattr and fileattr.size or 0 |
| 8055 |
local filetime=fileattr and fileattr.modification or 0 |
| 8056 |
local f=openfile(filename,true) |
| 8057 |
if not f then |
| 8058 |
report("unable to open %a",filename) |
| 8059 |
elseif filesize==0 then |
| 8060 |
report("empty file %a",filename) |
| 8061 |
closefile(f) |
| 8062 |
else |
| 8063 |
specification.filesize=filesize |
| 8064 |
specification.filetime=filetime |
| 8065 |
local version=readstring(f,4) |
| 8066 |
local fontdata=nil |
| 8067 |
if version=="OTTO" or version=="true" or version=="\0\1\0\0" then |
| 8068 |
fontdata=readdata(f,0,specification) |
| 8069 |
elseif version=="ttcf" then |
| 8070 |
local subfont=tonumber(specification.subfont) |
| 8071 |
local ttcversion=readulong(f) |
| 8072 |
local nofsubfonts=readulong(f) |
| 8073 |
local offsets=readcardinaltable(f,nofsubfonts,ulong) |
| 8074 |
if subfont then |
| 8075 |
if subfont>=1 and subfont<=nofsubfonts then |
| 8076 |
fontdata=readdata(f,offsets[subfont],specification) |
| 8077 |
else |
| 8078 |
report("no subfont %a in file %a",subfont,filename) |
| 8079 |
end |
| 8080 |
else |
| 8081 |
subfont=specification.subfont |
| 8082 |
if type(subfont)=="string" and subfont~="" then |
| 8083 |
specification.askedname=subfont |
| 8084 |
for i=1,nofsubfonts do |
| 8085 |
fontdata=readdata(f,offsets[i],specification) |
| 8086 |
if fontdata then |
| 8087 |
fontdata.subfontindex=i |
| 8088 |
report("subfont named %a has index %a",subfont,i) |
| 8089 |
break |
| 8090 |
end |
| 8091 |
end |
| 8092 |
if not fontdata then |
| 8093 |
report("no subfont named %a",subfont) |
| 8094 |
end |
| 8095 |
else |
| 8096 |
local subfonts={} |
| 8097 |
fontdata={ |
| 8098 |
filename=filename, |
| 8099 |
filesize=filesize, |
| 8100 |
filetime=filetime, |
| 8101 |
version=version, |
| 8102 |
subfonts=subfonts, |
| 8103 |
ttcversion=ttcversion, |
| 8104 |
nofsubfonts=nofsubfonts, |
| 8105 |
} |
| 8106 |
for i=1,nofsubfonts do |
| 8107 |
subfonts[i]=readdata(f,offsets[i],specification) |
| 8108 |
end |
| 8109 |
end |
| 8110 |
end |
| 8111 |
else |
| 8112 |
report("unknown version %a in file %a",version,filename) |
| 8113 |
end |
| 8114 |
closefile(f) |
| 8115 |
return fontdata or {} |
| 8116 |
end |
| 8117 |
end |
| 8118 |
local function loadfont(specification,n,instance) |
| 8119 |
if type(specification)=="string" then |
| 8120 |
specification={ |
| 8121 |
filename=specification, |
| 8122 |
info=true, |
| 8123 |
details=true, |
| 8124 |
glyphs=true, |
| 8125 |
shapes=true, |
| 8126 |
kerns=true, |
| 8127 |
variable=true, |
| 8128 |
globalkerns=true, |
| 8129 |
lookups=true, |
| 8130 |
subfont=n or true, |
| 8131 |
tounicode=false, |
| 8132 |
instance=instance |
| 8133 |
} |
| 8134 |
end |
| 8135 |
if specification.shapes or specification.lookups or specification.kerns then |
| 8136 |
specification.glyphs=true |
| 8137 |
end |
| 8138 |
if specification.glyphs then |
| 8139 |
specification.details=true |
| 8140 |
end |
| 8141 |
if specification.details then |
| 8142 |
specification.info=true |
| 8143 |
end |
| 8144 |
if specification.platformnames then |
| 8145 |
specification.platformnames=true |
| 8146 |
end |
| 8147 |
if specification.instance or instance then |
| 8148 |
specification.variable=true |
| 8149 |
specification.instance=specification.instance or instance |
| 8150 |
end |
| 8151 |
local function message(str) |
| 8152 |
report("fatal error in file %a: %s\n%s",specification.filename,str,debug and debug.traceback()) |
| 8153 |
end |
| 8154 |
local ok,result=xpcall(loadfontdata,message,specification) |
| 8155 |
if ok then |
| 8156 |
return result |
| 8157 |
end |
| 8158 |
end |
| 8159 |
function readers.loadshapes(filename,n,instance,streams) |
| 8160 |
local fontdata=loadfont { |
| 8161 |
filename=filename, |
| 8162 |
shapes=true, |
| 8163 |
streams=streams, |
| 8164 |
variable=true, |
| 8165 |
subfont=n, |
| 8166 |
instance=instance, |
| 8167 |
} |
| 8168 |
if fontdata then |
| 8169 |
for k,v in next,fontdata.glyphs do |
| 8170 |
v.class=nil |
| 8171 |
v.index=nil |
| 8172 |
v.math=nil |
| 8173 |
end |
| 8174 |
local names=fontdata.names |
| 8175 |
if names then |
| 8176 |
for k,v in next,names do |
| 8177 |
names[k]=fullstrip(v.content) |
| 8178 |
end |
| 8179 |
end |
| 8180 |
end |
| 8181 |
return fontdata and { |
| 8182 |
filename=filename, |
| 8183 |
format=fontdata.format, |
| 8184 |
glyphs=fontdata.glyphs, |
| 8185 |
units=fontdata.fontheader.units, |
| 8186 |
cffinfo=fontdata.cffinfo, |
| 8187 |
fontheader=fontdata.fontheader, |
| 8188 |
horizontalheader=fontdata.horizontalheader, |
| 8189 |
verticalheader=fontdata.verticalheader, |
| 8190 |
maximumprofile=fontdata.maximumprofile, |
| 8191 |
names=fontdata.names, |
| 8192 |
postscript=fontdata.postscript, |
| 8193 |
} or { |
| 8194 |
filename=filename, |
| 8195 |
format="unknown", |
| 8196 |
glyphs={}, |
| 8197 |
units=0, |
| 8198 |
} |
| 8199 |
end |
| 8200 |
function readers.loadfont(filename,n,instance) |
| 8201 |
local fontdata=loadfont { |
| 8202 |
filename=filename, |
| 8203 |
glyphs=true, |
| 8204 |
shapes=false, |
| 8205 |
lookups=true, |
| 8206 |
variable=true, |
| 8207 |
subfont=n, |
| 8208 |
instance=instance, |
| 8209 |
} |
| 8210 |
if fontdata then |
| 8211 |
return { |
| 8212 |
tableversion=tableversion, |
| 8213 |
creator="context mkiv", |
| 8214 |
size=fontdata.filesize, |
| 8215 |
time=fontdata.filetime, |
| 8216 |
glyphs=fontdata.glyphs, |
| 8217 |
descriptions=fontdata.descriptions, |
| 8218 |
format=fontdata.format, |
| 8219 |
goodies={}, |
| 8220 |
metadata=getinfo(fontdata,n,false,false,true,true), |
| 8221 |
properties={ |
| 8222 |
hasitalics=fontdata.hasitalics or false, |
| 8223 |
maxcolorclass=fontdata.maxcolorclass, |
| 8224 |
hascolor=fontdata.hascolor or false, |
| 8225 |
instance=fontdata.instance, |
| 8226 |
factors=fontdata.factors, |
| 8227 |
nofsubfonts=fontdata.subfonts and #fontdata.subfonts or nil, |
| 8228 |
}, |
| 8229 |
resources={ |
| 8230 |
filename=filename, |
| 8231 |
private=privateoffset, |
| 8232 |
duplicates=fontdata.duplicates or {}, |
| 8233 |
features=fontdata.features or {}, |
| 8234 |
sublookups=fontdata.sublookups or {}, |
| 8235 |
marks=fontdata.marks or {}, |
| 8236 |
markclasses=fontdata.markclasses or {}, |
| 8237 |
marksets=fontdata.marksets or {}, |
| 8238 |
sequences=fontdata.sequences or {}, |
| 8239 |
variants=fontdata.variants, |
| 8240 |
version=getname(fontdata,"version"), |
| 8241 |
cidinfo=fontdata.cidinfo, |
| 8242 |
mathconstants=fontdata.mathconstants, |
| 8243 |
colorpalettes=fontdata.colorpalettes, |
| 8244 |
colorpaintdata=fontdata.colorpaintdata, |
| 8245 |
colorpaintlist=fontdata.colorpaintlist, |
| 8246 |
colorlinesdata=fontdata.colorlinesdata, |
| 8247 |
coloraffinedata=fontdata.coloraffinedata, |
| 8248 |
svgshapes=fontdata.svgshapes, |
| 8249 |
pngshapes=fontdata.pngshapes, |
| 8250 |
variabledata=fontdata.variabledata, |
| 8251 |
foundtables=fontdata.foundtables, |
| 8252 |
}, |
| 8253 |
} |
| 8254 |
end |
| 8255 |
end |
| 8256 |
function readers.getinfo(filename,specification) |
| 8257 |
local subfont=nil |
| 8258 |
local platformnames=false |
| 8259 |
local rawfamilynames=false |
| 8260 |
local instancenames=true |
| 8261 |
local tableoffsets=false |
| 8262 |
if type(specification)=="table" then |
| 8263 |
subfont=tonumber(specification.subfont) |
| 8264 |
platformnames=specification.platformnames |
| 8265 |
rawfamilynames=specification.rawfamilynames |
| 8266 |
tableoffsets=specification.tableoffsets |
| 8267 |
else |
| 8268 |
subfont=tonumber(specification) |
| 8269 |
end |
| 8270 |
local fontdata=loadfont { |
| 8271 |
filename=filename, |
| 8272 |
details=true, |
| 8273 |
platformnames=platformnames, |
| 8274 |
instancenames=true, |
| 8275 |
tableoffsets=tableoffsets, |
| 8276 |
} |
| 8277 |
if fontdata then |
| 8278 |
local subfonts=fontdata.subfonts |
| 8279 |
if not subfonts then |
| 8280 |
return getinfo(fontdata,nil,platformnames,rawfamilynames,false,instancenames) |
| 8281 |
elseif not subfont then |
| 8282 |
local info={} |
| 8283 |
for i=1,#subfonts do |
| 8284 |
info[i]=getinfo(fontdata,i,platformnames,rawfamilynames,false,instancenames) |
| 8285 |
end |
| 8286 |
return info |
| 8287 |
elseif subfont>=1 and subfont<=#subfonts then |
| 8288 |
return getinfo(fontdata,subfont,platformnames,rawfamilynames,false,instancenames) |
| 8289 |
else |
| 8290 |
return { |
| 8291 |
filename=filename, |
| 8292 |
comment="there is no subfont "..subfont.." in this file" |
| 8293 |
} |
| 8294 |
end |
| 8295 |
else |
| 8296 |
return { |
| 8297 |
filename=filename, |
| 8298 |
comment="the file cannot be opened for reading", |
| 8299 |
} |
| 8300 |
end |
| 8301 |
end |
| 8302 |
function readers.rehash() |
| 8303 |
report("the %a helper is not yet implemented","rehash") |
| 8304 |
end |
| 8305 |
function readers.checkhash() |
| 8306 |
report("the %a helper is not yet implemented","checkhash") |
| 8307 |
end |
| 8308 |
function readers.pack() |
| 8309 |
report("the %a helper is not yet implemented","pack") |
| 8310 |
end |
| 8311 |
function readers.unpack(fontdata) |
| 8312 |
report("the %a helper is not yet implemented","unpack") |
| 8313 |
end |
| 8314 |
function readers.expand(fontdata) |
| 8315 |
report("the %a helper is not yet implemented","unpack") |
| 8316 |
end |
| 8317 |
function readers.compact(fontdata) |
| 8318 |
report("the %a helper is not yet implemented","compact") |
| 8319 |
end |
| 8320 |
function readers.condense(fontdata) |
| 8321 |
report("the %a helper is not yet implemented","condense") |
| 8322 |
end |
| 8323 |
local extenders={} |
| 8324 |
function readers.registerextender(extender) |
| 8325 |
extenders[#extenders+1]=extender |
| 8326 |
end |
| 8327 |
function readers.extend(fontdata) |
| 8328 |
for i=1,#extenders do |
| 8329 |
local extender=extenders[i] |
| 8330 |
local name=extender.name or "unknown" |
| 8331 |
local action=extender.action |
| 8332 |
if action then |
| 8333 |
action(fontdata) |
| 8334 |
end |
| 8335 |
end |
| 8336 |
end |
| 8337 |
|
| 8338 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-otr”] --- |
| 8339 |
|
| 8340 |
|
| 8341 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-oti” 309a75f9c14b77d87e94eba827dc4e71] --- |
| 8342 |
|
| 8343 |
if not modules then modules={} end modules ['font-oti']={ |
| 8344 |
version=1.001, |
| 8345 |
comment="companion to font-ini.mkiv", |
| 8346 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 8347 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 8348 |
license="see context related readme files" |
| 8349 |
} |
| 8350 |
local lower=string.lower |
| 8351 |
local fonts=fonts |
| 8352 |
local constructors=fonts.constructors |
| 8353 |
local otf=constructors.handlers.otf |
| 8354 |
local otffeatures=constructors.features.otf |
| 8355 |
local registerotffeature=otffeatures.register |
| 8356 |
local otftables=otf.tables or {} |
| 8357 |
otf.tables=otftables |
| 8358 |
local allocate=utilities.storage.allocate |
| 8359 |
registerotffeature { |
| 8360 |
name="features", |
| 8361 |
description="initialization of feature handler", |
| 8362 |
default=true, |
| 8363 |
} |
| 8364 |
local function setmode(tfmdata,value) |
| 8365 |
if value then |
| 8366 |
tfmdata.properties.mode=lower(value) |
| 8367 |
end |
| 8368 |
end |
| 8369 |
otf.modeinitializer=setmode |
| 8370 |
local function setlanguage(tfmdata,value) |
| 8371 |
if value then |
| 8372 |
local cleanvalue=lower(value) |
| 8373 |
local languages=otftables and otftables.languages |
| 8374 |
local properties=tfmdata.properties |
| 8375 |
if not languages then |
| 8376 |
properties.language=cleanvalue |
| 8377 |
elseif languages[value] then |
| 8378 |
properties.language=cleanvalue |
| 8379 |
else |
| 8380 |
properties.language="dflt" |
| 8381 |
end |
| 8382 |
end |
| 8383 |
end |
| 8384 |
local function setscript(tfmdata,value) |
| 8385 |
if value then |
| 8386 |
local cleanvalue=lower(value) |
| 8387 |
local scripts=otftables and otftables.scripts |
| 8388 |
local properties=tfmdata.properties |
| 8389 |
if not scripts then |
| 8390 |
properties.script=cleanvalue |
| 8391 |
elseif scripts[value] then |
| 8392 |
properties.script=cleanvalue |
| 8393 |
else |
| 8394 |
properties.script="dflt" |
| 8395 |
end |
| 8396 |
end |
| 8397 |
end |
| 8398 |
registerotffeature { |
| 8399 |
name="mode", |
| 8400 |
description="mode", |
| 8401 |
initializers={ |
| 8402 |
base=setmode, |
| 8403 |
node=setmode, |
| 8404 |
plug=setmode, |
| 8405 |
} |
| 8406 |
} |
| 8407 |
registerotffeature { |
| 8408 |
name="language", |
| 8409 |
description="language", |
| 8410 |
initializers={ |
| 8411 |
base=setlanguage, |
| 8412 |
node=setlanguage, |
| 8413 |
plug=setlanguage, |
| 8414 |
} |
| 8415 |
} |
| 8416 |
registerotffeature { |
| 8417 |
name="script", |
| 8418 |
description="script", |
| 8419 |
initializers={ |
| 8420 |
base=setscript, |
| 8421 |
node=setscript, |
| 8422 |
plug=setscript, |
| 8423 |
} |
| 8424 |
} |
| 8425 |
otftables.featuretypes=allocate { |
| 8426 |
gpos_single="position", |
| 8427 |
gpos_pair="position", |
| 8428 |
gpos_cursive="position", |
| 8429 |
gpos_mark2base="position", |
| 8430 |
gpos_mark2ligature="position", |
| 8431 |
gpos_mark2mark="position", |
| 8432 |
gpos_context="position", |
| 8433 |
gpos_contextchain="position", |
| 8434 |
gsub_single="substitution", |
| 8435 |
gsub_multiple="substitution", |
| 8436 |
gsub_alternate="substitution", |
| 8437 |
gsub_ligature="substitution", |
| 8438 |
gsub_context="substitution", |
| 8439 |
gsub_contextchain="substitution", |
| 8440 |
gsub_reversecontextchain="substitution", |
| 8441 |
gsub_reversesub="substitution", |
| 8442 |
} |
| 8443 |
function otffeatures.checkeddefaultscript(featuretype,autoscript,scripts) |
| 8444 |
if featuretype=="position" then |
| 8445 |
local default=scripts.dflt |
| 8446 |
if default then |
| 8447 |
if autoscript=="position" or autoscript==true then |
| 8448 |
return default |
| 8449 |
else |
| 8450 |
report_otf("script feature %s not applied, enable default positioning") |
| 8451 |
end |
| 8452 |
else |
| 8453 |
end |
| 8454 |
elseif featuretype=="substitution" then |
| 8455 |
local default=scripts.dflt |
| 8456 |
if default then |
| 8457 |
if autoscript=="substitution" or autoscript==true then |
| 8458 |
return default |
| 8459 |
end |
| 8460 |
end |
| 8461 |
end |
| 8462 |
end |
| 8463 |
function otffeatures.checkeddefaultlanguage(featuretype,autolanguage,languages) |
| 8464 |
if featuretype=="position" then |
| 8465 |
local default=languages.dflt |
| 8466 |
if default then |
| 8467 |
if autolanguage=="position" or autolanguage==true then |
| 8468 |
return default |
| 8469 |
else |
| 8470 |
report_otf("language feature %s not applied, enable default positioning") |
| 8471 |
end |
| 8472 |
else |
| 8473 |
end |
| 8474 |
elseif featuretype=="substitution" then |
| 8475 |
local default=languages.dflt |
| 8476 |
if default then |
| 8477 |
if autolanguage=="substitution" or autolanguage==true then |
| 8478 |
return default |
| 8479 |
end |
| 8480 |
end |
| 8481 |
end |
| 8482 |
end |
| 8483 |
|
| 8484 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-oti”] --- |
| 8485 |
|
| 8486 |
|
| 8487 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ott” 427bdc77dd187158eafb79b7193400dc] --- |
| 8488 |
|
| 8489 |
if not modules then modules={} end modules ["font-ott"]={ |
| 8490 |
version=1.001, |
| 8491 |
comment="companion to font-ini.mkiv", |
| 8492 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 8493 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 8494 |
license="see context related readme files", |
| 8495 |
} |
| 8496 |
local type,next,tonumber,tostring,rawget,rawset=type,next,tonumber,tostring,rawget,rawset |
| 8497 |
local gsub,lower,format,match,gmatch,find=string.gsub,string.lower,string.format,string.match,string.gmatch,string.find |
| 8498 |
local sequenced=table.sequenced |
| 8499 |
local is_boolean=string.is_boolean |
| 8500 |
local setmetatableindex=table.setmetatableindex |
| 8501 |
local setmetatablenewindex=table.setmetatablenewindex |
| 8502 |
local allocate=utilities.storage.allocate |
| 8503 |
local fonts=fonts |
| 8504 |
local otf=fonts.handlers.otf |
| 8505 |
local otffeatures=otf.features |
| 8506 |
local tables=otf.tables or {} |
| 8507 |
otf.tables=tables |
| 8508 |
local statistics=otf.statistics or {} |
| 8509 |
otf.statistics=statistics |
| 8510 |
local scripts=allocate { |
| 8511 |
["adlm"]="adlam", |
| 8512 |
["aghb"]="caucasian albanian", |
| 8513 |
["ahom"]="ahom", |
| 8514 |
["arab"]="arabic", |
| 8515 |
["armi"]="imperial aramaic", |
| 8516 |
["armn"]="armenian", |
| 8517 |
["avst"]="avestan", |
| 8518 |
["bali"]="balinese", |
| 8519 |
["bamu"]="bamum", |
| 8520 |
["bass"]="bassa vah", |
| 8521 |
["batk"]="batak", |
| 8522 |
["beng"]="bengali", |
| 8523 |
["bhks"]="bhaiksuki", |
| 8524 |
["bng2"]="bengali variant 2", |
| 8525 |
["bopo"]="bopomofo", |
| 8526 |
["brah"]="brahmi", |
| 8527 |
["brai"]="braille", |
| 8528 |
["bugi"]="buginese", |
| 8529 |
["buhd"]="buhid", |
| 8530 |
["byzm"]="byzantine music", |
| 8531 |
["cakm"]="chakma", |
| 8532 |
["cans"]="canadian syllabics", |
| 8533 |
["cari"]="carian", |
| 8534 |
["cham"]="cham", |
| 8535 |
["cher"]="cherokee", |
| 8536 |
["chrs"]="chorasmian", |
| 8537 |
["copt"]="coptic", |
| 8538 |
["cpmn"]="cypro-minoan", |
| 8539 |
["cprt"]="cypriot syllabary", |
| 8540 |
["cyrl"]="cyrillic", |
| 8541 |
["dev2"]="devanagari variant 2", |
| 8542 |
["deva"]="devanagari", |
| 8543 |
["diak"]="dives akuru", |
| 8544 |
["dogr"]="dogra", |
| 8545 |
["dsrt"]="deseret", |
| 8546 |
["dupl"]="duployan", |
| 8547 |
["egyp"]="egyptian heiroglyphs", |
| 8548 |
["elba"]="elbasan", |
| 8549 |
["elym"]="elymaic", |
| 8550 |
["ethi"]="ethiopic", |
| 8551 |
["geor"]="georgian", |
| 8552 |
["gjr2"]="gujarati variant 2", |
| 8553 |
["glag"]="glagolitic", |
| 8554 |
["gong"]="gunjala gondi", |
| 8555 |
["gonm"]="masaram gondi", |
| 8556 |
["goth"]="gothic", |
| 8557 |
["gran"]="grantha", |
| 8558 |
["grek"]="greek", |
| 8559 |
["gujr"]="gujarati", |
| 8560 |
["gur2"]="gurmukhi variant 2", |
| 8561 |
["guru"]="gurmukhi", |
| 8562 |
["hang"]="hangul", |
| 8563 |
["hani"]="cjk ideographic", |
| 8564 |
["hano"]="hanunoo", |
| 8565 |
["hatr"]="hatran", |
| 8566 |
["hebr"]="hebrew", |
| 8567 |
["hluw"]="anatolian hieroglyphs", |
| 8568 |
["hmng"]="pahawh hmong", |
| 8569 |
["hmnp"]="nyiakeng puachue hmong", |
| 8570 |
["hung"]="old hungarian", |
| 8571 |
["ital"]="old italic", |
| 8572 |
["jamo"]="hangul jamo", |
| 8573 |
["java"]="javanese", |
| 8574 |
["kali"]="kayah li", |
| 8575 |
["kana"]="hiragana and katakana", |
| 8576 |
["khar"]="kharosthi", |
| 8577 |
["khmr"]="khmer", |
| 8578 |
["khoj"]="khojki", |
| 8579 |
["kits"]="khitan small script", |
| 8580 |
["knd2"]="kannada variant 2", |
| 8581 |
["knda"]="kannada", |
| 8582 |
["kthi"]="kaithi", |
| 8583 |
["lana"]="tai tham", |
| 8584 |
["lao" ]="lao", |
| 8585 |
["latn"]="latin", |
| 8586 |
["lepc"]="lepcha", |
| 8587 |
["limb"]="limbu", |
| 8588 |
["lina"]="linear a", |
| 8589 |
["linb"]="linear b", |
| 8590 |
["lisu"]="lisu", |
| 8591 |
["lyci"]="lycian", |
| 8592 |
["lydi"]="lydian", |
| 8593 |
["mahj"]="mahajani", |
| 8594 |
["maka"]="makasar", |
| 8595 |
["mand"]="mandaic and mandaean", |
| 8596 |
["mani"]="manichaean", |
| 8597 |
["marc"]="marchen", |
| 8598 |
["math"]="mathematical alphanumeric symbols", |
| 8599 |
["medf"]="medefaidrin", |
| 8600 |
["mend"]="mende kikakui", |
| 8601 |
["merc"]="meroitic cursive", |
| 8602 |
["mero"]="meroitic hieroglyphs", |
| 8603 |
["mlm2"]="malayalam variant 2", |
| 8604 |
["mlym"]="malayalam", |
| 8605 |
["modi"]="modi", |
| 8606 |
["mong"]="mongolian", |
| 8607 |
["mroo"]="mro", |
| 8608 |
["mtei"]="meitei Mayek", |
| 8609 |
["mult"]="multani", |
| 8610 |
["musc"]="musical symbols", |
| 8611 |
["mym2"]="myanmar variant 2", |
| 8612 |
["mymr"]="myanmar", |
| 8613 |
["nand"]="nandinagari", |
| 8614 |
["narb"]="old north arabian", |
| 8615 |
["nbat"]="nabataean", |
| 8616 |
["newa"]="newa", |
| 8617 |
["nko" ]='n"ko', |
| 8618 |
["nshu"]="nüshu", |
| 8619 |
["ogam"]="ogham", |
| 8620 |
["olck"]="ol chiki", |
| 8621 |
["orkh"]="old turkic and orkhon runic", |
| 8622 |
["ory2"]="odia variant 2", |
| 8623 |
["orya"]="odia", |
| 8624 |
["osge"]="osage", |
| 8625 |
["osma"]="osmanya", |
| 8626 |
["ougr"]="old uyghur", |
| 8627 |
["palm"]="palmyrene", |
| 8628 |
["pauc"]="pau cin hau", |
| 8629 |
["perm"]="old permic", |
| 8630 |
["phag"]="phags-pa", |
| 8631 |
["phli"]="inscriptional pahlavi", |
| 8632 |
["phlp"]="psalter pahlavi", |
| 8633 |
["phnx"]="phoenician", |
| 8634 |
["plrd"]="miao", |
| 8635 |
["prti"]="inscriptional parthian", |
| 8636 |
["rjng"]="rejang", |
| 8637 |
["rohg"]="hanifi rohingya", |
| 8638 |
["runr"]="runic", |
| 8639 |
["samr"]="samaritan", |
| 8640 |
["sarb"]="old south arabian", |
| 8641 |
["saur"]="saurashtra", |
| 8642 |
["sgnw"]="sign writing", |
| 8643 |
["shaw"]="shavian", |
| 8644 |
["shrd"]="sharada", |
| 8645 |
["sidd"]="siddham", |
| 8646 |
["sind"]="khudawadi", |
| 8647 |
["sinh"]="sinhala", |
| 8648 |
["sogd"]="sogdian", |
| 8649 |
["sogo"]="old sogdian", |
| 8650 |
["sora"]="sora sompeng", |
| 8651 |
["soyo"]="soyombo", |
| 8652 |
["sund"]="sundanese", |
| 8653 |
["sylo"]="syloti nagri", |
| 8654 |
["syrc"]="syriac", |
| 8655 |
["tagb"]="tagbanwa", |
| 8656 |
["takr"]="takri", |
| 8657 |
["tale"]="tai le", |
| 8658 |
["talu"]="new tai lue", |
| 8659 |
["taml"]="tamil", |
| 8660 |
["tang"]="tangut", |
| 8661 |
["tavt"]="tai viet", |
| 8662 |
["tel2"]="telugu variant 2", |
| 8663 |
["telu"]="telugu", |
| 8664 |
["tfng"]="tifinagh", |
| 8665 |
["tglg"]="tagalog", |
| 8666 |
["thaa"]="thaana", |
| 8667 |
["thai"]="thai", |
| 8668 |
["tibt"]="tibetan", |
| 8669 |
["tirh"]="tirhuta", |
| 8670 |
["tnsa"]="tangsa", |
| 8671 |
["tml2"]="tamil variant 2", |
| 8672 |
["toto"]="toto", |
| 8673 |
["ugar"]="ugaritic cuneiform", |
| 8674 |
["vai" ]="vai", |
| 8675 |
["wara"]="warang citi", |
| 8676 |
["wcho"]="wancho", |
| 8677 |
["xpeo"]="old persian cuneiform", |
| 8678 |
["xsux"]="sumero-akkadian cuneiform", |
| 8679 |
["yezi"]="yezidi", |
| 8680 |
["yi" ]="yi", |
| 8681 |
["zanb"]="zanabazar square", |
| 8682 |
} |
| 8683 |
local languages=allocate { |
| 8684 |
["aba" ]="abaza", |
| 8685 |
["abk" ]="abkhazian", |
| 8686 |
["ach" ]="acholi", |
| 8687 |
["acr" ]="achi", |
| 8688 |
["ady" ]="adyghe", |
| 8689 |
["afk" ]="afrikaans", |
| 8690 |
["afr" ]="afar", |
| 8691 |
["agw" ]="agaw", |
| 8692 |
["aio" ]="aiton", |
| 8693 |
["aka" ]="akan", |
| 8694 |
["akb" ]="batak angkola", |
| 8695 |
["als" ]="alsatian", |
| 8696 |
["alt" ]="altai", |
| 8697 |
["amh" ]="amharic", |
| 8698 |
["ang" ]="anglo-saxon", |
| 8699 |
["apph"]="phonetic transcription—americanist conventions", |
| 8700 |
["ara" ]="arabic", |
| 8701 |
["arg" ]="aragonese", |
| 8702 |
["ari" ]="aari", |
| 8703 |
["ark" ]="rakhine", |
| 8704 |
["asm" ]="assamese", |
| 8705 |
["ast" ]="asturian", |
| 8706 |
["ath" ]="athapaskan", |
| 8707 |
["avn" ]="avatime", |
| 8708 |
["avr" ]="avar", |
| 8709 |
["awa" ]="awadhi", |
| 8710 |
["aym" ]="aymara", |
| 8711 |
["azb" ]="torki", |
| 8712 |
["aze" ]="azerbaijani", |
| 8713 |
["bad" ]="badaga", |
| 8714 |
["bad0"]="banda", |
| 8715 |
["bag" ]="baghelkhandi", |
| 8716 |
["bal" ]="balkar", |
| 8717 |
["ban" ]="balinese", |
| 8718 |
["bar" ]="bavarian", |
| 8719 |
["bau" ]="baulé", |
| 8720 |
["bbc" ]="batak toba", |
| 8721 |
["bbr" ]="berber", |
| 8722 |
["bch" ]="bench", |
| 8723 |
["bcr" ]="bible cree", |
| 8724 |
["bdy" ]="bandjalang", |
| 8725 |
["bel" ]="belarussian", |
| 8726 |
["bem" ]="bemba", |
| 8727 |
["ben" ]="bengali", |
| 8728 |
["bgc" ]="haryanvi", |
| 8729 |
["bgq" ]="bagri", |
| 8730 |
["bgr" ]="bulgarian", |
| 8731 |
["bhi" ]="bhili", |
| 8732 |
["bho" ]="bhojpuri", |
| 8733 |
["bik" ]="bikol", |
| 8734 |
["bil" ]="bilen", |
| 8735 |
["bis" ]="bislama", |
| 8736 |
["bjj" ]="kanauji", |
| 8737 |
["bkf" ]="blackfoot", |
| 8738 |
["bli" ]="baluchi", |
| 8739 |
["blk" ]="pa'o karen", |
| 8740 |
["bln" ]="balante", |
| 8741 |
["blt" ]="balti", |
| 8742 |
["bmb" ]="bambara (bamanankan)", |
| 8743 |
["bml" ]="bamileke", |
| 8744 |
["bos" ]="bosnian", |
| 8745 |
["bpy" ]="bishnupriya manipuri", |
| 8746 |
["bre" ]="breton", |
| 8747 |
["brh" ]="brahui", |
| 8748 |
["bri" ]="braj bhasha", |
| 8749 |
["brm" ]="burmese", |
| 8750 |
["brx" ]="bodo", |
| 8751 |
["bsh" ]="bashkir", |
| 8752 |
["bsk" ]="burushaski", |
| 8753 |
["bta" ]="batak alas kluet", |
| 8754 |
["btd" ]="batak dairi (pakpak)", |
| 8755 |
["bti" ]="beti", |
| 8756 |
["btm" ]="batak mandailing", |
| 8757 |
["bts" ]="batak simalungun", |
| 8758 |
["btx" ]="batak karo", |
| 8759 |
["bug" ]="bugis", |
| 8760 |
["byv" ]="medumba", |
| 8761 |
["cak" ]="kaqchikel", |
| 8762 |
["cat" ]="catalan", |
| 8763 |
["cbk" ]="zamboanga chavacano", |
| 8764 |
["cchn"]="chinantec", |
| 8765 |
["ceb" ]="cebuano", |
| 8766 |
["cgg" ]="chiga", |
| 8767 |
["cha" ]="chamorro", |
| 8768 |
["che" ]="chechen", |
| 8769 |
["chg" ]="chaha gurage", |
| 8770 |
["chh" ]="chattisgarhi", |
| 8771 |
["chi" ]="chichewa (chewa, nyanja)", |
| 8772 |
["chk" ]="chukchi", |
| 8773 |
["chk0"]="chuukese", |
| 8774 |
["cho" ]="choctaw", |
| 8775 |
["chp" ]="chipewyan", |
| 8776 |
["chr" ]="cherokee", |
| 8777 |
["chu" ]="chuvash", |
| 8778 |
["chy" ]="cheyenne", |
| 8779 |
["cja" ]="western cham", |
| 8780 |
["cjm" ]="eastern cham", |
| 8781 |
["cmr" ]="comorian", |
| 8782 |
["cop" ]="coptic", |
| 8783 |
["cor" ]="cornish", |
| 8784 |
["cos" ]="corsican", |
| 8785 |
["cpp" ]="creoles", |
| 8786 |
["cre" ]="cree", |
| 8787 |
["crr" ]="carrier", |
| 8788 |
["crt" ]="crimean tatar", |
| 8789 |
["csb" ]="kashubian", |
| 8790 |
["csl" ]="church slavonic", |
| 8791 |
["csy" ]="czech", |
| 8792 |
["ctg" ]="chittagonian", |
| 8793 |
["ctt" ]="wayanad chetti", |
| 8794 |
["cuk" ]="san blas kuna", |
| 8795 |
["dag" ]="dagbani", |
| 8796 |
["dan" ]="danish", |
| 8797 |
["dar" ]="dargwa", |
| 8798 |
["dax" ]="dayi", |
| 8799 |
["dcr" ]="woods cree", |
| 8800 |
["deu" ]="german", |
| 8801 |
["dgo" ]="dogri (individual language)", |
| 8802 |
["dgr" ]="dogri (macro language)", |
| 8803 |
["dhg" ]="dhangu", |
| 8804 |
["dhv" ]="divehi (dhivehi, maldivian)", |
| 8805 |
["diq" ]="dimli", |
| 8806 |
["div" ]="divehi (dhivehi, maldivian)", |
| 8807 |
["djr" ]="zarma", |
| 8808 |
["djr0"]="djambarrpuyngu", |
| 8809 |
["dng" ]="dangme", |
| 8810 |
["dnj" ]="dan", |
| 8811 |
["dnk" ]="dinka", |
| 8812 |
["dri" ]="dari", |
| 8813 |
["duj" ]="dhuwal", |
| 8814 |
["dun" ]="dungan", |
| 8815 |
["dzn" ]="dzongkha", |
| 8816 |
["ebi" ]="ebira", |
| 8817 |
["ecr" ]="eastern cree", |
| 8818 |
["edo" ]="edo", |
| 8819 |
["efi" ]="efik", |
| 8820 |
["ell" ]="greek", |
| 8821 |
["emk" ]="eastern maninkakan", |
| 8822 |
["eng" ]="english", |
| 8823 |
["erz" ]="erzya", |
| 8824 |
["esp" ]="spanish", |
| 8825 |
["esu" ]="central yupik", |
| 8826 |
["eti" ]="estonian", |
| 8827 |
["euq" ]="basque", |
| 8828 |
["evk" ]="evenki", |
| 8829 |
["evn" ]="even", |
| 8830 |
["ewe" ]="ewe", |
| 8831 |
["fan" ]="french antillean", |
| 8832 |
["fan0"]=" fang", |
| 8833 |
["far" ]="persian", |
| 8834 |
["fat" ]="fanti", |
| 8835 |
["fin" ]="finnish", |
| 8836 |
["fji" ]="fijian", |
| 8837 |
["fle" ]="dutch (flemish)", |
| 8838 |
["fmp" ]="fe’fe’", |
| 8839 |
["fne" ]="forest nenets", |
| 8840 |
["fon" ]="fon", |
| 8841 |
["fos" ]="faroese", |
| 8842 |
["fra" ]="french", |
| 8843 |
["frc" ]="cajun french", |
| 8844 |
["fri" ]="frisian", |
| 8845 |
["frl" ]="friulian", |
| 8846 |
["frp" ]="arpitan", |
| 8847 |
["fta" ]="futa", |
| 8848 |
["ful" ]="fulah", |
| 8849 |
["fuv" ]="nigerian fulfulde", |
| 8850 |
["gad" ]="ga", |
| 8851 |
["gae" ]="scottish gaelic (gaelic)", |
| 8852 |
["gag" ]="gagauz", |
| 8853 |
["gal" ]="galician", |
| 8854 |
["gar" ]="garshuni", |
| 8855 |
["gaw" ]="garhwali", |
| 8856 |
["gez" ]="ge'ez", |
| 8857 |
["gih" ]="githabul", |
| 8858 |
["gil" ]="gilyak", |
| 8859 |
["gil0"]="kiribati (gilbertese)", |
| 8860 |
["gkp" ]="kpelle (guinea)", |
| 8861 |
["glk" ]="gilaki", |
| 8862 |
["gmz" ]="gumuz", |
| 8863 |
["gnn" ]="gumatj", |
| 8864 |
["gog" ]="gogo", |
| 8865 |
["gon" ]="gondi", |
| 8866 |
["grn" ]="greenlandic", |
| 8867 |
["gro" ]="garo", |
| 8868 |
["gua" ]="guarani", |
| 8869 |
["guc" ]="wayuu", |
| 8870 |
["guf" ]="gupapuyngu", |
| 8871 |
["guj" ]="gujarati", |
| 8872 |
["guz" ]="gusii", |
| 8873 |
["hai" ]="haitian (haitian creole)", |
| 8874 |
["hai0"]="haida", |
| 8875 |
["hal" ]="halam", |
| 8876 |
["har" ]="harauti", |
| 8877 |
["hau" ]="hausa", |
| 8878 |
["haw" ]="hawaiian", |
| 8879 |
["hay" ]="haya", |
| 8880 |
["haz" ]="hazaragi", |
| 8881 |
["hmz" ]="hmong shuat", |
| 8882 |
["hbn" ]="hammer-banna", |
| 8883 |
["hei" ]="heiltsuk", |
| 8884 |
["her" ]="herero", |
| 8885 |
["hil" ]="hiligaynon", |
| 8886 |
["hin" ]="hindi", |
| 8887 |
["hma" ]="high mari", |
| 8888 |
["hmn" ]="hmong", |
| 8889 |
["hmo" ]="hiri motu", |
| 8890 |
["hnd" ]="hindko", |
| 8891 |
["ho" ]="ho", |
| 8892 |
["hri" ]="harari", |
| 8893 |
["hrv" ]="croatian", |
| 8894 |
["hun" ]="hungarian", |
| 8895 |
["hye" ]="armenian", |
| 8896 |
["hye0"]="armenian east", |
| 8897 |
["iba" ]="iban", |
| 8898 |
["ibb" ]="ibibio", |
| 8899 |
["ibo" ]="igbo", |
| 8900 |
["ido" ]="ido", |
| 8901 |
["ijo" ]="ijo languages", |
| 8902 |
["ile" ]="interlingue", |
| 8903 |
["ilo" ]="ilokano", |
| 8904 |
["ina" ]="interlingua", |
| 8905 |
["ind" ]="indonesian", |
| 8906 |
["ing" ]="ingush", |
| 8907 |
["inu" ]="inuktitut", |
| 8908 |
["inuk"]="nunavik inuktitut", |
| 8909 |
["ipk" ]="inupiat", |
| 8910 |
["ipph"]="phonetic transcription—ipa conventions", |
| 8911 |
["iri" ]="irish", |
| 8912 |
["irt" ]="irish traditional", |
| 8913 |
["uri" ]="irula", |
| 8914 |
["isl" ]="icelandic", |
| 8915 |
["ism" ]="inari sami", |
| 8916 |
["ita" ]="italian", |
| 8917 |
["iwr" ]="hebrew", |
| 8918 |
["jam" ]="jamaican creole", |
| 8919 |
["jan" ]="japanese", |
| 8920 |
["jav" ]="javanese", |
| 8921 |
["jbo" ]="lojban", |
| 8922 |
["jct" ]="krymchak", |
| 8923 |
["jii" ]="yiddish", |
| 8924 |
["jud" ]="ladino", |
| 8925 |
["jul" ]="jula", |
| 8926 |
["kab" ]="kabardian", |
| 8927 |
["kab0"]="kabyle", |
| 8928 |
["kac" ]="kachchi", |
| 8929 |
["kal" ]="kalenjin", |
| 8930 |
["kan" ]="kannada", |
| 8931 |
["kar" ]="karachay", |
| 8932 |
["kat" ]="georgian", |
| 8933 |
["kaw" ]="kawi (old javanese)", |
| 8934 |
["kaz" ]="kazakh", |
| 8935 |
["kde" ]="makonde", |
| 8936 |
["kea" ]="kabuverdianu (crioulo)", |
| 8937 |
["keb" ]="kebena", |
| 8938 |
["kek" ]="kekchi", |
| 8939 |
["kge" ]="khutsuri georgian", |
| 8940 |
["kha" ]="khakass", |
| 8941 |
["khk" ]="khanty-kazim", |
| 8942 |
["khm" ]="khmer", |
| 8943 |
["khs" ]="khanty-shurishkar", |
| 8944 |
["kht" ]="khamti shan", |
| 8945 |
["khv" ]="khanty-vakhi", |
| 8946 |
["khw" ]="khowar", |
| 8947 |
["kik" ]="kikuyu (gikuyu)", |
| 8948 |
["kir" ]="kirghiz (kyrgyz)", |
| 8949 |
["kis" ]="kisii", |
| 8950 |
["kiu" ]="kirmanjki", |
| 8951 |
["kjd" ]="southern kiwai", |
| 8952 |
["kjp" ]="eastern pwo karen", |
| 8953 |
["kjz" ]="bumthangkha", |
| 8954 |
["kkn" ]="kokni", |
| 8955 |
["klm" ]="kalmyk", |
| 8956 |
["kmb" ]="kamba", |
| 8957 |
["kmn" ]="kumaoni", |
| 8958 |
["kmo" ]="komo", |
| 8959 |
["kms" ]="komso", |
| 8960 |
["kmz" ]="khorasani turkic", |
| 8961 |
["knr" ]="kanuri", |
| 8962 |
["kod" ]="kodagu", |
| 8963 |
["koh" ]="korean old hangul", |
| 8964 |
["kok" ]="konkani", |
| 8965 |
["kom" ]="komi", |
| 8966 |
["kon" ]="kikongo", |
| 8967 |
["kon0"]="kongo", |
| 8968 |
["kop" ]="komi-permyak", |
| 8969 |
["kor" ]="korean", |
| 8970 |
["kos" ]="kosraean", |
| 8971 |
["koz" ]="komi-zyrian", |
| 8972 |
["kpl" ]="kpelle", |
| 8973 |
["kri" ]="krio", |
| 8974 |
["krk" ]="karakalpak", |
| 8975 |
["krl" ]="karelian", |
| 8976 |
["krm" ]="karaim", |
| 8977 |
["krn" ]="karen", |
| 8978 |
["krt" ]="koorete", |
| 8979 |
["ksh" ]="kashmiri", |
| 8980 |
["ksh0"]="ripuarian", |
| 8981 |
["ksi" ]="khasi", |
| 8982 |
["ksm" ]="kildin sami", |
| 8983 |
["ksw" ]="s’gaw karen", |
| 8984 |
["kua" ]="kuanyama", |
| 8985 |
["kui" ]="kui", |
| 8986 |
["kul" ]="kulvi", |
| 8987 |
["kum" ]="kumyk", |
| 8988 |
["kur" ]="kurdish", |
| 8989 |
["kuu" ]="kurukh", |
| 8990 |
["kuy" ]="kuy", |
| 8991 |
["kwk" ]="kwakʼwala", |
| 8992 |
["kyk" ]="koryak", |
| 8993 |
["kyu" ]="western kayah", |
| 8994 |
["lad" ]="ladin", |
| 8995 |
["lah" ]="lahuli", |
| 8996 |
["lak" ]="lak", |
| 8997 |
["lam" ]="lambani", |
| 8998 |
["lao" ]="lao", |
| 8999 |
["lat" ]="latin", |
| 9000 |
["laz" ]="laz", |
| 9001 |
["lcr" ]="l-cree", |
| 9002 |
["ldk" ]="ladakhi", |
| 9003 |
["lef" ]="lelemi", |
| 9004 |
["lez" ]="lezgi", |
| 9005 |
["lij" ]="ligurian", |
| 9006 |
["lim" ]="limburgish", |
| 9007 |
["lin" ]="lingala", |
| 9008 |
["lis" ]="lisu", |
| 9009 |
["ljp" ]="lampung", |
| 9010 |
["lki" ]="laki", |
| 9011 |
["lma" ]="low mari", |
| 9012 |
["lmb" ]="limbu", |
| 9013 |
["lmo" ]="lombard", |
| 9014 |
["lmw" ]="lomwe", |
| 9015 |
["lom" ]="loma", |
| 9016 |
["lpo" ]="lipo", |
| 9017 |
["lrc" ]="luri", |
| 9018 |
["lsb" ]="lower sorbian", |
| 9019 |
["lsm" ]="lule sami", |
| 9020 |
["lth" ]="lithuanian", |
| 9021 |
["ltz" ]="luxembourgish", |
| 9022 |
["lua" ]="luba-lulua", |
| 9023 |
["lub" ]="luba-katanga", |
| 9024 |
["lug" ]="ganda", |
| 9025 |
["luh" ]="luyia", |
| 9026 |
["luo" ]="luo", |
| 9027 |
["lvi" ]="latvian", |
| 9028 |
["mad" ]="madura", |
| 9029 |
["mag" ]="magahi", |
| 9030 |
["mah" ]="marshallese", |
| 9031 |
["maj" ]="majang", |
| 9032 |
["mak" ]="makhuwa", |
| 9033 |
["mal" ]="malayalam", |
| 9034 |
["mam" ]="mam", |
| 9035 |
["man" ]="mansi", |
| 9036 |
["map" ]="mapudungun", |
| 9037 |
["mar" ]="marathi", |
| 9038 |
["maw" ]="marwari", |
| 9039 |
["mbn" ]="mbundu", |
| 9040 |
["mbo" ]="mbo", |
| 9041 |
["mch" ]="manchu", |
| 9042 |
["mcr" ]="moose cree", |
| 9043 |
["mde" ]="mende", |
| 9044 |
["mdr" ]="mandar", |
| 9045 |
["men" ]="me'en", |
| 9046 |
["mer" ]="meru", |
| 9047 |
["mfa" ]="pattani malay", |
| 9048 |
["mfe" ]="morisyen", |
| 9049 |
["min" ]="minangkabau", |
| 9050 |
["miz" ]="mizo", |
| 9051 |
["mkd" ]="macedonian", |
| 9052 |
["mkr" ]="makasar", |
| 9053 |
["mkw" ]="kituba", |
| 9054 |
["mle" ]="male", |
| 9055 |
["mlg" ]="malagasy", |
| 9056 |
["mln" ]="malinke", |
| 9057 |
["mlr" ]="malayalam reformed", |
| 9058 |
["mly" ]="malay", |
| 9059 |
["mnd" ]="mandinka", |
| 9060 |
["mng" ]="mongolian", |
| 9061 |
["mni" ]="manipuri", |
| 9062 |
["mnk" ]="maninka", |
| 9063 |
["mnx" ]="manx", |
| 9064 |
["moh" ]="mohawk", |
| 9065 |
["mok" ]="moksha", |
| 9066 |
["mol" ]="moldavian", |
| 9067 |
["mon" ]="mon", |
| 9068 |
["mnw" ]="thailand mon", |
| 9069 |
["mor" ]="moroccan", |
| 9070 |
["mos" ]="mossi", |
| 9071 |
["mri" ]="maori", |
| 9072 |
["mth" ]="maithili", |
| 9073 |
["mts" ]="maltese", |
| 9074 |
["mun" ]="mundari", |
| 9075 |
["mus" ]="muscogee", |
| 9076 |
["mwl" ]="mirandese", |
| 9077 |
["mww" ]="hmong daw", |
| 9078 |
["myn" ]="mayan", |
| 9079 |
["mzn" ]="mazanderani", |
| 9080 |
["nag" ]="naga-assamese", |
| 9081 |
["nah" ]="nahuatl", |
| 9082 |
["nan" ]="nanai", |
| 9083 |
["nap" ]="neapolitan", |
| 9084 |
["nas" ]="naskapi", |
| 9085 |
["nau" ]="nauruan", |
| 9086 |
["nav" ]="navajo", |
| 9087 |
["ncr" ]="n-cree", |
| 9088 |
["ndb" ]="ndebele", |
| 9089 |
["ndc" ]="ndau", |
| 9090 |
["ndg" ]="ndonga", |
| 9091 |
["nds" ]="low saxon", |
| 9092 |
["nep" ]="nepali", |
| 9093 |
["new" ]="newari", |
| 9094 |
["nga" ]="ngbaka", |
| 9095 |
["ngr" ]="nagari", |
| 9096 |
["nhc" ]="norway house cree", |
| 9097 |
["nis" ]="nisi", |
| 9098 |
["niu" ]="niuean", |
| 9099 |
["nkl" ]="nyankole", |
| 9100 |
["nko" ]="n'ko", |
| 9101 |
["nld" ]="dutch", |
| 9102 |
["noe" ]="nimadi", |
| 9103 |
["nog" ]="nogai", |
| 9104 |
["nor" ]="norwegian", |
| 9105 |
["nov" ]="novial", |
| 9106 |
["nsm" ]="northern sami", |
| 9107 |
["nso" ]="northern sotho", |
| 9108 |
["nta" ]="northern tai", |
| 9109 |
["nto" ]="esperanto", |
| 9110 |
["nym" ]="nyamwezi", |
| 9111 |
["nyn" ]="norwegian nynorsk", |
| 9112 |
["nza" ]="mbembe tigon", |
| 9113 |
["oci" ]="occitan", |
| 9114 |
["ocr" ]="oji-cree", |
| 9115 |
["ojb" ]="ojibway", |
| 9116 |
["ori" ]="odia", |
| 9117 |
["oro" ]="oromo", |
| 9118 |
["oss" ]="ossetian", |
| 9119 |
["paa" ]="palestinian aramaic", |
| 9120 |
["pag" ]="pangasinan", |
| 9121 |
["pal" ]="pali", |
| 9122 |
["pam" ]="pampangan", |
| 9123 |
["pan" ]="punjabi", |
| 9124 |
["pap" ]="palpa", |
| 9125 |
["pap0"]="papiamentu", |
| 9126 |
["pas" ]="pashto", |
| 9127 |
["pau" ]="palauan", |
| 9128 |
["pcc" ]="bouyei", |
| 9129 |
["pcd" ]="picard", |
| 9130 |
["pdc" ]="pennsylvania german", |
| 9131 |
["pgr" ]="polytonic greek", |
| 9132 |
["phk" ]="phake", |
| 9133 |
["pih" ]="norfolk", |
| 9134 |
["pil" ]="filipino", |
| 9135 |
["plg" ]="palaung", |
| 9136 |
["plk" ]="polish", |
| 9137 |
["pms" ]="piemontese", |
| 9138 |
["pnb" ]="western panjabi", |
| 9139 |
["poh" ]="pocomchi", |
| 9140 |
["pon" ]="pohnpeian", |
| 9141 |
["pro" ]="provencal", |
| 9142 |
["ptg" ]="portuguese", |
| 9143 |
["pwo" ]="western pwo karen", |
| 9144 |
["qin" ]="chin", |
| 9145 |
["quc" ]="k’iche’", |
| 9146 |
["quh" ]="quechua (bolivia)", |
| 9147 |
["quz" ]="quechua", |
| 9148 |
["qvi" ]="quechua (ecuador)", |
| 9149 |
["qwh" ]="quechua (peru)", |
| 9150 |
["raj" ]="rajasthani", |
| 9151 |
["rar" ]="rarotongan", |
| 9152 |
["rbu" ]="russian buriat", |
| 9153 |
["rcr" ]="r-cree", |
| 9154 |
["rej" ]="rejang", |
| 9155 |
["rhg" ]="rohingya", |
| 9156 |
["ria" ]="riang", |
| 9157 |
["rif" ]="tarifit", |
| 9158 |
["rit" ]="ritarungo", |
| 9159 |
["rkw" ]="arakwal", |
| 9160 |
["rms" ]="romansh", |
| 9161 |
["rmy" ]="vlax romani", |
| 9162 |
["rom" ]="romanian", |
| 9163 |
["roy" ]="romany", |
| 9164 |
["rsy" ]="rusyn", |
| 9165 |
["rtm" ]="rotuman", |
| 9166 |
["rua" ]="kinyarwanda", |
| 9167 |
["run" ]="rundi", |
| 9168 |
["rup" ]="aromanian", |
| 9169 |
["rus" ]="russian", |
| 9170 |
["sad" ]="sadri", |
| 9171 |
["san" ]="sanskrit", |
| 9172 |
["sas" ]="sasak", |
| 9173 |
["sat" ]="santali", |
| 9174 |
["say" ]="sayisi", |
| 9175 |
["scn" ]="sicilian", |
| 9176 |
["sco" ]="scots", |
| 9177 |
["scs" ]="north slavey", |
| 9178 |
["sek" ]="sekota", |
| 9179 |
["sel" ]="selkup", |
| 9180 |
["sfm" ]="small flowery miao", |
| 9181 |
["sga" ]="old irish", |
| 9182 |
["sgo" ]="sango", |
| 9183 |
["sgs" ]="samogitian", |
| 9184 |
["shi" ]="tachelhit", |
| 9185 |
["shn" ]="shan", |
| 9186 |
["sib" ]="sibe", |
| 9187 |
["sid" ]="sidamo", |
| 9188 |
["sig" ]="silte gurage", |
| 9189 |
["sks" ]="skolt sami", |
| 9190 |
["sky" ]="slovak", |
| 9191 |
["sla" ]="slavey", |
| 9192 |
["slv" ]="slovenian", |
| 9193 |
["sml" ]="somali", |
| 9194 |
["smo" ]="samoan", |
| 9195 |
["sna" ]="sena", |
| 9196 |
["sna0"]="shona", |
| 9197 |
["snd" ]="sindhi", |
| 9198 |
["snh" ]="sinhala (sinhalese)", |
| 9199 |
["snk" ]="soninke", |
| 9200 |
["sog" ]="sodo gurage", |
| 9201 |
["sop" ]="songe", |
| 9202 |
["sot" ]="southern sotho", |
| 9203 |
["sqi" ]="albanian", |
| 9204 |
["srb" ]="serbian", |
| 9205 |
["srd" ]="sardinian", |
| 9206 |
["srk" ]="saraiki", |
| 9207 |
["srr" ]="serer", |
| 9208 |
["ssl" ]="south slavey", |
| 9209 |
["ssm" ]="southern sami", |
| 9210 |
["stq" ]="saterland frisian", |
| 9211 |
["suk" ]="sukuma", |
| 9212 |
["sun" ]="sundanese", |
| 9213 |
["sur" ]="suri", |
| 9214 |
["sva" ]="svan", |
| 9215 |
["sve" ]="swedish", |
| 9216 |
["swa" ]="swadaya aramaic", |
| 9217 |
["swk" ]="swahili", |
| 9218 |
["swz" ]="swati", |
| 9219 |
["sxt" ]="sutu", |
| 9220 |
["sxu" ]="upper saxon", |
| 9221 |
["syl" ]="sylheti", |
| 9222 |
["syr" ]="syriac", |
| 9223 |
["syre"]="estrangela syriac", |
| 9224 |
["syrj"]="western syriac", |
| 9225 |
["syrn"]="eastern syriac", |
| 9226 |
["szl" ]="silesian", |
| 9227 |
["tab" ]="tabasaran", |
| 9228 |
["taj" ]="tajiki", |
| 9229 |
["tam" ]="tamil", |
| 9230 |
["tat" ]="tatar", |
| 9231 |
["tcr" ]="th-cree", |
| 9232 |
["tdd" ]="dehong dai", |
| 9233 |
["tel" ]="telugu", |
| 9234 |
["tet" ]="tetum", |
| 9235 |
["tgl" ]="tagalog", |
| 9236 |
["tgn" ]="tongan", |
| 9237 |
["tgr" ]="tigre", |
| 9238 |
["tgy" ]="tigrinya", |
| 9239 |
["tha" ]="thai", |
| 9240 |
["tht" ]="tahitian", |
| 9241 |
["tib" ]="tibetan", |
| 9242 |
["tiv" ]="tiv", |
| 9243 |
["tj;" ]="tai laing", |
| 9244 |
["tkm" ]="turkmen", |
| 9245 |
["tli" ]="tlingit", |
| 9246 |
["tmh" ]="tamashek", |
| 9247 |
["tmn" ]="temne", |
| 9248 |
["tna" ]="tswana", |
| 9249 |
["tne" ]="tundra nenets", |
| 9250 |
["tng" ]="tonga", |
| 9251 |
["tod" ]="todo", |
| 9252 |
["tod0"]="toma", |
| 9253 |
["tpi" ]="tok pisin", |
| 9254 |
["trk" ]="turkish", |
| 9255 |
["tsg" ]="tsonga", |
| 9256 |
["tsj" ]="tshangla", |
| 9257 |
["tua" ]="turoyo aramaic", |
| 9258 |
["tul" ]="tulu", |
| 9259 |
["tum" ]="tumbuka", |
| 9260 |
["tuv" ]="tuvin", |
| 9261 |
["tvl" ]="tuvalu", |
| 9262 |
["twi" ]="twi", |
| 9263 |
["tyz" ]="tày", |
| 9264 |
["tzm" ]="tamazight", |
| 9265 |
["tzo" ]="tzotzil", |
| 9266 |
["udm" ]="udmurt", |
| 9267 |
["ukr" ]="ukrainian", |
| 9268 |
["umb" ]="umbundu", |
| 9269 |
["urd" ]="urdu", |
| 9270 |
["usb" ]="upper sorbian", |
| 9271 |
["uyg" ]="uyghur", |
| 9272 |
["uzb" ]="uzbek", |
| 9273 |
["vec" ]="venetian", |
| 9274 |
["ven" ]="venda", |
| 9275 |
["vit" ]="vietnamese", |
| 9276 |
["vol" ]="volapük", |
| 9277 |
["vro" ]="võro", |
| 9278 |
["wa" ]="wa", |
| 9279 |
["wag" ]="wagdi", |
| 9280 |
["war" ]="waray-waray", |
| 9281 |
["wci" ]="waci gbe", |
| 9282 |
["wcr" ]="west-cree", |
| 9283 |
["wel" ]="welsh", |
| 9284 |
["wlf" ]="wolof", |
| 9285 |
["wln" ]="walloon", |
| 9286 |
["wtm" ]="mewati", |
| 9287 |
["xbd" ]="lü", |
| 9288 |
["xhs" ]="xhosa", |
| 9289 |
["xjb" ]="minjangbal", |
| 9290 |
["xkf" ]="khengkha", |
| 9291 |
["xog" ]="soga", |
| 9292 |
["xpe" ]="kpelle (liberia)", |
| 9293 |
["xub" ]="bette kuruma", |
| 9294 |
["xuj" ]="jennu kuruma", |
| 9295 |
["yak" ]="sakha", |
| 9296 |
["yao" ]="yao", |
| 9297 |
["yap" ]="yapese", |
| 9298 |
["yba" ]="yoruba", |
| 9299 |
["ycr" ]="y-cree", |
| 9300 |
["ygp" ]="gepo", |
| 9301 |
["yic" ]="yi classic", |
| 9302 |
["yim" ]="yi modern", |
| 9303 |
["yna" ]="aluo", |
| 9304 |
["ywq" ]="wuding-luquan", |
| 9305 |
["zea" ]="zealandic", |
| 9306 |
["zgh" ]="standard morrocan tamazigh", |
| 9307 |
["zha" ]="zhuang", |
| 9308 |
["zhh" ]="chinese, hong kong sar", |
| 9309 |
["zho" ]="chinese traditional, macao", |
| 9310 |
["zhp" ]="chinese phonetic", |
| 9311 |
["zhs" ]="chinese simplified", |
| 9312 |
["zht" ]="chinese traditional", |
| 9313 |
["znd" ]="zande", |
| 9314 |
["zul" ]="zulu", |
| 9315 |
["zza" ]="zazaki", |
| 9316 |
} |
| 9317 |
local features=allocate { |
| 9318 |
["aalt"]="access all alternates", |
| 9319 |
["abvf"]="above-base forms", |
| 9320 |
["abvm"]="above-base mark positioning", |
| 9321 |
["abvs"]="above-base substitutions", |
| 9322 |
["afrc"]="alternative fractions", |
| 9323 |
["akhn"]="akhands", |
| 9324 |
["blwf"]="below-base forms", |
| 9325 |
["blwm"]="below-base mark positioning", |
| 9326 |
["blws"]="below-base substitutions", |
| 9327 |
["c2pc"]="petite capitals from capitals", |
| 9328 |
["c2sc"]="small capitals from capitals", |
| 9329 |
["calt"]="contextual alternates", |
| 9330 |
["case"]="case-sensitive forms", |
| 9331 |
["ccmp"]="glyph composition/decomposition", |
| 9332 |
["cfar"]="conjunct form after ro", |
| 9333 |
["chws"]="contextual half-width spacing", |
| 9334 |
["cjct"]="conjunct forms", |
| 9335 |
["clig"]="contextual ligatures", |
| 9336 |
["cpct"]="centered cjk punctuation", |
| 9337 |
["cpsp"]="capital spacing", |
| 9338 |
["cswh"]="contextual swash", |
| 9339 |
["curs"]="cursive positioning", |
| 9340 |
["dflt"]="default processing", |
| 9341 |
["dist"]="distances", |
| 9342 |
["dlig"]="discretionary ligatures", |
| 9343 |
["dnom"]="denominators", |
| 9344 |
["dtls"]="dotless forms", |
| 9345 |
["expt"]="expert forms", |
| 9346 |
["falt"]="final glyph alternates", |
| 9347 |
["fin2"]="terminal forms #2", |
| 9348 |
["fin3"]="terminal forms #3", |
| 9349 |
["fina"]="terminal forms", |
| 9350 |
["flac"]="flattened accents over capitals", |
| 9351 |
["frac"]="fractions", |
| 9352 |
["fwid"]="full width", |
| 9353 |
["half"]="half forms", |
| 9354 |
["haln"]="halant forms", |
| 9355 |
["halt"]="alternate half width", |
| 9356 |
["hist"]="historical forms", |
| 9357 |
["hkna"]="horizontal kana alternates", |
| 9358 |
["hlig"]="historical ligatures", |
| 9359 |
["hngl"]="hangul", |
| 9360 |
["hojo"]="hojo kanji forms", |
| 9361 |
["hwid"]="half width", |
| 9362 |
["init"]="initial forms", |
| 9363 |
["isol"]="isolated forms", |
| 9364 |
["ital"]="italics", |
| 9365 |
["jalt"]="justification alternatives", |
| 9366 |
["jp04"]="jis2004 forms", |
| 9367 |
["jp78"]="jis78 forms", |
| 9368 |
["jp83"]="jis83 forms", |
| 9369 |
["jp90"]="jis90 forms", |
| 9370 |
["kern"]="kerning", |
| 9371 |
["lfbd"]="left bounds", |
| 9372 |
["liga"]="standard ligatures", |
| 9373 |
["ljmo"]="leading jamo forms", |
| 9374 |
["lnum"]="lining figures", |
| 9375 |
["locl"]="localized forms", |
| 9376 |
["ltra"]="left-to-right alternates", |
| 9377 |
["ltrm"]="left-to-right mirrored forms", |
| 9378 |
["mark"]="mark positioning", |
| 9379 |
["med2"]="medial forms #2", |
| 9380 |
["medi"]="medial forms", |
| 9381 |
["mgrk"]="mathematical greek", |
| 9382 |
["mkmk"]="mark to mark positioning", |
| 9383 |
["mset"]="mark positioning via substitution", |
| 9384 |
["nalt"]="alternate annotation forms", |
| 9385 |
["nlck"]="nlc kanji forms", |
| 9386 |
["nukt"]="nukta forms", |
| 9387 |
["numr"]="numerators", |
| 9388 |
["onum"]="old style figures", |
| 9389 |
["opbd"]="optical bounds", |
| 9390 |
["ordn"]="ordinals", |
| 9391 |
["ornm"]="ornaments", |
| 9392 |
["palt"]="proportional alternate width", |
| 9393 |
["pcap"]="petite capitals", |
| 9394 |
["pkna"]="proportional kana", |
| 9395 |
["pnum"]="proportional figures", |
| 9396 |
["pref"]="pre-base forms", |
| 9397 |
["pres"]="pre-base substitutions", |
| 9398 |
["pstf"]="post-base forms", |
| 9399 |
["psts"]="post-base substitutions", |
| 9400 |
["pwid"]="proportional widths", |
| 9401 |
["qwid"]="quarter widths", |
| 9402 |
["rand"]="randomize", |
| 9403 |
["rclt"]="required contextual alternates", |
| 9404 |
["rkrf"]="rakar forms", |
| 9405 |
["rlig"]="required ligatures", |
| 9406 |
["rphf"]="reph form", |
| 9407 |
["rtbd"]="right bounds", |
| 9408 |
["rtla"]="right-to-left alternates", |
| 9409 |
["rtlm"]="right to left mirrored forms", |
| 9410 |
["ruby"]="ruby notation forms", |
| 9411 |
["rvrn"]="required variation alternates", |
| 9412 |
["salt"]="stylistic alternates", |
| 9413 |
["sinf"]="scientific inferiors", |
| 9414 |
["size"]="optical size", |
| 9415 |
["smcp"]="small capitals", |
| 9416 |
["smpl"]="simplified forms", |
| 9417 |
["ssty"]="script style", |
| 9418 |
["stch"]="stretching glyph decomposition", |
| 9419 |
["subs"]="subscript", |
| 9420 |
["sups"]="superscript", |
| 9421 |
["swsh"]="swash", |
| 9422 |
["titl"]="titling", |
| 9423 |
["tjmo"]="trailing jamo forms", |
| 9424 |
["tnam"]="traditional name forms", |
| 9425 |
["tnum"]="tabular figures", |
| 9426 |
["trad"]="traditional forms", |
| 9427 |
["twid"]="third widths", |
| 9428 |
["unic"]="unicase", |
| 9429 |
["valt"]="alternate vertical metrics", |
| 9430 |
["vatu"]="vattu variants", |
| 9431 |
["vchw"]="vertical contextual half-width spacing", |
| 9432 |
["vert"]="vertical writing", |
| 9433 |
["vhal"]="alternate vertical half metrics", |
| 9434 |
["vjmo"]="vowel jamo forms", |
| 9435 |
["vkna"]="vertical kana alternates", |
| 9436 |
["vkrn"]="vertical kerning", |
| 9437 |
["vpal"]="proportional alternate vertical metrics", |
| 9438 |
["vrtr"]="vertical alternates for rotation", |
| 9439 |
["vrt2"]="vertical rotation", |
| 9440 |
["zero"]="slashed zero", |
| 9441 |
["trep"]="traditional tex replacements", |
| 9442 |
["tlig"]="traditional tex ligatures", |
| 9443 |
["ss.."]="stylistic set ..", |
| 9444 |
["cv.."]="character variant ..", |
| 9445 |
["js.."]="justification ..", |
| 9446 |
["dv.."]="devanagari ..", |
| 9447 |
["ml.."]="malayalam ..", |
| 9448 |
} |
| 9449 |
local baselines=allocate { |
| 9450 |
["hang"]="hanging baseline", |
| 9451 |
["icfb"]="ideographic character face bottom edge baseline", |
| 9452 |
["icft"]="ideographic character face tope edige baseline", |
| 9453 |
["ideo"]="ideographic em-box bottom edge baseline", |
| 9454 |
["idtp"]="ideographic em-box top edge baseline", |
| 9455 |
["math"]="mathematical centered baseline", |
| 9456 |
["romn"]="roman baseline" |
| 9457 |
} |
| 9458 |
tables.scripts=scripts |
| 9459 |
tables.languages=languages |
| 9460 |
tables.features=features |
| 9461 |
tables.baselines=baselines |
| 9462 |
local acceptscripts=true directives.register("otf.acceptscripts",function(v) acceptscripts=v end) |
| 9463 |
local acceptlanguages=true directives.register("otf.acceptlanguages",function(v) acceptlanguages=v end) |
| 9464 |
local report_checks=logs.reporter("fonts","checks") |
| 9465 |
if otffeatures.features then |
| 9466 |
for k,v in next,otffeatures.features do |
| 9467 |
features[k]=v |
| 9468 |
end |
| 9469 |
otffeatures.features=features |
| 9470 |
end |
| 9471 |
local function swapped(h) |
| 9472 |
local r={} |
| 9473 |
for k,v in next,h do |
| 9474 |
r[gsub(v,"[^a-z0-9]","")]=k |
| 9475 |
end |
| 9476 |
return r |
| 9477 |
end |
| 9478 |
local verbosescripts=allocate(swapped(scripts )) |
| 9479 |
local verboselanguages=allocate(swapped(languages)) |
| 9480 |
local verbosefeatures=allocate(swapped(features )) |
| 9481 |
local verbosebaselines=allocate(swapped(baselines)) |
| 9482 |
local function resolve(t,k) |
| 9483 |
if k then |
| 9484 |
k=gsub(lower(k),"[^a-z0-9]","") |
| 9485 |
local v=rawget(t,k) |
| 9486 |
if v then |
| 9487 |
return v |
| 9488 |
end |
| 9489 |
end |
| 9490 |
end |
| 9491 |
setmetatableindex(verbosescripts,resolve) |
| 9492 |
setmetatableindex(verboselanguages,resolve) |
| 9493 |
setmetatableindex(verbosefeatures,resolve) |
| 9494 |
setmetatableindex(verbosebaselines,resolve) |
| 9495 |
setmetatableindex(scripts,function(t,k) |
| 9496 |
if k then |
| 9497 |
k=lower(k) |
| 9498 |
if k=="dflt" then |
| 9499 |
return k |
| 9500 |
end |
| 9501 |
local v=rawget(t,k) |
| 9502 |
if v then |
| 9503 |
return v |
| 9504 |
end |
| 9505 |
k=gsub(k," ","") |
| 9506 |
v=rawget(t,v) |
| 9507 |
if v then |
| 9508 |
return v |
| 9509 |
elseif acceptscripts then |
| 9510 |
report_checks("registering extra script %a",k) |
| 9511 |
rawset(t,k,k) |
| 9512 |
return k |
| 9513 |
end |
| 9514 |
end |
| 9515 |
return "dflt" |
| 9516 |
end) |
| 9517 |
setmetatableindex(languages,function(t,k) |
| 9518 |
if k then |
| 9519 |
k=lower(k) |
| 9520 |
if k=="dflt" then |
| 9521 |
return k |
| 9522 |
end |
| 9523 |
local v=rawget(t,k) |
| 9524 |
if v then |
| 9525 |
return v |
| 9526 |
end |
| 9527 |
k=gsub(k," ","") |
| 9528 |
v=rawget(t,v) |
| 9529 |
if v then |
| 9530 |
return v |
| 9531 |
elseif acceptlanguages then |
| 9532 |
report_checks("registering extra language %a",k) |
| 9533 |
rawset(t,k,k) |
| 9534 |
return k |
| 9535 |
end |
| 9536 |
end |
| 9537 |
return "dflt" |
| 9538 |
end) |
| 9539 |
if setmetatablenewindex then |
| 9540 |
setmetatablenewindex(languages,"ignore") |
| 9541 |
setmetatablenewindex(scripts,"ignore") |
| 9542 |
setmetatablenewindex(baselines,"ignore") |
| 9543 |
end |
| 9544 |
local function resolve(t,k) |
| 9545 |
if k then |
| 9546 |
k=lower(k) |
| 9547 |
local v=rawget(t,k) |
| 9548 |
if v then |
| 9549 |
return v |
| 9550 |
end |
| 9551 |
k=gsub(k," ","") |
| 9552 |
local v=rawget(t,k) |
| 9553 |
if v then |
| 9554 |
return v |
| 9555 |
end |
| 9556 |
local tag,dd=match(k,"(..)(%d+)") |
| 9557 |
if tag and dd then |
| 9558 |
local v=rawget(t,tag) |
| 9559 |
if v then |
| 9560 |
return v |
| 9561 |
else |
| 9562 |
local v=rawget(t,tag.."..") |
| 9563 |
if v then |
| 9564 |
return (gsub(v,"%.%.",tonumber(dd))) |
| 9565 |
end |
| 9566 |
end |
| 9567 |
end |
| 9568 |
end |
| 9569 |
return k |
| 9570 |
end |
| 9571 |
setmetatableindex(features,resolve) |
| 9572 |
local function assign(t,k,v) |
| 9573 |
if k and v then |
| 9574 |
v=lower(v) |
| 9575 |
rawset(t,k,v) |
| 9576 |
end |
| 9577 |
end |
| 9578 |
if setmetatablenewindex then |
| 9579 |
setmetatablenewindex(features,assign) |
| 9580 |
end |
| 9581 |
local checkers={ |
| 9582 |
rand=function(v) |
| 9583 |
return v==true and "random" or v |
| 9584 |
end |
| 9585 |
} |
| 9586 |
if not storage then |
| 9587 |
return |
| 9588 |
end |
| 9589 |
local usedfeatures=statistics.usedfeatures or {} |
| 9590 |
statistics.usedfeatures=usedfeatures |
| 9591 |
table.setmetatableindex(usedfeatures,function(t,k) if k then local v={} t[k]=v return v end end) |
| 9592 |
storage.register("fonts/otf/usedfeatures",usedfeatures,"fonts.handlers.otf.statistics.usedfeatures" ) |
| 9593 |
local normalizedaxis=otf.readers.helpers.normalizedaxis or function(s) return s end |
| 9594 |
function otffeatures.normalize(features,wrap) |
| 9595 |
if features then |
| 9596 |
local h={} |
| 9597 |
for key,value in next,features do |
| 9598 |
local k=lower(key) |
| 9599 |
if k=="language" then |
| 9600 |
local v=gsub(lower(value),"[^a-z0-9]","") |
| 9601 |
h.language=rawget(verboselanguages,v) or (languages[v] and v) or "dflt" |
| 9602 |
elseif k=="script" then |
| 9603 |
local v=gsub(lower(value),"[^a-z0-9]","") |
| 9604 |
h.script=rawget(verbosescripts,v) or (scripts[v] and v) or "dflt" |
| 9605 |
elseif k=="axis" then |
| 9606 |
h[k]=normalizedaxis(value) |
| 9607 |
else |
| 9608 |
local uk=usedfeatures[key] |
| 9609 |
local uv=uk[value] |
| 9610 |
if uv then |
| 9611 |
else |
| 9612 |
uv=tonumber(value) |
| 9613 |
if uv then |
| 9614 |
elseif type(value)=="string" then |
| 9615 |
local b=is_boolean(value) |
| 9616 |
if type(b)=="nil" then |
| 9617 |
if wrap and find(value,",") then |
| 9618 |
uv="{"..lower(value).."}" |
| 9619 |
else |
| 9620 |
uv=lower(value) |
| 9621 |
end |
| 9622 |
else |
| 9623 |
uv=b |
| 9624 |
end |
| 9625 |
elseif type(value)=="table" then |
| 9626 |
uv=sequenced(t,",") |
| 9627 |
else |
| 9628 |
uv=value |
| 9629 |
end |
| 9630 |
if not rawget(features,k) then |
| 9631 |
k=rawget(verbosefeatures,k) or k |
| 9632 |
end |
| 9633 |
local c=checkers[k] |
| 9634 |
if c then |
| 9635 |
uv=c(uv) or vc |
| 9636 |
end |
| 9637 |
uk[value]=uv |
| 9638 |
end |
| 9639 |
h[k]=uv |
| 9640 |
end |
| 9641 |
end |
| 9642 |
return h |
| 9643 |
end |
| 9644 |
end |
| 9645 |
|
| 9646 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ott”] --- |
| 9647 |
|
| 9648 |
|
| 9649 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-cff” 999da544079698ce70178fd84bcdd67a] --- |
| 9650 |
|
| 9651 |
if not modules then modules={} end modules ['font-cff']={ |
| 9652 |
version=1.001, |
| 9653 |
optimize=true, |
| 9654 |
comment="companion to font-ini.mkiv", |
| 9655 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 9656 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 9657 |
license="see context related readme files" |
| 9658 |
} |
| 9659 |
local next,type,tonumber,rawget=next,type,tonumber,rawget |
| 9660 |
local byte,char,gmatch,sub=string.byte,string.char,string.gmatch,string.sub |
| 9661 |
local concat,insert,remove,unpack=table.concat,table.insert,table.remove,table.unpack |
| 9662 |
local floor,abs,round,ceil,min,max=math.floor,math.abs,math.round,math.ceil,math.min,math.max |
| 9663 |
local P,C,R,S,C,Cs,Ct=lpeg.P,lpeg.C,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Ct |
| 9664 |
local lpegmatch=lpeg.match |
| 9665 |
local formatters=string.formatters |
| 9666 |
local bytetable=string.bytetable |
| 9667 |
local idiv=number.idiv |
| 9668 |
local rshift,band,extract=bit32.rshift,bit32.band,bit32.extract |
| 9669 |
local readers=fonts.handlers.otf.readers |
| 9670 |
local streamreader=readers.streamreader |
| 9671 |
local readstring=streamreader.readstring |
| 9672 |
local readbyte=streamreader.readcardinal1 |
| 9673 |
local readushort=streamreader.readcardinal2 |
| 9674 |
local readuint=streamreader.readcardinal3 |
| 9675 |
local readulong=streamreader.readcardinal4 |
| 9676 |
local setposition=streamreader.setposition |
| 9677 |
local getposition=streamreader.getposition |
| 9678 |
local readbytetable=streamreader.readbytetable |
| 9679 |
directives.register("fonts.streamreader",function() |
| 9680 |
streamreader=utilities.streams |
| 9681 |
readstring=streamreader.readstring |
| 9682 |
readbyte=streamreader.readcardinal1 |
| 9683 |
readushort=streamreader.readcardinal2 |
| 9684 |
readuint=streamreader.readcardinal3 |
| 9685 |
readulong=streamreader.readcardinal4 |
| 9686 |
setposition=streamreader.setposition |
| 9687 |
getposition=streamreader.getposition |
| 9688 |
readbytetable=streamreader.readbytetable |
| 9689 |
end) |
| 9690 |
local setmetatableindex=table.setmetatableindex |
| 9691 |
local trace_charstrings=false trackers.register("fonts.cff.charstrings",function(v) trace_charstrings=v end) |
| 9692 |
local report=logs.reporter("otf reader","cff") |
| 9693 |
local parsedictionaries |
| 9694 |
local parsecharstring |
| 9695 |
local parsecharstrings |
| 9696 |
local resetcharstrings |
| 9697 |
local parseprivates |
| 9698 |
local startparsing |
| 9699 |
local stopparsing |
| 9700 |
local defaultstrings={ [0]= |
| 9701 |
".notdef","space","exclam","quotedbl","numbersign","dollar","percent", |
| 9702 |
"ampersand","quoteright","parenleft","parenright","asterisk","plus", |
| 9703 |
"comma","hyphen","period","slash","zero","one","two","three","four", |
| 9704 |
"five","six","seven","eight","nine","colon","semicolon","less", |
| 9705 |
"equal","greater","question","at","A","B","C","D","E","F","G","H", |
| 9706 |
"I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W", |
| 9707 |
"X","Y","Z","bracketleft","backslash","bracketright","asciicircum", |
| 9708 |
"underscore","quoteleft","a","b","c","d","e","f","g","h","i","j", |
| 9709 |
"k","l","m","n","o","p","q","r","s","t","u","v","w","x","y", |
| 9710 |
"z","braceleft","bar","braceright","asciitilde","exclamdown","cent", |
| 9711 |
"sterling","fraction","yen","florin","section","currency", |
| 9712 |
"quotesingle","quotedblleft","guillemotleft","guilsinglleft", |
| 9713 |
"guilsinglright","fi","fl","endash","dagger","daggerdbl", |
| 9714 |
"periodcentered","paragraph","bullet","quotesinglbase","quotedblbase", |
| 9715 |
"quotedblright","guillemotright","ellipsis","perthousand","questiondown", |
| 9716 |
"grave","acute","circumflex","tilde","macron","breve","dotaccent", |
| 9717 |
"dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash", |
| 9718 |
"AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae", |
| 9719 |
"dotlessi","lslash","oslash","oe","germandbls","onesuperior", |
| 9720 |
"logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn", |
| 9721 |
"onequarter","divide","brokenbar","degree","thorn","threequarters", |
| 9722 |
"twosuperior","registered","minus","eth","multiply","threesuperior", |
| 9723 |
"copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring", |
| 9724 |
"Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave", |
| 9725 |
"Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute", |
| 9726 |
"Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute", |
| 9727 |
"Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron", |
| 9728 |
"aacute","acircumflex","adieresis","agrave","aring","atilde", |
| 9729 |
"ccedilla","eacute","ecircumflex","edieresis","egrave","iacute", |
| 9730 |
"icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex", |
| 9731 |
"odieresis","ograve","otilde","scaron","uacute","ucircumflex", |
| 9732 |
"udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall", |
| 9733 |
"Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall", |
| 9734 |
"Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader", |
| 9735 |
"onedotenleader","zerooldstyle","oneoldstyle","twooldstyle", |
| 9736 |
"threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle", |
| 9737 |
"sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior", |
| 9738 |
"threequartersemdash","periodsuperior","questionsmall","asuperior", |
| 9739 |
"bsuperior","centsuperior","dsuperior","esuperior","isuperior", |
| 9740 |
"lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior", |
| 9741 |
"tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior", |
| 9742 |
"Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall", |
| 9743 |
"Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall", |
| 9744 |
"Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall", |
| 9745 |
"Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall", |
| 9746 |
"Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah", |
| 9747 |
"Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall", |
| 9748 |
"Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall", |
| 9749 |
"Dotaccentsmall","Macronsmall","figuredash","hypheninferior", |
| 9750 |
"Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth", |
| 9751 |
"threeeighths","fiveeighths","seveneighths","onethird","twothirds", |
| 9752 |
"zerosuperior","foursuperior","fivesuperior","sixsuperior", |
| 9753 |
"sevensuperior","eightsuperior","ninesuperior","zeroinferior", |
| 9754 |
"oneinferior","twoinferior","threeinferior","fourinferior", |
| 9755 |
"fiveinferior","sixinferior","seveninferior","eightinferior", |
| 9756 |
"nineinferior","centinferior","dollarinferior","periodinferior", |
| 9757 |
"commainferior","Agravesmall","Aacutesmall","Acircumflexsmall", |
| 9758 |
"Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall", |
| 9759 |
"Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall", |
| 9760 |
"Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall", |
| 9761 |
"Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall", |
| 9762 |
"Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall", |
| 9763 |
"Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall", |
| 9764 |
"Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003", |
| 9765 |
"Black","Bold","Book","Light","Medium","Regular","Roman","Semibold", |
| 9766 |
} |
| 9767 |
local standardnames={ [0]= |
| 9768 |
false,false,false,false,false,false,false,false,false,false,false, |
| 9769 |
false,false,false,false,false,false,false,false,false,false,false, |
| 9770 |
false,false,false,false,false,false,false,false,false,false, |
| 9771 |
"space","exclam","quotedbl","numbersign","dollar","percent", |
| 9772 |
"ampersand","quoteright","parenleft","parenright","asterisk","plus", |
| 9773 |
"comma","hyphen","period","slash","zero","one","two","three","four", |
| 9774 |
"five","six","seven","eight","nine","colon","semicolon","less", |
| 9775 |
"equal","greater","question","at","A","B","C","D","E","F","G","H", |
| 9776 |
"I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W", |
| 9777 |
"X","Y","Z","bracketleft","backslash","bracketright","asciicircum", |
| 9778 |
"underscore","quoteleft","a","b","c","d","e","f","g","h","i","j", |
| 9779 |
"k","l","m","n","o","p","q","r","s","t","u","v","w","x","y", |
| 9780 |
"z","braceleft","bar","braceright","asciitilde",false,false,false, |
| 9781 |
false,false,false,false,false,false,false,false,false,false,false, |
| 9782 |
false,false,false,false,false,false,false,false,false,false,false, |
| 9783 |
false,false,false,false,false,false,false,false,false,"exclamdown", |
| 9784 |
"cent","sterling","fraction","yen","florin","section","currency", |
| 9785 |
"quotesingle","quotedblleft","guillemotleft","guilsinglleft", |
| 9786 |
"guilsinglright","fi","fl",false,"endash","dagger","daggerdbl", |
| 9787 |
"periodcentered",false,"paragraph","bullet","quotesinglbase", |
| 9788 |
"quotedblbase","quotedblright","guillemotright","ellipsis","perthousand", |
| 9789 |
false,"questiondown",false,"grave","acute","circumflex","tilde", |
| 9790 |
"macron","breve","dotaccent","dieresis",false,"ring","cedilla",false, |
| 9791 |
"hungarumlaut","ogonek","caron","emdash",false,false,false,false, |
| 9792 |
false,false,false,false,false,false,false,false,false,false,false, |
| 9793 |
false,"AE",false,"ordfeminine",false,false,false,false,"Lslash", |
| 9794 |
"Oslash","OE","ordmasculine",false,false,false,false,false,"ae", |
| 9795 |
false,false,false,"dotlessi",false,false,"lslash","oslash","oe", |
| 9796 |
"germandbls",false,false,false,false |
| 9797 |
} |
| 9798 |
local cffreaders={ |
| 9799 |
readbyte, |
| 9800 |
readushort, |
| 9801 |
readuint, |
| 9802 |
readulong, |
| 9803 |
} |
| 9804 |
directives.register("fonts.streamreader",function() |
| 9805 |
cffreaders={ |
| 9806 |
readbyte, |
| 9807 |
readushort, |
| 9808 |
readuint, |
| 9809 |
readulong, |
| 9810 |
} |
| 9811 |
end) |
| 9812 |
local function readheader(f) |
| 9813 |
local offset=getposition(f) |
| 9814 |
local major=readbyte(f) |
| 9815 |
local header={ |
| 9816 |
offset=offset, |
| 9817 |
major=major, |
| 9818 |
minor=readbyte(f), |
| 9819 |
size=readbyte(f), |
| 9820 |
} |
| 9821 |
if major==1 then |
| 9822 |
header.dsize=readbyte(f) |
| 9823 |
elseif major==2 then |
| 9824 |
header.dsize=readushort(f) |
| 9825 |
else |
| 9826 |
end |
| 9827 |
setposition(f,offset+header.size) |
| 9828 |
return header |
| 9829 |
end |
| 9830 |
local function readlengths(f,longcount) |
| 9831 |
local count=longcount and readulong(f) or readushort(f) |
| 9832 |
if count==0 then |
| 9833 |
return {} |
| 9834 |
end |
| 9835 |
local osize=readbyte(f) |
| 9836 |
local read=cffreaders[osize] |
| 9837 |
if not read then |
| 9838 |
report("bad offset size: %i",osize) |
| 9839 |
return {} |
| 9840 |
end |
| 9841 |
local lengths={} |
| 9842 |
local previous=read(f) |
| 9843 |
for i=1,count do |
| 9844 |
local offset=read(f) |
| 9845 |
local length=offset-previous |
| 9846 |
if length<0 then |
| 9847 |
report("bad offset: %i",length) |
| 9848 |
length=0 |
| 9849 |
end |
| 9850 |
lengths[i]=length |
| 9851 |
previous=offset |
| 9852 |
end |
| 9853 |
return lengths |
| 9854 |
end |
| 9855 |
local function readfontnames(f) |
| 9856 |
local names=readlengths(f) |
| 9857 |
for i=1,#names do |
| 9858 |
names[i]=readstring(f,names[i]) |
| 9859 |
end |
| 9860 |
return names |
| 9861 |
end |
| 9862 |
local function readtopdictionaries(f) |
| 9863 |
local dictionaries=readlengths(f) |
| 9864 |
for i=1,#dictionaries do |
| 9865 |
dictionaries[i]=readstring(f,dictionaries[i]) |
| 9866 |
end |
| 9867 |
return dictionaries |
| 9868 |
end |
| 9869 |
local function readstrings(f) |
| 9870 |
local lengths=readlengths(f) |
| 9871 |
local strings=setmetatableindex({},defaultstrings) |
| 9872 |
local index=#defaultstrings |
| 9873 |
for i=1,#lengths do |
| 9874 |
index=index+1 |
| 9875 |
strings[index]=readstring(f,lengths[i]) |
| 9876 |
end |
| 9877 |
return strings |
| 9878 |
end |
| 9879 |
do |
| 9880 |
local stack={} |
| 9881 |
local top=0 |
| 9882 |
local result={} |
| 9883 |
local strings={} |
| 9884 |
local p_single=P("\00")/function() |
| 9885 |
result.version=strings[stack[top]] or "unset" |
| 9886 |
top=0 |
| 9887 |
end+P("\01")/function() |
| 9888 |
result.notice=strings[stack[top]] or "unset" |
| 9889 |
top=0 |
| 9890 |
end+P("\02")/function() |
| 9891 |
result.fullname=strings[stack[top]] or "unset" |
| 9892 |
top=0 |
| 9893 |
end+P("\03")/function() |
| 9894 |
result.familyname=strings[stack[top]] or "unset" |
| 9895 |
top=0 |
| 9896 |
end+P("\04")/function() |
| 9897 |
result.weight=strings[stack[top]] or "unset" |
| 9898 |
top=0 |
| 9899 |
end+P("\05")/function() |
| 9900 |
result.fontbbox={ unpack(stack,1,4) } |
| 9901 |
top=0 |
| 9902 |
end+P("\06")/function() |
| 9903 |
result.bluevalues={ unpack(stack,1,top) } |
| 9904 |
top=0 |
| 9905 |
end+P("\07")/function() |
| 9906 |
result.otherblues={ unpack(stack,1,top) } |
| 9907 |
top=0 |
| 9908 |
end+P("\08")/function() |
| 9909 |
result.familyblues={ unpack(stack,1,top) } |
| 9910 |
top=0 |
| 9911 |
end+P("\09")/function() |
| 9912 |
result.familyotherblues={ unpack(stack,1,top) } |
| 9913 |
top=0 |
| 9914 |
end+P("\10")/function() |
| 9915 |
result.stdhw=stack[top] |
| 9916 |
top=0 |
| 9917 |
end+P("\11")/function() |
| 9918 |
result.stdvw=stack[top] |
| 9919 |
top=0 |
| 9920 |
end+P("\13")/function() |
| 9921 |
result.uniqueid=stack[top] |
| 9922 |
top=0 |
| 9923 |
end+P("\14")/function() |
| 9924 |
result.xuid=concat(stack,"",1,top) |
| 9925 |
top=0 |
| 9926 |
end+P("\15")/function() |
| 9927 |
result.charset=stack[top] |
| 9928 |
top=0 |
| 9929 |
end+P("\16")/function() |
| 9930 |
result.encoding=stack[top] |
| 9931 |
top=0 |
| 9932 |
end+P("\17")/function() |
| 9933 |
result.charstrings=stack[top] |
| 9934 |
top=0 |
| 9935 |
end+P("\18")/function() |
| 9936 |
result.private={ |
| 9937 |
size=stack[top-1], |
| 9938 |
offset=stack[top], |
| 9939 |
} |
| 9940 |
top=0 |
| 9941 |
end+P("\19")/function() |
| 9942 |
result.subroutines=stack[top] |
| 9943 |
top=0 |
| 9944 |
end+P("\20")/function() |
| 9945 |
result.defaultwidthx=stack[top] |
| 9946 |
top=0 |
| 9947 |
end+P("\21")/function() |
| 9948 |
result.nominalwidthx=stack[top] |
| 9949 |
top=0 |
| 9950 |
end |
| 9951 |
+P("\24")/function() |
| 9952 |
result.vstore=stack[top] |
| 9953 |
top=0 |
| 9954 |
end+P("\25")/function() |
| 9955 |
result.maxstack=stack[top] |
| 9956 |
top=0 |
| 9957 |
end |
| 9958 |
local p_double=P("\12")*( |
| 9959 |
P("\00")/function() |
| 9960 |
result.copyright=stack[top] |
| 9961 |
top=0 |
| 9962 |
end+P("\01")/function() |
| 9963 |
result.monospaced=stack[top]==1 and true or false |
| 9964 |
top=0 |
| 9965 |
end+P("\02")/function() |
| 9966 |
result.italicangle=stack[top] |
| 9967 |
top=0 |
| 9968 |
end+P("\03")/function() |
| 9969 |
result.underlineposition=stack[top] |
| 9970 |
top=0 |
| 9971 |
end+P("\04")/function() |
| 9972 |
result.underlinethickness=stack[top] |
| 9973 |
top=0 |
| 9974 |
end+P("\05")/function() |
| 9975 |
result.painttype=stack[top] |
| 9976 |
top=0 |
| 9977 |
end+P("\06")/function() |
| 9978 |
result.charstringtype=stack[top] |
| 9979 |
top=0 |
| 9980 |
end+P("\07")/function() |
| 9981 |
result.fontmatrix={ unpack(stack,1,6) } |
| 9982 |
top=0 |
| 9983 |
end+P("\08")/function() |
| 9984 |
result.strokewidth=stack[top] |
| 9985 |
top=0 |
| 9986 |
end+P("\09")/function() |
| 9987 |
result.bluescale=stack[top] |
| 9988 |
top=0 |
| 9989 |
end+P("\10")/function() |
| 9990 |
result.blueshift=stack[top] |
| 9991 |
top=0 |
| 9992 |
end+P("\11")/function() |
| 9993 |
result.bluefuzz=stack[top] |
| 9994 |
top=0 |
| 9995 |
end+P("\12")/function() |
| 9996 |
result.stemsnaph={ unpack(stack,1,top) } |
| 9997 |
top=0 |
| 9998 |
end+P("\13")/function() |
| 9999 |
result.stemsnapv={ unpack(stack,1,top) } |
| 10000 |
top=0 |
| 10001 |
end+P("\20")/function() |
| 10002 |
result.syntheticbase=stack[top] |
| 10003 |
top=0 |
| 10004 |
end+P("\21")/function() |
| 10005 |
result.postscript=strings[stack[top]] or "unset" |
| 10006 |
top=0 |
| 10007 |
end+P("\22")/function() |
| 10008 |
result.basefontname=strings[stack[top]] or "unset" |
| 10009 |
top=0 |
| 10010 |
end+P("\21")/function() |
| 10011 |
result.basefontblend=stack[top] |
| 10012 |
top=0 |
| 10013 |
end+P("\30")/function() |
| 10014 |
result.cid.registry=strings[stack[top-2]] or "unset" |
| 10015 |
result.cid.ordering=strings[stack[top-1]] or "unset" |
| 10016 |
result.cid.supplement=stack[top] |
| 10017 |
top=0 |
| 10018 |
end+P("\31")/function() |
| 10019 |
result.cid.fontversion=stack[top] |
| 10020 |
top=0 |
| 10021 |
end+P("\32")/function() |
| 10022 |
result.cid.fontrevision=stack[top] |
| 10023 |
top=0 |
| 10024 |
end+P("\33")/function() |
| 10025 |
result.cid.fonttype=stack[top] |
| 10026 |
top=0 |
| 10027 |
end+P("\34")/function() |
| 10028 |
result.cid.count=stack[top] |
| 10029 |
top=0 |
| 10030 |
end+P("\35")/function() |
| 10031 |
result.cid.uidbase=stack[top] |
| 10032 |
top=0 |
| 10033 |
end+P("\36")/function() |
| 10034 |
result.cid.fdarray=stack[top] |
| 10035 |
top=0 |
| 10036 |
end+P("\37")/function() |
| 10037 |
result.cid.fdselect=stack[top] |
| 10038 |
top=0 |
| 10039 |
end+P("\38")/function() |
| 10040 |
result.cid.fontname=strings[stack[top]] or "unset" |
| 10041 |
top=0 |
| 10042 |
end |
| 10043 |
) |
| 10044 |
local remap_1={ |
| 10045 |
["\x00"]="00",["\x01"]="01",["\x02"]="02",["\x03"]="03",["\x04"]="04",["\x05"]="05",["\x06"]="06",["\x07"]="07",["\x08"]="08",["\x09"]="09",["\x0A"]="0.",["\x0B"]="0E",["\x0C"]="0E-",["\x0D"]="0",["\x0E"]="0-",["\x0F"]="0", |
| 10046 |
["\x10"]="10",["\x11"]="11",["\x12"]="12",["\x13"]="13",["\x14"]="14",["\x15"]="15",["\x16"]="16",["\x17"]="17",["\x18"]="18",["\x19"]="19",["\x1A"]="1.",["\x1B"]="1E",["\x1C"]="1E-",["\x1D"]="1",["\x1E"]="1-",["\x1F"]="1", |
| 10047 |
["\x20"]="20",["\x21"]="21",["\x22"]="22",["\x23"]="23",["\x24"]="24",["\x25"]="25",["\x26"]="26",["\x27"]="27",["\x28"]="28",["\x29"]="29",["\x2A"]="2.",["\x2B"]="2E",["\x2C"]="2E-",["\x2D"]="2",["\x2E"]="2-",["\x2F"]="2", |
| 10048 |
["\x30"]="30",["\x31"]="31",["\x32"]="32",["\x33"]="33",["\x34"]="34",["\x35"]="35",["\x36"]="36",["\x37"]="37",["\x38"]="38",["\x39"]="39",["\x3A"]="3.",["\x3B"]="3E",["\x3C"]="3E-",["\x3D"]="3",["\x3E"]="3-",["\x3F"]="3", |
| 10049 |
["\x40"]="40",["\x41"]="41",["\x42"]="42",["\x43"]="43",["\x44"]="44",["\x45"]="45",["\x46"]="46",["\x47"]="47",["\x48"]="48",["\x49"]="49",["\x4A"]="4.",["\x4B"]="4E",["\x4C"]="4E-",["\x4D"]="4",["\x4E"]="4-",["\x4F"]="4", |
| 10050 |
["\x50"]="50",["\x51"]="51",["\x52"]="52",["\x53"]="53",["\x54"]="54",["\x55"]="55",["\x56"]="56",["\x57"]="57",["\x58"]="58",["\x59"]="59",["\x5A"]="5.",["\x5B"]="5E",["\x5C"]="5E-",["\x5D"]="5",["\x5E"]="5-",["\x5F"]="5", |
| 10051 |
["\x60"]="60",["\x61"]="61",["\x62"]="62",["\x63"]="63",["\x64"]="64",["\x65"]="65",["\x66"]="66",["\x67"]="67",["\x68"]="68",["\x69"]="69",["\x6A"]="6.",["\x6B"]="6E",["\x6C"]="6E-",["\x6D"]="6",["\x6E"]="6-",["\x6F"]="6", |
| 10052 |
["\x70"]="70",["\x71"]="71",["\x72"]="72",["\x73"]="73",["\x74"]="74",["\x75"]="75",["\x76"]="76",["\x77"]="77",["\x78"]="78",["\x79"]="79",["\x7A"]="7.",["\x7B"]="7E",["\x7C"]="7E-",["\x7D"]="7",["\x7E"]="7-",["\x7F"]="7", |
| 10053 |
["\x80"]="80",["\x81"]="81",["\x82"]="82",["\x83"]="83",["\x84"]="84",["\x85"]="85",["\x86"]="86",["\x87"]="87",["\x88"]="88",["\x89"]="89",["\x8A"]="8.",["\x8B"]="8E",["\x8C"]="8E-",["\x8D"]="8",["\x8E"]="8-",["\x8F"]="8", |
| 10054 |
["\x90"]="90",["\x91"]="91",["\x92"]="92",["\x93"]="93",["\x94"]="94",["\x95"]="95",["\x96"]="96",["\x97"]="97",["\x98"]="98",["\x99"]="99",["\x9A"]="9.",["\x9B"]="9E",["\x9C"]="9E-",["\x9D"]="9",["\x9E"]="9-",["\x9F"]="9", |
| 10055 |
["\xA0"]=".0",["\xA1"]=".1",["\xA2"]=".2",["\xA3"]=".3",["\xA4"]=".4",["\xA5"]=".5",["\xA6"]=".6",["\xA7"]=".7",["\xA8"]=".8",["\xA9"]=".9",["\xAA"]="..",["\xAB"]=".E",["\xAC"]=".E-",["\xAD"]=".",["\xAE"]=".-",["\xAF"]=".", |
| 10056 |
["\xB0"]="E0",["\xB1"]="E1",["\xB2"]="E2",["\xB3"]="E3",["\xB4"]="E4",["\xB5"]="E5",["\xB6"]="E6",["\xB7"]="E7",["\xB8"]="E8",["\xB9"]="E9",["\xBA"]="E.",["\xBB"]="EE",["\xBC"]="EE-",["\xBD"]="E",["\xBE"]="E-",["\xBF"]="E", |
| 10057 |
["\xC0"]="E-0",["\xC1"]="E-1",["\xC2"]="E-2",["\xC3"]="E-3",["\xC4"]="E-4",["\xC5"]="E-5",["\xC6"]="E-6",["\xC7"]="E-7",["\xC8"]="E-8",["\xC9"]="E-9",["\xCA"]="E-.",["\xCB"]="E-E",["\xCC"]="E-E-",["\xCD"]="E-",["\xCE"]="E--",["\xCF"]="E-", |
| 10058 |
["\xD0"]="-0",["\xD1"]="-1",["\xD2"]="-2",["\xD3"]="-3",["\xD4"]="-4",["\xD5"]="-5",["\xD6"]="-6",["\xD7"]="-7",["\xD8"]="-8",["\xD9"]="-9",["\xDA"]="-.",["\xDB"]="-E",["\xDC"]="-E-",["\xDD"]="-",["\xDE"]="--",["\xDF"]="-", |
| 10059 |
} |
| 10060 |
local remap_2={ |
| 10061 |
["\x0F"]="0",["\x1F"]="1",["\x2F"]="2",["\x3F"]="3",["\x4F"]="4", |
| 10062 |
["\x5F"]="5",["\x6F"]="6",["\x7F"]="7",["\x8F"]="8",["\x9F"]="9", |
| 10063 |
} |
| 10064 |
local p_last_1=S("\x0F\x1F\x2F\x3F\x4F\x5F\x6F\x7F\x8F\x9F\xAF\xBF") |
| 10065 |
local p_last_2=R("\xF0\xFF") |
| 10066 |
local p_nibbles=P("\30")*Cs(((1-(p_last_1+p_last_2))/remap_1)^0*(p_last_1/remap_2+p_last_2/""))/function(n) |
| 10067 |
top=top+1 |
| 10068 |
stack[top]=tonumber(n) or 0 |
| 10069 |
end |
| 10070 |
local p_byte=C(R("\32\246"))/function(b0) |
| 10071 |
top=top+1 |
| 10072 |
stack[top]=byte(b0)-139 |
| 10073 |
end |
| 10074 |
local p_positive=C(R("\247\250"))*C(1)/function(b0,b1) |
| 10075 |
top=top+1 |
| 10076 |
stack[top]=(byte(b0)-247)*256+byte(b1)+108 |
| 10077 |
end |
| 10078 |
local p_negative=C(R("\251\254"))*C(1)/function(b0,b1) |
| 10079 |
top=top+1 |
| 10080 |
stack[top]=-(byte(b0)-251)*256-byte(b1)-108 |
| 10081 |
end |
| 10082 |
local p_short=P("\28")*C(1)*C(1)/function(b1,b2) |
| 10083 |
top=top+1 |
| 10084 |
local n=0x100*byte(b1)+byte(b2) |
| 10085 |
if n>=0x8000 then |
| 10086 |
stack[top]=n-0xFFFF-1 |
| 10087 |
else |
| 10088 |
stack[top]=n |
| 10089 |
end |
| 10090 |
end |
| 10091 |
local p_long=P("\29")*C(1)*C(1)*C(1)*C(1)/function(b1,b2,b3,b4) |
| 10092 |
top=top+1 |
| 10093 |
local n=0x1000000*byte(b1)+0x10000*byte(b2)+0x100*byte(b3)+byte(b4) |
| 10094 |
if n>=0x8000000 then |
| 10095 |
stack[top]=n-0xFFFFFFFF-1 |
| 10096 |
else |
| 10097 |
stack[top]=n |
| 10098 |
end |
| 10099 |
end |
| 10100 |
local p_unsupported=P(1)/function(detail) |
| 10101 |
top=0 |
| 10102 |
end |
| 10103 |
local p_dictionary=( |
| 10104 |
p_byte+p_positive+p_negative+p_short+p_long+p_nibbles+p_single+p_double |
| 10105 |
+p_unsupported |
| 10106 |
)^1 |
| 10107 |
parsedictionaries=function(data,dictionaries,version) |
| 10108 |
stack={} |
| 10109 |
strings=data.strings |
| 10110 |
if trace_charstrings then |
| 10111 |
report("charstring format %a",version) |
| 10112 |
end |
| 10113 |
for i=1,#dictionaries do |
| 10114 |
top=0 |
| 10115 |
result=version=="cff" and { |
| 10116 |
monospaced=false, |
| 10117 |
italicangle=0, |
| 10118 |
underlineposition=-100, |
| 10119 |
underlinethickness=50, |
| 10120 |
painttype=0, |
| 10121 |
charstringtype=2, |
| 10122 |
fontmatrix={ 0.001,0,0,0.001,0,0 }, |
| 10123 |
fontbbox={ 0,0,0,0 }, |
| 10124 |
strokewidth=0, |
| 10125 |
charset=0, |
| 10126 |
encoding=0, |
| 10127 |
cid={ |
| 10128 |
fontversion=0, |
| 10129 |
fontrevision=0, |
| 10130 |
fonttype=0, |
| 10131 |
count=8720, |
| 10132 |
} |
| 10133 |
} or { |
| 10134 |
charstringtype=2, |
| 10135 |
charset=0, |
| 10136 |
vstore=0, |
| 10137 |
cid={ |
| 10138 |
}, |
| 10139 |
} |
| 10140 |
lpegmatch(p_dictionary,dictionaries[i]) |
| 10141 |
dictionaries[i]=result |
| 10142 |
end |
| 10143 |
result={} |
| 10144 |
top=0 |
| 10145 |
stack={} |
| 10146 |
end |
| 10147 |
parseprivates=function(data,dictionaries) |
| 10148 |
stack={} |
| 10149 |
strings=data.strings |
| 10150 |
for i=1,#dictionaries do |
| 10151 |
local private=dictionaries[i].private |
| 10152 |
if private and private.data then |
| 10153 |
top=0 |
| 10154 |
result={ |
| 10155 |
forcebold=false, |
| 10156 |
languagegroup=0, |
| 10157 |
expansionfactor=0.06, |
| 10158 |
initialrandomseed=0, |
| 10159 |
subroutines=0, |
| 10160 |
defaultwidthx=0, |
| 10161 |
nominalwidthx=0, |
| 10162 |
cid={ |
| 10163 |
}, |
| 10164 |
} |
| 10165 |
lpegmatch(p_dictionary,private.data) |
| 10166 |
private.data=result |
| 10167 |
end |
| 10168 |
end |
| 10169 |
result={} |
| 10170 |
top=0 |
| 10171 |
stack={} |
| 10172 |
end |
| 10173 |
local x=0 |
| 10174 |
local y=0 |
| 10175 |
local width=false |
| 10176 |
local lsb=0 |
| 10177 |
local result={} |
| 10178 |
local r=0 |
| 10179 |
local stems=0 |
| 10180 |
local globalbias=0 |
| 10181 |
local localbias=0 |
| 10182 |
local nominalwidth=0 |
| 10183 |
local defaultwidth=0 |
| 10184 |
local charset=false |
| 10185 |
local globals=false |
| 10186 |
local locals=false |
| 10187 |
local depth=1 |
| 10188 |
local xmin=0 |
| 10189 |
local xmax=0 |
| 10190 |
local ymin=0 |
| 10191 |
local ymax=0 |
| 10192 |
local checked=false |
| 10193 |
local keepcurve=false |
| 10194 |
local version=2 |
| 10195 |
local regions=false |
| 10196 |
local nofregions=0 |
| 10197 |
local region=false |
| 10198 |
local factors=false |
| 10199 |
local axis=false |
| 10200 |
local vsindex=0 |
| 10201 |
local justpass=false |
| 10202 |
local seacs={} |
| 10203 |
local procidx=nil |
| 10204 |
local function showstate(where,i,n) |
| 10205 |
if i then |
| 10206 |
local j=i+n-1 |
| 10207 |
report("%w%-10s : [%s] step",depth*2+2,where,concat(stack," ",i,j<=top and j or top)) |
| 10208 |
else |
| 10209 |
report("%w%-10s : [%s] n=%i",depth*2,where,concat(stack," ",1,top),top) |
| 10210 |
end |
| 10211 |
end |
| 10212 |
local function showvalue(where,value,showstack) |
| 10213 |
if showstack then |
| 10214 |
report("%w%-10s : %s : [%s] n=%i",depth*2,where,tostring(value),concat(stack," ",1,top),top) |
| 10215 |
else |
| 10216 |
report("%w%-10s : %s",depth*2,where,tostring(value)) |
| 10217 |
end |
| 10218 |
end |
| 10219 |
local function xymoveto() |
| 10220 |
if keepcurve then |
| 10221 |
r=r+1 |
| 10222 |
result[r]={ x,y,"m" } |
| 10223 |
end |
| 10224 |
if checked then |
| 10225 |
if x>xmax then xmax=x elseif x<xmin then xmin=x end |
| 10226 |
if y>ymax then ymax=y elseif y<ymin then ymin=y end |
| 10227 |
else |
| 10228 |
xmin=x |
| 10229 |
ymin=y |
| 10230 |
xmax=x |
| 10231 |
ymax=y |
| 10232 |
checked=true |
| 10233 |
end |
| 10234 |
end |
| 10235 |
local function xmoveto() |
| 10236 |
if keepcurve then |
| 10237 |
r=r+1 |
| 10238 |
result[r]={ x,y,"m" } |
| 10239 |
end |
| 10240 |
if not checked then |
| 10241 |
xmin=x |
| 10242 |
ymin=y |
| 10243 |
xmax=x |
| 10244 |
ymax=y |
| 10245 |
checked=true |
| 10246 |
elseif x>xmax then |
| 10247 |
xmax=x |
| 10248 |
elseif x<xmin then |
| 10249 |
xmin=x |
| 10250 |
end |
| 10251 |
end |
| 10252 |
local function ymoveto() |
| 10253 |
if keepcurve then |
| 10254 |
r=r+1 |
| 10255 |
result[r]={ x,y,"m" } |
| 10256 |
end |
| 10257 |
if not checked then |
| 10258 |
xmin=x |
| 10259 |
ymin=y |
| 10260 |
xmax=x |
| 10261 |
ymax=y |
| 10262 |
checked=true |
| 10263 |
elseif y>ymax then |
| 10264 |
ymax=y |
| 10265 |
elseif y<ymin then |
| 10266 |
ymin=y |
| 10267 |
end |
| 10268 |
end |
| 10269 |
local function moveto() |
| 10270 |
if trace_charstrings then |
| 10271 |
showstate("moveto") |
| 10272 |
end |
| 10273 |
top=0 |
| 10274 |
xymoveto() |
| 10275 |
end |
| 10276 |
local function xylineto() |
| 10277 |
if keepcurve then |
| 10278 |
r=r+1 |
| 10279 |
result[r]={ x,y,"l" } |
| 10280 |
end |
| 10281 |
if checked then |
| 10282 |
if x>xmax then xmax=x elseif x<xmin then xmin=x end |
| 10283 |
if y>ymax then ymax=y elseif y<ymin then ymin=y end |
| 10284 |
else |
| 10285 |
xmin=x |
| 10286 |
ymin=y |
| 10287 |
xmax=x |
| 10288 |
ymax=y |
| 10289 |
checked=true |
| 10290 |
end |
| 10291 |
end |
| 10292 |
local function xlineto() |
| 10293 |
if keepcurve then |
| 10294 |
r=r+1 |
| 10295 |
result[r]={ x,y,"l" } |
| 10296 |
end |
| 10297 |
if not checked then |
| 10298 |
xmin=x |
| 10299 |
ymin=y |
| 10300 |
xmax=x |
| 10301 |
ymax=y |
| 10302 |
checked=true |
| 10303 |
elseif x>xmax then |
| 10304 |
xmax=x |
| 10305 |
elseif x<xmin then |
| 10306 |
xmin=x |
| 10307 |
end |
| 10308 |
end |
| 10309 |
local function ylineto() |
| 10310 |
if keepcurve then |
| 10311 |
r=r+1 |
| 10312 |
result[r]={ x,y,"l" } |
| 10313 |
end |
| 10314 |
if not checked then |
| 10315 |
xmin=x |
| 10316 |
ymin=y |
| 10317 |
xmax=x |
| 10318 |
ymax=y |
| 10319 |
checked=true |
| 10320 |
elseif y>ymax then |
| 10321 |
ymax=y |
| 10322 |
elseif y<ymin then |
| 10323 |
ymin=y |
| 10324 |
end |
| 10325 |
end |
| 10326 |
local function xycurveto(x1,y1,x2,y2,x3,y3,i,n) |
| 10327 |
if trace_charstrings then |
| 10328 |
showstate("curveto",i,n) |
| 10329 |
end |
| 10330 |
if keepcurve then |
| 10331 |
r=r+1 |
| 10332 |
result[r]={ x1,y1,x2,y2,x3,y3,"c" } |
| 10333 |
end |
| 10334 |
if checked then |
| 10335 |
if x1>xmax then xmax=x1 elseif x1<xmin then xmin=x1 end |
| 10336 |
if y1>ymax then ymax=y1 elseif y1<ymin then ymin=y1 end |
| 10337 |
else |
| 10338 |
xmin=x1 |
| 10339 |
ymin=y1 |
| 10340 |
xmax=x1 |
| 10341 |
ymax=y1 |
| 10342 |
checked=true |
| 10343 |
end |
| 10344 |
if x2>xmax then xmax=x2 elseif x2<xmin then xmin=x2 end |
| 10345 |
if y2>ymax then ymax=y2 elseif y2<ymin then ymin=y2 end |
| 10346 |
if x3>xmax then xmax=x3 elseif x3<xmin then xmin=x3 end |
| 10347 |
if y3>ymax then ymax=y3 elseif y3<ymin then ymin=y3 end |
| 10348 |
end |
| 10349 |
local function rmoveto() |
| 10350 |
if not width then |
| 10351 |
if top>2 then |
| 10352 |
width=stack[1] |
| 10353 |
if trace_charstrings then |
| 10354 |
showvalue("backtrack width",width) |
| 10355 |
end |
| 10356 |
else |
| 10357 |
width=true |
| 10358 |
end |
| 10359 |
end |
| 10360 |
if trace_charstrings then |
| 10361 |
showstate("rmoveto") |
| 10362 |
end |
| 10363 |
x=x+stack[top-1] |
| 10364 |
y=y+stack[top] |
| 10365 |
top=0 |
| 10366 |
xymoveto() |
| 10367 |
end |
| 10368 |
local function hmoveto() |
| 10369 |
if not width then |
| 10370 |
if top>1 then |
| 10371 |
width=stack[1] |
| 10372 |
if trace_charstrings then |
| 10373 |
showvalue("backtrack width",width) |
| 10374 |
end |
| 10375 |
else |
| 10376 |
width=true |
| 10377 |
end |
| 10378 |
end |
| 10379 |
if trace_charstrings then |
| 10380 |
showstate("hmoveto") |
| 10381 |
end |
| 10382 |
x=x+stack[top] |
| 10383 |
top=0 |
| 10384 |
xmoveto() |
| 10385 |
end |
| 10386 |
local function vmoveto() |
| 10387 |
if not width then |
| 10388 |
if top>1 then |
| 10389 |
width=stack[1] |
| 10390 |
if trace_charstrings then |
| 10391 |
showvalue("backtrack width",width) |
| 10392 |
end |
| 10393 |
else |
| 10394 |
width=true |
| 10395 |
end |
| 10396 |
end |
| 10397 |
if trace_charstrings then |
| 10398 |
showstate("vmoveto") |
| 10399 |
end |
| 10400 |
y=y+stack[top] |
| 10401 |
top=0 |
| 10402 |
ymoveto() |
| 10403 |
end |
| 10404 |
local function rlineto() |
| 10405 |
if trace_charstrings then |
| 10406 |
showstate("rlineto") |
| 10407 |
end |
| 10408 |
for i=1,top,2 do |
| 10409 |
x=x+stack[i] |
| 10410 |
y=y+stack[i+1] |
| 10411 |
xylineto() |
| 10412 |
end |
| 10413 |
top=0 |
| 10414 |
end |
| 10415 |
local function hlineto() |
| 10416 |
if trace_charstrings then |
| 10417 |
showstate("hlineto") |
| 10418 |
end |
| 10419 |
if top==1 then |
| 10420 |
x=x+stack[1] |
| 10421 |
xlineto() |
| 10422 |
else |
| 10423 |
local swap=true |
| 10424 |
for i=1,top do |
| 10425 |
if swap then |
| 10426 |
x=x+stack[i] |
| 10427 |
xlineto() |
| 10428 |
swap=false |
| 10429 |
else |
| 10430 |
y=y+stack[i] |
| 10431 |
ylineto() |
| 10432 |
swap=true |
| 10433 |
end |
| 10434 |
end |
| 10435 |
end |
| 10436 |
top=0 |
| 10437 |
end |
| 10438 |
local function vlineto() |
| 10439 |
if trace_charstrings then |
| 10440 |
showstate("vlineto") |
| 10441 |
end |
| 10442 |
if top==1 then |
| 10443 |
y=y+stack[1] |
| 10444 |
ylineto() |
| 10445 |
else |
| 10446 |
local swap=false |
| 10447 |
for i=1,top do |
| 10448 |
if swap then |
| 10449 |
x=x+stack[i] |
| 10450 |
xlineto() |
| 10451 |
swap=false |
| 10452 |
else |
| 10453 |
y=y+stack[i] |
| 10454 |
ylineto() |
| 10455 |
swap=true |
| 10456 |
end |
| 10457 |
end |
| 10458 |
end |
| 10459 |
top=0 |
| 10460 |
end |
| 10461 |
local function rrcurveto() |
| 10462 |
if trace_charstrings then |
| 10463 |
showstate("rrcurveto") |
| 10464 |
end |
| 10465 |
if top==6 then |
| 10466 |
local ax=x+stack[1] |
| 10467 |
local ay=y+stack[2] |
| 10468 |
local bx=ax+stack[3] |
| 10469 |
local by=ay+stack[4] |
| 10470 |
x=bx+stack[5] |
| 10471 |
y=by+stack[6] |
| 10472 |
xycurveto(ax,ay,bx,by,x,y,1,6) |
| 10473 |
else |
| 10474 |
for i=1,top,6 do |
| 10475 |
local ax=x+stack[i] |
| 10476 |
local ay=y+stack[i+1] |
| 10477 |
local bx=ax+stack[i+2] |
| 10478 |
local by=ay+stack[i+3] |
| 10479 |
x=bx+stack[i+4] |
| 10480 |
y=by+stack[i+5] |
| 10481 |
xycurveto(ax,ay,bx,by,x,y,i,6) |
| 10482 |
end |
| 10483 |
end |
| 10484 |
top=0 |
| 10485 |
end |
| 10486 |
local function hhcurveto() |
| 10487 |
if trace_charstrings then |
| 10488 |
showstate("hhcurveto") |
| 10489 |
end |
| 10490 |
local s=1 |
| 10491 |
if top%2~=0 then |
| 10492 |
y=y+stack[1] |
| 10493 |
s=2 |
| 10494 |
end |
| 10495 |
if top==4 then |
| 10496 |
local ax=x+stack[1] |
| 10497 |
local ay=y |
| 10498 |
local bx=ax+stack[2] |
| 10499 |
local by=ay+stack[3] |
| 10500 |
x=bx+stack[4] |
| 10501 |
y=by |
| 10502 |
xycurveto(ax,ay,bx,by,x,y,1,4) |
| 10503 |
else |
| 10504 |
for i=s,top,4 do |
| 10505 |
local ax=x+stack[i] |
| 10506 |
local ay=y |
| 10507 |
local bx=ax+stack[i+1] |
| 10508 |
local by=ay+stack[i+2] |
| 10509 |
x=bx+stack[i+3] |
| 10510 |
y=by |
| 10511 |
xycurveto(ax,ay,bx,by,x,y,i,4) |
| 10512 |
end |
| 10513 |
end |
| 10514 |
top=0 |
| 10515 |
end |
| 10516 |
local function vvcurveto() |
| 10517 |
if trace_charstrings then |
| 10518 |
showstate("vvcurveto") |
| 10519 |
end |
| 10520 |
local s=1 |
| 10521 |
local d=0 |
| 10522 |
if top%2~=0 then |
| 10523 |
d=stack[1] |
| 10524 |
s=2 |
| 10525 |
end |
| 10526 |
if top==4 then |
| 10527 |
local ax=x+d |
| 10528 |
local ay=y+stack[1] |
| 10529 |
local bx=ax+stack[2] |
| 10530 |
local by=ay+stack[3] |
| 10531 |
x=bx |
| 10532 |
y=by+stack[4] |
| 10533 |
xycurveto(ax,ay,bx,by,x,y,1,4) |
| 10534 |
d=0 |
| 10535 |
else |
| 10536 |
for i=s,top,4 do |
| 10537 |
local ax=x+d |
| 10538 |
local ay=y+stack[i] |
| 10539 |
local bx=ax+stack[i+1] |
| 10540 |
local by=ay+stack[i+2] |
| 10541 |
x=bx |
| 10542 |
y=by+stack[i+3] |
| 10543 |
xycurveto(ax,ay,bx,by,x,y,i,4) |
| 10544 |
d=0 |
| 10545 |
end |
| 10546 |
end |
| 10547 |
top=0 |
| 10548 |
end |
| 10549 |
local function xxcurveto(swap) |
| 10550 |
local last=top%4~=0 and stack[top] |
| 10551 |
if last then |
| 10552 |
top=top-1 |
| 10553 |
end |
| 10554 |
if top==4 then |
| 10555 |
local ax,ay,bx,by |
| 10556 |
if swap then |
| 10557 |
ax=x+stack[1] |
| 10558 |
ay=y |
| 10559 |
bx=ax+stack[2] |
| 10560 |
by=ay+stack[3] |
| 10561 |
y=by+stack[4] |
| 10562 |
if last then |
| 10563 |
x=bx+last |
| 10564 |
else |
| 10565 |
x=bx |
| 10566 |
end |
| 10567 |
else |
| 10568 |
ax=x |
| 10569 |
ay=y+stack[1] |
| 10570 |
bx=ax+stack[2] |
| 10571 |
by=ay+stack[3] |
| 10572 |
x=bx+stack[4] |
| 10573 |
if last then |
| 10574 |
y=by+last |
| 10575 |
else |
| 10576 |
y=by |
| 10577 |
end |
| 10578 |
end |
| 10579 |
xycurveto(ax,ay,bx,by,x,y,1,4) |
| 10580 |
else |
| 10581 |
for i=1,top,4 do |
| 10582 |
local ax,ay,bx,by |
| 10583 |
if swap then |
| 10584 |
ax=x+stack[i] |
| 10585 |
ay=y |
| 10586 |
bx=ax+stack[i+1] |
| 10587 |
by=ay+stack[i+2] |
| 10588 |
y=by+stack[i+3] |
| 10589 |
if last and i+3==top then |
| 10590 |
x=bx+last |
| 10591 |
else |
| 10592 |
x=bx |
| 10593 |
end |
| 10594 |
swap=false |
| 10595 |
else |
| 10596 |
ax=x |
| 10597 |
ay=y+stack[i] |
| 10598 |
bx=ax+stack[i+1] |
| 10599 |
by=ay+stack[i+2] |
| 10600 |
x=bx+stack[i+3] |
| 10601 |
if last and i+3==top then |
| 10602 |
y=by+last |
| 10603 |
else |
| 10604 |
y=by |
| 10605 |
end |
| 10606 |
swap=true |
| 10607 |
end |
| 10608 |
xycurveto(ax,ay,bx,by,x,y,i,4) |
| 10609 |
end |
| 10610 |
end |
| 10611 |
top=0 |
| 10612 |
end |
| 10613 |
local function hvcurveto() |
| 10614 |
if trace_charstrings then |
| 10615 |
showstate("hvcurveto") |
| 10616 |
end |
| 10617 |
xxcurveto(true) |
| 10618 |
end |
| 10619 |
local function vhcurveto() |
| 10620 |
if trace_charstrings then |
| 10621 |
showstate("vhcurveto") |
| 10622 |
end |
| 10623 |
xxcurveto(false) |
| 10624 |
end |
| 10625 |
local function rcurveline() |
| 10626 |
if trace_charstrings then |
| 10627 |
showstate("rcurveline") |
| 10628 |
end |
| 10629 |
for i=1,top-2,6 do |
| 10630 |
local ax=x+stack[i] |
| 10631 |
local ay=y+stack[i+1] |
| 10632 |
local bx=ax+stack[i+2] |
| 10633 |
local by=ay+stack[i+3] |
| 10634 |
x=bx+stack[i+4] |
| 10635 |
y=by+stack[i+5] |
| 10636 |
xycurveto(ax,ay,bx,by,x,y,i,6) |
| 10637 |
end |
| 10638 |
x=x+stack[top-1] |
| 10639 |
y=y+stack[top] |
| 10640 |
xylineto() |
| 10641 |
top=0 |
| 10642 |
end |
| 10643 |
local function rlinecurve() |
| 10644 |
if trace_charstrings then |
| 10645 |
showstate("rlinecurve") |
| 10646 |
end |
| 10647 |
if top>6 then |
| 10648 |
for i=1,top-6,2 do |
| 10649 |
x=x+stack[i] |
| 10650 |
y=y+stack[i+1] |
| 10651 |
xylineto() |
| 10652 |
end |
| 10653 |
end |
| 10654 |
local ax=x+stack[top-5] |
| 10655 |
local ay=y+stack[top-4] |
| 10656 |
local bx=ax+stack[top-3] |
| 10657 |
local by=ay+stack[top-2] |
| 10658 |
x=bx+stack[top-1] |
| 10659 |
y=by+stack[top] |
| 10660 |
xycurveto(ax,ay,bx,by,x,y) |
| 10661 |
top=0 |
| 10662 |
end |
| 10663 |
local function flex() |
| 10664 |
if trace_charstrings then |
| 10665 |
showstate("flex") |
| 10666 |
end |
| 10667 |
local ax=x+stack[1] |
| 10668 |
local ay=y+stack[2] |
| 10669 |
local bx=ax+stack[3] |
| 10670 |
local by=ay+stack[4] |
| 10671 |
local cx=bx+stack[5] |
| 10672 |
local cy=by+stack[6] |
| 10673 |
xycurveto(ax,ay,bx,by,cx,cy) |
| 10674 |
local dx=cx+stack[7] |
| 10675 |
local dy=cy+stack[8] |
| 10676 |
local ex=dx+stack[9] |
| 10677 |
local ey=dy+stack[10] |
| 10678 |
x=ex+stack[11] |
| 10679 |
y=ey+stack[12] |
| 10680 |
xycurveto(dx,dy,ex,ey,x,y) |
| 10681 |
top=0 |
| 10682 |
end |
| 10683 |
local function hflex() |
| 10684 |
if trace_charstrings then |
| 10685 |
showstate("hflex") |
| 10686 |
end |
| 10687 |
local ax=x+stack[1] |
| 10688 |
local ay=y |
| 10689 |
local bx=ax+stack[2] |
| 10690 |
local by=ay+stack[3] |
| 10691 |
local cx=bx+stack[4] |
| 10692 |
local cy=by |
| 10693 |
xycurveto(ax,ay,bx,by,cx,cy) |
| 10694 |
local dx=cx+stack[5] |
| 10695 |
local dy=by |
| 10696 |
local ex=dx+stack[6] |
| 10697 |
local ey=y |
| 10698 |
x=ex+stack[7] |
| 10699 |
xycurveto(dx,dy,ex,ey,x,y) |
| 10700 |
top=0 |
| 10701 |
end |
| 10702 |
local function hflex1() |
| 10703 |
if trace_charstrings then |
| 10704 |
showstate("hflex1") |
| 10705 |
end |
| 10706 |
local ax=x+stack[1] |
| 10707 |
local ay=y+stack[2] |
| 10708 |
local bx=ax+stack[3] |
| 10709 |
local by=ay+stack[4] |
| 10710 |
local cx=bx+stack[5] |
| 10711 |
local cy=by |
| 10712 |
xycurveto(ax,ay,bx,by,cx,cy) |
| 10713 |
local dx=cx+stack[6] |
| 10714 |
local dy=by |
| 10715 |
local ex=dx+stack[7] |
| 10716 |
local ey=dy+stack[8] |
| 10717 |
x=ex+stack[9] |
| 10718 |
xycurveto(dx,dy,ex,ey,x,y) |
| 10719 |
top=0 |
| 10720 |
end |
| 10721 |
local function flex1() |
| 10722 |
if trace_charstrings then |
| 10723 |
showstate("flex1") |
| 10724 |
end |
| 10725 |
local ax=x+stack[1] |
| 10726 |
local ay=y+stack[2] |
| 10727 |
local bx=ax+stack[3] |
| 10728 |
local by=ay+stack[4] |
| 10729 |
local cx=bx+stack[5] |
| 10730 |
local cy=by+stack[6] |
| 10731 |
xycurveto(ax,ay,bx,by,cx,cy) |
| 10732 |
local dx=cx+stack[7] |
| 10733 |
local dy=cy+stack[8] |
| 10734 |
local ex=dx+stack[9] |
| 10735 |
local ey=dy+stack[10] |
| 10736 |
if abs(ex-x)>abs(ey-y) then |
| 10737 |
x=ex+stack[11] |
| 10738 |
else |
| 10739 |
y=ey+stack[11] |
| 10740 |
end |
| 10741 |
xycurveto(dx,dy,ex,ey,x,y) |
| 10742 |
top=0 |
| 10743 |
end |
| 10744 |
local function getstem() |
| 10745 |
if top==0 then |
| 10746 |
elseif top%2~=0 then |
| 10747 |
if width then |
| 10748 |
remove(stack,1) |
| 10749 |
else |
| 10750 |
width=remove(stack,1) |
| 10751 |
if trace_charstrings then |
| 10752 |
showvalue("width",width) |
| 10753 |
end |
| 10754 |
end |
| 10755 |
top=top-1 |
| 10756 |
end |
| 10757 |
if trace_charstrings then |
| 10758 |
showstate("stem") |
| 10759 |
end |
| 10760 |
stems=stems+idiv(top,2) |
| 10761 |
top=0 |
| 10762 |
end |
| 10763 |
local function getmask() |
| 10764 |
if top==0 then |
| 10765 |
elseif top%2~=0 then |
| 10766 |
if width then |
| 10767 |
remove(stack,1) |
| 10768 |
else |
| 10769 |
width=remove(stack,1) |
| 10770 |
if trace_charstrings then |
| 10771 |
showvalue("width",width) |
| 10772 |
end |
| 10773 |
end |
| 10774 |
top=top-1 |
| 10775 |
end |
| 10776 |
if trace_charstrings then |
| 10777 |
showstate(operator==19 and "hintmark" or "cntrmask") |
| 10778 |
end |
| 10779 |
stems=stems+idiv(top,2) |
| 10780 |
top=0 |
| 10781 |
if stems==0 then |
| 10782 |
elseif stems<=8 then |
| 10783 |
return 1 |
| 10784 |
else |
| 10785 |
return idiv(stems+7,8) |
| 10786 |
end |
| 10787 |
end |
| 10788 |
local function unsupported(t) |
| 10789 |
if trace_charstrings then |
| 10790 |
showstate("unsupported "..t) |
| 10791 |
end |
| 10792 |
top=0 |
| 10793 |
end |
| 10794 |
local function unsupportedsub(t) |
| 10795 |
if trace_charstrings then |
| 10796 |
showstate("unsupported sub "..t) |
| 10797 |
end |
| 10798 |
top=0 |
| 10799 |
end |
| 10800 |
local function getstem3() |
| 10801 |
if trace_charstrings then |
| 10802 |
showstate("stem3") |
| 10803 |
end |
| 10804 |
top=0 |
| 10805 |
end |
| 10806 |
local function divide() |
| 10807 |
if version=="cff" then |
| 10808 |
local d=stack[top] |
| 10809 |
top=top-1 |
| 10810 |
stack[top]=stack[top]/d |
| 10811 |
end |
| 10812 |
end |
| 10813 |
local function closepath() |
| 10814 |
if version=="cff" then |
| 10815 |
if trace_charstrings then |
| 10816 |
showstate("closepath") |
| 10817 |
end |
| 10818 |
end |
| 10819 |
top=0 |
| 10820 |
end |
| 10821 |
local function hsbw() |
| 10822 |
if version=="cff" then |
| 10823 |
if trace_charstrings then |
| 10824 |
showstate("hsbw") |
| 10825 |
end |
| 10826 |
lsb=stack[top-1] or 0 |
| 10827 |
width=stack[top] |
| 10828 |
end |
| 10829 |
top=0 |
| 10830 |
end |
| 10831 |
local function sbw() |
| 10832 |
if version=="cff" then |
| 10833 |
if trace_charstrings then |
| 10834 |
showstate("sbw") |
| 10835 |
end |
| 10836 |
lsb=stack[top-3] |
| 10837 |
width=stack[top-1] |
| 10838 |
end |
| 10839 |
top=0 |
| 10840 |
end |
| 10841 |
local function seac() |
| 10842 |
if version=="cff" then |
| 10843 |
if trace_charstrings then |
| 10844 |
showstate("seac") |
| 10845 |
end |
| 10846 |
end |
| 10847 |
top=0 |
| 10848 |
end |
| 10849 |
local popped=3 |
| 10850 |
local hints=3 |
| 10851 |
local function callothersubr() |
| 10852 |
if version=="cff" then |
| 10853 |
if trace_charstrings then |
| 10854 |
showstate("callothersubr") |
| 10855 |
end |
| 10856 |
if stack[top]==hints then |
| 10857 |
popped=stack[top-2] |
| 10858 |
else |
| 10859 |
popped=3 |
| 10860 |
end |
| 10861 |
local t=stack[top-1] |
| 10862 |
if t then |
| 10863 |
top=top-(t+2) |
| 10864 |
if top<0 then |
| 10865 |
top=0 |
| 10866 |
end |
| 10867 |
else |
| 10868 |
top=0 |
| 10869 |
end |
| 10870 |
else |
| 10871 |
top=0 |
| 10872 |
end |
| 10873 |
end |
| 10874 |
local function pop() |
| 10875 |
if version=="cff" then |
| 10876 |
if trace_charstrings then |
| 10877 |
showstate("pop") |
| 10878 |
end |
| 10879 |
top=top+1 |
| 10880 |
stack[top]=popped |
| 10881 |
else |
| 10882 |
top=0 |
| 10883 |
end |
| 10884 |
end |
| 10885 |
local function setcurrentpoint() |
| 10886 |
if version=="cff" then |
| 10887 |
if trace_charstrings then |
| 10888 |
showstate("setcurrentpoint (unsupported)") |
| 10889 |
end |
| 10890 |
x=x+stack[top-1] |
| 10891 |
y=y+stack[top] |
| 10892 |
end |
| 10893 |
top=0 |
| 10894 |
end |
| 10895 |
local reginit=false |
| 10896 |
local function updateregions(n) |
| 10897 |
if regions then |
| 10898 |
local current=regions[n+1] or regions[1] |
| 10899 |
nofregions=#current |
| 10900 |
if axis and n~=reginit then |
| 10901 |
factors={} |
| 10902 |
for i=1,nofregions do |
| 10903 |
local region=current[i] |
| 10904 |
local s=1 |
| 10905 |
for j=1,#axis do |
| 10906 |
local f=axis[j] |
| 10907 |
local r=region[j] |
| 10908 |
local start=r.start |
| 10909 |
local peak=r.peak |
| 10910 |
local stop=r.stop |
| 10911 |
if start>peak or peak>stop then |
| 10912 |
elseif start<0 and stop>0 and peak~=0 then |
| 10913 |
elseif peak==0 then |
| 10914 |
elseif f<start or f>stop then |
| 10915 |
s=0 |
| 10916 |
break |
| 10917 |
elseif f<peak then |
| 10918 |
s=s*(f-start)/(peak-start) |
| 10919 |
elseif f>peak then |
| 10920 |
s=s*(stop-f)/(stop-peak) |
| 10921 |
else |
| 10922 |
end |
| 10923 |
end |
| 10924 |
factors[i]=s |
| 10925 |
end |
| 10926 |
end |
| 10927 |
end |
| 10928 |
reginit=n |
| 10929 |
end |
| 10930 |
local function setvsindex() |
| 10931 |
local vsindex=stack[top] |
| 10932 |
if trace_charstrings then |
| 10933 |
showstate(formatters["vsindex %i"](vsindex)) |
| 10934 |
end |
| 10935 |
updateregions(vsindex) |
| 10936 |
top=top-1 |
| 10937 |
end |
| 10938 |
local function blend() |
| 10939 |
local n=stack[top] |
| 10940 |
top=top-1 |
| 10941 |
if axis then |
| 10942 |
if trace_charstrings then |
| 10943 |
local t=top-nofregions*n |
| 10944 |
local m=t-n |
| 10945 |
for i=1,n do |
| 10946 |
local k=m+i |
| 10947 |
local d=m+n+(i-1)*nofregions |
| 10948 |
local old=stack[k] |
| 10949 |
local new=old |
| 10950 |
for r=1,nofregions do |
| 10951 |
new=new+stack[d+r]*factors[r] |
| 10952 |
end |
| 10953 |
stack[k]=new |
| 10954 |
showstate(formatters["blend %i of %i: %s -> %s"](i,n,old,new)) |
| 10955 |
end |
| 10956 |
top=t |
| 10957 |
elseif n==1 then |
| 10958 |
top=top-nofregions |
| 10959 |
local v=stack[top] |
| 10960 |
for r=1,nofregions do |
| 10961 |
v=v+stack[top+r]*factors[r] |
| 10962 |
end |
| 10963 |
stack[top]=v |
| 10964 |
else |
| 10965 |
top=top-nofregions*n |
| 10966 |
local d=top |
| 10967 |
local k=top-n |
| 10968 |
for i=1,n do |
| 10969 |
k=k+1 |
| 10970 |
local v=stack[k] |
| 10971 |
for r=1,nofregions do |
| 10972 |
v=v+stack[d+r]*factors[r] |
| 10973 |
end |
| 10974 |
stack[k]=v |
| 10975 |
d=d+nofregions |
| 10976 |
end |
| 10977 |
end |
| 10978 |
else |
| 10979 |
top=top-nofregions*n |
| 10980 |
end |
| 10981 |
end |
| 10982 |
local actions={ [0]=unsupported, |
| 10983 |
getstem, |
| 10984 |
unsupported, |
| 10985 |
getstem, |
| 10986 |
vmoveto, |
| 10987 |
rlineto, |
| 10988 |
hlineto, |
| 10989 |
vlineto, |
| 10990 |
rrcurveto, |
| 10991 |
unsupported, |
| 10992 |
unsupported, |
| 10993 |
unsupported, |
| 10994 |
unsupported, |
| 10995 |
hsbw, |
| 10996 |
unsupported, |
| 10997 |
setvsindex, |
| 10998 |
blend, |
| 10999 |
unsupported, |
| 11000 |
getstem, |
| 11001 |
getmask, |
| 11002 |
getmask, |
| 11003 |
rmoveto, |
| 11004 |
hmoveto, |
| 11005 |
getstem, |
| 11006 |
rcurveline, |
| 11007 |
rlinecurve, |
| 11008 |
vvcurveto, |
| 11009 |
hhcurveto, |
| 11010 |
unsupported, |
| 11011 |
unsupported, |
| 11012 |
vhcurveto, |
| 11013 |
hvcurveto, |
| 11014 |
} |
| 11015 |
local reverse={ [0]="unsupported", |
| 11016 |
"getstem", |
| 11017 |
"unsupported", |
| 11018 |
"getstem", |
| 11019 |
"vmoveto", |
| 11020 |
"rlineto", |
| 11021 |
"hlineto", |
| 11022 |
"vlineto", |
| 11023 |
"rrcurveto", |
| 11024 |
"unsupported", |
| 11025 |
"unsupported", |
| 11026 |
"unsupported", |
| 11027 |
"unsupported", |
| 11028 |
"hsbw", |
| 11029 |
"unsupported", |
| 11030 |
"setvsindex", |
| 11031 |
"blend", |
| 11032 |
"unsupported", |
| 11033 |
"getstem", |
| 11034 |
"getmask", |
| 11035 |
"getmask", |
| 11036 |
"rmoveto", |
| 11037 |
"hmoveto", |
| 11038 |
"getstem", |
| 11039 |
"rcurveline", |
| 11040 |
"rlinecurve", |
| 11041 |
"vvcurveto", |
| 11042 |
"hhcurveto", |
| 11043 |
"unsupported", |
| 11044 |
"unsupported", |
| 11045 |
"vhcurveto", |
| 11046 |
"hvcurveto", |
| 11047 |
} |
| 11048 |
local subactions={ |
| 11049 |
[000]=dotsection, |
| 11050 |
[001]=getstem3, |
| 11051 |
[002]=getstem3, |
| 11052 |
[006]=seac, |
| 11053 |
[007]=sbw, |
| 11054 |
[012]=divide, |
| 11055 |
[016]=callothersubr, |
| 11056 |
[017]=pop, |
| 11057 |
[033]=setcurrentpoint, |
| 11058 |
[034]=hflex, |
| 11059 |
[035]=flex, |
| 11060 |
[036]=hflex1, |
| 11061 |
[037]=flex1, |
| 11062 |
} |
| 11063 |
local chars=setmetatableindex(function (t,k) |
| 11064 |
local v=char(k) |
| 11065 |
t[k]=v |
| 11066 |
return v |
| 11067 |
end) |
| 11068 |
local c_endchar=chars[14] |
| 11069 |
local encode={} |
| 11070 |
local typeone=false |
| 11071 |
setmetatableindex(encode,function(t,i) |
| 11072 |
for i=-2048,-1130 do |
| 11073 |
t[i]=char(28,band(rshift(i,8),0xFF),band(i,0xFF)) |
| 11074 |
end |
| 11075 |
for i=-1131,-108 do |
| 11076 |
local v=0xFB00-i-108 |
| 11077 |
t[i]=char(band(rshift(v,8),0xFF),band(v,0xFF)) |
| 11078 |
end |
| 11079 |
for i=-107,107 do |
| 11080 |
t[i]=chars[i+139] |
| 11081 |
end |
| 11082 |
for i=108,1131 do |
| 11083 |
local v=0xF700+i-108 |
| 11084 |
t[i]=char(extract(v,8,8),extract(v,0,8)) |
| 11085 |
end |
| 11086 |
for i=1132,2048 do |
| 11087 |
t[i]=char(28,band(rshift(i,8),0xFF),band(i,0xFF)) |
| 11088 |
end |
| 11089 |
setmetatableindex(encode,function(t,k) |
| 11090 |
local r=round(k) |
| 11091 |
local v=rawget(t,r) |
| 11092 |
if v then |
| 11093 |
return v |
| 11094 |
end |
| 11095 |
local v1=floor(k) |
| 11096 |
local v2=floor((k-v1)*0x10000) |
| 11097 |
return char(255,extract(v1,8,8),extract(v1,0,8),extract(v2,8,8),extract(v2,0,8)) |
| 11098 |
end) |
| 11099 |
return t[i] |
| 11100 |
end) |
| 11101 |
readers.cffencoder=encode |
| 11102 |
local function p_setvsindex() |
| 11103 |
local vsindex=stack[top] |
| 11104 |
updateregions(vsindex) |
| 11105 |
top=top-1 |
| 11106 |
end |
| 11107 |
local function p_blend() |
| 11108 |
local n=stack[top] |
| 11109 |
top=top-1 |
| 11110 |
if not axis then |
| 11111 |
elseif n==1 then |
| 11112 |
top=top-nofregions |
| 11113 |
local v=stack[top] |
| 11114 |
for r=1,nofregions do |
| 11115 |
v=v+stack[top+r]*factors[r] |
| 11116 |
end |
| 11117 |
stack[top]=round(v) |
| 11118 |
else |
| 11119 |
top=top-nofregions*n |
| 11120 |
local d=top |
| 11121 |
local k=top-n |
| 11122 |
for i=1,n do |
| 11123 |
k=k+1 |
| 11124 |
local v=stack[k] |
| 11125 |
for r=1,nofregions do |
| 11126 |
v=v+stack[d+r]*factors[r] |
| 11127 |
end |
| 11128 |
stack[k]=round(v) |
| 11129 |
d=d+nofregions |
| 11130 |
end |
| 11131 |
end |
| 11132 |
end |
| 11133 |
local function p_getstem() |
| 11134 |
local n=0 |
| 11135 |
if top%2~=0 then |
| 11136 |
n=1 |
| 11137 |
end |
| 11138 |
if top>n then |
| 11139 |
stems=stems+idiv(top-n,2) |
| 11140 |
end |
| 11141 |
end |
| 11142 |
local function p_getmask() |
| 11143 |
local n=0 |
| 11144 |
if top%2~=0 then |
| 11145 |
n=1 |
| 11146 |
end |
| 11147 |
if top>n then |
| 11148 |
stems=stems+idiv(top-n,2) |
| 11149 |
end |
| 11150 |
if stems==0 then |
| 11151 |
return 0 |
| 11152 |
elseif stems<=8 then |
| 11153 |
return 1 |
| 11154 |
else |
| 11155 |
return idiv(stems+7,8) |
| 11156 |
end |
| 11157 |
end |
| 11158 |
local process |
| 11159 |
local function call(scope,list,bias) |
| 11160 |
depth=depth+1 |
| 11161 |
if top==0 then |
| 11162 |
showstate(formatters["unknown %s call %s, case %s"](scope,"?",1)) |
| 11163 |
top=0 |
| 11164 |
else |
| 11165 |
local index=stack[top]+bias |
| 11166 |
top=top-1 |
| 11167 |
if trace_charstrings then |
| 11168 |
showvalue(scope,index,true) |
| 11169 |
end |
| 11170 |
local tab=list[index] |
| 11171 |
if tab then |
| 11172 |
process(tab) |
| 11173 |
else |
| 11174 |
showstate(formatters["unknown %s call %s, case %s"](scope,index,2)) |
| 11175 |
top=0 |
| 11176 |
end |
| 11177 |
end |
| 11178 |
depth=depth-1 |
| 11179 |
end |
| 11180 |
process=function(tab) |
| 11181 |
local i=1 |
| 11182 |
local n=#tab |
| 11183 |
while i<=n do |
| 11184 |
local t=tab[i] |
| 11185 |
if t>=32 then |
| 11186 |
top=top+1 |
| 11187 |
if t<=246 then |
| 11188 |
stack[top]=t-139 |
| 11189 |
i=i+1 |
| 11190 |
elseif t<=250 then |
| 11191 |
stack[top]=t*256-63124+tab[i+1] |
| 11192 |
i=i+2 |
| 11193 |
elseif t<=254 then |
| 11194 |
stack[top]=-t*256+64148-tab[i+1] |
| 11195 |
i=i+2 |
| 11196 |
elseif typeone then |
| 11197 |
local n=0x1000000*tab[i+1]+0x10000*tab[i+2]+0x100*tab[i+3]+tab[i+4] |
| 11198 |
if n>=0x8000000 then |
| 11199 |
n=n-0xFFFFFFFF-1 |
| 11200 |
end |
| 11201 |
stack[top]=n |
| 11202 |
i=i+5 |
| 11203 |
else |
| 11204 |
local n1=0x100*tab[i+1]+tab[i+2] |
| 11205 |
local n2=0x100*tab[i+3]+tab[i+4] |
| 11206 |
if n1>=0x8000 then |
| 11207 |
n1=n1-0x10000 |
| 11208 |
end |
| 11209 |
stack[top]=n1+n2/0xFFFF |
| 11210 |
i=i+5 |
| 11211 |
end |
| 11212 |
elseif t==28 then |
| 11213 |
top=top+1 |
| 11214 |
local n=0x100*tab[i+1]+tab[i+2] |
| 11215 |
if n>=0x8000 then |
| 11216 |
stack[top]=n-0x10000 |
| 11217 |
else |
| 11218 |
stack[top]=n |
| 11219 |
end |
| 11220 |
i=i+3 |
| 11221 |
elseif t==11 then |
| 11222 |
if trace_charstrings then |
| 11223 |
showstate("return") |
| 11224 |
end |
| 11225 |
return |
| 11226 |
elseif t==10 then |
| 11227 |
call("local",locals,localbias) |
| 11228 |
i=i+1 |
| 11229 |
elseif t==14 then |
| 11230 |
if width then |
| 11231 |
elseif top>0 then |
| 11232 |
width=stack[1] |
| 11233 |
if trace_charstrings then |
| 11234 |
showvalue("width",width) |
| 11235 |
end |
| 11236 |
else |
| 11237 |
width=true |
| 11238 |
end |
| 11239 |
if trace_charstrings then |
| 11240 |
showstate("endchar") |
| 11241 |
end |
| 11242 |
return |
| 11243 |
elseif t==29 then |
| 11244 |
call("global",globals,globalbias) |
| 11245 |
i=i+1 |
| 11246 |
elseif t==12 then |
| 11247 |
i=i+1 |
| 11248 |
local t=tab[i] |
| 11249 |
if justpass then |
| 11250 |
if t>=34 and t<=37 then |
| 11251 |
for i=1,top do |
| 11252 |
r=r+1;result[r]=encode[stack[i]] |
| 11253 |
end |
| 11254 |
r=r+1;result[r]=chars[12] |
| 11255 |
r=r+1;result[r]=chars[t] |
| 11256 |
top=0 |
| 11257 |
elseif t==6 then |
| 11258 |
seacs[procidx]={ |
| 11259 |
asb=stack[1], |
| 11260 |
adx=stack[2], |
| 11261 |
ady=stack[3], |
| 11262 |
base=stack[4], |
| 11263 |
accent=stack[5], |
| 11264 |
width=width, |
| 11265 |
lsb=lsb, |
| 11266 |
} |
| 11267 |
top=0 |
| 11268 |
else |
| 11269 |
local a=subactions[t] |
| 11270 |
if a then |
| 11271 |
a(t) |
| 11272 |
else |
| 11273 |
top=0 |
| 11274 |
end |
| 11275 |
end |
| 11276 |
else |
| 11277 |
local a=subactions[t] |
| 11278 |
if a then |
| 11279 |
a(t) |
| 11280 |
else |
| 11281 |
if trace_charstrings then |
| 11282 |
showvalue("<subaction>",t) |
| 11283 |
end |
| 11284 |
top=0 |
| 11285 |
end |
| 11286 |
end |
| 11287 |
i=i+1 |
| 11288 |
elseif justpass then |
| 11289 |
if t==15 then |
| 11290 |
p_setvsindex() |
| 11291 |
i=i+1 |
| 11292 |
elseif t==16 then |
| 11293 |
local s=p_blend() or 0 |
| 11294 |
i=i+s+1 |
| 11295 |
elseif t==1 or t==3 or t==18 or operation==23 then |
| 11296 |
p_getstem() |
| 11297 |
if version=="cff" then |
| 11298 |
if top>0 then |
| 11299 |
for i=1,top do |
| 11300 |
r=r+1;result[r]=encode[stack[i]] |
| 11301 |
end |
| 11302 |
top=0 |
| 11303 |
end |
| 11304 |
r=r+1;result[r]=chars[t] |
| 11305 |
else |
| 11306 |
top=0 |
| 11307 |
end |
| 11308 |
i=i+1 |
| 11309 |
elseif t==19 or t==20 then |
| 11310 |
local s=p_getmask() or 0 |
| 11311 |
if true then |
| 11312 |
if top>0 then |
| 11313 |
for i=1,top do |
| 11314 |
r=r+1;result[r]=encode[stack[i]] |
| 11315 |
end |
| 11316 |
top=0 |
| 11317 |
end |
| 11318 |
r=r+1;result[r]=chars[t] |
| 11319 |
for j=1,s do |
| 11320 |
i=i+1 |
| 11321 |
r=r+1;result[r]=chars[tab[i]] |
| 11322 |
end |
| 11323 |
else |
| 11324 |
i=i+s |
| 11325 |
top=0 |
| 11326 |
end |
| 11327 |
i=i+1 |
| 11328 |
elseif t==9 then |
| 11329 |
top=0 |
| 11330 |
i=i+1 |
| 11331 |
elseif t==13 then |
| 11332 |
hsbw() |
| 11333 |
if true then |
| 11334 |
r=r+1;result[r]=encode[lsb] |
| 11335 |
r=r+1;result[r]=chars[22] |
| 11336 |
else |
| 11337 |
end |
| 11338 |
i=i+1 |
| 11339 |
else |
| 11340 |
if trace_charstrings then |
| 11341 |
showstate(reverse[t] or "<action>") |
| 11342 |
end |
| 11343 |
if top>0 then |
| 11344 |
if t==8 and top>48 then |
| 11345 |
local n=0 |
| 11346 |
for i=1,top do |
| 11347 |
if n==48 then |
| 11348 |
r=r+1;result[r]=chars[t] |
| 11349 |
n=1 |
| 11350 |
else |
| 11351 |
n=n+1 |
| 11352 |
end |
| 11353 |
r=r+1;result[r]=encode[stack[i]] |
| 11354 |
end |
| 11355 |
else |
| 11356 |
for i=1,top do |
| 11357 |
r=r+1;result[r]=encode[stack[i]] |
| 11358 |
end |
| 11359 |
end |
| 11360 |
top=0 |
| 11361 |
end |
| 11362 |
r=r+1;result[r]=chars[t] |
| 11363 |
i=i+1 |
| 11364 |
end |
| 11365 |
else |
| 11366 |
local a=actions[t] |
| 11367 |
if a then |
| 11368 |
local s=a(t) |
| 11369 |
if s then |
| 11370 |
i=i+s+1 |
| 11371 |
else |
| 11372 |
i=i+1 |
| 11373 |
end |
| 11374 |
else |
| 11375 |
if trace_charstrings then |
| 11376 |
showstate(reverse[t] or "<action>") |
| 11377 |
end |
| 11378 |
top=0 |
| 11379 |
i=i+1 |
| 11380 |
end |
| 11381 |
end |
| 11382 |
end |
| 11383 |
end |
| 11384 |
local function setbias(globals,locals,nobias) |
| 11385 |
if nobias then |
| 11386 |
return 0,0 |
| 11387 |
else |
| 11388 |
local g=#globals |
| 11389 |
local l=#locals |
| 11390 |
return |
| 11391 |
((g<1240 and 107) or (g<33900 and 1131) or 32768)+1, |
| 11392 |
((l<1240 and 107) or (l<33900 and 1131) or 32768)+1 |
| 11393 |
end |
| 11394 |
end |
| 11395 |
local function processshape(glyphs,tab,index,hack) |
| 11396 |
if not tab then |
| 11397 |
glyphs[index]={ |
| 11398 |
boundingbox={ 0,0,0,0 }, |
| 11399 |
width=0, |
| 11400 |
name=charset and charset[index] or nil, |
| 11401 |
} |
| 11402 |
return |
| 11403 |
end |
| 11404 |
tab=bytetable(tab) |
| 11405 |
x=0 |
| 11406 |
y=0 |
| 11407 |
width=false |
| 11408 |
lsb=0 |
| 11409 |
r=0 |
| 11410 |
top=0 |
| 11411 |
stems=0 |
| 11412 |
result={} |
| 11413 |
popped=3 |
| 11414 |
procidx=index |
| 11415 |
xmin=0 |
| 11416 |
xmax=0 |
| 11417 |
ymin=0 |
| 11418 |
ymax=0 |
| 11419 |
checked=false |
| 11420 |
if trace_charstrings then |
| 11421 |
report("glyph: %i",index) |
| 11422 |
report("data : % t",tab) |
| 11423 |
end |
| 11424 |
if regions then |
| 11425 |
updateregions(vsindex) |
| 11426 |
end |
| 11427 |
process(tab) |
| 11428 |
if hack then |
| 11429 |
return x,y |
| 11430 |
end |
| 11431 |
local boundingbox={ |
| 11432 |
round(xmin), |
| 11433 |
round(ymin), |
| 11434 |
round(xmax), |
| 11435 |
round(ymax), |
| 11436 |
} |
| 11437 |
if width==true or width==false then |
| 11438 |
width=defaultwidth |
| 11439 |
else |
| 11440 |
width=nominalwidth+width |
| 11441 |
end |
| 11442 |
local glyph=glyphs[index] |
| 11443 |
if justpass then |
| 11444 |
r=r+1 |
| 11445 |
result[r]=c_endchar |
| 11446 |
local stream=concat(result) |
| 11447 |
result=nil |
| 11448 |
if glyph then |
| 11449 |
glyph.stream=stream |
| 11450 |
glyph.width=width |
| 11451 |
else |
| 11452 |
glyphs[index]={ stream=stream,width=width } |
| 11453 |
end |
| 11454 |
elseif glyph then |
| 11455 |
glyph.segments=keepcurve~=false and result or nil |
| 11456 |
glyph.boundingbox=boundingbox |
| 11457 |
if not glyph.width then |
| 11458 |
glyph.width=width |
| 11459 |
end |
| 11460 |
if charset and not glyph.name then |
| 11461 |
glyph.name=charset[index] |
| 11462 |
end |
| 11463 |
elseif keepcurve then |
| 11464 |
glyphs[index]={ |
| 11465 |
segments=result, |
| 11466 |
boundingbox=boundingbox, |
| 11467 |
width=width, |
| 11468 |
name=charset and charset[index] or nil, |
| 11469 |
} |
| 11470 |
result=nil |
| 11471 |
else |
| 11472 |
glyphs[index]={ |
| 11473 |
boundingbox=boundingbox, |
| 11474 |
width=width, |
| 11475 |
name=charset and charset[index] or nil, |
| 11476 |
} |
| 11477 |
end |
| 11478 |
if trace_charstrings then |
| 11479 |
report("width : %s",tostring(width)) |
| 11480 |
report("boundingbox: % t",boundingbox) |
| 11481 |
end |
| 11482 |
end |
| 11483 |
startparsing=function(fontdata,data,streams) |
| 11484 |
reginit=false |
| 11485 |
axis=false |
| 11486 |
regions=data.regions |
| 11487 |
justpass=streams==true |
| 11488 |
popped=3 |
| 11489 |
seacs={} |
| 11490 |
if regions then |
| 11491 |
regions={} |
| 11492 |
local deltas=data.deltas |
| 11493 |
for i=1,#deltas do |
| 11494 |
regions[i]=deltas[i].regions |
| 11495 |
end |
| 11496 |
axis=data.factors or false |
| 11497 |
end |
| 11498 |
end |
| 11499 |
stopparsing=function(fontdata,data) |
| 11500 |
stack={} |
| 11501 |
glyphs=false |
| 11502 |
result={} |
| 11503 |
top=0 |
| 11504 |
locals=false |
| 11505 |
globals=false |
| 11506 |
strings=false |
| 11507 |
popped=3 |
| 11508 |
seacs={} |
| 11509 |
end |
| 11510 |
local function setwidths(private) |
| 11511 |
if not private then |
| 11512 |
return 0,0 |
| 11513 |
end |
| 11514 |
local privatedata=private.data |
| 11515 |
if not privatedata then |
| 11516 |
return 0,0 |
| 11517 |
end |
| 11518 |
return privatedata.nominalwidthx or 0,privatedata.defaultwidthx or 0 |
| 11519 |
end |
| 11520 |
parsecharstrings=function(fontdata,data,glphs,doshapes,tversion,streams,nobias,istypeone) |
| 11521 |
local dictionary=data.dictionaries[1] |
| 11522 |
local charstrings=dictionary.charstrings |
| 11523 |
keepcurve=doshapes |
| 11524 |
version=tversion |
| 11525 |
typeone=istypeone or false |
| 11526 |
strings=data.strings |
| 11527 |
globals=data.routines or {} |
| 11528 |
locals=dictionary.subroutines or {} |
| 11529 |
charset=dictionary.charset |
| 11530 |
vsindex=dictionary.vsindex or 0 |
| 11531 |
local glyphs=glphs or {} |
| 11532 |
globalbias,localbias=setbias(globals,locals,nobias) |
| 11533 |
nominalwidth,defaultwidth=setwidths(dictionary.private) |
| 11534 |
if charstrings then |
| 11535 |
startparsing(fontdata,data,streams) |
| 11536 |
for index=1,#charstrings do |
| 11537 |
processshape(glyphs,charstrings[index],index-1) |
| 11538 |
end |
| 11539 |
if justpass and next(seacs) then |
| 11540 |
local charset=data.dictionaries[1].charset |
| 11541 |
if charset then |
| 11542 |
local lookup=table.swapped(charset) |
| 11543 |
for index,v in next,seacs do |
| 11544 |
local bindex=lookup[standardnames[v.base]] |
| 11545 |
local aindex=lookup[standardnames[v.accent]] |
| 11546 |
local bglyph=bindex and glyphs[bindex] |
| 11547 |
local aglyph=aindex and glyphs[aindex] |
| 11548 |
if bglyph and aglyph then |
| 11549 |
local jp=justpass |
| 11550 |
justpass=false |
| 11551 |
local x,y=processshape(glyphs,charstrings[bindex+1],bindex,true) |
| 11552 |
justpass=jp |
| 11553 |
local base=bglyph.stream |
| 11554 |
local accent=aglyph.stream |
| 11555 |
local moveto=encode[-x-v.asb+v.adx]..chars[22]..encode[-y+v.ady]..chars[ 4] |
| 11556 |
base=sub(base,1,#base-1) |
| 11557 |
glyphs[index].stream=base..moveto..accent |
| 11558 |
end |
| 11559 |
end |
| 11560 |
end |
| 11561 |
end |
| 11562 |
stopparsing(fontdata,data) |
| 11563 |
else |
| 11564 |
report("no charstrings") |
| 11565 |
end |
| 11566 |
return glyphs |
| 11567 |
end |
| 11568 |
parsecharstring=function(fontdata,data,dictionary,tab,glphs,index,doshapes,tversion,streams) |
| 11569 |
keepcurve=doshapes |
| 11570 |
version=tversion |
| 11571 |
strings=data.strings |
| 11572 |
globals=data.routines or {} |
| 11573 |
locals=dictionary.subroutines or {} |
| 11574 |
charset=false |
| 11575 |
vsindex=dictionary.vsindex or 0 |
| 11576 |
local glyphs=glphs or {} |
| 11577 |
justpass=streams==true |
| 11578 |
seacs={} |
| 11579 |
globalbias,localbias=setbias(globals,locals,nobias) |
| 11580 |
nominalwidth,defaultwidth=setwidths(dictionary.private) |
| 11581 |
processshape(glyphs,tab,index-1) |
| 11582 |
return glyphs[index] |
| 11583 |
end |
| 11584 |
end |
| 11585 |
local function readglobals(f,data,version) |
| 11586 |
local routines=readlengths(f,version=="cff2") |
| 11587 |
for i=1,#routines do |
| 11588 |
routines[i]=readbytetable(f,routines[i]) |
| 11589 |
end |
| 11590 |
data.routines=routines |
| 11591 |
end |
| 11592 |
local function readencodings(f,data) |
| 11593 |
data.encodings={} |
| 11594 |
end |
| 11595 |
local function readcharsets(f,data,dictionary) |
| 11596 |
local header=data.header |
| 11597 |
local strings=data.strings |
| 11598 |
local nofglyphs=data.nofglyphs |
| 11599 |
local charsetoffset=dictionary.charset |
| 11600 |
if charsetoffset and charsetoffset~=0 then |
| 11601 |
setposition(f,header.offset+charsetoffset) |
| 11602 |
local format=readbyte(f) |
| 11603 |
local charset={ [0]=".notdef" } |
| 11604 |
dictionary.charset=charset |
| 11605 |
if format==0 then |
| 11606 |
for i=1,nofglyphs do |
| 11607 |
charset[i]=strings[readushort(f)] |
| 11608 |
end |
| 11609 |
elseif format==1 or format==2 then |
| 11610 |
local readcount=format==1 and readbyte or readushort |
| 11611 |
local i=1 |
| 11612 |
while i<=nofglyphs do |
| 11613 |
local sid=readushort(f) |
| 11614 |
local n=readcount(f) |
| 11615 |
for s=sid,sid+n do |
| 11616 |
charset[i]=strings[s] |
| 11617 |
i=i+1 |
| 11618 |
if i>nofglyphs then |
| 11619 |
break |
| 11620 |
end |
| 11621 |
end |
| 11622 |
end |
| 11623 |
else |
| 11624 |
report("cff parser: unsupported charset format %a",format) |
| 11625 |
end |
| 11626 |
else |
| 11627 |
dictionary.nocharset=true |
| 11628 |
dictionary.charset=nil |
| 11629 |
end |
| 11630 |
end |
| 11631 |
local function readprivates(f,data) |
| 11632 |
local header=data.header |
| 11633 |
local dictionaries=data.dictionaries |
| 11634 |
local private=dictionaries[1].private |
| 11635 |
if private then |
| 11636 |
setposition(f,header.offset+private.offset) |
| 11637 |
private.data=readstring(f,private.size) |
| 11638 |
end |
| 11639 |
end |
| 11640 |
local function readlocals(f,data,dictionary,version) |
| 11641 |
local header=data.header |
| 11642 |
local private=dictionary.private |
| 11643 |
if private then |
| 11644 |
local subroutineoffset=private.data.subroutines |
| 11645 |
if subroutineoffset~=0 then |
| 11646 |
setposition(f,header.offset+private.offset+subroutineoffset) |
| 11647 |
local subroutines=readlengths(f,version=="cff2") |
| 11648 |
for i=1,#subroutines do |
| 11649 |
subroutines[i]=readbytetable(f,subroutines[i]) |
| 11650 |
end |
| 11651 |
dictionary.subroutines=subroutines |
| 11652 |
private.data.subroutines=nil |
| 11653 |
else |
| 11654 |
dictionary.subroutines={} |
| 11655 |
end |
| 11656 |
else |
| 11657 |
dictionary.subroutines={} |
| 11658 |
end |
| 11659 |
end |
| 11660 |
local function readcharstrings(f,data,version) |
| 11661 |
local header=data.header |
| 11662 |
local dictionaries=data.dictionaries |
| 11663 |
local dictionary=dictionaries[1] |
| 11664 |
local stringtype=dictionary.charstringtype |
| 11665 |
local offset=dictionary.charstrings |
| 11666 |
if type(offset)~="number" then |
| 11667 |
elseif stringtype==2 then |
| 11668 |
setposition(f,header.offset+offset) |
| 11669 |
local charstrings=readlengths(f,version=="cff2") |
| 11670 |
local nofglyphs=#charstrings |
| 11671 |
for i=1,nofglyphs do |
| 11672 |
charstrings[i]=readstring(f,charstrings[i]) |
| 11673 |
end |
| 11674 |
data.nofglyphs=nofglyphs |
| 11675 |
dictionary.charstrings=charstrings |
| 11676 |
else |
| 11677 |
report("unsupported charstr type %i",stringtype) |
| 11678 |
data.nofglyphs=0 |
| 11679 |
dictionary.charstrings={} |
| 11680 |
end |
| 11681 |
end |
| 11682 |
local function readcidprivates(f,data) |
| 11683 |
local header=data.header |
| 11684 |
local dictionaries=data.dictionaries[1].cid.dictionaries |
| 11685 |
for i=1,#dictionaries do |
| 11686 |
local dictionary=dictionaries[i] |
| 11687 |
local private=dictionary.private |
| 11688 |
if private then |
| 11689 |
setposition(f,header.offset+private.offset) |
| 11690 |
private.data=readstring(f,private.size) |
| 11691 |
end |
| 11692 |
end |
| 11693 |
parseprivates(data,dictionaries) |
| 11694 |
end |
| 11695 |
readers.parsecharstrings=parsecharstrings |
| 11696 |
local function readnoselect(f,fontdata,data,glyphs,doshapes,version,streams) |
| 11697 |
local dictionaries=data.dictionaries |
| 11698 |
local dictionary=dictionaries[1] |
| 11699 |
local cid=not dictionary.private and dictionary.cid |
| 11700 |
readglobals(f,data,version) |
| 11701 |
readcharstrings(f,data,version) |
| 11702 |
if version=="cff2" then |
| 11703 |
dictionary.charset=nil |
| 11704 |
else |
| 11705 |
readencodings(f,data) |
| 11706 |
readcharsets(f,data,dictionary) |
| 11707 |
end |
| 11708 |
if cid then |
| 11709 |
local fdarray=cid.fdarray |
| 11710 |
if fdarray then |
| 11711 |
setposition(f,data.header.offset+fdarray) |
| 11712 |
local dictionaries=readlengths(f,version=="cff2") |
| 11713 |
local nofdictionaries=#dictionaries |
| 11714 |
if nofdictionaries>0 then |
| 11715 |
for i=1,nofdictionaries do |
| 11716 |
dictionaries[i]=readstring(f,dictionaries[i]) |
| 11717 |
end |
| 11718 |
parsedictionaries(data,dictionaries) |
| 11719 |
dictionary.private=dictionaries[1].private |
| 11720 |
if nofdictionaries>1 then |
| 11721 |
report("ignoring dictionaries > 1 in cid font") |
| 11722 |
end |
| 11723 |
end |
| 11724 |
end |
| 11725 |
end |
| 11726 |
readprivates(f,data) |
| 11727 |
parseprivates(data,data.dictionaries) |
| 11728 |
readlocals(f,data,dictionary,version) |
| 11729 |
startparsing(fontdata,data,streams) |
| 11730 |
parsecharstrings(fontdata,data,glyphs,doshapes,version,streams,false) |
| 11731 |
stopparsing(fontdata,data) |
| 11732 |
end |
| 11733 |
local function readfdselect(f,fontdata,data,glyphs,doshapes,version,streams) |
| 11734 |
local header=data.header |
| 11735 |
local dictionaries=data.dictionaries |
| 11736 |
local dictionary=dictionaries[1] |
| 11737 |
local cid=dictionary.cid |
| 11738 |
local cidselect=cid and cid.fdselect |
| 11739 |
readglobals(f,data,version) |
| 11740 |
readcharstrings(f,data,version) |
| 11741 |
if version~="cff2" then |
| 11742 |
readencodings(f,data) |
| 11743 |
end |
| 11744 |
local charstrings=dictionary.charstrings |
| 11745 |
local fdindex={} |
| 11746 |
local nofglyphs=data.nofglyphs |
| 11747 |
local maxindex=-1 |
| 11748 |
setposition(f,header.offset+cidselect) |
| 11749 |
local format=readbyte(f) |
| 11750 |
if format==1 then |
| 11751 |
for i=0,nofglyphs do |
| 11752 |
local index=readbyte(f) |
| 11753 |
fdindex[i]=index |
| 11754 |
if index>maxindex then |
| 11755 |
maxindex=index |
| 11756 |
end |
| 11757 |
end |
| 11758 |
elseif format==3 then |
| 11759 |
local nofranges=readushort(f) |
| 11760 |
local first=readushort(f) |
| 11761 |
local index=readbyte(f) |
| 11762 |
while true do |
| 11763 |
local last=readushort(f) |
| 11764 |
if index>maxindex then |
| 11765 |
maxindex=index |
| 11766 |
end |
| 11767 |
for i=first,last do |
| 11768 |
fdindex[i]=index |
| 11769 |
end |
| 11770 |
if last>=nofglyphs then |
| 11771 |
break |
| 11772 |
else |
| 11773 |
first=last+1 |
| 11774 |
index=readbyte(f) |
| 11775 |
end |
| 11776 |
end |
| 11777 |
else |
| 11778 |
report("unsupported fd index format %i",format) |
| 11779 |
end |
| 11780 |
if maxindex>=0 then |
| 11781 |
local cidarray=cid.fdarray |
| 11782 |
if cidarray then |
| 11783 |
setposition(f,header.offset+cidarray) |
| 11784 |
local dictionaries=readlengths(f,version=="cff2") |
| 11785 |
if #dictionaries>0 then |
| 11786 |
for i=1,#dictionaries do |
| 11787 |
dictionaries[i]=readstring(f,dictionaries[i]) |
| 11788 |
end |
| 11789 |
parsedictionaries(data,dictionaries) |
| 11790 |
cid.dictionaries=dictionaries |
| 11791 |
readcidprivates(f,data) |
| 11792 |
for i=1,#dictionaries do |
| 11793 |
readlocals(f,data,dictionaries[i],version) |
| 11794 |
end |
| 11795 |
startparsing(fontdata,data,streams) |
| 11796 |
for i=1,#charstrings do |
| 11797 |
local dictionary=dictionaries[fdindex[i]+1] |
| 11798 |
if dictionary then |
| 11799 |
parsecharstring(fontdata,data,dictionary,charstrings[i],glyphs,i,doshapes,version,streams) |
| 11800 |
else |
| 11801 |
end |
| 11802 |
end |
| 11803 |
stopparsing(fontdata,data) |
| 11804 |
else |
| 11805 |
report("no cid dictionaries") |
| 11806 |
end |
| 11807 |
else |
| 11808 |
report("no cid array") |
| 11809 |
end |
| 11810 |
end |
| 11811 |
end |
| 11812 |
local gotodatatable=readers.helpers.gotodatatable |
| 11813 |
local function cleanup(data,dictionaries) |
| 11814 |
end |
| 11815 |
function readers.cff(f,fontdata,specification) |
| 11816 |
local tableoffset=gotodatatable(f,fontdata,"cff",specification.details or specification.glyphs) |
| 11817 |
if tableoffset then |
| 11818 |
local header=readheader(f) |
| 11819 |
if header.major~=1 then |
| 11820 |
report("only version %s is supported for table %a",1,"cff") |
| 11821 |
return |
| 11822 |
end |
| 11823 |
local glyphs=fontdata.glyphs |
| 11824 |
local names=readfontnames(f) |
| 11825 |
local dictionaries=readtopdictionaries(f) |
| 11826 |
local strings=readstrings(f) |
| 11827 |
local data={ |
| 11828 |
header=header, |
| 11829 |
names=names, |
| 11830 |
dictionaries=dictionaries, |
| 11831 |
strings=strings, |
| 11832 |
nofglyphs=fontdata.nofglyphs, |
| 11833 |
} |
| 11834 |
parsedictionaries(data,dictionaries,"cff") |
| 11835 |
local dic=dictionaries[1] |
| 11836 |
local cid=dic.cid |
| 11837 |
local cffinfo={ |
| 11838 |
familyname=dic.familyname, |
| 11839 |
fullname=dic.fullname, |
| 11840 |
boundingbox=dic.boundingbox, |
| 11841 |
weight=dic.weight, |
| 11842 |
italicangle=dic.italicangle, |
| 11843 |
underlineposition=dic.underlineposition, |
| 11844 |
underlinethickness=dic.underlinethickness, |
| 11845 |
defaultwidth=dic.defaultwidthx, |
| 11846 |
nominalwidth=dic.nominalwidthx, |
| 11847 |
monospaced=dic.monospaced, |
| 11848 |
} |
| 11849 |
fontdata.cidinfo=cid and { |
| 11850 |
registry=cid.registry, |
| 11851 |
ordering=cid.ordering, |
| 11852 |
supplement=cid.supplement, |
| 11853 |
} |
| 11854 |
fontdata.cffinfo=cffinfo |
| 11855 |
local all=specification.shapes or specification.streams or false |
| 11856 |
if specification.glyphs or all then |
| 11857 |
if cid and cid.fdselect then |
| 11858 |
readfdselect(f,fontdata,data,glyphs,all,"cff",specification.streams) |
| 11859 |
else |
| 11860 |
readnoselect(f,fontdata,data,glyphs,all,"cff",specification.streams) |
| 11861 |
end |
| 11862 |
end |
| 11863 |
local private=dic.private |
| 11864 |
if private then |
| 11865 |
local data=private.data |
| 11866 |
if type(data)=="table" then |
| 11867 |
cffinfo.defaultwidth=data.defaultwidthx or cffinfo.defaultwidth |
| 11868 |
cffinfo.nominalwidth=data.nominalwidthx or cffinfo.nominalwidth |
| 11869 |
cffinfo.bluevalues=data.bluevalues |
| 11870 |
cffinfo.otherblues=data.otherblues |
| 11871 |
cffinfo.familyblues=data.familyblues |
| 11872 |
cffinfo.familyotherblues=data.familyotherblues |
| 11873 |
cffinfo.bluescale=data.bluescale |
| 11874 |
cffinfo.blueshift=data.blueshift |
| 11875 |
cffinfo.bluefuzz=data.bluefuzz |
| 11876 |
cffinfo.stdhw=data.stdhw |
| 11877 |
cffinfo.stdvw=data.stdvw |
| 11878 |
cffinfo.stemsnaph=data.stemsnaph |
| 11879 |
cffinfo.stemsnapv=data.stemsnapv |
| 11880 |
end |
| 11881 |
end |
| 11882 |
cleanup(data,dictionaries) |
| 11883 |
end |
| 11884 |
end |
| 11885 |
function readers.cff2(f,fontdata,specification) |
| 11886 |
local tableoffset=gotodatatable(f,fontdata,"cff2",specification.glyphs) |
| 11887 |
if tableoffset then |
| 11888 |
local header=readheader(f) |
| 11889 |
if header.major~=2 then |
| 11890 |
report("only version %s is supported for table %a",2,"cff2") |
| 11891 |
return |
| 11892 |
end |
| 11893 |
local glyphs=fontdata.glyphs |
| 11894 |
local dictionaries={ readstring(f,header.dsize) } |
| 11895 |
local data={ |
| 11896 |
header=header, |
| 11897 |
dictionaries=dictionaries, |
| 11898 |
nofglyphs=fontdata.nofglyphs, |
| 11899 |
} |
| 11900 |
parsedictionaries(data,dictionaries,"cff2") |
| 11901 |
local offset=dictionaries[1].vstore |
| 11902 |
if offset>0 then |
| 11903 |
local storeoffset=dictionaries[1].vstore+data.header.offset+2 |
| 11904 |
local regions,deltas=readers.helpers.readvariationdata(f,storeoffset,factors) |
| 11905 |
data.regions=regions |
| 11906 |
data.deltas=deltas |
| 11907 |
else |
| 11908 |
data.regions={} |
| 11909 |
data.deltas={} |
| 11910 |
end |
| 11911 |
data.factors=specification.factors |
| 11912 |
local cid=data.dictionaries[1].cid |
| 11913 |
local all=specification.shapes or specification.streams or false |
| 11914 |
if cid and cid.fdselect then |
| 11915 |
readfdselect(f,fontdata,data,glyphs,all,"cff2",specification.streams) |
| 11916 |
else |
| 11917 |
readnoselect(f,fontdata,data,glyphs,all,"cff2",specification.streams) |
| 11918 |
end |
| 11919 |
cleanup(data,dictionaries) |
| 11920 |
end |
| 11921 |
end |
| 11922 |
|
| 11923 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-cff”] --- |
| 11924 |
|
| 11925 |
|
| 11926 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ttf” ff94e130d7c71edd899c4bae7745b7db] --- |
| 11927 |
|
| 11928 |
if not modules then modules={} end modules ['font-ttf']={ |
| 11929 |
version=1.001, |
| 11930 |
optimize=true, |
| 11931 |
comment="companion to font-ini.mkiv", |
| 11932 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 11933 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 11934 |
license="see context related readme files" |
| 11935 |
} |
| 11936 |
local next,type,unpack=next,type,unpack |
| 11937 |
local band,rshift=bit32.band,bit32.rshift |
| 11938 |
local sqrt,round,abs,min,max=math.sqrt,math.round,math.abs,math.min,math.max |
| 11939 |
local char,rep=string.char,string.rep |
| 11940 |
local concat=table.concat |
| 11941 |
local idiv=number.idiv |
| 11942 |
local setmetatableindex=table.setmetatableindex |
| 11943 |
local report=logs.reporter("otf reader","ttf") |
| 11944 |
local trace_deltas=false |
| 11945 |
local readers=fonts.handlers.otf.readers |
| 11946 |
local streamreader=readers.streamreader |
| 11947 |
local setposition=streamreader.setposition |
| 11948 |
local getposition=streamreader.getposition |
| 11949 |
local skipbytes=streamreader.skip |
| 11950 |
local readbyte=streamreader.readcardinal1 |
| 11951 |
local readushort=streamreader.readcardinal2 |
| 11952 |
local readulong=streamreader.readcardinal4 |
| 11953 |
local readchar=streamreader.readinteger1 |
| 11954 |
local readshort=streamreader.readinteger2 |
| 11955 |
local read2dot14=streamreader.read2dot14 |
| 11956 |
local readinteger=streamreader.readinteger1 |
| 11957 |
local readcardinaltable=streamreader.readcardinaltable |
| 11958 |
local readintegertable=streamreader.readintegertable |
| 11959 |
directives.register("fonts.streamreader",function() |
| 11960 |
streamreader=utilities.streams |
| 11961 |
setposition=streamreader.setposition |
| 11962 |
getposition=streamreader.getposition |
| 11963 |
skipbytes=streamreader.skip |
| 11964 |
readbyte=streamreader.readcardinal1 |
| 11965 |
readushort=streamreader.readcardinal2 |
| 11966 |
readulong=streamreader.readcardinal4 |
| 11967 |
readchar=streamreader.readinteger1 |
| 11968 |
readshort=streamreader.readinteger2 |
| 11969 |
read2dot14=streamreader.read2dot14 |
| 11970 |
readinteger=streamreader.readinteger1 |
| 11971 |
readcardinaltable=streamreader.readcardinaltable |
| 11972 |
readintegertable=streamreader.readintegertable |
| 11973 |
end) |
| 11974 |
local short=2 |
| 11975 |
local ushort=2 |
| 11976 |
local ulong=4 |
| 11977 |
local helpers=readers.helpers |
| 11978 |
local gotodatatable=helpers.gotodatatable |
| 11979 |
local function mergecomposites(glyphs,shapes) |
| 11980 |
local function merge(index,shape,components) |
| 11981 |
local contours={} |
| 11982 |
local points={} |
| 11983 |
local nofcontours=0 |
| 11984 |
local nofpoints=0 |
| 11985 |
local offset=0 |
| 11986 |
local deltas=shape.deltas |
| 11987 |
for i=1,#components do |
| 11988 |
local component=components[i] |
| 11989 |
local subindex=component.index |
| 11990 |
local subshape=shapes[subindex] |
| 11991 |
local subcontours=subshape.contours |
| 11992 |
local subpoints=subshape.points |
| 11993 |
if not subcontours then |
| 11994 |
local subcomponents=subshape.components |
| 11995 |
if subcomponents then |
| 11996 |
subcontours,subpoints=merge(subindex,subshape,subcomponents) |
| 11997 |
end |
| 11998 |
end |
| 11999 |
if subpoints then |
| 12000 |
local matrix=component.matrix |
| 12001 |
local xscale=matrix[1] |
| 12002 |
local xrotate=matrix[2] |
| 12003 |
local yrotate=matrix[3] |
| 12004 |
local yscale=matrix[4] |
| 12005 |
local xoffset=matrix[5] |
| 12006 |
local yoffset=matrix[6] |
| 12007 |
local count=#subpoints |
| 12008 |
if xscale==1 and yscale==1 and xrotate==0 and yrotate==0 then |
| 12009 |
for i=1,count do |
| 12010 |
local p=subpoints[i] |
| 12011 |
nofpoints=nofpoints+1 |
| 12012 |
points[nofpoints]={ |
| 12013 |
p[1]+xoffset, |
| 12014 |
p[2]+yoffset, |
| 12015 |
p[3] |
| 12016 |
} |
| 12017 |
end |
| 12018 |
else |
| 12019 |
for i=1,count do |
| 12020 |
local p=subpoints[i] |
| 12021 |
local x=p[1] |
| 12022 |
local y=p[2] |
| 12023 |
nofpoints=nofpoints+1 |
| 12024 |
points[nofpoints]={ |
| 12025 |
xscale*x+xrotate*y+xoffset, |
| 12026 |
yscale*y+yrotate*x+yoffset, |
| 12027 |
p[3] |
| 12028 |
} |
| 12029 |
end |
| 12030 |
end |
| 12031 |
local subcount=#subcontours |
| 12032 |
if subcount==1 then |
| 12033 |
nofcontours=nofcontours+1 |
| 12034 |
contours[nofcontours]=offset+subcontours[1] |
| 12035 |
else |
| 12036 |
for i=1,#subcontours do |
| 12037 |
nofcontours=nofcontours+1 |
| 12038 |
contours[nofcontours]=offset+subcontours[i] |
| 12039 |
end |
| 12040 |
end |
| 12041 |
offset=offset+count |
| 12042 |
else |
| 12043 |
report("missing contours composite %s, component %s of %s, glyph %s",index,i,#components,subindex) |
| 12044 |
end |
| 12045 |
end |
| 12046 |
shape.points=points |
| 12047 |
shape.contours=contours |
| 12048 |
shape.components=nil |
| 12049 |
return contours,points |
| 12050 |
end |
| 12051 |
for index=0,#glyphs do |
| 12052 |
local shape=shapes[index] |
| 12053 |
if shape then |
| 12054 |
local components=shape.components |
| 12055 |
if components then |
| 12056 |
merge(index,shape,components) |
| 12057 |
end |
| 12058 |
end |
| 12059 |
end |
| 12060 |
end |
| 12061 |
local function readnothing(f) |
| 12062 |
return { |
| 12063 |
type="nothing", |
| 12064 |
} |
| 12065 |
end |
| 12066 |
local function curveto(m_x,m_y,l_x,l_y,r_x,r_y) |
| 12067 |
return |
| 12068 |
l_x+2/3*(m_x-l_x),l_y+2/3*(m_y-l_y), |
| 12069 |
r_x+2/3*(m_x-r_x),r_y+2/3*(m_y-r_y), |
| 12070 |
r_x,r_y,"c" |
| 12071 |
end |
| 12072 |
local xv={} |
| 12073 |
local yv={} |
| 12074 |
local function applyaxis(glyph,shape,deltas,dowidth) |
| 12075 |
local points=shape.points |
| 12076 |
if points then |
| 12077 |
local nofpoints=#points |
| 12078 |
local dw=0 |
| 12079 |
local dl=0 |
| 12080 |
for i=1,#deltas do |
| 12081 |
local deltaset=deltas[i] |
| 12082 |
local xvalues=deltaset.xvalues |
| 12083 |
local yvalues=deltaset.yvalues |
| 12084 |
if xvalues and yvalues then |
| 12085 |
local dpoints=deltaset.points |
| 12086 |
local factor=deltaset.factor |
| 12087 |
if dpoints then |
| 12088 |
local cnt=#dpoints |
| 12089 |
if dowidth then |
| 12090 |
cnt=cnt-4 |
| 12091 |
end |
| 12092 |
if cnt>0 then |
| 12093 |
local contours=shape.contours |
| 12094 |
local nofcontours=#contours |
| 12095 |
local first=1 |
| 12096 |
local firstindex=1 |
| 12097 |
for contour=1,nofcontours do |
| 12098 |
local last=contours[contour] |
| 12099 |
if last>=first then |
| 12100 |
local lastindex=cnt |
| 12101 |
if firstindex<cnt then |
| 12102 |
for currentindex=firstindex,cnt do |
| 12103 |
local found=dpoints[currentindex] |
| 12104 |
if found<=first then |
| 12105 |
firstindex=currentindex |
| 12106 |
end |
| 12107 |
if found==last then |
| 12108 |
lastindex=currentindex |
| 12109 |
break |
| 12110 |
elseif found>last then |
| 12111 |
while lastindex>1 and dpoints[lastindex]>last do |
| 12112 |
lastindex=lastindex-1 |
| 12113 |
end |
| 12114 |
break |
| 12115 |
end |
| 12116 |
end |
| 12117 |
end |
| 12118 |
local function find(i) |
| 12119 |
local prv=lastindex |
| 12120 |
for j=firstindex,lastindex do |
| 12121 |
local nxt=dpoints[j] |
| 12122 |
if nxt==i then |
| 12123 |
return false,j,false |
| 12124 |
elseif nxt>i then |
| 12125 |
return prv,false,j |
| 12126 |
end |
| 12127 |
prv=j |
| 12128 |
end |
| 12129 |
return prv,false,firstindex |
| 12130 |
end |
| 12131 |
for point=first,last do |
| 12132 |
local d1,d2,d3=find(point) |
| 12133 |
local p2=points[point] |
| 12134 |
if d2 then |
| 12135 |
xv[point]=xvalues[d2] |
| 12136 |
yv[point]=yvalues[d2] |
| 12137 |
else |
| 12138 |
local n1=dpoints[d1] |
| 12139 |
local n3=dpoints[d3] |
| 12140 |
if n1>nofpoints then |
| 12141 |
n1=nofpoints |
| 12142 |
end |
| 12143 |
if n3>nofpoints then |
| 12144 |
n3=nofpoints |
| 12145 |
end |
| 12146 |
local p1=points[n1] |
| 12147 |
local p3=points[n3] |
| 12148 |
local p1x=p1[1] |
| 12149 |
local p2x=p2[1] |
| 12150 |
local p3x=p3[1] |
| 12151 |
local p1y=p1[2] |
| 12152 |
local p2y=p2[2] |
| 12153 |
local p3y=p3[2] |
| 12154 |
local x1=xvalues[d1] |
| 12155 |
local y1=yvalues[d1] |
| 12156 |
local x3=xvalues[d3] |
| 12157 |
local y3=yvalues[d3] |
| 12158 |
local fx |
| 12159 |
local fy |
| 12160 |
if p1x==p3x then |
| 12161 |
if x1==x3 then |
| 12162 |
fx=x1 |
| 12163 |
else |
| 12164 |
fx=0 |
| 12165 |
end |
| 12166 |
elseif p2x<=min(p1x,p3x) then |
| 12167 |
if p1x<p3x then |
| 12168 |
fx=x1 |
| 12169 |
else |
| 12170 |
fx=x3 |
| 12171 |
end |
| 12172 |
elseif p2x>=max(p1x,p3x) then |
| 12173 |
if p1x>p3x then |
| 12174 |
fx=x1 |
| 12175 |
else |
| 12176 |
fx=x3 |
| 12177 |
end |
| 12178 |
else |
| 12179 |
fx=(p2x-p1x)/(p3x-p1x) |
| 12180 |
fx=(1-fx)*x1+fx*x3 |
| 12181 |
end |
| 12182 |
if p1y==p3y then |
| 12183 |
if y1==y3 then |
| 12184 |
fy=y1 |
| 12185 |
else |
| 12186 |
fy=0 |
| 12187 |
end |
| 12188 |
elseif p2y<=min(p1y,p3y) then |
| 12189 |
if p1y<p3y then |
| 12190 |
fy=y1 |
| 12191 |
else |
| 12192 |
fy=y3 |
| 12193 |
end |
| 12194 |
elseif p2y>=max(p1y,p3y) then |
| 12195 |
if p1y>p3y then |
| 12196 |
fy=y1 |
| 12197 |
else |
| 12198 |
fy=y3 |
| 12199 |
end |
| 12200 |
else |
| 12201 |
fy=(p2y-p1y)/(p3y-p1y) |
| 12202 |
fy=(1-fy)*y1+fy*y3 |
| 12203 |
end |
| 12204 |
xv[point]=fx |
| 12205 |
yv[point]=fy |
| 12206 |
end |
| 12207 |
end |
| 12208 |
if lastindex<cnt then |
| 12209 |
firstindex=lastindex+1 |
| 12210 |
end |
| 12211 |
end |
| 12212 |
first=last+1 |
| 12213 |
end |
| 12214 |
for i=1,nofpoints do |
| 12215 |
local pi=points[i] |
| 12216 |
local fx=xv[i] |
| 12217 |
local fy=yv[i] |
| 12218 |
if fx~=0 then |
| 12219 |
pi[1]=pi[1]+factor*fx |
| 12220 |
end |
| 12221 |
if fy~=0 then |
| 12222 |
pi[2]=pi[2]+factor*fy |
| 12223 |
end |
| 12224 |
end |
| 12225 |
else |
| 12226 |
report("bad deltapoint data, maybe a missing hvar table") |
| 12227 |
end |
| 12228 |
else |
| 12229 |
for i=1,nofpoints do |
| 12230 |
local p=points[i] |
| 12231 |
local x=xvalues[i] |
| 12232 |
if x then |
| 12233 |
local y=yvalues[i] |
| 12234 |
if x~=0 then |
| 12235 |
p[1]=p[1]+factor*x |
| 12236 |
end |
| 12237 |
if y~=0 then |
| 12238 |
p[2]=p[2]+factor*y |
| 12239 |
end |
| 12240 |
else |
| 12241 |
break |
| 12242 |
end |
| 12243 |
end |
| 12244 |
end |
| 12245 |
if dowidth then |
| 12246 |
local h=nofpoints+2 |
| 12247 |
local l=nofpoints+1 |
| 12248 |
local x=xvalues[h] |
| 12249 |
if x then |
| 12250 |
dw=dw+factor*x |
| 12251 |
end |
| 12252 |
local x=xvalues[l] |
| 12253 |
if x then |
| 12254 |
dl=dl+factor*x |
| 12255 |
end |
| 12256 |
end |
| 12257 |
end |
| 12258 |
end |
| 12259 |
if dowidth then |
| 12260 |
local width=glyph.width or 0 |
| 12261 |
glyph.width=width+dw-dl |
| 12262 |
end |
| 12263 |
else |
| 12264 |
report("no points for glyph %a",glyph.name) |
| 12265 |
end |
| 12266 |
end |
| 12267 |
local quadratic=false |
| 12268 |
local function contours2outlines_normal(glyphs,shapes) |
| 12269 |
for index=0,#glyphs-1 do |
| 12270 |
local shape=shapes[index] |
| 12271 |
if shape then |
| 12272 |
local glyph=glyphs[index] |
| 12273 |
local contours=shape.contours |
| 12274 |
local points=shape.points |
| 12275 |
if contours then |
| 12276 |
local nofcontours=#contours |
| 12277 |
local segments={} |
| 12278 |
local nofsegments=0 |
| 12279 |
glyph.segments=segments |
| 12280 |
if nofcontours>0 then |
| 12281 |
local px=0 |
| 12282 |
local py=0 |
| 12283 |
local first=1 |
| 12284 |
for i=1,nofcontours do |
| 12285 |
local last=contours[i] |
| 12286 |
if last>=first then |
| 12287 |
local first_pt=points[first] |
| 12288 |
local first_on=first_pt[3] |
| 12289 |
if first==last then |
| 12290 |
first_pt[3]="m" |
| 12291 |
nofsegments=nofsegments+1 |
| 12292 |
segments[nofsegments]=first_pt |
| 12293 |
else |
| 12294 |
local first_on=first_pt[3] |
| 12295 |
local last_pt=points[last] |
| 12296 |
local last_on=last_pt[3] |
| 12297 |
local start=1 |
| 12298 |
local control_pt=false |
| 12299 |
if first_on then |
| 12300 |
start=2 |
| 12301 |
else |
| 12302 |
if last_on then |
| 12303 |
first_pt=last_pt |
| 12304 |
else |
| 12305 |
first_pt={ (first_pt[1]+last_pt[1])/2,(first_pt[2]+last_pt[2])/2,false } |
| 12306 |
end |
| 12307 |
control_pt=first_pt |
| 12308 |
end |
| 12309 |
local x=first_pt[1] |
| 12310 |
local y=first_pt[2] |
| 12311 |
if not done then |
| 12312 |
xmin=x |
| 12313 |
ymin=y |
| 12314 |
xmax=x |
| 12315 |
ymax=y |
| 12316 |
done=true |
| 12317 |
end |
| 12318 |
nofsegments=nofsegments+1 |
| 12319 |
segments[nofsegments]={ x,y,"m" } |
| 12320 |
if not quadratic then |
| 12321 |
px=x |
| 12322 |
py=y |
| 12323 |
end |
| 12324 |
local previous_pt=first_pt |
| 12325 |
for i=first,last do |
| 12326 |
local current_pt=points[i] |
| 12327 |
local current_on=current_pt[3] |
| 12328 |
local previous_on=previous_pt[3] |
| 12329 |
if previous_on then |
| 12330 |
if current_on then |
| 12331 |
local x,y=current_pt[1],current_pt[2] |
| 12332 |
nofsegments=nofsegments+1 |
| 12333 |
segments[nofsegments]={ x,y,"l" } |
| 12334 |
if not quadratic then |
| 12335 |
px,py=x,y |
| 12336 |
end |
| 12337 |
else |
| 12338 |
control_pt=current_pt |
| 12339 |
end |
| 12340 |
elseif current_on then |
| 12341 |
local x1=control_pt[1] |
| 12342 |
local y1=control_pt[2] |
| 12343 |
local x2=current_pt[1] |
| 12344 |
local y2=current_pt[2] |
| 12345 |
nofsegments=nofsegments+1 |
| 12346 |
if quadratic then |
| 12347 |
segments[nofsegments]={ x1,y1,x2,y2,"q" } |
| 12348 |
else |
| 12349 |
x1,y1,x2,y2,px,py=curveto(x1,y1,px,py,x2,y2) |
| 12350 |
segments[nofsegments]={ x1,y1,x2,y2,px,py,"c" } |
| 12351 |
end |
| 12352 |
control_pt=false |
| 12353 |
else |
| 12354 |
local x2=(previous_pt[1]+current_pt[1])/2 |
| 12355 |
local y2=(previous_pt[2]+current_pt[2])/2 |
| 12356 |
local x1=control_pt[1] |
| 12357 |
local y1=control_pt[2] |
| 12358 |
nofsegments=nofsegments+1 |
| 12359 |
if quadratic then |
| 12360 |
segments[nofsegments]={ x1,y1,x2,y2,"q" } |
| 12361 |
else |
| 12362 |
x1,y1,x2,y2,px,py=curveto(x1,y1,px,py,x2,y2) |
| 12363 |
segments[nofsegments]={ x1,y1,x2,y2,px,py,"c" } |
| 12364 |
end |
| 12365 |
control_pt=current_pt |
| 12366 |
end |
| 12367 |
previous_pt=current_pt |
| 12368 |
end |
| 12369 |
if first_pt==last_pt then |
| 12370 |
else |
| 12371 |
nofsegments=nofsegments+1 |
| 12372 |
local x2=first_pt[1] |
| 12373 |
local y2=first_pt[2] |
| 12374 |
if not control_pt then |
| 12375 |
segments[nofsegments]={ x2,y2,"l" } |
| 12376 |
elseif quadratic then |
| 12377 |
local x1=control_pt[1] |
| 12378 |
local y1=control_pt[2] |
| 12379 |
segments[nofsegments]={ x1,y1,x2,y2,"q" } |
| 12380 |
else |
| 12381 |
local x1=control_pt[1] |
| 12382 |
local y1=control_pt[2] |
| 12383 |
x1,y1,x2,y2,px,py=curveto(x1,y1,px,py,x2,y2) |
| 12384 |
segments[nofsegments]={ x1,y1,x2,y2,px,py,"c" } |
| 12385 |
end |
| 12386 |
end |
| 12387 |
end |
| 12388 |
end |
| 12389 |
first=last+1 |
| 12390 |
end |
| 12391 |
end |
| 12392 |
end |
| 12393 |
end |
| 12394 |
end |
| 12395 |
end |
| 12396 |
local function contours2outlines_shaped(glyphs,shapes,keepcurve) |
| 12397 |
for index=0,#glyphs-1 do |
| 12398 |
local shape=shapes[index] |
| 12399 |
if shape then |
| 12400 |
local glyph=glyphs[index] |
| 12401 |
local contours=shape.contours |
| 12402 |
local points=shape.points |
| 12403 |
if contours then |
| 12404 |
local nofcontours=#contours |
| 12405 |
local segments=keepcurve and {} or nil |
| 12406 |
local nofsegments=0 |
| 12407 |
if keepcurve then |
| 12408 |
glyph.segments=segments |
| 12409 |
end |
| 12410 |
if nofcontours>0 then |
| 12411 |
local xmin,ymin,xmax,ymax,done=0,0,0,0,false |
| 12412 |
local px,py=0,0 |
| 12413 |
local first=1 |
| 12414 |
for i=1,nofcontours do |
| 12415 |
local last=contours[i] |
| 12416 |
if last>=first then |
| 12417 |
local first_pt=points[first] |
| 12418 |
local first_on=first_pt[3] |
| 12419 |
if first==last then |
| 12420 |
if keepcurve then |
| 12421 |
first_pt[3]="m" |
| 12422 |
nofsegments=nofsegments+1 |
| 12423 |
segments[nofsegments]=first_pt |
| 12424 |
end |
| 12425 |
else |
| 12426 |
local first_on=first_pt[3] |
| 12427 |
local last_pt=points[last] |
| 12428 |
local last_on=last_pt[3] |
| 12429 |
local start=1 |
| 12430 |
local control_pt=false |
| 12431 |
if first_on then |
| 12432 |
start=2 |
| 12433 |
else |
| 12434 |
if last_on then |
| 12435 |
first_pt=last_pt |
| 12436 |
else |
| 12437 |
first_pt={ (first_pt[1]+last_pt[1])/2,(first_pt[2]+last_pt[2])/2,false } |
| 12438 |
end |
| 12439 |
control_pt=first_pt |
| 12440 |
end |
| 12441 |
local x=first_pt[1] |
| 12442 |
local y=first_pt[2] |
| 12443 |
if not done then |
| 12444 |
xmin,ymin,xmax,ymax=x,y,x,y |
| 12445 |
done=true |
| 12446 |
else |
| 12447 |
if x<xmin then xmin=x elseif x>xmax then xmax=x end |
| 12448 |
if y<ymin then ymin=y elseif y>ymax then ymax=y end |
| 12449 |
end |
| 12450 |
if keepcurve then |
| 12451 |
nofsegments=nofsegments+1 |
| 12452 |
segments[nofsegments]={ x,y,"m" } |
| 12453 |
end |
| 12454 |
if not quadratic then |
| 12455 |
px=x |
| 12456 |
py=y |
| 12457 |
end |
| 12458 |
local previous_pt=first_pt |
| 12459 |
for i=first,last do |
| 12460 |
local current_pt=points[i] |
| 12461 |
local current_on=current_pt[3] |
| 12462 |
local previous_on=previous_pt[3] |
| 12463 |
if previous_on then |
| 12464 |
if current_on then |
| 12465 |
local x=current_pt[1] |
| 12466 |
local y=current_pt[2] |
| 12467 |
if x<xmin then xmin=x elseif x>xmax then xmax=x end |
| 12468 |
if y<ymin then ymin=y elseif y>ymax then ymax=y end |
| 12469 |
if keepcurve then |
| 12470 |
nofsegments=nofsegments+1 |
| 12471 |
segments[nofsegments]={ x,y,"l" } |
| 12472 |
end |
| 12473 |
if not quadratic then |
| 12474 |
px=x |
| 12475 |
py=y |
| 12476 |
end |
| 12477 |
else |
| 12478 |
control_pt=current_pt |
| 12479 |
end |
| 12480 |
elseif current_on then |
| 12481 |
local x1=control_pt[1] |
| 12482 |
local y1=control_pt[2] |
| 12483 |
local x2=current_pt[1] |
| 12484 |
local y2=current_pt[2] |
| 12485 |
if quadratic then |
| 12486 |
if x1<xmin then xmin=x1 elseif x1>xmax then xmax=x1 end |
| 12487 |
if y1<ymin then ymin=y1 elseif y1>ymax then ymax=y1 end |
| 12488 |
if keepcurve then |
| 12489 |
nofsegments=nofsegments+1 |
| 12490 |
segments[nofsegments]={ x1,y1,x2,y2,"q" } |
| 12491 |
end |
| 12492 |
else |
| 12493 |
x1,y1,x2,y2,px,py=curveto(x1,y1,px,py,x2,y2) |
| 12494 |
if x1<xmin then xmin=x1 elseif x1>xmax then xmax=x1 end |
| 12495 |
if y1<ymin then ymin=y1 elseif y1>ymax then ymax=y1 end |
| 12496 |
if x2<xmin then xmin=x2 elseif x2>xmax then xmax=x2 end |
| 12497 |
if y2<ymin then ymin=y2 elseif y2>ymax then ymax=y2 end |
| 12498 |
if px<xmin then xmin=px elseif px>xmax then xmax=px end |
| 12499 |
if py<ymin then ymin=py elseif py>ymax then ymax=py end |
| 12500 |
if keepcurve then |
| 12501 |
nofsegments=nofsegments+1 |
| 12502 |
segments[nofsegments]={ x1,y1,x2,y2,px,py,"c" } |
| 12503 |
end |
| 12504 |
end |
| 12505 |
control_pt=false |
| 12506 |
else |
| 12507 |
local x2=(previous_pt[1]+current_pt[1])/2 |
| 12508 |
local y2=(previous_pt[2]+current_pt[2])/2 |
| 12509 |
local x1=control_pt[1] |
| 12510 |
local y1=control_pt[2] |
| 12511 |
if quadratic then |
| 12512 |
if x1<xmin then xmin=x1 elseif x1>xmax then xmax=x1 end |
| 12513 |
if y1<ymin then ymin=y1 elseif y1>ymax then ymax=y1 end |
| 12514 |
if keepcurve then |
| 12515 |
nofsegments=nofsegments+1 |
| 12516 |
segments[nofsegments]={ x1,y1,x2,y2,"q" } |
| 12517 |
end |
| 12518 |
else |
| 12519 |
x1,y1,x2,y2,px,py=curveto(x1,y1,px,py,x2,y2) |
| 12520 |
if x1<xmin then xmin=x1 elseif x1>xmax then xmax=x1 end |
| 12521 |
if y1<ymin then ymin=y1 elseif y1>ymax then ymax=y1 end |
| 12522 |
if x2<xmin then xmin=x2 elseif x2>xmax then xmax=x2 end |
| 12523 |
if y2<ymin then ymin=y2 elseif y2>ymax then ymax=y2 end |
| 12524 |
if px<xmin then xmin=px elseif px>xmax then xmax=px end |
| 12525 |
if py<ymin then ymin=py elseif py>ymax then ymax=py end |
| 12526 |
if keepcurve then |
| 12527 |
nofsegments=nofsegments+1 |
| 12528 |
segments[nofsegments]={ x1,y1,x2,y2,px,py,"c" } |
| 12529 |
end |
| 12530 |
end |
| 12531 |
control_pt=current_pt |
| 12532 |
end |
| 12533 |
previous_pt=current_pt |
| 12534 |
end |
| 12535 |
if first_pt==last_pt then |
| 12536 |
elseif not control_pt then |
| 12537 |
if keepcurve then |
| 12538 |
nofsegments=nofsegments+1 |
| 12539 |
segments[nofsegments]={ first_pt[1],first_pt[2],"l" } |
| 12540 |
end |
| 12541 |
else |
| 12542 |
local x1=control_pt[1] |
| 12543 |
local y1=control_pt[2] |
| 12544 |
local x2=first_pt[1] |
| 12545 |
local y2=first_pt[2] |
| 12546 |
if x1<xmin then xmin=x1 elseif x1>xmax then xmax=x1 end |
| 12547 |
if y1<ymin then ymin=y1 elseif y1>ymax then ymax=y1 end |
| 12548 |
if quadratic then |
| 12549 |
if keepcurve then |
| 12550 |
nofsegments=nofsegments+1 |
| 12551 |
segments[nofsegments]={ x1,y1,x2,y2,"q" } |
| 12552 |
end |
| 12553 |
else |
| 12554 |
x1,y1,x2,y2,px,py=curveto(x1,y1,px,py,x2,y2) |
| 12555 |
if x2<xmin then xmin=x2 elseif x2>xmax then xmax=x2 end |
| 12556 |
if y2<ymin then ymin=y2 elseif y2>ymax then ymax=y2 end |
| 12557 |
if px<xmin then xmin=px elseif px>xmax then xmax=px end |
| 12558 |
if py<ymin then ymin=py elseif py>ymax then ymax=py end |
| 12559 |
if keepcurve then |
| 12560 |
nofsegments=nofsegments+1 |
| 12561 |
segments[nofsegments]={ x1,y1,x2,y2,px,py,"c" } |
| 12562 |
end |
| 12563 |
end |
| 12564 |
end |
| 12565 |
end |
| 12566 |
end |
| 12567 |
first=last+1 |
| 12568 |
end |
| 12569 |
xmin=glyph.boundingbox[1] |
| 12570 |
local dlsb=glyph.dlsb |
| 12571 |
if dlsb then |
| 12572 |
xmin=xmin+dlsb |
| 12573 |
glyph.dlsb=nil |
| 12574 |
end |
| 12575 |
glyph.boundingbox={ round(xmin),round(ymin),round(xmax),round(ymax) } |
| 12576 |
end |
| 12577 |
end |
| 12578 |
end |
| 12579 |
end |
| 12580 |
end |
| 12581 |
local c_zero=char(0) |
| 12582 |
local s_zero=char(0,0) |
| 12583 |
local function toushort(n) |
| 12584 |
return char(band(rshift(n,8),0xFF),band(n,0xFF)) |
| 12585 |
end |
| 12586 |
local function toshort(n) |
| 12587 |
if n<0 then |
| 12588 |
n=n+0x10000 |
| 12589 |
end |
| 12590 |
return char(band(rshift(n,8),0xFF),band(n,0xFF)) |
| 12591 |
end |
| 12592 |
local chars=setmetatableindex(function(t,k) |
| 12593 |
for i=0,255 do local v=char(i) t[i]=v end return t[k] |
| 12594 |
end) |
| 12595 |
local function repackpoints(glyphs,shapes) |
| 12596 |
local noboundingbox={ 0,0,0,0 } |
| 12597 |
local result={} |
| 12598 |
local xpoints={} |
| 12599 |
local ypoints={} |
| 12600 |
for index=0,#glyphs do |
| 12601 |
local shape=shapes[index] |
| 12602 |
if shape then |
| 12603 |
local r=0 |
| 12604 |
local glyph=glyphs[index] |
| 12605 |
local contours=shape.contours |
| 12606 |
local nofcontours=contours and #contours or 0 |
| 12607 |
local boundingbox=glyph.boundingbox or noboundingbox |
| 12608 |
r=r+1 result[r]=toshort(nofcontours) |
| 12609 |
r=r+1 result[r]=toshort(boundingbox[1]) |
| 12610 |
r=r+1 result[r]=toshort(boundingbox[2]) |
| 12611 |
r=r+1 result[r]=toshort(boundingbox[3]) |
| 12612 |
r=r+1 result[r]=toshort(boundingbox[4]) |
| 12613 |
if nofcontours>0 then |
| 12614 |
for i=1,nofcontours do |
| 12615 |
r=r+1 result[r]=toshort(contours[i]-1) |
| 12616 |
end |
| 12617 |
r=r+1 result[r]=s_zero |
| 12618 |
local points=shape.points |
| 12619 |
local currentx=0 |
| 12620 |
local currenty=0 |
| 12621 |
local x=0 |
| 12622 |
local y=0 |
| 12623 |
local lastflag=nil |
| 12624 |
local nofflags=0 |
| 12625 |
for i=1,#points do |
| 12626 |
local pt=points[i] |
| 12627 |
local px=pt[1] |
| 12628 |
local py=pt[2] |
| 12629 |
local fl=pt[3] and 0x01 or 0x00 |
| 12630 |
if px==currentx then |
| 12631 |
fl=fl+0x10 |
| 12632 |
else |
| 12633 |
local dx=round(px-currentx) |
| 12634 |
x=x+1 |
| 12635 |
if dx<-255 or dx>255 then |
| 12636 |
xpoints[x]=toshort(dx) |
| 12637 |
elseif dx<0 then |
| 12638 |
fl=fl+0x02 |
| 12639 |
xpoints[x]=chars[-dx] |
| 12640 |
elseif dx>0 then |
| 12641 |
fl=fl+0x12 |
| 12642 |
xpoints[x]=chars[dx] |
| 12643 |
else |
| 12644 |
fl=fl+0x02 |
| 12645 |
xpoints[x]=c_zero |
| 12646 |
end |
| 12647 |
end |
| 12648 |
if py==currenty then |
| 12649 |
fl=fl+0x20 |
| 12650 |
else |
| 12651 |
local dy=round(py-currenty) |
| 12652 |
y=y+1 |
| 12653 |
if dy<-255 or dy>255 then |
| 12654 |
ypoints[y]=toshort(dy) |
| 12655 |
elseif dy<0 then |
| 12656 |
fl=fl+0x04 |
| 12657 |
ypoints[y]=chars[-dy] |
| 12658 |
elseif dy>0 then |
| 12659 |
fl=fl+0x24 |
| 12660 |
ypoints[y]=chars[dy] |
| 12661 |
else |
| 12662 |
fl=fl+0x04 |
| 12663 |
ypoints[y]=c_zero |
| 12664 |
end |
| 12665 |
end |
| 12666 |
currentx=px |
| 12667 |
currenty=py |
| 12668 |
if lastflag==fl then |
| 12669 |
if nofflags==255 then |
| 12670 |
lastflag=lastflag+0x08 |
| 12671 |
r=r+1 result[r]=char(lastflag,nofflags-1) |
| 12672 |
nofflags=1 |
| 12673 |
lastflag=fl |
| 12674 |
else |
| 12675 |
nofflags=nofflags+1 |
| 12676 |
end |
| 12677 |
else |
| 12678 |
if nofflags==1 then |
| 12679 |
r=r+1 result[r]=chars[lastflag] |
| 12680 |
elseif nofflags==2 then |
| 12681 |
r=r+1 result[r]=char(lastflag,lastflag) |
| 12682 |
elseif nofflags>2 then |
| 12683 |
lastflag=lastflag+0x08 |
| 12684 |
r=r+1 result[r]=char(lastflag,nofflags-1) |
| 12685 |
end |
| 12686 |
nofflags=1 |
| 12687 |
lastflag=fl |
| 12688 |
end |
| 12689 |
end |
| 12690 |
if nofflags==1 then |
| 12691 |
r=r+1 result[r]=chars[lastflag] |
| 12692 |
elseif nofflags==2 then |
| 12693 |
r=r+1 result[r]=char(lastflag,lastflag) |
| 12694 |
elseif nofflags>2 then |
| 12695 |
lastflag=lastflag+0x08 |
| 12696 |
r=r+1 result[r]=char(lastflag,nofflags-1) |
| 12697 |
end |
| 12698 |
r=r+1 result[r]=concat(xpoints,"",1,x) |
| 12699 |
r=r+1 result[r]=concat(ypoints,"",1,y) |
| 12700 |
end |
| 12701 |
local stream=concat(result,"",1,r) |
| 12702 |
local length=#stream |
| 12703 |
local padding=idiv(length+3,4)*4-length |
| 12704 |
if padding>0 then |
| 12705 |
if padding==1 then |
| 12706 |
padding="\0" |
| 12707 |
elseif padding==2 then |
| 12708 |
padding="\0\0" |
| 12709 |
else |
| 12710 |
padding="\0\0\0" |
| 12711 |
end |
| 12712 |
padding=stream..padding |
| 12713 |
end |
| 12714 |
glyph.stream=stream |
| 12715 |
end |
| 12716 |
end |
| 12717 |
end |
| 12718 |
local flags={} |
| 12719 |
local function readglyph(f,nofcontours) |
| 12720 |
local points={} |
| 12721 |
local contours={} |
| 12722 |
for i=1,nofcontours do |
| 12723 |
contours[i]=readshort(f)+1 |
| 12724 |
end |
| 12725 |
local nofpoints=contours[nofcontours] |
| 12726 |
local nofinstructions=readushort(f) |
| 12727 |
skipbytes(f,nofinstructions) |
| 12728 |
local i=1 |
| 12729 |
while i<=nofpoints do |
| 12730 |
local flag=readbyte(f) |
| 12731 |
flags[i]=flag |
| 12732 |
if band(flag,0x08)~=0 then |
| 12733 |
local n=readbyte(f) |
| 12734 |
if n==1 then |
| 12735 |
i=i+1 |
| 12736 |
flags[i]=flag |
| 12737 |
else |
| 12738 |
for j=1,n do |
| 12739 |
i=i+1 |
| 12740 |
flags[i]=flag |
| 12741 |
end |
| 12742 |
end |
| 12743 |
end |
| 12744 |
i=i+1 |
| 12745 |
end |
| 12746 |
local x=0 |
| 12747 |
for i=1,nofpoints do |
| 12748 |
local flag=flags[i] |
| 12749 |
if band(flag,0x02)~=0 then |
| 12750 |
if band(flag,0x10)~=0 then |
| 12751 |
x=x+readbyte(f) |
| 12752 |
else |
| 12753 |
x=x-readbyte(f) |
| 12754 |
end |
| 12755 |
elseif band(flag,0x10)~=0 then |
| 12756 |
else |
| 12757 |
x=x+readshort(f) |
| 12758 |
end |
| 12759 |
points[i]={ x,0,band(flag,0x01)~=0 } |
| 12760 |
end |
| 12761 |
local y=0 |
| 12762 |
for i=1,nofpoints do |
| 12763 |
local flag=flags[i] |
| 12764 |
if band(flag,0x04)~=0 then |
| 12765 |
if band(flag,0x20)~=0 then |
| 12766 |
y=y+readbyte(f) |
| 12767 |
else |
| 12768 |
y=y-readbyte(f) |
| 12769 |
end |
| 12770 |
elseif band(flag,0x20)~=0 then |
| 12771 |
else |
| 12772 |
y=y+readshort(f) |
| 12773 |
end |
| 12774 |
points[i][2]=y |
| 12775 |
end |
| 12776 |
return { |
| 12777 |
type="glyph", |
| 12778 |
points=points, |
| 12779 |
contours=contours, |
| 12780 |
nofpoints=nofpoints, |
| 12781 |
} |
| 12782 |
end |
| 12783 |
local function readcomposite(f) |
| 12784 |
local components={} |
| 12785 |
local nofcomponents=0 |
| 12786 |
local instructions=false |
| 12787 |
while true do |
| 12788 |
local flags=readushort(f) |
| 12789 |
local index=readushort(f) |
| 12790 |
local f_xyarg=band(flags,0x0002)~=0 |
| 12791 |
local f_offset=band(flags,0x0800)~=0 |
| 12792 |
local xscale=1 |
| 12793 |
local xrotate=0 |
| 12794 |
local yrotate=0 |
| 12795 |
local yscale=1 |
| 12796 |
local xoffset=0 |
| 12797 |
local yoffset=0 |
| 12798 |
local base=false |
| 12799 |
local reference=false |
| 12800 |
if f_xyarg then |
| 12801 |
if band(flags,0x0001)~=0 then |
| 12802 |
xoffset=readshort(f) |
| 12803 |
yoffset=readshort(f) |
| 12804 |
else |
| 12805 |
xoffset=readchar(f) |
| 12806 |
yoffset=readchar(f) |
| 12807 |
end |
| 12808 |
else |
| 12809 |
if band(flags,0x0001)~=0 then |
| 12810 |
base=readshort(f) |
| 12811 |
reference=readshort(f) |
| 12812 |
else |
| 12813 |
base=readchar(f) |
| 12814 |
reference=readchar(f) |
| 12815 |
end |
| 12816 |
end |
| 12817 |
if band(flags,0x0008)~=0 then |
| 12818 |
xscale=read2dot14(f) |
| 12819 |
yscale=xscale |
| 12820 |
if f_xyarg and f_offset then |
| 12821 |
xoffset=xoffset*xscale |
| 12822 |
yoffset=yoffset*yscale |
| 12823 |
end |
| 12824 |
elseif band(flags,0x0040)~=0 then |
| 12825 |
xscale=read2dot14(f) |
| 12826 |
yscale=read2dot14(f) |
| 12827 |
if f_xyarg and f_offset then |
| 12828 |
xoffset=xoffset*xscale |
| 12829 |
yoffset=yoffset*yscale |
| 12830 |
end |
| 12831 |
elseif band(flags,0x0080)~=0 then |
| 12832 |
xscale=read2dot14(f) |
| 12833 |
xrotate=read2dot14(f) |
| 12834 |
yrotate=read2dot14(f) |
| 12835 |
yscale=read2dot14(f) |
| 12836 |
if f_xyarg and f_offset then |
| 12837 |
xoffset=xoffset*sqrt(xscale^2+yrotate^2) |
| 12838 |
yoffset=yoffset*sqrt(xrotate^2+yscale^2) |
| 12839 |
end |
| 12840 |
end |
| 12841 |
nofcomponents=nofcomponents+1 |
| 12842 |
components[nofcomponents]={ |
| 12843 |
index=index, |
| 12844 |
usemine=band(flags,0x0200)~=0, |
| 12845 |
round=band(flags,0x0006)~=0, |
| 12846 |
base=base, |
| 12847 |
reference=reference, |
| 12848 |
matrix={ xscale,xrotate,yrotate,yscale,xoffset,yoffset }, |
| 12849 |
} |
| 12850 |
if band(flags,0x0100)~=0 then |
| 12851 |
instructions=true |
| 12852 |
end |
| 12853 |
if band(flags,0x0020)==0 then |
| 12854 |
break |
| 12855 |
end |
| 12856 |
end |
| 12857 |
return { |
| 12858 |
type="composite", |
| 12859 |
components=components, |
| 12860 |
} |
| 12861 |
end |
| 12862 |
function readers.loca(f,fontdata,specification) |
| 12863 |
if specification.glyphs then |
| 12864 |
local datatable=fontdata.tables.loca |
| 12865 |
if datatable then |
| 12866 |
local offset=fontdata.tables.glyf.offset |
| 12867 |
local format=fontdata.fontheader.indextolocformat |
| 12868 |
local profile=fontdata.maximumprofile |
| 12869 |
local nofglyphs=profile and profile.nofglyphs |
| 12870 |
local locations={} |
| 12871 |
setposition(f,datatable.offset) |
| 12872 |
if format==1 then |
| 12873 |
if not nofglyphs then |
| 12874 |
nofglyphs=idiv(datatable.length,4)-1 |
| 12875 |
end |
| 12876 |
for i=0,nofglyphs do |
| 12877 |
locations[i]=offset+readulong(f) |
| 12878 |
end |
| 12879 |
fontdata.nofglyphs=nofglyphs |
| 12880 |
else |
| 12881 |
if not nofglyphs then |
| 12882 |
nofglyphs=idiv(datatable.length,2)-1 |
| 12883 |
end |
| 12884 |
for i=0,nofglyphs do |
| 12885 |
locations[i]=offset+readushort(f)*2 |
| 12886 |
end |
| 12887 |
end |
| 12888 |
fontdata.nofglyphs=nofglyphs |
| 12889 |
fontdata.locations=locations |
| 12890 |
end |
| 12891 |
end |
| 12892 |
end |
| 12893 |
function readers.glyf(f,fontdata,specification) |
| 12894 |
local tableoffset=gotodatatable(f,fontdata,"glyf",specification.glyphs) |
| 12895 |
if tableoffset then |
| 12896 |
local locations=fontdata.locations |
| 12897 |
if locations then |
| 12898 |
local glyphs=fontdata.glyphs |
| 12899 |
local nofglyphs=fontdata.nofglyphs |
| 12900 |
local filesize=fontdata.filesize |
| 12901 |
local nothing={ 0,0,0,0 } |
| 12902 |
local shapes={} |
| 12903 |
local loadshapes=specification.shapes or specification.instance or specification.streams |
| 12904 |
for index=0,nofglyphs-1 do |
| 12905 |
local location=locations[index] |
| 12906 |
local length=locations[index+1]-location |
| 12907 |
if location>=filesize then |
| 12908 |
report("discarding %s glyphs due to glyph location bug",nofglyphs-index+1) |
| 12909 |
fontdata.nofglyphs=index-1 |
| 12910 |
fontdata.badfont=true |
| 12911 |
break |
| 12912 |
elseif length>0 then |
| 12913 |
setposition(f,location) |
| 12914 |
local nofcontours=readshort(f) |
| 12915 |
glyphs[index].boundingbox={ |
| 12916 |
readshort(f), |
| 12917 |
readshort(f), |
| 12918 |
readshort(f), |
| 12919 |
readshort(f), |
| 12920 |
} |
| 12921 |
if not loadshapes then |
| 12922 |
elseif nofcontours==0 then |
| 12923 |
shapes[index]=readnothing(f) |
| 12924 |
elseif nofcontours>0 then |
| 12925 |
shapes[index]=readglyph(f,nofcontours) |
| 12926 |
else |
| 12927 |
shapes[index]=readcomposite(f,nofcontours) |
| 12928 |
end |
| 12929 |
else |
| 12930 |
if loadshapes then |
| 12931 |
shapes[index]=readnothing(f) |
| 12932 |
end |
| 12933 |
glyphs[index].boundingbox=nothing |
| 12934 |
end |
| 12935 |
end |
| 12936 |
if loadshapes then |
| 12937 |
if readers.gvar then |
| 12938 |
readers.gvar(f,fontdata,specification,glyphs,shapes) |
| 12939 |
end |
| 12940 |
mergecomposites(glyphs,shapes) |
| 12941 |
if specification.instance then |
| 12942 |
if specification.streams then |
| 12943 |
repackpoints(glyphs,shapes) |
| 12944 |
else |
| 12945 |
contours2outlines_shaped(glyphs,shapes,specification.shapes) |
| 12946 |
end |
| 12947 |
elseif specification.shapes then |
| 12948 |
if specification.streams then |
| 12949 |
repackpoints(glyphs,shapes) |
| 12950 |
else |
| 12951 |
contours2outlines_normal(glyphs,shapes) |
| 12952 |
end |
| 12953 |
elseif specification.streams then |
| 12954 |
repackpoints(glyphs,shapes) |
| 12955 |
end |
| 12956 |
end |
| 12957 |
end |
| 12958 |
end |
| 12959 |
end |
| 12960 |
local function readtuplerecord(f,nofaxis) |
| 12961 |
local record={} |
| 12962 |
for i=1,nofaxis do |
| 12963 |
record[i]=read2dot14(f) |
| 12964 |
end |
| 12965 |
return record |
| 12966 |
end |
| 12967 |
local function readpoints(f) |
| 12968 |
local count=readbyte(f) |
| 12969 |
if count==0 then |
| 12970 |
return nil,0 |
| 12971 |
else |
| 12972 |
if count<128 then |
| 12973 |
elseif band(count,0x80)~=0 then |
| 12974 |
count=band(count,0x7F)*256+readbyte(f) |
| 12975 |
else |
| 12976 |
end |
| 12977 |
local points={} |
| 12978 |
local p=0 |
| 12979 |
local n=1 |
| 12980 |
while p<count do |
| 12981 |
local control=readbyte(f) |
| 12982 |
local runreader=band(control,0x80)~=0 and readushort or readbyte |
| 12983 |
local runlength=band(control,0x7F) |
| 12984 |
for i=1,runlength+1 do |
| 12985 |
n=n+runreader(f) |
| 12986 |
p=p+1 |
| 12987 |
points[p]=n |
| 12988 |
end |
| 12989 |
end |
| 12990 |
return points,p |
| 12991 |
end |
| 12992 |
end |
| 12993 |
local function readdeltas(f,nofpoints) |
| 12994 |
local deltas={} |
| 12995 |
local p=0 |
| 12996 |
while nofpoints>0 do |
| 12997 |
local control=readbyte(f) |
| 12998 |
if control then |
| 12999 |
local allzero=band(control,0x80)~=0 |
| 13000 |
local runlength=band(control,0x3F)+1 |
| 13001 |
if allzero then |
| 13002 |
for i=1,runlength do |
| 13003 |
p=p+1 |
| 13004 |
deltas[p]=0 |
| 13005 |
end |
| 13006 |
else |
| 13007 |
local runreader=band(control,0x40)~=0 and readshort or readinteger |
| 13008 |
for i=1,runlength do |
| 13009 |
p=p+1 |
| 13010 |
deltas[p]=runreader(f) |
| 13011 |
end |
| 13012 |
end |
| 13013 |
nofpoints=nofpoints-runlength |
| 13014 |
else |
| 13015 |
break |
| 13016 |
end |
| 13017 |
end |
| 13018 |
if p>0 then |
| 13019 |
return deltas |
| 13020 |
else |
| 13021 |
end |
| 13022 |
end |
| 13023 |
function readers.gvar(f,fontdata,specification,glyphdata,shapedata) |
| 13024 |
local instance=specification.instance |
| 13025 |
if not instance then |
| 13026 |
return |
| 13027 |
end |
| 13028 |
local factors=specification.factors |
| 13029 |
if not factors then |
| 13030 |
return |
| 13031 |
end |
| 13032 |
local tableoffset=gotodatatable(f,fontdata,"gvar",specification.variable or specification.shapes) |
| 13033 |
if tableoffset then |
| 13034 |
local version=readulong(f) |
| 13035 |
local nofaxis=readushort(f) |
| 13036 |
local noftuples=readushort(f) |
| 13037 |
local tupleoffset=tableoffset+readulong(f) |
| 13038 |
local nofglyphs=readushort(f) |
| 13039 |
local flags=readushort(f) |
| 13040 |
local dataoffset=tableoffset+readulong(f) |
| 13041 |
local data={} |
| 13042 |
local tuples={} |
| 13043 |
local glyphdata=fontdata.glyphs |
| 13044 |
local dowidth=not fontdata.variabledata.hvarwidths |
| 13045 |
if band(flags,0x0001)~=0 then |
| 13046 |
for i=1,nofglyphs+1 do |
| 13047 |
data[i]=dataoffset+readulong(f) |
| 13048 |
end |
| 13049 |
else |
| 13050 |
for i=1,nofglyphs+1 do |
| 13051 |
data[i]=dataoffset+2*readushort(f) |
| 13052 |
end |
| 13053 |
end |
| 13054 |
if noftuples>0 then |
| 13055 |
setposition(f,tupleoffset) |
| 13056 |
for i=1,noftuples do |
| 13057 |
tuples[i]=readtuplerecord(f,nofaxis) |
| 13058 |
end |
| 13059 |
end |
| 13060 |
local nextoffset=false |
| 13061 |
local startoffset=data[1] |
| 13062 |
for i=1,nofglyphs do |
| 13063 |
nextoffset=data[i+1] |
| 13064 |
local glyph=glyphdata[i-1] |
| 13065 |
local name=trace_deltas and glyph.name |
| 13066 |
if startoffset==nextoffset then |
| 13067 |
if name then |
| 13068 |
report("no deltas for glyph %a",name) |
| 13069 |
end |
| 13070 |
else |
| 13071 |
local shape=shapedata[i-1] |
| 13072 |
if not shape then |
| 13073 |
if name then |
| 13074 |
report("no shape for glyph %a",name) |
| 13075 |
end |
| 13076 |
else |
| 13077 |
lastoffset=startoffset |
| 13078 |
setposition(f,startoffset) |
| 13079 |
local flags=readushort(f) |
| 13080 |
local count=band(flags,0x0FFF) |
| 13081 |
local offset=startoffset+readushort(f) |
| 13082 |
local deltas={} |
| 13083 |
local allpoints=(shape.nofpoints or 0) |
| 13084 |
local shared=false |
| 13085 |
local nofshared=0 |
| 13086 |
if band(flags,0x8000)~=0 then |
| 13087 |
local current=getposition(f) |
| 13088 |
setposition(f,offset) |
| 13089 |
shared,nofshared=readpoints(f) |
| 13090 |
offset=getposition(f) |
| 13091 |
setposition(f,current) |
| 13092 |
end |
| 13093 |
for j=1,count do |
| 13094 |
local size=readushort(f) |
| 13095 |
local flags=readushort(f) |
| 13096 |
local index=band(flags,0x0FFF) |
| 13097 |
local haspeak=band(flags,0x8000)~=0 |
| 13098 |
local intermediate=band(flags,0x4000)~=0 |
| 13099 |
local private=band(flags,0x2000)~=0 |
| 13100 |
local peak=nil |
| 13101 |
local start=nil |
| 13102 |
local stop=nil |
| 13103 |
local xvalues=nil |
| 13104 |
local yvalues=nil |
| 13105 |
local points=shared |
| 13106 |
local nofpoints=nofshared |
| 13107 |
if haspeak then |
| 13108 |
peak=readtuplerecord(f,nofaxis) |
| 13109 |
else |
| 13110 |
if index+1>#tuples then |
| 13111 |
report("error, bad tuple index",index) |
| 13112 |
end |
| 13113 |
peak=tuples[index+1] |
| 13114 |
end |
| 13115 |
if intermediate then |
| 13116 |
start=readtuplerecord(f,nofaxis) |
| 13117 |
stop=readtuplerecord(f,nofaxis) |
| 13118 |
end |
| 13119 |
if size>0 then |
| 13120 |
local current=getposition(f) |
| 13121 |
setposition(f,offset) |
| 13122 |
if private then |
| 13123 |
points,nofpoints=readpoints(f) |
| 13124 |
end |
| 13125 |
if nofpoints==0 then |
| 13126 |
nofpoints=allpoints+4 |
| 13127 |
end |
| 13128 |
if nofpoints>0 then |
| 13129 |
xvalues=readdeltas(f,nofpoints) |
| 13130 |
yvalues=readdeltas(f,nofpoints) |
| 13131 |
end |
| 13132 |
offset=offset+size |
| 13133 |
setposition(f,current) |
| 13134 |
end |
| 13135 |
if not xvalues and not yvalues then |
| 13136 |
points=nil |
| 13137 |
end |
| 13138 |
local s=1 |
| 13139 |
for i=1,nofaxis do |
| 13140 |
local f=factors[i] |
| 13141 |
local peak=peak and peak [i] or 0 |
| 13142 |
local start=start and start[i] or (peak<0 and peak or 0) |
| 13143 |
local stop=stop and stop [i] or (peak>0 and peak or 0) |
| 13144 |
if start>peak or peak>stop then |
| 13145 |
elseif start<0 and stop>0 and peak~=0 then |
| 13146 |
elseif peak==0 then |
| 13147 |
elseif f<start or f>stop then |
| 13148 |
s=0 |
| 13149 |
break |
| 13150 |
elseif f<peak then |
| 13151 |
s=s*(f-start)/(peak-start) |
| 13152 |
elseif f>peak then |
| 13153 |
s=s*(stop-f)/(stop-peak) |
| 13154 |
else |
| 13155 |
end |
| 13156 |
end |
| 13157 |
if s==0 then |
| 13158 |
if name then |
| 13159 |
report("no deltas applied for glyph %a",name) |
| 13160 |
end |
| 13161 |
else |
| 13162 |
deltas[#deltas+1]={ |
| 13163 |
factor=s, |
| 13164 |
points=points, |
| 13165 |
xvalues=xvalues, |
| 13166 |
yvalues=yvalues, |
| 13167 |
} |
| 13168 |
end |
| 13169 |
end |
| 13170 |
if shape.type=="glyph" then |
| 13171 |
applyaxis(glyph,shape,deltas,dowidth) |
| 13172 |
else |
| 13173 |
shape.deltas=deltas |
| 13174 |
end |
| 13175 |
end |
| 13176 |
end |
| 13177 |
startoffset=nextoffset |
| 13178 |
end |
| 13179 |
end |
| 13180 |
end |
| 13181 |
|
| 13182 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ttf”] --- |
| 13183 |
|
| 13184 |
|
| 13185 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-dsp” f2897da5fd67280b4700c32696d21fb1] --- |
| 13186 |
|
| 13187 |
if not modules then modules={} end modules ['font-dsp']={ |
| 13188 |
version=1.001, |
| 13189 |
optimize=true, |
| 13190 |
comment="companion to font-ini.mkiv", |
| 13191 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 13192 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 13193 |
license="see context related readme files" |
| 13194 |
} |
| 13195 |
local next,type,tonumber=next,type,tonumber |
| 13196 |
local band=bit32.band |
| 13197 |
local extract=bit32.extract |
| 13198 |
local bor=bit32.bor |
| 13199 |
local lshift=bit32.lshift |
| 13200 |
local rshift=bit32.rshift |
| 13201 |
local gsub=string.gsub |
| 13202 |
local lower=string.lower |
| 13203 |
local sub=string.sub |
| 13204 |
local strip=string.strip |
| 13205 |
local tohash=table.tohash |
| 13206 |
local concat=table.concat |
| 13207 |
local copy=table.copy |
| 13208 |
local reversed=table.reversed |
| 13209 |
local sort=table.sort |
| 13210 |
local insert=table.insert |
| 13211 |
local round=math.round |
| 13212 |
local settings_to_hash=utilities.parsers.settings_to_hash_colon_too |
| 13213 |
local setmetatableindex=table.setmetatableindex |
| 13214 |
local formatters=string.formatters |
| 13215 |
local sortedkeys=table.sortedkeys |
| 13216 |
local sortedhash=table.sortedhash |
| 13217 |
local sequenced=table.sequenced |
| 13218 |
local report=logs.reporter("otf reader") |
| 13219 |
local readers=fonts.handlers.otf.readers |
| 13220 |
local streamreader=readers.streamreader |
| 13221 |
local setposition=streamreader.setposition |
| 13222 |
local getposition=streamreader.getposition |
| 13223 |
local readuinteger=streamreader.readcardinal1 |
| 13224 |
local readushort=streamreader.readcardinal2 |
| 13225 |
local readulong=streamreader.readcardinal4 |
| 13226 |
local readinteger=streamreader.readinteger1 |
| 13227 |
local readshort=streamreader.readinteger2 |
| 13228 |
local readstring=streamreader.readstring |
| 13229 |
local readtag=streamreader.readtag |
| 13230 |
local readbytes=streamreader.readbytes |
| 13231 |
local readfixed=streamreader.readfixed4 |
| 13232 |
local read2dot14=streamreader.read2dot14 |
| 13233 |
local skipshort=streamreader.skipshort |
| 13234 |
local skipbytes=streamreader.skip |
| 13235 |
local readbytetable=streamreader.readbytetable |
| 13236 |
local readbyte=streamreader.readbyte |
| 13237 |
local readcardinaltable=streamreader.readcardinaltable |
| 13238 |
local readintegertable=streamreader.readintegertable |
| 13239 |
local readfword=readshort |
| 13240 |
local short=2 |
| 13241 |
local ushort=2 |
| 13242 |
local ulong=4 |
| 13243 |
directives.register("fonts.streamreader",function() |
| 13244 |
streamreader=utilities.streams |
| 13245 |
setposition=streamreader.setposition |
| 13246 |
getposition=streamreader.getposition |
| 13247 |
readuinteger=streamreader.readcardinal1 |
| 13248 |
readushort=streamreader.readcardinal2 |
| 13249 |
readulong=streamreader.readcardinal4 |
| 13250 |
readinteger=streamreader.readinteger1 |
| 13251 |
readshort=streamreader.readinteger2 |
| 13252 |
readstring=streamreader.readstring |
| 13253 |
readtag=streamreader.readtag |
| 13254 |
readbytes=streamreader.readbytes |
| 13255 |
readfixed=streamreader.readfixed4 |
| 13256 |
read2dot14=streamreader.read2dot14 |
| 13257 |
skipshort=streamreader.skipshort |
| 13258 |
skipbytes=streamreader.skip |
| 13259 |
readbytetable=streamreader.readbytetable |
| 13260 |
readbyte=streamreader.readbyte |
| 13261 |
readcardinaltable=streamreader.readcardinaltable |
| 13262 |
readintegertable=streamreader.readintegertable |
| 13263 |
readfword=readshort |
| 13264 |
end) |
| 13265 |
local gsubhandlers={} |
| 13266 |
local gposhandlers={} |
| 13267 |
readers.gsubhandlers=gsubhandlers |
| 13268 |
readers.gposhandlers=gposhandlers |
| 13269 |
local helpers=readers.helpers |
| 13270 |
local gotodatatable=helpers.gotodatatable |
| 13271 |
local setvariabledata=helpers.setvariabledata |
| 13272 |
local lookupidoffset=-1 |
| 13273 |
local classes={ |
| 13274 |
"base", |
| 13275 |
"ligature", |
| 13276 |
"mark", |
| 13277 |
"component", |
| 13278 |
} |
| 13279 |
local gsubtypes={ |
| 13280 |
"single", |
| 13281 |
"multiple", |
| 13282 |
"alternate", |
| 13283 |
"ligature", |
| 13284 |
"context", |
| 13285 |
"chainedcontext", |
| 13286 |
"extension", |
| 13287 |
"reversechainedcontextsingle", |
| 13288 |
} |
| 13289 |
local gpostypes={ |
| 13290 |
"single", |
| 13291 |
"pair", |
| 13292 |
"cursive", |
| 13293 |
"marktobase", |
| 13294 |
"marktoligature", |
| 13295 |
"marktomark", |
| 13296 |
"context", |
| 13297 |
"chainedcontext", |
| 13298 |
"extension", |
| 13299 |
} |
| 13300 |
local chaindirections={ |
| 13301 |
context=0, |
| 13302 |
chainedcontext=1, |
| 13303 |
reversechainedcontextsingle=-1, |
| 13304 |
} |
| 13305 |
local function setmetrics(data,where,tag,d) |
| 13306 |
local w=data[where] |
| 13307 |
if w then |
| 13308 |
local v=w[tag] |
| 13309 |
if v then |
| 13310 |
w[tag]=v+d |
| 13311 |
end |
| 13312 |
end |
| 13313 |
end |
| 13314 |
local variabletags={ |
| 13315 |
hasc=function(data,d) setmetrics(data,"windowsmetrics","typoascender",d) end, |
| 13316 |
hdsc=function(data,d) setmetrics(data,"windowsmetrics","typodescender",d) end, |
| 13317 |
hlgp=function(data,d) setmetrics(data,"windowsmetrics","typolinegap",d) end, |
| 13318 |
hcla=function(data,d) setmetrics(data,"windowsmetrics","winascent",d) end, |
| 13319 |
hcld=function(data,d) setmetrics(data,"windowsmetrics","windescent",d) end, |
| 13320 |
vasc=function(data,d) setmetrics(data,"vhea not done","ascent",d) end, |
| 13321 |
vdsc=function(data,d) setmetrics(data,"vhea not done","descent",d) end, |
| 13322 |
vlgp=function(data,d) setmetrics(data,"vhea not done","linegap",d) end, |
| 13323 |
xhgt=function(data,d) setmetrics(data,"windowsmetrics","xheight",d) end, |
| 13324 |
cpht=function(data,d) setmetrics(data,"windowsmetrics","capheight",d) end, |
| 13325 |
sbxs=function(data,d) setmetrics(data,"windowsmetrics","subscriptxsize",d) end, |
| 13326 |
sbys=function(data,d) setmetrics(data,"windowsmetrics","subscriptysize",d) end, |
| 13327 |
sbxo=function(data,d) setmetrics(data,"windowsmetrics","subscriptxoffset",d) end, |
| 13328 |
sbyo=function(data,d) setmetrics(data,"windowsmetrics","subscriptyoffset",d) end, |
| 13329 |
spxs=function(data,d) setmetrics(data,"windowsmetrics","superscriptxsize",d) end, |
| 13330 |
spys=function(data,d) setmetrics(data,"windowsmetrics","superscriptysize",d) end, |
| 13331 |
spxo=function(data,d) setmetrics(data,"windowsmetrics","superscriptxoffset",d) end, |
| 13332 |
spyo=function(data,d) setmetrics(data,"windowsmetrics","superscriptyoffset",d) end, |
| 13333 |
strs=function(data,d) setmetrics(data,"windowsmetrics","strikeoutsize",d) end, |
| 13334 |
stro=function(data,d) setmetrics(data,"windowsmetrics","strikeoutpos",d) end, |
| 13335 |
unds=function(data,d) setmetrics(data,"postscript","underlineposition",d) end, |
| 13336 |
undo=function(data,d) setmetrics(data,"postscript","underlinethickness",d) end, |
| 13337 |
} |
| 13338 |
local read_cardinal={ |
| 13339 |
streamreader.readcardinal1, |
| 13340 |
streamreader.readcardinal2, |
| 13341 |
streamreader.readcardinal3, |
| 13342 |
streamreader.readcardinal4, |
| 13343 |
} |
| 13344 |
local read_integer={ |
| 13345 |
streamreader.readinteger1, |
| 13346 |
streamreader.readinteger2, |
| 13347 |
streamreader.readinteger3, |
| 13348 |
streamreader.readinteger4, |
| 13349 |
} |
| 13350 |
directives.register("fonts.streamreader",function() |
| 13351 |
read_cardinal={ |
| 13352 |
streamreader.readcardinal1, |
| 13353 |
streamreader.readcardinal2, |
| 13354 |
streamreader.readcardinal3, |
| 13355 |
streamreader.readcardinal4, |
| 13356 |
} |
| 13357 |
read_integer={ |
| 13358 |
streamreader.readinteger1, |
| 13359 |
streamreader.readinteger2, |
| 13360 |
streamreader.readinteger3, |
| 13361 |
streamreader.readinteger4, |
| 13362 |
} |
| 13363 |
end) |
| 13364 |
local lookupnames={ |
| 13365 |
gsub={ |
| 13366 |
single="gsub_single", |
| 13367 |
multiple="gsub_multiple", |
| 13368 |
alternate="gsub_alternate", |
| 13369 |
ligature="gsub_ligature", |
| 13370 |
context="gsub_context", |
| 13371 |
chainedcontext="gsub_contextchain", |
| 13372 |
reversechainedcontextsingle="gsub_reversecontextchain", |
| 13373 |
}, |
| 13374 |
gpos={ |
| 13375 |
single="gpos_single", |
| 13376 |
pair="gpos_pair", |
| 13377 |
cursive="gpos_cursive", |
| 13378 |
marktobase="gpos_mark2base", |
| 13379 |
marktoligature="gpos_mark2ligature", |
| 13380 |
marktomark="gpos_mark2mark", |
| 13381 |
context="gpos_context", |
| 13382 |
chainedcontext="gpos_contextchain", |
| 13383 |
} |
| 13384 |
} |
| 13385 |
local lookupflags=setmetatableindex(function(t,k) |
| 13386 |
local v={ |
| 13387 |
band(k,0x0008)~=0 and true or false, |
| 13388 |
band(k,0x0004)~=0 and true or false, |
| 13389 |
band(k,0x0002)~=0 and true or false, |
| 13390 |
band(k,0x0001)~=0 and true or false, |
| 13391 |
} |
| 13392 |
t[k]=v |
| 13393 |
return v |
| 13394 |
end) |
| 13395 |
local function axistofactors(str) |
| 13396 |
local t=settings_to_hash(str) |
| 13397 |
for k,v in next,t do |
| 13398 |
t[k]=tonumber(v) or v |
| 13399 |
end |
| 13400 |
return t |
| 13401 |
end |
| 13402 |
local hash=table.setmetatableindex(function(t,k) |
| 13403 |
local v=sequenced(axistofactors(k),",") |
| 13404 |
t[k]=v |
| 13405 |
return v |
| 13406 |
end) |
| 13407 |
helpers.normalizedaxishash=hash |
| 13408 |
local cleanname=fonts.names and fonts.names.cleanname or function(name) |
| 13409 |
return name and (gsub(lower(name),"[^%a%d]","")) or nil |
| 13410 |
end |
| 13411 |
helpers.cleanname=cleanname |
| 13412 |
function helpers.normalizedaxis(str) |
| 13413 |
return hash[str] or str |
| 13414 |
end |
| 13415 |
local function getaxisscale(segments,minimum,default,maximum,user) |
| 13416 |
if not minimum or not default or not maximum then |
| 13417 |
return false |
| 13418 |
end |
| 13419 |
if user<minimum then |
| 13420 |
user=minimum |
| 13421 |
elseif user>maximum then |
| 13422 |
user=maximum |
| 13423 |
end |
| 13424 |
if user<default then |
| 13425 |
default=- (default-user)/(default-minimum) |
| 13426 |
elseif user>default then |
| 13427 |
default=(user-default)/(maximum-default) |
| 13428 |
else |
| 13429 |
default=0 |
| 13430 |
end |
| 13431 |
if not segments then |
| 13432 |
return default |
| 13433 |
end |
| 13434 |
local e |
| 13435 |
for i=1,#segments do |
| 13436 |
local s=segments[i] |
| 13437 |
if type(s)~="number" then |
| 13438 |
return default |
| 13439 |
elseif s[1]>=default then |
| 13440 |
if s[2]==default then |
| 13441 |
return default |
| 13442 |
else |
| 13443 |
e=i |
| 13444 |
break |
| 13445 |
end |
| 13446 |
end |
| 13447 |
end |
| 13448 |
if e then |
| 13449 |
local b=segments[e-1] |
| 13450 |
local e=segments[e] |
| 13451 |
return b[2]+(e[2]-b[2])*(default-b[1])/(e[1]-b[1]) |
| 13452 |
else |
| 13453 |
return false |
| 13454 |
end |
| 13455 |
end |
| 13456 |
local function getfactors(data,instancespec) |
| 13457 |
if instancespec==true then |
| 13458 |
elseif type(instancespec)~="string" or instancespec=="" then |
| 13459 |
return |
| 13460 |
end |
| 13461 |
local variabledata=data.variabledata |
| 13462 |
if not variabledata then |
| 13463 |
return |
| 13464 |
end |
| 13465 |
local instances=variabledata.instances |
| 13466 |
local axis=variabledata.axis |
| 13467 |
local segments=variabledata.segments |
| 13468 |
if instances and axis then |
| 13469 |
local values |
| 13470 |
if instancespec==true then |
| 13471 |
values={} |
| 13472 |
for i=1,#axis do |
| 13473 |
values[i]={ |
| 13474 |
value=axis[i].default, |
| 13475 |
} |
| 13476 |
end |
| 13477 |
else |
| 13478 |
for i=1,#instances do |
| 13479 |
local instance=instances[i] |
| 13480 |
if cleanname(instance.subfamily)==instancespec then |
| 13481 |
values=instance.values |
| 13482 |
break |
| 13483 |
end |
| 13484 |
end |
| 13485 |
end |
| 13486 |
if values then |
| 13487 |
local factors={} |
| 13488 |
for i=1,#axis do |
| 13489 |
local a=axis[i] |
| 13490 |
factors[i]=getaxisscale(segments,a.minimum,a.default,a.maximum,values[i].value) |
| 13491 |
end |
| 13492 |
return factors |
| 13493 |
end |
| 13494 |
local values=axistofactors(hash[instancespec] or instancespec) |
| 13495 |
if values then |
| 13496 |
local factors={} |
| 13497 |
for i=1,#axis do |
| 13498 |
local a=axis[i] |
| 13499 |
local d=a.default |
| 13500 |
factors[i]=getaxisscale(segments,a.minimum,d,a.maximum,values[a.name or a.tag] or d) |
| 13501 |
end |
| 13502 |
return factors |
| 13503 |
end |
| 13504 |
end |
| 13505 |
end |
| 13506 |
local function getscales(regions,factors) |
| 13507 |
local scales={} |
| 13508 |
for i=1,#regions do |
| 13509 |
local region=regions[i] |
| 13510 |
local s=1 |
| 13511 |
for j=1,#region do |
| 13512 |
local axis=region[j] |
| 13513 |
local f=factors[j] |
| 13514 |
local start=axis.start |
| 13515 |
local peak=axis.peak |
| 13516 |
local stop=axis.stop |
| 13517 |
if start>peak or peak>stop then |
| 13518 |
elseif start<0 and stop>0 and peak~=0 then |
| 13519 |
elseif peak==0 then |
| 13520 |
elseif f<start or f>stop then |
| 13521 |
s=0 |
| 13522 |
break |
| 13523 |
elseif f<peak then |
| 13524 |
s=s*(f-start)/(peak-start) |
| 13525 |
elseif f>peak then |
| 13526 |
s=s*(stop-f)/(stop-peak) |
| 13527 |
else |
| 13528 |
end |
| 13529 |
end |
| 13530 |
scales[i]=s |
| 13531 |
end |
| 13532 |
return scales |
| 13533 |
end |
| 13534 |
helpers.getaxisscale=getaxisscale |
| 13535 |
helpers.getfactors=getfactors |
| 13536 |
helpers.getscales=getscales |
| 13537 |
helpers.axistofactors=axistofactors |
| 13538 |
local function readvariationdata(f,storeoffset,factors) |
| 13539 |
local position=getposition(f) |
| 13540 |
setposition(f,storeoffset) |
| 13541 |
local format=readushort(f) |
| 13542 |
local regionoffset=storeoffset+readulong(f) |
| 13543 |
local nofdeltadata=readushort(f) |
| 13544 |
local deltadata=readcardinaltable(f,nofdeltadata,ulong) |
| 13545 |
setposition(f,regionoffset) |
| 13546 |
local nofaxis=readushort(f) |
| 13547 |
local nofregions=readushort(f) |
| 13548 |
local regions={} |
| 13549 |
for i=1,nofregions do |
| 13550 |
local t={} |
| 13551 |
for i=1,nofaxis do |
| 13552 |
t[i]={ |
| 13553 |
start=read2dot14(f), |
| 13554 |
peak=read2dot14(f), |
| 13555 |
stop=read2dot14(f), |
| 13556 |
} |
| 13557 |
end |
| 13558 |
regions[i]=t |
| 13559 |
end |
| 13560 |
for i=1,nofdeltadata do |
| 13561 |
setposition(f,storeoffset+deltadata[i]) |
| 13562 |
local nofdeltasets=readushort(f) |
| 13563 |
local nofshorts=readushort(f) |
| 13564 |
local nofregions=readushort(f) |
| 13565 |
local usedregions={} |
| 13566 |
local deltas={} |
| 13567 |
for i=1,nofregions do |
| 13568 |
usedregions[i]=regions[readushort(f)+1] |
| 13569 |
end |
| 13570 |
for i=1,nofdeltasets do |
| 13571 |
local t=readintegertable(f,nofshorts,short) |
| 13572 |
for i=nofshorts+1,nofregions do |
| 13573 |
t[i]=readinteger(f) |
| 13574 |
end |
| 13575 |
deltas[i]=t |
| 13576 |
end |
| 13577 |
deltadata[i]={ |
| 13578 |
regions=usedregions, |
| 13579 |
deltas=deltas, |
| 13580 |
scales=factors and getscales(usedregions,factors) or nil, |
| 13581 |
} |
| 13582 |
end |
| 13583 |
setposition(f,position) |
| 13584 |
return regions,deltadata |
| 13585 |
end |
| 13586 |
helpers.readvariationdata=readvariationdata |
| 13587 |
local function readcoverage(f,offset,simple) |
| 13588 |
setposition(f,offset) |
| 13589 |
local coverageformat=readushort(f) |
| 13590 |
if coverageformat==1 then |
| 13591 |
local nofcoverage=readushort(f) |
| 13592 |
if simple then |
| 13593 |
if nofcoverage==1 then |
| 13594 |
return { readushort(f) } |
| 13595 |
elseif nofcoverage==2 then |
| 13596 |
return { readushort(f),readushort(f) } |
| 13597 |
else |
| 13598 |
return readcardinaltable(f,nofcoverage,ushort) |
| 13599 |
end |
| 13600 |
elseif nofcoverage==1 then |
| 13601 |
return { [readushort(f)]=0 } |
| 13602 |
elseif nofcoverage==2 then |
| 13603 |
return { [readushort(f)]=0,[readushort(f)]=1 } |
| 13604 |
else |
| 13605 |
local coverage={} |
| 13606 |
for i=0,nofcoverage-1 do |
| 13607 |
coverage[readushort(f)]=i |
| 13608 |
end |
| 13609 |
return coverage |
| 13610 |
end |
| 13611 |
elseif coverageformat==2 then |
| 13612 |
local nofranges=readushort(f) |
| 13613 |
local coverage={} |
| 13614 |
local n=simple and 1 or 0 |
| 13615 |
for i=1,nofranges do |
| 13616 |
local firstindex=readushort(f) |
| 13617 |
local lastindex=readushort(f) |
| 13618 |
local coverindex=readushort(f) |
| 13619 |
if simple then |
| 13620 |
for i=firstindex,lastindex do |
| 13621 |
coverage[n]=i |
| 13622 |
n=n+1 |
| 13623 |
end |
| 13624 |
else |
| 13625 |
for i=firstindex,lastindex do |
| 13626 |
coverage[i]=n |
| 13627 |
n=n+1 |
| 13628 |
end |
| 13629 |
end |
| 13630 |
end |
| 13631 |
return coverage |
| 13632 |
else |
| 13633 |
report("unknown coverage format %a ",coverageformat) |
| 13634 |
return {} |
| 13635 |
end |
| 13636 |
end |
| 13637 |
local function readclassdef(f,offset,preset) |
| 13638 |
setposition(f,offset) |
| 13639 |
local classdefformat=readushort(f) |
| 13640 |
local classdef={} |
| 13641 |
if type(preset)=="number" then |
| 13642 |
for k=0,preset-1 do |
| 13643 |
classdef[k]=1 |
| 13644 |
end |
| 13645 |
end |
| 13646 |
if classdefformat==1 then |
| 13647 |
local index=readushort(f) |
| 13648 |
local nofclassdef=readushort(f) |
| 13649 |
for i=1,nofclassdef do |
| 13650 |
classdef[index]=readushort(f)+1 |
| 13651 |
index=index+1 |
| 13652 |
end |
| 13653 |
elseif classdefformat==2 then |
| 13654 |
local nofranges=readushort(f) |
| 13655 |
local n=0 |
| 13656 |
for i=1,nofranges do |
| 13657 |
local firstindex=readushort(f) |
| 13658 |
local lastindex=readushort(f) |
| 13659 |
local class=readushort(f)+1 |
| 13660 |
for i=firstindex,lastindex do |
| 13661 |
classdef[i]=class |
| 13662 |
end |
| 13663 |
end |
| 13664 |
else |
| 13665 |
report("unknown classdef format %a ",classdefformat) |
| 13666 |
end |
| 13667 |
if type(preset)=="table" then |
| 13668 |
for k in next,preset do |
| 13669 |
if not classdef[k] then |
| 13670 |
classdef[k]=1 |
| 13671 |
end |
| 13672 |
end |
| 13673 |
end |
| 13674 |
return classdef |
| 13675 |
end |
| 13676 |
local function classtocoverage(defs) |
| 13677 |
if defs then |
| 13678 |
local list={} |
| 13679 |
for index,class in next,defs do |
| 13680 |
local c=list[class] |
| 13681 |
if c then |
| 13682 |
c[#c+1]=index |
| 13683 |
else |
| 13684 |
list[class]={ index } |
| 13685 |
end |
| 13686 |
end |
| 13687 |
return list |
| 13688 |
end |
| 13689 |
end |
| 13690 |
local skips={ [0]=0, |
| 13691 |
1, |
| 13692 |
1, |
| 13693 |
2, |
| 13694 |
1, |
| 13695 |
2, |
| 13696 |
2, |
| 13697 |
3, |
| 13698 |
2, |
| 13699 |
2, |
| 13700 |
3, |
| 13701 |
2, |
| 13702 |
3, |
| 13703 |
3, |
| 13704 |
4, |
| 13705 |
} |
| 13706 |
local function readvariation(f,offset) |
| 13707 |
local p=getposition(f) |
| 13708 |
setposition(f,offset) |
| 13709 |
local outer=readushort(f) |
| 13710 |
local inner=readushort(f) |
| 13711 |
local format=readushort(f) |
| 13712 |
setposition(f,p) |
| 13713 |
if format==0x8000 then |
| 13714 |
return outer,inner |
| 13715 |
end |
| 13716 |
end |
| 13717 |
local function readposition(f,format,mainoffset,getdelta) |
| 13718 |
if format==0 then |
| 13719 |
return false |
| 13720 |
end |
| 13721 |
if format==0x04 then |
| 13722 |
local h=readshort(f) |
| 13723 |
if h==0 then |
| 13724 |
return true |
| 13725 |
else |
| 13726 |
return { 0,0,h,0 } |
| 13727 |
end |
| 13728 |
end |
| 13729 |
if format==0x05 then |
| 13730 |
local x=readshort(f) |
| 13731 |
local h=readshort(f) |
| 13732 |
if x==0 and h==0 then |
| 13733 |
return true |
| 13734 |
else |
| 13735 |
return { x,0,h,0 } |
| 13736 |
end |
| 13737 |
end |
| 13738 |
if format==0x44 then |
| 13739 |
local h=readshort(f) |
| 13740 |
if getdelta then |
| 13741 |
local d=readshort(f) |
| 13742 |
if d>0 then |
| 13743 |
local outer,inner=readvariation(f,mainoffset+d) |
| 13744 |
if outer then |
| 13745 |
h=h+getdelta(outer,inner) |
| 13746 |
end |
| 13747 |
end |
| 13748 |
else |
| 13749 |
skipshort(f,1) |
| 13750 |
end |
| 13751 |
if h==0 then |
| 13752 |
return true |
| 13753 |
else |
| 13754 |
return { 0,0,h,0 } |
| 13755 |
end |
| 13756 |
end |
| 13757 |
local x=band(format,0x1)~=0 and readshort(f) or 0 |
| 13758 |
local y=band(format,0x2)~=0 and readshort(f) or 0 |
| 13759 |
local h=band(format,0x4)~=0 and readshort(f) or 0 |
| 13760 |
local v=band(format,0x8)~=0 and readshort(f) or 0 |
| 13761 |
if format>=0x10 then |
| 13762 |
local X=band(format,0x10)~=0 and skipshort(f) or 0 |
| 13763 |
local Y=band(format,0x20)~=0 and skipshort(f) or 0 |
| 13764 |
local H=band(format,0x40)~=0 and skipshort(f) or 0 |
| 13765 |
local V=band(format,0x80)~=0 and skipshort(f) or 0 |
| 13766 |
local s=skips[extract(format,4,4)] |
| 13767 |
if s>0 then |
| 13768 |
skipshort(f,s) |
| 13769 |
end |
| 13770 |
if getdelta then |
| 13771 |
if X>0 then |
| 13772 |
local outer,inner=readvariation(f,mainoffset+X) |
| 13773 |
if outer then |
| 13774 |
x=x+getdelta(outer,inner) |
| 13775 |
end |
| 13776 |
end |
| 13777 |
if Y>0 then |
| 13778 |
local outer,inner=readvariation(f,mainoffset+Y) |
| 13779 |
if outer then |
| 13780 |
y=y+getdelta(outer,inner) |
| 13781 |
end |
| 13782 |
end |
| 13783 |
if H>0 then |
| 13784 |
local outer,inner=readvariation(f,mainoffset+H) |
| 13785 |
if outer then |
| 13786 |
h=h+getdelta(outer,inner) |
| 13787 |
end |
| 13788 |
end |
| 13789 |
if V>0 then |
| 13790 |
local outer,inner=readvariation(f,mainoffset+V) |
| 13791 |
if outer then |
| 13792 |
v=v+getdelta(outer,inner) |
| 13793 |
end |
| 13794 |
end |
| 13795 |
end |
| 13796 |
return { x,y,h,v } |
| 13797 |
elseif x==0 and y==0 and h==0 and v==0 then |
| 13798 |
return true |
| 13799 |
else |
| 13800 |
return { x,y,h,v } |
| 13801 |
end |
| 13802 |
end |
| 13803 |
local function readanchor(f,offset,getdelta) |
| 13804 |
if not offset or offset==0 then |
| 13805 |
return nil |
| 13806 |
end |
| 13807 |
setposition(f,offset) |
| 13808 |
local format=readshort(f) |
| 13809 |
local x=readshort(f) |
| 13810 |
local y=readshort(f) |
| 13811 |
if format==3 then |
| 13812 |
if getdelta then |
| 13813 |
local X=readshort(f) |
| 13814 |
local Y=readshort(f) |
| 13815 |
if X>0 then |
| 13816 |
local outer,inner=readvariation(f,offset+X) |
| 13817 |
if outer then |
| 13818 |
x=x+getdelta(outer,inner) |
| 13819 |
end |
| 13820 |
end |
| 13821 |
if Y>0 then |
| 13822 |
local outer,inner=readvariation(f,offset+Y) |
| 13823 |
if outer then |
| 13824 |
y=y+getdelta(outer,inner) |
| 13825 |
end |
| 13826 |
end |
| 13827 |
else |
| 13828 |
skipshort(f,2) |
| 13829 |
end |
| 13830 |
return { x,y } |
| 13831 |
else |
| 13832 |
return { x,y } |
| 13833 |
end |
| 13834 |
end |
| 13835 |
local function readfirst(f,offset) |
| 13836 |
if offset then |
| 13837 |
setposition(f,offset) |
| 13838 |
end |
| 13839 |
return { readushort(f) } |
| 13840 |
end |
| 13841 |
local function readarray(f,offset) |
| 13842 |
if offset then |
| 13843 |
setposition(f,offset) |
| 13844 |
end |
| 13845 |
local n=readushort(f) |
| 13846 |
if n==1 then |
| 13847 |
return { readushort(f) },1 |
| 13848 |
elseif n>0 then |
| 13849 |
return readcardinaltable(f,n,ushort),n |
| 13850 |
end |
| 13851 |
end |
| 13852 |
local function readcoveragearray(f,offset,t,simple) |
| 13853 |
if not t then |
| 13854 |
return nil |
| 13855 |
end |
| 13856 |
local n=#t |
| 13857 |
if n==0 then |
| 13858 |
return nil |
| 13859 |
end |
| 13860 |
for i=1,n do |
| 13861 |
t[i]=readcoverage(f,offset+t[i],simple) |
| 13862 |
end |
| 13863 |
return t |
| 13864 |
end |
| 13865 |
local function covered(subset,all) |
| 13866 |
local used,u |
| 13867 |
for i=1,#subset do |
| 13868 |
local s=subset[i] |
| 13869 |
if all[s] then |
| 13870 |
if used then |
| 13871 |
u=u+1 |
| 13872 |
used[u]=s |
| 13873 |
else |
| 13874 |
u=1 |
| 13875 |
used={ s } |
| 13876 |
end |
| 13877 |
end |
| 13878 |
end |
| 13879 |
return used |
| 13880 |
end |
| 13881 |
local function readlookuparray(f,noflookups,nofcurrent) |
| 13882 |
local lookups={} |
| 13883 |
if noflookups>0 then |
| 13884 |
local length=0 |
| 13885 |
for i=1,noflookups do |
| 13886 |
local index=readushort(f)+1 |
| 13887 |
if index>length then |
| 13888 |
length=index |
| 13889 |
end |
| 13890 |
local lookup=readushort(f)+1 |
| 13891 |
local list=lookups[index] |
| 13892 |
if list then |
| 13893 |
list[#list+1]=lookup |
| 13894 |
else |
| 13895 |
lookups[index]={ lookup } |
| 13896 |
end |
| 13897 |
end |
| 13898 |
for index=1,length do |
| 13899 |
if not lookups[index] then |
| 13900 |
lookups[index]=false |
| 13901 |
end |
| 13902 |
end |
| 13903 |
end |
| 13904 |
return lookups |
| 13905 |
end |
| 13906 |
local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,what) |
| 13907 |
local tableoffset=lookupoffset+offset |
| 13908 |
setposition(f,tableoffset) |
| 13909 |
local subtype=readushort(f) |
| 13910 |
if subtype==1 then |
| 13911 |
local coverage=readushort(f) |
| 13912 |
local subclasssets=readarray(f) |
| 13913 |
local rules={} |
| 13914 |
if subclasssets then |
| 13915 |
coverage=readcoverage(f,tableoffset+coverage,true) |
| 13916 |
for i=1,#subclasssets do |
| 13917 |
local offset=subclasssets[i] |
| 13918 |
if offset>0 then |
| 13919 |
local firstcoverage=coverage[i] |
| 13920 |
local rulesoffset=tableoffset+offset |
| 13921 |
local subclassrules=readarray(f,rulesoffset) |
| 13922 |
for rule=1,#subclassrules do |
| 13923 |
setposition(f,rulesoffset+subclassrules[rule]) |
| 13924 |
local nofcurrent=readushort(f) |
| 13925 |
local noflookups=readushort(f) |
| 13926 |
local current={ { firstcoverage } } |
| 13927 |
for i=2,nofcurrent do |
| 13928 |
current[i]={ readushort(f) } |
| 13929 |
end |
| 13930 |
local lookups=readlookuparray(f,noflookups,nofcurrent) |
| 13931 |
rules[#rules+1]={ |
| 13932 |
current=current, |
| 13933 |
lookups=lookups |
| 13934 |
} |
| 13935 |
end |
| 13936 |
end |
| 13937 |
end |
| 13938 |
else |
| 13939 |
report("empty subclassset in %a subtype %i","unchainedcontext",subtype) |
| 13940 |
end |
| 13941 |
return { |
| 13942 |
format="glyphs", |
| 13943 |
rules=rules, |
| 13944 |
} |
| 13945 |
elseif subtype==2 then |
| 13946 |
local coverage=readushort(f) |
| 13947 |
local currentclassdef=readushort(f) |
| 13948 |
local subclasssets=readarray(f) |
| 13949 |
local rules={} |
| 13950 |
if subclasssets then |
| 13951 |
coverage=readcoverage(f,tableoffset+coverage) |
| 13952 |
currentclassdef=readclassdef(f,tableoffset+currentclassdef,coverage) |
| 13953 |
local currentclasses=classtocoverage(currentclassdef,fontdata.glyphs) |
| 13954 |
for class=1,#subclasssets do |
| 13955 |
local offset=subclasssets[class] |
| 13956 |
if offset>0 then |
| 13957 |
local firstcoverage=currentclasses[class] |
| 13958 |
if firstcoverage then |
| 13959 |
firstcoverage=covered(firstcoverage,coverage) |
| 13960 |
if firstcoverage then |
| 13961 |
local rulesoffset=tableoffset+offset |
| 13962 |
local subclassrules=readarray(f,rulesoffset) |
| 13963 |
for rule=1,#subclassrules do |
| 13964 |
setposition(f,rulesoffset+subclassrules[rule]) |
| 13965 |
local nofcurrent=readushort(f) |
| 13966 |
local noflookups=readushort(f) |
| 13967 |
local current={ firstcoverage } |
| 13968 |
for i=2,nofcurrent do |
| 13969 |
current[i]=currentclasses[readushort(f)+1] |
| 13970 |
end |
| 13971 |
local lookups=readlookuparray(f,noflookups,nofcurrent) |
| 13972 |
rules[#rules+1]={ |
| 13973 |
current=current, |
| 13974 |
lookups=lookups |
| 13975 |
} |
| 13976 |
end |
| 13977 |
else |
| 13978 |
report("no coverage") |
| 13979 |
end |
| 13980 |
else |
| 13981 |
report("no coverage class") |
| 13982 |
end |
| 13983 |
end |
| 13984 |
end |
| 13985 |
else |
| 13986 |
report("empty subclassset in %a subtype %i","unchainedcontext",subtype) |
| 13987 |
end |
| 13988 |
return { |
| 13989 |
format="class", |
| 13990 |
rules=rules, |
| 13991 |
} |
| 13992 |
elseif subtype==3 then |
| 13993 |
local nofglyphs=readushort(f) |
| 13994 |
local noflookups=readushort(f) |
| 13995 |
local current=readcardinaltable(f,nofglyphs,ushort) |
| 13996 |
local lookups=readlookuparray(f,noflookups,#current) |
| 13997 |
current=readcoveragearray(f,tableoffset,current,true) |
| 13998 |
return { |
| 13999 |
format="coverage", |
| 14000 |
rules={ |
| 14001 |
{ |
| 14002 |
current=current, |
| 14003 |
lookups=lookups, |
| 14004 |
} |
| 14005 |
} |
| 14006 |
} |
| 14007 |
else |
| 14008 |
report("unsupported subtype %a in %a %s",subtype,"unchainedcontext",what) |
| 14009 |
end |
| 14010 |
end |
| 14011 |
local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,what) |
| 14012 |
local tableoffset=lookupoffset+offset |
| 14013 |
setposition(f,tableoffset) |
| 14014 |
local subtype=readushort(f) |
| 14015 |
if subtype==1 then |
| 14016 |
local coverage=readushort(f) |
| 14017 |
local subclasssets=readarray(f) |
| 14018 |
local rules={} |
| 14019 |
if subclasssets then |
| 14020 |
coverage=readcoverage(f,tableoffset+coverage,true) |
| 14021 |
for i=1,#subclasssets do |
| 14022 |
local offset=subclasssets[i] |
| 14023 |
if offset>0 then |
| 14024 |
local firstcoverage=coverage[i] |
| 14025 |
local rulesoffset=tableoffset+offset |
| 14026 |
local subclassrules=readarray(f,rulesoffset) |
| 14027 |
for rule=1,#subclassrules do |
| 14028 |
setposition(f,rulesoffset+subclassrules[rule]) |
| 14029 |
local nofbefore=readushort(f) |
| 14030 |
local before |
| 14031 |
if nofbefore>0 then |
| 14032 |
before={} |
| 14033 |
for i=1,nofbefore do |
| 14034 |
before[i]={ readushort(f) } |
| 14035 |
end |
| 14036 |
end |
| 14037 |
local nofcurrent=readushort(f) |
| 14038 |
local current={ { firstcoverage } } |
| 14039 |
for i=2,nofcurrent do |
| 14040 |
current[i]={ readushort(f) } |
| 14041 |
end |
| 14042 |
local nofafter=readushort(f) |
| 14043 |
local after |
| 14044 |
if nofafter>0 then |
| 14045 |
after={} |
| 14046 |
for i=1,nofafter do |
| 14047 |
after[i]={ readushort(f) } |
| 14048 |
end |
| 14049 |
end |
| 14050 |
local noflookups=readushort(f) |
| 14051 |
local lookups=readlookuparray(f,noflookups,nofcurrent) |
| 14052 |
rules[#rules+1]={ |
| 14053 |
before=before, |
| 14054 |
current=current, |
| 14055 |
after=after, |
| 14056 |
lookups=lookups, |
| 14057 |
} |
| 14058 |
end |
| 14059 |
end |
| 14060 |
end |
| 14061 |
else |
| 14062 |
report("empty subclassset in %a subtype %i","chainedcontext",subtype) |
| 14063 |
end |
| 14064 |
return { |
| 14065 |
format="glyphs", |
| 14066 |
rules=rules, |
| 14067 |
} |
| 14068 |
elseif subtype==2 then |
| 14069 |
local coverage=readushort(f) |
| 14070 |
local beforeclassdef=readushort(f) |
| 14071 |
local currentclassdef=readushort(f) |
| 14072 |
local afterclassdef=readushort(f) |
| 14073 |
local subclasssets=readarray(f) |
| 14074 |
local rules={} |
| 14075 |
if subclasssets then |
| 14076 |
local coverage=readcoverage(f,tableoffset+coverage) |
| 14077 |
local beforeclassdef=readclassdef(f,tableoffset+beforeclassdef,nofglyphs) |
| 14078 |
local currentclassdef=readclassdef(f,tableoffset+currentclassdef,coverage) |
| 14079 |
local afterclassdef=readclassdef(f,tableoffset+afterclassdef,nofglyphs) |
| 14080 |
local beforeclasses=classtocoverage(beforeclassdef,fontdata.glyphs) |
| 14081 |
local currentclasses=classtocoverage(currentclassdef,fontdata.glyphs) |
| 14082 |
local afterclasses=classtocoverage(afterclassdef,fontdata.glyphs) |
| 14083 |
for class=1,#subclasssets do |
| 14084 |
local offset=subclasssets[class] |
| 14085 |
if offset>0 then |
| 14086 |
local firstcoverage=currentclasses[class] |
| 14087 |
if firstcoverage then |
| 14088 |
firstcoverage=covered(firstcoverage,coverage) |
| 14089 |
if firstcoverage then |
| 14090 |
local rulesoffset=tableoffset+offset |
| 14091 |
local subclassrules=readarray(f,rulesoffset) |
| 14092 |
for rule=1,#subclassrules do |
| 14093 |
setposition(f,rulesoffset+subclassrules[rule]) |
| 14094 |
local nofbefore=readushort(f) |
| 14095 |
local before |
| 14096 |
if nofbefore>0 then |
| 14097 |
before={} |
| 14098 |
for i=1,nofbefore do |
| 14099 |
before[i]=beforeclasses[readushort(f)+1] |
| 14100 |
end |
| 14101 |
end |
| 14102 |
local nofcurrent=readushort(f) |
| 14103 |
local current={ firstcoverage } |
| 14104 |
for i=2,nofcurrent do |
| 14105 |
current[i]=currentclasses[readushort(f)+1] |
| 14106 |
end |
| 14107 |
local nofafter=readushort(f) |
| 14108 |
local after |
| 14109 |
if nofafter>0 then |
| 14110 |
after={} |
| 14111 |
for i=1,nofafter do |
| 14112 |
after[i]=afterclasses[readushort(f)+1] |
| 14113 |
end |
| 14114 |
end |
| 14115 |
local noflookups=readushort(f) |
| 14116 |
local lookups=readlookuparray(f,noflookups,nofcurrent) |
| 14117 |
rules[#rules+1]={ |
| 14118 |
before=before, |
| 14119 |
current=current, |
| 14120 |
after=after, |
| 14121 |
lookups=lookups, |
| 14122 |
} |
| 14123 |
end |
| 14124 |
else |
| 14125 |
report("no coverage") |
| 14126 |
end |
| 14127 |
else |
| 14128 |
report("class is not covered") |
| 14129 |
end |
| 14130 |
end |
| 14131 |
end |
| 14132 |
else |
| 14133 |
report("empty subclassset in %a subtype %i","chainedcontext",subtype) |
| 14134 |
end |
| 14135 |
return { |
| 14136 |
format="class", |
| 14137 |
rules=rules, |
| 14138 |
} |
| 14139 |
elseif subtype==3 then |
| 14140 |
local before=readarray(f) |
| 14141 |
local current=readarray(f) |
| 14142 |
local after=readarray(f) |
| 14143 |
local noflookups=readushort(f) |
| 14144 |
local lookups=readlookuparray(f,noflookups,#current) |
| 14145 |
before=readcoveragearray(f,tableoffset,before,true) |
| 14146 |
current=readcoveragearray(f,tableoffset,current,true) |
| 14147 |
after=readcoveragearray(f,tableoffset,after,true) |
| 14148 |
return { |
| 14149 |
format="coverage", |
| 14150 |
rules={ |
| 14151 |
{ |
| 14152 |
before=before, |
| 14153 |
current=current, |
| 14154 |
after=after, |
| 14155 |
lookups=lookups, |
| 14156 |
} |
| 14157 |
} |
| 14158 |
} |
| 14159 |
else |
| 14160 |
report("unsupported subtype %a in %a %s",subtype,"chainedcontext",what) |
| 14161 |
end |
| 14162 |
end |
| 14163 |
local function extension(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,types,handlers,what) |
| 14164 |
local tableoffset=lookupoffset+offset |
| 14165 |
setposition(f,tableoffset) |
| 14166 |
local subtype=readushort(f) |
| 14167 |
if subtype==1 then |
| 14168 |
local lookuptype=types[readushort(f)] |
| 14169 |
local faroffset=readulong(f) |
| 14170 |
local handler=handlers[lookuptype] |
| 14171 |
if handler then |
| 14172 |
return handler(f,fontdata,lookupid,tableoffset+faroffset,0,glyphs,nofglyphs),lookuptype |
| 14173 |
else |
| 14174 |
report("no handler for lookuptype %a subtype %a in %s %s",lookuptype,subtype,what,"extension") |
| 14175 |
end |
| 14176 |
else |
| 14177 |
report("unsupported subtype %a in %s %s",subtype,what,"extension") |
| 14178 |
end |
| 14179 |
end |
| 14180 |
function gsubhandlers.single(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14181 |
local tableoffset=lookupoffset+offset |
| 14182 |
setposition(f,tableoffset) |
| 14183 |
local subtype=readushort(f) |
| 14184 |
if subtype==1 then |
| 14185 |
local coverage=readushort(f) |
| 14186 |
local delta=readshort(f) |
| 14187 |
local coverage=readcoverage(f,tableoffset+coverage) |
| 14188 |
for index in next,coverage do |
| 14189 |
local newindex=(index+delta)%65536 |
| 14190 |
if index>nofglyphs or newindex>nofglyphs then |
| 14191 |
report("invalid index in %s format %i: %i -> %i (max %i)","single",subtype,index,newindex,nofglyphs) |
| 14192 |
coverage[index]=nil |
| 14193 |
else |
| 14194 |
coverage[index]=newindex |
| 14195 |
end |
| 14196 |
end |
| 14197 |
return { |
| 14198 |
coverage=coverage |
| 14199 |
} |
| 14200 |
elseif subtype==2 then |
| 14201 |
local coverage=readushort(f) |
| 14202 |
local nofreplacements=readushort(f) |
| 14203 |
local replacements=readcardinaltable(f,nofreplacements,ushort) |
| 14204 |
local coverage=readcoverage(f,tableoffset+coverage) |
| 14205 |
for index,newindex in next,coverage do |
| 14206 |
newindex=newindex+1 |
| 14207 |
if index>nofglyphs or newindex>nofglyphs then |
| 14208 |
report("invalid index in %s format %i: %i -> %i (max %i)","single",subtype,index,newindex,nofglyphs) |
| 14209 |
coverage[index]=nil |
| 14210 |
else |
| 14211 |
coverage[index]=replacements[newindex] |
| 14212 |
end |
| 14213 |
end |
| 14214 |
return { |
| 14215 |
coverage=coverage |
| 14216 |
} |
| 14217 |
else |
| 14218 |
report("unsupported subtype %a in %a substitution",subtype,"single") |
| 14219 |
end |
| 14220 |
end |
| 14221 |
local function sethandler(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,what) |
| 14222 |
local tableoffset=lookupoffset+offset |
| 14223 |
setposition(f,tableoffset) |
| 14224 |
local subtype=readushort(f) |
| 14225 |
if subtype==1 then |
| 14226 |
local coverage=readushort(f) |
| 14227 |
local nofsequence=readushort(f) |
| 14228 |
local sequences=readcardinaltable(f,nofsequence,ushort) |
| 14229 |
for i=1,nofsequence do |
| 14230 |
setposition(f,tableoffset+sequences[i]) |
| 14231 |
sequences[i]=readcardinaltable(f,readushort(f),ushort) |
| 14232 |
end |
| 14233 |
local coverage=readcoverage(f,tableoffset+coverage) |
| 14234 |
for index,newindex in next,coverage do |
| 14235 |
newindex=newindex+1 |
| 14236 |
if index>nofglyphs or newindex>nofglyphs then |
| 14237 |
report("invalid index in %s format %i: %i -> %i (max %i)",what,subtype,index,newindex,nofglyphs) |
| 14238 |
coverage[index]=nil |
| 14239 |
else |
| 14240 |
coverage[index]=sequences[newindex] |
| 14241 |
end |
| 14242 |
end |
| 14243 |
return { |
| 14244 |
coverage=coverage |
| 14245 |
} |
| 14246 |
else |
| 14247 |
report("unsupported subtype %a in %a substitution",subtype,what) |
| 14248 |
end |
| 14249 |
end |
| 14250 |
function gsubhandlers.multiple(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14251 |
return sethandler(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,"multiple") |
| 14252 |
end |
| 14253 |
function gsubhandlers.alternate(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14254 |
return sethandler(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,"alternate") |
| 14255 |
end |
| 14256 |
function gsubhandlers.ligature(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14257 |
local tableoffset=lookupoffset+offset |
| 14258 |
setposition(f,tableoffset) |
| 14259 |
local subtype=readushort(f) |
| 14260 |
if subtype==1 then |
| 14261 |
local coverage=readushort(f) |
| 14262 |
local nofsets=readushort(f) |
| 14263 |
local ligatures=readcardinaltable(f,nofsets,ushort) |
| 14264 |
for i=1,nofsets do |
| 14265 |
local offset=lookupoffset+offset+ligatures[i] |
| 14266 |
setposition(f,offset) |
| 14267 |
local n=readushort(f) |
| 14268 |
if n==1 then |
| 14269 |
ligatures[i]={ offset+readushort(f) } |
| 14270 |
else |
| 14271 |
local l={} |
| 14272 |
for i=1,n do |
| 14273 |
l[i]=offset+readushort(f) |
| 14274 |
end |
| 14275 |
ligatures[i]=l |
| 14276 |
end |
| 14277 |
end |
| 14278 |
local coverage=readcoverage(f,tableoffset+coverage) |
| 14279 |
for index,newindex in next,coverage do |
| 14280 |
local hash={} |
| 14281 |
local ligatures=ligatures[newindex+1] |
| 14282 |
for i=1,#ligatures do |
| 14283 |
local offset=ligatures[i] |
| 14284 |
setposition(f,offset) |
| 14285 |
local lig=readushort(f) |
| 14286 |
local cnt=readushort(f) |
| 14287 |
local hsh=hash |
| 14288 |
for i=2,cnt do |
| 14289 |
local c=readushort(f) |
| 14290 |
local h=hsh[c] |
| 14291 |
if not h then |
| 14292 |
h={} |
| 14293 |
hsh[c]=h |
| 14294 |
end |
| 14295 |
hsh=h |
| 14296 |
end |
| 14297 |
hsh.ligature=lig |
| 14298 |
end |
| 14299 |
coverage[index]=hash |
| 14300 |
end |
| 14301 |
return { |
| 14302 |
coverage=coverage |
| 14303 |
} |
| 14304 |
else |
| 14305 |
report("unsupported subtype %a in %a substitution",subtype,"ligature") |
| 14306 |
end |
| 14307 |
end |
| 14308 |
function gsubhandlers.context(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14309 |
return unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,"substitution"),"context" |
| 14310 |
end |
| 14311 |
function gsubhandlers.chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14312 |
return chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,"substitution"),"chainedcontext" |
| 14313 |
end |
| 14314 |
function gsubhandlers.extension(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14315 |
return extension(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,gsubtypes,gsubhandlers,"substitution") |
| 14316 |
end |
| 14317 |
function gsubhandlers.reversechainedcontextsingle(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14318 |
local tableoffset=lookupoffset+offset |
| 14319 |
setposition(f,tableoffset) |
| 14320 |
local subtype=readushort(f) |
| 14321 |
if subtype==1 then |
| 14322 |
local current=readfirst(f) |
| 14323 |
local before=readarray(f) |
| 14324 |
local after=readarray(f) |
| 14325 |
local replacements=readarray(f) |
| 14326 |
current=readcoveragearray(f,tableoffset,current,true) |
| 14327 |
before=readcoveragearray(f,tableoffset,before,true) |
| 14328 |
after=readcoveragearray(f,tableoffset,after,true) |
| 14329 |
return { |
| 14330 |
format="reversecoverage", |
| 14331 |
rules={ |
| 14332 |
{ |
| 14333 |
before=before, |
| 14334 |
current=current, |
| 14335 |
after=after, |
| 14336 |
replacements=replacements, |
| 14337 |
} |
| 14338 |
} |
| 14339 |
},"reversechainedcontextsingle" |
| 14340 |
else |
| 14341 |
report("unsupported subtype %a in %a substitution",subtype,"reversechainedcontextsingle") |
| 14342 |
end |
| 14343 |
end |
| 14344 |
local function readpairsets(f,tableoffset,sets,format1,format2,mainoffset,getdelta) |
| 14345 |
local done={} |
| 14346 |
for i=1,#sets do |
| 14347 |
local offset=sets[i] |
| 14348 |
local reused=done[offset] |
| 14349 |
if not reused then |
| 14350 |
offset=tableoffset+offset |
| 14351 |
setposition(f,offset) |
| 14352 |
local n=readushort(f) |
| 14353 |
reused={} |
| 14354 |
for i=1,n do |
| 14355 |
reused[i]={ |
| 14356 |
readushort(f), |
| 14357 |
readposition(f,format1,offset,getdelta), |
| 14358 |
readposition(f,format2,offset,getdelta), |
| 14359 |
} |
| 14360 |
end |
| 14361 |
done[offset]=reused |
| 14362 |
end |
| 14363 |
sets[i]=reused |
| 14364 |
end |
| 14365 |
return sets |
| 14366 |
end |
| 14367 |
local function readpairclasssets(f,nofclasses1,nofclasses2,format1,format2,mainoffset,getdelta) |
| 14368 |
local classlist1={} |
| 14369 |
for i=1,nofclasses1 do |
| 14370 |
local classlist2={} |
| 14371 |
classlist1[i]=classlist2 |
| 14372 |
for j=1,nofclasses2 do |
| 14373 |
local one=readposition(f,format1,mainoffset,getdelta) |
| 14374 |
local two=readposition(f,format2,mainoffset,getdelta) |
| 14375 |
if one or two then |
| 14376 |
classlist2[j]={ one,two } |
| 14377 |
else |
| 14378 |
classlist2[j]=false |
| 14379 |
end |
| 14380 |
end |
| 14381 |
end |
| 14382 |
return classlist1 |
| 14383 |
end |
| 14384 |
function gposhandlers.single(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14385 |
local tableoffset=lookupoffset+offset |
| 14386 |
setposition(f,tableoffset) |
| 14387 |
local subtype=readushort(f) |
| 14388 |
local getdelta=fontdata.temporary.getdelta |
| 14389 |
if subtype==1 then |
| 14390 |
local coverage=readushort(f) |
| 14391 |
local format=readushort(f) |
| 14392 |
local value=readposition(f,format,tableoffset,getdelta) |
| 14393 |
local coverage=readcoverage(f,tableoffset+coverage) |
| 14394 |
for index,newindex in next,coverage do |
| 14395 |
coverage[index]=value |
| 14396 |
end |
| 14397 |
return { |
| 14398 |
format="single", |
| 14399 |
coverage=coverage, |
| 14400 |
} |
| 14401 |
elseif subtype==2 then |
| 14402 |
local coverage=readushort(f) |
| 14403 |
local format=readushort(f) |
| 14404 |
local nofvalues=readushort(f) |
| 14405 |
local values={} |
| 14406 |
for i=1,nofvalues do |
| 14407 |
values[i]=readposition(f,format,tableoffset,getdelta) |
| 14408 |
end |
| 14409 |
local coverage=readcoverage(f,tableoffset+coverage) |
| 14410 |
for index,newindex in next,coverage do |
| 14411 |
coverage[index]=values[newindex+1] |
| 14412 |
end |
| 14413 |
return { |
| 14414 |
format="single", |
| 14415 |
coverage=coverage, |
| 14416 |
} |
| 14417 |
else |
| 14418 |
report("unsupported subtype %a in %a positioning",subtype,"single") |
| 14419 |
end |
| 14420 |
end |
| 14421 |
function gposhandlers.pair(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14422 |
local tableoffset=lookupoffset+offset |
| 14423 |
setposition(f,tableoffset) |
| 14424 |
local subtype=readushort(f) |
| 14425 |
local getdelta=fontdata.temporary.getdelta |
| 14426 |
if subtype==1 then |
| 14427 |
local coverage=readushort(f) |
| 14428 |
local format1=readushort(f) |
| 14429 |
local format2=readushort(f) |
| 14430 |
local sets=readarray(f) |
| 14431 |
sets=readpairsets(f,tableoffset,sets,format1,format2,mainoffset,getdelta) |
| 14432 |
coverage=readcoverage(f,tableoffset+coverage) |
| 14433 |
local shared={} |
| 14434 |
for index,newindex in next,coverage do |
| 14435 |
local set=sets[newindex+1] |
| 14436 |
local hash={} |
| 14437 |
for i=1,#set do |
| 14438 |
local value=set[i] |
| 14439 |
if value then |
| 14440 |
local other=value[1] |
| 14441 |
local share=shared[value] |
| 14442 |
if share==nil then |
| 14443 |
local first=value[2] |
| 14444 |
local second=value[3] |
| 14445 |
if first or second then |
| 14446 |
share={ first,second or nil } |
| 14447 |
else |
| 14448 |
share=false |
| 14449 |
end |
| 14450 |
shared[value]=share |
| 14451 |
end |
| 14452 |
hash[other]=share or nil |
| 14453 |
end |
| 14454 |
end |
| 14455 |
coverage[index]=hash |
| 14456 |
end |
| 14457 |
return { |
| 14458 |
shared=shared and true or nil, |
| 14459 |
format="pair", |
| 14460 |
coverage=coverage, |
| 14461 |
} |
| 14462 |
elseif subtype==2 then |
| 14463 |
local coverage=readushort(f) |
| 14464 |
local format1=readushort(f) |
| 14465 |
local format2=readushort(f) |
| 14466 |
local classdef1=readushort(f) |
| 14467 |
local classdef2=readushort(f) |
| 14468 |
local nofclasses1=readushort(f) |
| 14469 |
local nofclasses2=readushort(f) |
| 14470 |
local classlist=readpairclasssets(f,nofclasses1,nofclasses2,format1,format2,tableoffset,getdelta) |
| 14471 |
coverage=readcoverage(f,tableoffset+coverage) |
| 14472 |
classdef1=readclassdef(f,tableoffset+classdef1,coverage) |
| 14473 |
classdef2=readclassdef(f,tableoffset+classdef2,nofglyphs) |
| 14474 |
local usedcoverage={} |
| 14475 |
local shared={} |
| 14476 |
for g1,c1 in next,classdef1 do |
| 14477 |
if coverage[g1] then |
| 14478 |
local l1=classlist[c1] |
| 14479 |
if l1 then |
| 14480 |
local hash={} |
| 14481 |
for paired,class in next,classdef2 do |
| 14482 |
local offsets=l1[class] |
| 14483 |
if offsets then |
| 14484 |
local first=offsets[1] |
| 14485 |
local second=offsets[2] |
| 14486 |
if first or second then |
| 14487 |
local s1=shared[first] |
| 14488 |
if s1==nil then |
| 14489 |
s1={} |
| 14490 |
shared[first]=s1 |
| 14491 |
end |
| 14492 |
local s2=s1[second] |
| 14493 |
if s2==nil then |
| 14494 |
s2={ first,second or nil } |
| 14495 |
s1[second]=s2 |
| 14496 |
end |
| 14497 |
hash[paired]=s2 |
| 14498 |
end |
| 14499 |
end |
| 14500 |
end |
| 14501 |
usedcoverage[g1]=hash |
| 14502 |
end |
| 14503 |
end |
| 14504 |
end |
| 14505 |
return { |
| 14506 |
shared=shared and true or nil, |
| 14507 |
format="pair", |
| 14508 |
coverage=usedcoverage, |
| 14509 |
} |
| 14510 |
elseif subtype==3 then |
| 14511 |
report("yet unsupported subtype %a in %a positioning",subtype,"pair") |
| 14512 |
else |
| 14513 |
report("unsupported subtype %a in %a positioning",subtype,"pair") |
| 14514 |
end |
| 14515 |
end |
| 14516 |
function gposhandlers.cursive(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14517 |
local tableoffset=lookupoffset+offset |
| 14518 |
setposition(f,tableoffset) |
| 14519 |
local subtype=readushort(f) |
| 14520 |
local getdelta=fontdata.temporary.getdelta |
| 14521 |
if subtype==1 then |
| 14522 |
local coverage=tableoffset+readushort(f) |
| 14523 |
local nofrecords=readushort(f) |
| 14524 |
local records={} |
| 14525 |
for i=1,nofrecords do |
| 14526 |
local entry=readushort(f) |
| 14527 |
local exit=readushort(f) |
| 14528 |
records[i]={ |
| 14529 |
entry~=0 and (tableoffset+entry) or false, |
| 14530 |
exit~=0 and (tableoffset+exit ) or nil, |
| 14531 |
} |
| 14532 |
end |
| 14533 |
local cc=(fontdata.temporary.cursivecount or 0)+1 |
| 14534 |
fontdata.temporary.cursivecount=cc |
| 14535 |
cc="cc-"..cc |
| 14536 |
coverage=readcoverage(f,coverage) |
| 14537 |
for i=1,nofrecords do |
| 14538 |
local r=records[i] |
| 14539 |
records[i]={ |
| 14540 |
cc, |
| 14541 |
readanchor(f,r[1],getdelta) or false, |
| 14542 |
readanchor(f,r[2],getdelta) or nil, |
| 14543 |
} |
| 14544 |
end |
| 14545 |
for index,newindex in next,coverage do |
| 14546 |
coverage[index]=records[newindex+1] |
| 14547 |
end |
| 14548 |
return { |
| 14549 |
coverage=coverage, |
| 14550 |
} |
| 14551 |
else |
| 14552 |
report("unsupported subtype %a in %a positioning",subtype,"cursive") |
| 14553 |
end |
| 14554 |
end |
| 14555 |
local function handlemark(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,ligature) |
| 14556 |
local tableoffset=lookupoffset+offset |
| 14557 |
setposition(f,tableoffset) |
| 14558 |
local subtype=readushort(f) |
| 14559 |
local getdelta=fontdata.temporary.getdelta |
| 14560 |
if subtype==1 then |
| 14561 |
local markcoverage=tableoffset+readushort(f) |
| 14562 |
local basecoverage=tableoffset+readushort(f) |
| 14563 |
local nofclasses=readushort(f) |
| 14564 |
local markoffset=tableoffset+readushort(f) |
| 14565 |
local baseoffset=tableoffset+readushort(f) |
| 14566 |
local markcoverage=readcoverage(f,markcoverage) |
| 14567 |
local basecoverage=readcoverage(f,basecoverage,true) |
| 14568 |
setposition(f,markoffset) |
| 14569 |
local markclasses={} |
| 14570 |
local nofmarkclasses=readushort(f) |
| 14571 |
local lastanchor=fontdata.lastanchor or 0 |
| 14572 |
local usedanchors={} |
| 14573 |
for i=1,nofmarkclasses do |
| 14574 |
local class=readushort(f)+1 |
| 14575 |
local offset=readushort(f) |
| 14576 |
if offset==0 then |
| 14577 |
markclasses[i]=false |
| 14578 |
else |
| 14579 |
markclasses[i]={ class,markoffset+offset } |
| 14580 |
end |
| 14581 |
usedanchors[class]=true |
| 14582 |
end |
| 14583 |
for i=1,nofmarkclasses do |
| 14584 |
local mc=markclasses[i] |
| 14585 |
if mc then |
| 14586 |
mc[2]=readanchor(f,mc[2],getdelta) |
| 14587 |
end |
| 14588 |
end |
| 14589 |
setposition(f,baseoffset) |
| 14590 |
local nofbaserecords=readushort(f) |
| 14591 |
local baserecords={} |
| 14592 |
if ligature then |
| 14593 |
for i=1,nofbaserecords do |
| 14594 |
local offset=readushort(f) |
| 14595 |
if offset==0 then |
| 14596 |
baserecords[i]=false |
| 14597 |
else |
| 14598 |
baserecords[i]=baseoffset+offset |
| 14599 |
end |
| 14600 |
end |
| 14601 |
for i=1,nofbaserecords do |
| 14602 |
local recordoffset=baserecords[i] |
| 14603 |
if recordoffset then |
| 14604 |
setposition(f,recordoffset) |
| 14605 |
local nofcomponents=readushort(f) |
| 14606 |
local components={} |
| 14607 |
for i=1,nofcomponents do |
| 14608 |
local classes={} |
| 14609 |
for i=1,nofclasses do |
| 14610 |
local offset=readushort(f) |
| 14611 |
if offset~=0 then |
| 14612 |
classes[i]=recordoffset+offset |
| 14613 |
else |
| 14614 |
classes[i]=false |
| 14615 |
end |
| 14616 |
end |
| 14617 |
components[i]=classes |
| 14618 |
end |
| 14619 |
baserecords[i]=components |
| 14620 |
end |
| 14621 |
end |
| 14622 |
local baseclasses={} |
| 14623 |
for i=1,nofclasses do |
| 14624 |
baseclasses[i]={} |
| 14625 |
end |
| 14626 |
for i=1,nofbaserecords do |
| 14627 |
local components=baserecords[i] |
| 14628 |
if components then |
| 14629 |
local b=basecoverage[i] |
| 14630 |
for c=1,#components do |
| 14631 |
local classes=components[c] |
| 14632 |
if classes then |
| 14633 |
for i=1,nofclasses do |
| 14634 |
local anchor=readanchor(f,classes[i],getdelta) |
| 14635 |
local bclass=baseclasses[i] |
| 14636 |
local bentry=bclass[b] |
| 14637 |
if bentry then |
| 14638 |
bentry[c]=anchor |
| 14639 |
else |
| 14640 |
bclass[b]={ [c]=anchor } |
| 14641 |
end |
| 14642 |
end |
| 14643 |
end |
| 14644 |
end |
| 14645 |
end |
| 14646 |
end |
| 14647 |
for index,newindex in next,markcoverage do |
| 14648 |
markcoverage[index]=markclasses[newindex+1] or nil |
| 14649 |
end |
| 14650 |
return { |
| 14651 |
format="ligature", |
| 14652 |
baseclasses=baseclasses, |
| 14653 |
coverage=markcoverage, |
| 14654 |
} |
| 14655 |
else |
| 14656 |
for i=1,nofbaserecords do |
| 14657 |
local r={} |
| 14658 |
for j=1,nofclasses do |
| 14659 |
local offset=readushort(f) |
| 14660 |
if offset==0 then |
| 14661 |
r[j]=false |
| 14662 |
else |
| 14663 |
r[j]=baseoffset+offset |
| 14664 |
end |
| 14665 |
end |
| 14666 |
baserecords[i]=r |
| 14667 |
end |
| 14668 |
local baseclasses={} |
| 14669 |
for i=1,nofclasses do |
| 14670 |
baseclasses[i]={} |
| 14671 |
end |
| 14672 |
for i=1,nofbaserecords do |
| 14673 |
local r=baserecords[i] |
| 14674 |
local b=basecoverage[i] |
| 14675 |
for j=1,nofclasses do |
| 14676 |
baseclasses[j][b]=readanchor(f,r[j],getdelta) |
| 14677 |
end |
| 14678 |
end |
| 14679 |
for index,newindex in next,markcoverage do |
| 14680 |
markcoverage[index]=markclasses[newindex+1] or nil |
| 14681 |
end |
| 14682 |
return { |
| 14683 |
format="base", |
| 14684 |
baseclasses=baseclasses, |
| 14685 |
coverage=markcoverage, |
| 14686 |
} |
| 14687 |
end |
| 14688 |
else |
| 14689 |
report("unsupported subtype %a in",subtype) |
| 14690 |
end |
| 14691 |
end |
| 14692 |
function gposhandlers.marktobase(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14693 |
return handlemark(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14694 |
end |
| 14695 |
function gposhandlers.marktoligature(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14696 |
return handlemark(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,true) |
| 14697 |
end |
| 14698 |
function gposhandlers.marktomark(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14699 |
return handlemark(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14700 |
end |
| 14701 |
function gposhandlers.context(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14702 |
return unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,"positioning"),"context" |
| 14703 |
end |
| 14704 |
function gposhandlers.chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14705 |
return chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,"positioning"),"chainedcontext" |
| 14706 |
end |
| 14707 |
function gposhandlers.extension(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs) |
| 14708 |
return extension(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofglyphs,gpostypes,gposhandlers,"positioning") |
| 14709 |
end |
| 14710 |
do |
| 14711 |
local plugins={} |
| 14712 |
function plugins.size(f,fontdata,tableoffset,feature) |
| 14713 |
if fontdata.designsize then |
| 14714 |
else |
| 14715 |
local function check(offset) |
| 14716 |
setposition(f,offset) |
| 14717 |
local designsize=readushort(f) |
| 14718 |
if designsize>0 then |
| 14719 |
local fontstyleid=readushort(f) |
| 14720 |
local guimenuid=readushort(f) |
| 14721 |
local minsize=readushort(f) |
| 14722 |
local maxsize=readushort(f) |
| 14723 |
if minsize==0 and maxsize==0 and fontstyleid==0 and guimenuid==0 then |
| 14724 |
minsize=designsize |
| 14725 |
maxsize=designsize |
| 14726 |
end |
| 14727 |
if designsize>=minsize and designsize<=maxsize then |
| 14728 |
return minsize,maxsize,designsize |
| 14729 |
end |
| 14730 |
end |
| 14731 |
end |
| 14732 |
local minsize,maxsize,designsize=check(tableoffset+feature.offset+feature.parameters) |
| 14733 |
if not designsize then |
| 14734 |
minsize,maxsize,designsize=check(tableoffset+feature.parameters) |
| 14735 |
if designsize then |
| 14736 |
report("bad size feature in %a, falling back to wrong offset",fontdata.filename or "?") |
| 14737 |
else |
| 14738 |
report("bad size feature in %a,",fontdata.filename or "?") |
| 14739 |
end |
| 14740 |
end |
| 14741 |
if designsize then |
| 14742 |
fontdata.minsize=minsize |
| 14743 |
fontdata.maxsize=maxsize |
| 14744 |
fontdata.designsize=designsize |
| 14745 |
end |
| 14746 |
end |
| 14747 |
end |
| 14748 |
local function reorderfeatures(fontdata,scripts,features) |
| 14749 |
local scriptlangs={} |
| 14750 |
local featurehash={} |
| 14751 |
local featureorder={} |
| 14752 |
for script,languages in next,scripts do |
| 14753 |
for language,record in next,languages do |
| 14754 |
local hash={} |
| 14755 |
local list=record.featureindices |
| 14756 |
for k=1,#list do |
| 14757 |
local index=list[k] |
| 14758 |
local feature=features[index] |
| 14759 |
local lookups=feature.lookups |
| 14760 |
local tag=feature.tag |
| 14761 |
if tag then |
| 14762 |
hash[tag]=true |
| 14763 |
end |
| 14764 |
if lookups then |
| 14765 |
for i=1,#lookups do |
| 14766 |
local lookup=lookups[i] |
| 14767 |
local o=featureorder[lookup] |
| 14768 |
if o then |
| 14769 |
local okay=true |
| 14770 |
for i=1,#o do |
| 14771 |
if o[i]==tag then |
| 14772 |
okay=false |
| 14773 |
break |
| 14774 |
end |
| 14775 |
end |
| 14776 |
if okay then |
| 14777 |
o[#o+1]=tag |
| 14778 |
end |
| 14779 |
else |
| 14780 |
featureorder[lookup]={ tag } |
| 14781 |
end |
| 14782 |
local f=featurehash[lookup] |
| 14783 |
if f then |
| 14784 |
local h=f[tag] |
| 14785 |
if h then |
| 14786 |
local s=h[script] |
| 14787 |
if s then |
| 14788 |
s[language]=true |
| 14789 |
else |
| 14790 |
h[script]={ [language]=true } |
| 14791 |
end |
| 14792 |
else |
| 14793 |
f[tag]={ [script]={ [language]=true } } |
| 14794 |
end |
| 14795 |
else |
| 14796 |
featurehash[lookup]={ [tag]={ [script]={ [language]=true } } } |
| 14797 |
end |
| 14798 |
local h=scriptlangs[tag] |
| 14799 |
if h then |
| 14800 |
local s=h[script] |
| 14801 |
if s then |
| 14802 |
s[language]=true |
| 14803 |
else |
| 14804 |
h[script]={ [language]=true } |
| 14805 |
end |
| 14806 |
else |
| 14807 |
scriptlangs[tag]={ [script]={ [language]=true } } |
| 14808 |
end |
| 14809 |
end |
| 14810 |
end |
| 14811 |
end |
| 14812 |
end |
| 14813 |
end |
| 14814 |
return scriptlangs,featurehash,featureorder |
| 14815 |
end |
| 14816 |
local function readscriplan(f,fontdata,scriptoffset) |
| 14817 |
setposition(f,scriptoffset) |
| 14818 |
local nofscripts=readushort(f) |
| 14819 |
local scripts={} |
| 14820 |
for i=1,nofscripts do |
| 14821 |
scripts[readtag(f)]=scriptoffset+readushort(f) |
| 14822 |
end |
| 14823 |
local languagesystems=setmetatableindex("table") |
| 14824 |
for script,offset in next,scripts do |
| 14825 |
setposition(f,offset) |
| 14826 |
local defaultoffset=readushort(f) |
| 14827 |
local noflanguages=readushort(f) |
| 14828 |
local languages={} |
| 14829 |
if defaultoffset>0 then |
| 14830 |
languages.dflt=languagesystems[offset+defaultoffset] |
| 14831 |
end |
| 14832 |
for i=1,noflanguages do |
| 14833 |
local language=readtag(f) |
| 14834 |
local offset=offset+readushort(f) |
| 14835 |
languages[language]=languagesystems[offset] |
| 14836 |
end |
| 14837 |
scripts[script]=languages |
| 14838 |
end |
| 14839 |
for offset,usedfeatures in next,languagesystems do |
| 14840 |
if offset>0 then |
| 14841 |
setposition(f,offset) |
| 14842 |
local featureindices={} |
| 14843 |
usedfeatures.featureindices=featureindices |
| 14844 |
usedfeatures.lookuporder=readushort(f) |
| 14845 |
usedfeatures.requiredindex=readushort(f) |
| 14846 |
local noffeatures=readushort(f) |
| 14847 |
for i=1,noffeatures do |
| 14848 |
featureindices[i]=readushort(f)+1 |
| 14849 |
end |
| 14850 |
end |
| 14851 |
end |
| 14852 |
return scripts |
| 14853 |
end |
| 14854 |
local function readfeatures(f,fontdata,featureoffset) |
| 14855 |
setposition(f,featureoffset) |
| 14856 |
local features={} |
| 14857 |
local noffeatures=readushort(f) |
| 14858 |
for i=1,noffeatures do |
| 14859 |
features[i]={ |
| 14860 |
tag=readtag(f), |
| 14861 |
offset=readushort(f) |
| 14862 |
} |
| 14863 |
end |
| 14864 |
for i=1,noffeatures do |
| 14865 |
local feature=features[i] |
| 14866 |
local offset=featureoffset+feature.offset |
| 14867 |
setposition(f,offset) |
| 14868 |
local parameters=readushort(f) |
| 14869 |
local noflookups=readushort(f) |
| 14870 |
if noflookups>0 then |
| 14871 |
local lookups=readcardinaltable(f,noflookups,ushort) |
| 14872 |
feature.lookups=lookups |
| 14873 |
for j=1,noflookups do |
| 14874 |
lookups[j]=lookups[j]+1 |
| 14875 |
end |
| 14876 |
end |
| 14877 |
if parameters>0 then |
| 14878 |
feature.parameters=parameters |
| 14879 |
local plugin=plugins[feature.tag] |
| 14880 |
if plugin then |
| 14881 |
plugin(f,fontdata,featureoffset,feature) |
| 14882 |
end |
| 14883 |
end |
| 14884 |
end |
| 14885 |
return features |
| 14886 |
end |
| 14887 |
local function readlookups(f,lookupoffset,lookuptypes,featurehash,featureorder,nofmarkclasses) |
| 14888 |
setposition(f,lookupoffset) |
| 14889 |
local noflookups=readushort(f) |
| 14890 |
local lookups=readcardinaltable(f,noflookups,ushort) |
| 14891 |
for lookupid=1,noflookups do |
| 14892 |
local offset=lookups[lookupid] |
| 14893 |
setposition(f,lookupoffset+offset) |
| 14894 |
local subtables={} |
| 14895 |
local typebits=readushort(f) |
| 14896 |
local flagbits=readushort(f) |
| 14897 |
local lookuptype=lookuptypes[typebits] |
| 14898 |
local lookupflags=lookupflags[flagbits] |
| 14899 |
local nofsubtables=readushort(f) |
| 14900 |
for j=1,nofsubtables do |
| 14901 |
subtables[j]=offset+readushort(f) |
| 14902 |
end |
| 14903 |
local markclass=band(flagbits,0x0010)~=0 |
| 14904 |
local markset=rshift(flagbits,8) |
| 14905 |
if markclass then |
| 14906 |
markclass=readushort(f) |
| 14907 |
end |
| 14908 |
if markset>0 then |
| 14909 |
markclass=nofmarkclasses+markset |
| 14910 |
end |
| 14911 |
lookups[lookupid]={ |
| 14912 |
type=lookuptype, |
| 14913 |
flags=lookupflags, |
| 14914 |
name=lookupid, |
| 14915 |
subtables=subtables, |
| 14916 |
markclass=markclass, |
| 14917 |
features=featurehash[lookupid], |
| 14918 |
order=featureorder[lookupid], |
| 14919 |
} |
| 14920 |
end |
| 14921 |
return lookups |
| 14922 |
end |
| 14923 |
local f_lookupname=formatters["%s_%s_%s"] |
| 14924 |
local function resolvelookups(f,lookupoffset,fontdata,lookups,lookuptypes,lookuphandlers,what,tableoffset) |
| 14925 |
local sequences=fontdata.sequences or {} |
| 14926 |
local sublookuplist=fontdata.sublookups or {} |
| 14927 |
fontdata.sequences=sequences |
| 14928 |
fontdata.sublookups=sublookuplist |
| 14929 |
local nofsublookups=#sublookuplist |
| 14930 |
local nofsequences=#sequences |
| 14931 |
local lastsublookup=nofsublookups |
| 14932 |
local lastsequence=nofsequences |
| 14933 |
local lookupnames=lookupnames[what] |
| 14934 |
local sublookuphash={} |
| 14935 |
local sublookupcheck={} |
| 14936 |
local glyphs=fontdata.glyphs |
| 14937 |
local nofglyphs=fontdata.nofglyphs or #glyphs |
| 14938 |
local noflookups=#lookups |
| 14939 |
local lookupprefix=sub(what,2,2) |
| 14940 |
local usedlookups=false |
| 14941 |
local allsteps={} |
| 14942 |
for lookupid=1,noflookups do |
| 14943 |
local lookup=lookups[lookupid] |
| 14944 |
local lookuptype=lookup.type |
| 14945 |
local subtables=lookup.subtables |
| 14946 |
local features=lookup.features |
| 14947 |
local handler=lookuphandlers[lookuptype] |
| 14948 |
if handler then |
| 14949 |
local nofsubtables=#subtables |
| 14950 |
local order=lookup.order |
| 14951 |
local flags=lookup.flags |
| 14952 |
if flags[1] then flags[1]="mark" end |
| 14953 |
if flags[2] then flags[2]="ligature" end |
| 14954 |
if flags[3] then flags[3]="base" end |
| 14955 |
local markclass=lookup.markclass |
| 14956 |
if nofsubtables>0 then |
| 14957 |
local steps={} |
| 14958 |
local nofsteps=0 |
| 14959 |
local oldtype=nil |
| 14960 |
for s=1,nofsubtables do |
| 14961 |
local step,lt=handler(f,fontdata,lookupid,lookupoffset,subtables[s],glyphs,nofglyphs) |
| 14962 |
if lt then |
| 14963 |
lookuptype=lt |
| 14964 |
if oldtype and lt~=oldtype then |
| 14965 |
report("messy %s lookup type %a and %a",what,lookuptype,oldtype) |
| 14966 |
end |
| 14967 |
oldtype=lookuptype |
| 14968 |
end |
| 14969 |
if not step then |
| 14970 |
report("unsupported %s lookup type %a",what,lookuptype) |
| 14971 |
else |
| 14972 |
nofsteps=nofsteps+1 |
| 14973 |
steps[nofsteps]=step |
| 14974 |
local rules=step.rules |
| 14975 |
if rules then |
| 14976 |
allsteps[#allsteps+1]=step |
| 14977 |
for i=1,#rules do |
| 14978 |
local rule=rules[i] |
| 14979 |
local before=rule.before |
| 14980 |
local current=rule.current |
| 14981 |
local after=rule.after |
| 14982 |
local replacements=rule.replacements |
| 14983 |
if before then |
| 14984 |
for i=1,#before do |
| 14985 |
before[i]=tohash(before[i]) |
| 14986 |
end |
| 14987 |
rule.before=reversed(before) |
| 14988 |
end |
| 14989 |
if current then |
| 14990 |
if replacements then |
| 14991 |
local first=current[1] |
| 14992 |
local hash={} |
| 14993 |
local repl={} |
| 14994 |
for i=1,#first do |
| 14995 |
local c=first[i] |
| 14996 |
hash[c]=true |
| 14997 |
repl[c]=replacements[i] |
| 14998 |
end |
| 14999 |
rule.current={ hash } |
| 15000 |
rule.replacements=repl |
| 15001 |
else |
| 15002 |
for i=1,#current do |
| 15003 |
current[i]=tohash(current[i]) |
| 15004 |
end |
| 15005 |
end |
| 15006 |
else |
| 15007 |
end |
| 15008 |
if after then |
| 15009 |
for i=1,#after do |
| 15010 |
after[i]=tohash(after[i]) |
| 15011 |
end |
| 15012 |
end |
| 15013 |
if usedlookups then |
| 15014 |
local lookups=rule.lookups |
| 15015 |
if lookups then |
| 15016 |
for k,v in next,lookups do |
| 15017 |
if v then |
| 15018 |
for k,v in next,v do |
| 15019 |
usedlookups[v]=usedlookups[v]+1 |
| 15020 |
end |
| 15021 |
end |
| 15022 |
end |
| 15023 |
end |
| 15024 |
end |
| 15025 |
end |
| 15026 |
end |
| 15027 |
end |
| 15028 |
end |
| 15029 |
if nofsteps~=nofsubtables then |
| 15030 |
report("bogus subtables removed in %s lookup type %a",what,lookuptype) |
| 15031 |
end |
| 15032 |
lookuptype=lookupnames[lookuptype] or lookuptype |
| 15033 |
if features then |
| 15034 |
nofsequences=nofsequences+1 |
| 15035 |
local l={ |
| 15036 |
index=nofsequences, |
| 15037 |
name=f_lookupname(lookupprefix,"s",lookupid+lookupidoffset), |
| 15038 |
steps=steps, |
| 15039 |
nofsteps=nofsteps, |
| 15040 |
type=lookuptype, |
| 15041 |
markclass=markclass or nil, |
| 15042 |
flags=flags, |
| 15043 |
order=order, |
| 15044 |
features=features, |
| 15045 |
} |
| 15046 |
sequences[nofsequences]=l |
| 15047 |
lookup.done=l |
| 15048 |
else |
| 15049 |
nofsublookups=nofsublookups+1 |
| 15050 |
local l={ |
| 15051 |
index=nofsublookups, |
| 15052 |
name=f_lookupname(lookupprefix,"l",lookupid+lookupidoffset), |
| 15053 |
steps=steps, |
| 15054 |
nofsteps=nofsteps, |
| 15055 |
type=lookuptype, |
| 15056 |
markclass=markclass or nil, |
| 15057 |
flags=flags, |
| 15058 |
} |
| 15059 |
sublookuplist[nofsublookups]=l |
| 15060 |
sublookuphash[lookupid]=nofsublookups |
| 15061 |
sublookupcheck[lookupid]=0 |
| 15062 |
lookup.done=l |
| 15063 |
end |
| 15064 |
else |
| 15065 |
report("no subtables for lookup %a",lookupid) |
| 15066 |
end |
| 15067 |
else |
| 15068 |
report("no handler for lookup %a with type %a",lookupid,lookuptype) |
| 15069 |
end |
| 15070 |
end |
| 15071 |
if usedlookups then |
| 15072 |
report("used %s lookups: % t",what,sortedkeys(usedlookups)) |
| 15073 |
end |
| 15074 |
local reported={} |
| 15075 |
local function report_issue(i,what,step,kind) |
| 15076 |
report("rule %i in step %i of %s has %s lookups",i,step,what,kind) |
| 15077 |
end |
| 15078 |
for s=1,#allsteps do |
| 15079 |
local step=allsteps[s] |
| 15080 |
local rules=step.rules |
| 15081 |
if rules then |
| 15082 |
for i=1,#rules do |
| 15083 |
local rule=rules[i] |
| 15084 |
local rlookups=rule.lookups |
| 15085 |
if not rlookups then |
| 15086 |
report_issue(i,what,s,"no") |
| 15087 |
elseif not next(rlookups) then |
| 15088 |
rule.lookups=nil |
| 15089 |
else |
| 15090 |
local length=#rlookups |
| 15091 |
for index=1,length do |
| 15092 |
local lookuplist=rlookups[index] |
| 15093 |
if lookuplist then |
| 15094 |
local length=#lookuplist |
| 15095 |
local found={} |
| 15096 |
local noffound=0 |
| 15097 |
for index=1,length do |
| 15098 |
local lookupid=lookuplist[index] |
| 15099 |
if lookupid then |
| 15100 |
local h=sublookuphash[lookupid] |
| 15101 |
if not h then |
| 15102 |
local lookup=lookups[lookupid] |
| 15103 |
if lookup then |
| 15104 |
local d=lookup.done |
| 15105 |
if d then |
| 15106 |
nofsublookups=nofsublookups+1 |
| 15107 |
local l={ |
| 15108 |
index=nofsublookups, |
| 15109 |
name=f_lookupname(lookupprefix,"d",lookupid+lookupidoffset), |
| 15110 |
derived=true, |
| 15111 |
steps=d.steps, |
| 15112 |
nofsteps=d.nofsteps, |
| 15113 |
type=d.lookuptype or "gsub_single", |
| 15114 |
markclass=d.markclass or nil, |
| 15115 |
flags=d.flags, |
| 15116 |
} |
| 15117 |
sublookuplist[nofsublookups]=copy(l) |
| 15118 |
sublookuphash[lookupid]=nofsublookups |
| 15119 |
sublookupcheck[lookupid]=1 |
| 15120 |
h=nofsublookups |
| 15121 |
else |
| 15122 |
report_issue(i,what,s,"missing") |
| 15123 |
rule.lookups=nil |
| 15124 |
break |
| 15125 |
end |
| 15126 |
else |
| 15127 |
report_issue(i,what,s,"bad") |
| 15128 |
rule.lookups=nil |
| 15129 |
break |
| 15130 |
end |
| 15131 |
else |
| 15132 |
sublookupcheck[lookupid]=sublookupcheck[lookupid]+1 |
| 15133 |
end |
| 15134 |
if h then |
| 15135 |
noffound=noffound+1 |
| 15136 |
found[noffound]=h |
| 15137 |
end |
| 15138 |
end |
| 15139 |
end |
| 15140 |
rlookups[index]=noffound>0 and found or false |
| 15141 |
else |
| 15142 |
rlookups[index]=false |
| 15143 |
end |
| 15144 |
end |
| 15145 |
end |
| 15146 |
end |
| 15147 |
end |
| 15148 |
end |
| 15149 |
for i,n in sortedhash(sublookupcheck) do |
| 15150 |
local l=lookups[i] |
| 15151 |
local t=l.type |
| 15152 |
if n==0 and t~="extension" then |
| 15153 |
local d=l.done |
| 15154 |
report("%s lookup %s of type %a is not used",what,d and d.name or l.name,t) |
| 15155 |
end |
| 15156 |
end |
| 15157 |
end |
| 15158 |
local function loadvariations(f,fontdata,variationsoffset,lookuptypes,featurehash,featureorder) |
| 15159 |
setposition(f,variationsoffset) |
| 15160 |
local version=readulong(f) |
| 15161 |
local nofrecords=readulong(f) |
| 15162 |
local records={} |
| 15163 |
for i=1,nofrecords do |
| 15164 |
records[i]={ |
| 15165 |
conditions=readulong(f), |
| 15166 |
substitutions=readulong(f), |
| 15167 |
} |
| 15168 |
end |
| 15169 |
for i=1,nofrecords do |
| 15170 |
local record=records[i] |
| 15171 |
local offset=record.conditions |
| 15172 |
if offset==0 then |
| 15173 |
record.condition=nil |
| 15174 |
record.matchtype="always" |
| 15175 |
else |
| 15176 |
local offset=variationsoffset+offset |
| 15177 |
setposition(f,offset) |
| 15178 |
local nofconditions=readushort(f) |
| 15179 |
local conditions={} |
| 15180 |
for i=1,nofconditions do |
| 15181 |
conditions[i]=offset+readulong(f) |
| 15182 |
end |
| 15183 |
record.conditions=conditions |
| 15184 |
record.matchtype="condition" |
| 15185 |
end |
| 15186 |
end |
| 15187 |
for i=1,nofrecords do |
| 15188 |
local record=records[i] |
| 15189 |
if record.matchtype=="condition" then |
| 15190 |
local conditions=record.conditions |
| 15191 |
for i=1,#conditions do |
| 15192 |
setposition(f,conditions[i]) |
| 15193 |
conditions[i]={ |
| 15194 |
format=readushort(f), |
| 15195 |
axis=readushort(f), |
| 15196 |
minvalue=read2dot14(f), |
| 15197 |
maxvalue=read2dot14(f), |
| 15198 |
} |
| 15199 |
end |
| 15200 |
end |
| 15201 |
end |
| 15202 |
for i=1,nofrecords do |
| 15203 |
local record=records[i] |
| 15204 |
local offset=record.substitutions |
| 15205 |
if offset==0 then |
| 15206 |
record.substitutions={} |
| 15207 |
else |
| 15208 |
setposition(f,variationsoffset+offset) |
| 15209 |
local version=readulong(f) |
| 15210 |
local nofsubstitutions=readushort(f) |
| 15211 |
local substitutions={} |
| 15212 |
for i=1,nofsubstitutions do |
| 15213 |
substitutions[readushort(f)]=readulong(f) |
| 15214 |
end |
| 15215 |
for index,alternates in sortedhash(substitutions) do |
| 15216 |
if index==0 then |
| 15217 |
record.substitutions=false |
| 15218 |
else |
| 15219 |
local tableoffset=variationsoffset+offset+alternates |
| 15220 |
setposition(f,tableoffset) |
| 15221 |
local parameters=readulong(f) |
| 15222 |
local noflookups=readushort(f) |
| 15223 |
local lookups=readcardinaltable(f,noflookups,ushort) |
| 15224 |
record.substitutions=lookups |
| 15225 |
end |
| 15226 |
end |
| 15227 |
end |
| 15228 |
end |
| 15229 |
setvariabledata(fontdata,"features",records) |
| 15230 |
end |
| 15231 |
local function readscripts(f,fontdata,what,lookuptypes,lookuphandlers,lookupstoo) |
| 15232 |
local tableoffset=gotodatatable(f,fontdata,what,true) |
| 15233 |
if tableoffset then |
| 15234 |
local version=readulong(f) |
| 15235 |
local scriptoffset=tableoffset+readushort(f) |
| 15236 |
local featureoffset=tableoffset+readushort(f) |
| 15237 |
local lookupoffset=tableoffset+readushort(f) |
| 15238 |
local variationsoffset=version>0x00010000 and readulong(f) or 0 |
| 15239 |
if not scriptoffset then |
| 15240 |
return |
| 15241 |
end |
| 15242 |
local scripts=readscriplan(f,fontdata,scriptoffset) |
| 15243 |
local features=readfeatures(f,fontdata,featureoffset) |
| 15244 |
local scriptlangs,featurehash,featureorder=reorderfeatures(fontdata,scripts,features) |
| 15245 |
if fontdata.features then |
| 15246 |
fontdata.features[what]=scriptlangs |
| 15247 |
else |
| 15248 |
fontdata.features={ [what]=scriptlangs } |
| 15249 |
end |
| 15250 |
if not lookupstoo then |
| 15251 |
return |
| 15252 |
end |
| 15253 |
local nofmarkclasses=(fontdata.markclasses and #fontdata.markclasses or 0)-(fontdata.marksets and #fontdata.marksets or 0) |
| 15254 |
local lookups=readlookups(f,lookupoffset,lookuptypes,featurehash,featureorder,nofmarkclasses) |
| 15255 |
if lookups then |
| 15256 |
resolvelookups(f,lookupoffset,fontdata,lookups,lookuptypes,lookuphandlers,what,tableoffset) |
| 15257 |
end |
| 15258 |
if variationsoffset>0 then |
| 15259 |
loadvariations(f,fontdata,tableoffset+variationsoffset,lookuptypes,featurehash,featureorder) |
| 15260 |
end |
| 15261 |
end |
| 15262 |
end |
| 15263 |
local function checkkerns(f,fontdata,specification) |
| 15264 |
local datatable=fontdata.tables.kern |
| 15265 |
if not datatable then |
| 15266 |
return |
| 15267 |
end |
| 15268 |
local features=fontdata.features |
| 15269 |
local gposfeatures=features and features.gpos |
| 15270 |
local name |
| 15271 |
if not gposfeatures or not gposfeatures.kern then |
| 15272 |
name="kern" |
| 15273 |
elseif specification.globalkerns then |
| 15274 |
name="globalkern" |
| 15275 |
else |
| 15276 |
report("ignoring global kern table, using gpos kern feature") |
| 15277 |
return |
| 15278 |
end |
| 15279 |
setposition(f,datatable.offset) |
| 15280 |
local version=readushort(f) |
| 15281 |
local noftables=readushort(f) |
| 15282 |
if noftables>1 then |
| 15283 |
report("adding global kern table as gpos feature %a",name) |
| 15284 |
local kerns=setmetatableindex("table") |
| 15285 |
for i=1,noftables do |
| 15286 |
local version=readushort(f) |
| 15287 |
local length=readushort(f) |
| 15288 |
local coverage=readushort(f) |
| 15289 |
local format=rshift(coverage,8) |
| 15290 |
if format==0 then |
| 15291 |
local nofpairs=readushort(f) |
| 15292 |
local searchrange=readushort(f) |
| 15293 |
local entryselector=readushort(f) |
| 15294 |
local rangeshift=readushort(f) |
| 15295 |
for i=1,nofpairs do |
| 15296 |
kerns[readushort(f)][readushort(f)]=readfword(f) |
| 15297 |
end |
| 15298 |
elseif format==2 then |
| 15299 |
else |
| 15300 |
end |
| 15301 |
end |
| 15302 |
local feature={ dflt={ dflt=true } } |
| 15303 |
if not features then |
| 15304 |
fontdata.features={ gpos={ [name]=feature } } |
| 15305 |
elseif not gposfeatures then |
| 15306 |
fontdata.features.gpos={ [name]=feature } |
| 15307 |
else |
| 15308 |
gposfeatures[name]=feature |
| 15309 |
end |
| 15310 |
local sequences=fontdata.sequences |
| 15311 |
if not sequences then |
| 15312 |
sequences={} |
| 15313 |
fontdata.sequences=sequences |
| 15314 |
end |
| 15315 |
local nofsequences=#sequences+1 |
| 15316 |
sequences[nofsequences]={ |
| 15317 |
index=nofsequences, |
| 15318 |
name=name, |
| 15319 |
steps={ |
| 15320 |
{ |
| 15321 |
coverage=kerns, |
| 15322 |
format="kern", |
| 15323 |
}, |
| 15324 |
}, |
| 15325 |
nofsteps=1, |
| 15326 |
type="gpos_pair", |
| 15327 |
flags={ false,false,false,false }, |
| 15328 |
order={ name }, |
| 15329 |
features={ [name]=feature }, |
| 15330 |
} |
| 15331 |
else |
| 15332 |
report("ignoring empty kern table of feature %a",name) |
| 15333 |
end |
| 15334 |
end |
| 15335 |
function readers.gsub(f,fontdata,specification) |
| 15336 |
if specification.details then |
| 15337 |
readscripts(f,fontdata,"gsub",gsubtypes,gsubhandlers,specification.lookups) |
| 15338 |
end |
| 15339 |
end |
| 15340 |
function readers.gpos(f,fontdata,specification) |
| 15341 |
if specification.details then |
| 15342 |
readscripts(f,fontdata,"gpos",gpostypes,gposhandlers,specification.lookups) |
| 15343 |
if specification.lookups then |
| 15344 |
checkkerns(f,fontdata,specification) |
| 15345 |
end |
| 15346 |
end |
| 15347 |
end |
| 15348 |
end |
| 15349 |
function readers.gdef(f,fontdata,specification) |
| 15350 |
if not specification.glyphs then |
| 15351 |
return |
| 15352 |
end |
| 15353 |
local datatable=fontdata.tables.gdef |
| 15354 |
if datatable then |
| 15355 |
local tableoffset=datatable.offset |
| 15356 |
setposition(f,tableoffset) |
| 15357 |
local version=readulong(f) |
| 15358 |
local classoffset=readushort(f) |
| 15359 |
local attachmentoffset=readushort(f) |
| 15360 |
local ligaturecarets=readushort(f) |
| 15361 |
local markclassoffset=readushort(f) |
| 15362 |
local marksetsoffset=version>=0x00010002 and readushort(f) or 0 |
| 15363 |
local varsetsoffset=version>=0x00010003 and readulong(f) or 0 |
| 15364 |
local glyphs=fontdata.glyphs |
| 15365 |
local marks={} |
| 15366 |
local markclasses=setmetatableindex("table") |
| 15367 |
local marksets=setmetatableindex("table") |
| 15368 |
fontdata.marks=marks |
| 15369 |
fontdata.markclasses=markclasses |
| 15370 |
fontdata.marksets=marksets |
| 15371 |
if classoffset~=0 then |
| 15372 |
setposition(f,tableoffset+classoffset) |
| 15373 |
local classformat=readushort(f) |
| 15374 |
if classformat==1 then |
| 15375 |
local firstindex=readushort(f) |
| 15376 |
local lastindex=firstindex+readushort(f)-1 |
| 15377 |
for index=firstindex,lastindex do |
| 15378 |
local class=classes[readushort(f)] |
| 15379 |
if class=="mark" then |
| 15380 |
marks[index]=true |
| 15381 |
end |
| 15382 |
glyphs[index].class=class |
| 15383 |
end |
| 15384 |
elseif classformat==2 then |
| 15385 |
local nofranges=readushort(f) |
| 15386 |
for i=1,nofranges do |
| 15387 |
local firstindex=readushort(f) |
| 15388 |
local lastindex=readushort(f) |
| 15389 |
local class=classes[readushort(f)] |
| 15390 |
if class then |
| 15391 |
for index=firstindex,lastindex do |
| 15392 |
glyphs[index].class=class |
| 15393 |
if class=="mark" then |
| 15394 |
marks[index]=true |
| 15395 |
end |
| 15396 |
end |
| 15397 |
end |
| 15398 |
end |
| 15399 |
end |
| 15400 |
end |
| 15401 |
if markclassoffset~=0 then |
| 15402 |
setposition(f,tableoffset+markclassoffset) |
| 15403 |
local classformat=readushort(f) |
| 15404 |
if classformat==1 then |
| 15405 |
local firstindex=readushort(f) |
| 15406 |
local lastindex=firstindex+readushort(f)-1 |
| 15407 |
for index=firstindex,lastindex do |
| 15408 |
markclasses[readushort(f)][index]=true |
| 15409 |
end |
| 15410 |
elseif classformat==2 then |
| 15411 |
local nofranges=readushort(f) |
| 15412 |
for i=1,nofranges do |
| 15413 |
local firstindex=readushort(f) |
| 15414 |
local lastindex=readushort(f) |
| 15415 |
local class=markclasses[readushort(f)] |
| 15416 |
for index=firstindex,lastindex do |
| 15417 |
class[index]=true |
| 15418 |
end |
| 15419 |
end |
| 15420 |
end |
| 15421 |
end |
| 15422 |
if marksetsoffset~=0 then |
| 15423 |
local nofmarkclasses=fontdata.markclasses and #fontdata.markclasses or 0 |
| 15424 |
marksetsoffset=tableoffset+marksetsoffset |
| 15425 |
setposition(f,marksetsoffset) |
| 15426 |
local format=readushort(f) |
| 15427 |
if format==1 then |
| 15428 |
local nofsets=readushort(f) |
| 15429 |
local sets=readcardinaltable(f,nofsets,ulong) |
| 15430 |
for i=1,nofsets do |
| 15431 |
local offset=sets[i] |
| 15432 |
if offset~=0 then |
| 15433 |
markclasses[nofmarkclasses+i]=readcoverage(f,marksetsoffset+offset) |
| 15434 |
marksets[i]={} |
| 15435 |
end |
| 15436 |
end |
| 15437 |
end |
| 15438 |
end |
| 15439 |
local factors=specification.factors |
| 15440 |
if (specification.variable or factors) and varsetsoffset~=0 then |
| 15441 |
local regions,deltas=readvariationdata(f,tableoffset+varsetsoffset,factors) |
| 15442 |
if factors then |
| 15443 |
fontdata.temporary.getdelta=function(outer,inner) |
| 15444 |
local delta=deltas[outer+1] |
| 15445 |
if delta then |
| 15446 |
local d=delta.deltas[inner+1] |
| 15447 |
if d then |
| 15448 |
local scales=delta.scales |
| 15449 |
local dd=0 |
| 15450 |
for i=1,#scales do |
| 15451 |
local di=d[i] |
| 15452 |
if di then |
| 15453 |
dd=dd+scales[i]*di |
| 15454 |
else |
| 15455 |
break |
| 15456 |
end |
| 15457 |
end |
| 15458 |
return round(dd) |
| 15459 |
end |
| 15460 |
end |
| 15461 |
return 0 |
| 15462 |
end |
| 15463 |
end |
| 15464 |
end |
| 15465 |
end |
| 15466 |
end |
| 15467 |
local function readmathvalue(f) |
| 15468 |
local v=readshort(f) |
| 15469 |
skipshort(f,1) |
| 15470 |
return v |
| 15471 |
end |
| 15472 |
local function readmathconstants(f,fontdata,offset) |
| 15473 |
setposition(f,offset) |
| 15474 |
fontdata.mathconstants={ |
| 15475 |
ScriptPercentScaleDown=readshort(f), |
| 15476 |
ScriptScriptPercentScaleDown=readshort(f), |
| 15477 |
DelimitedSubFormulaMinHeight=readushort(f), |
| 15478 |
DisplayOperatorMinHeight=readushort(f), |
| 15479 |
MathLeading=readmathvalue(f), |
| 15480 |
AxisHeight=readmathvalue(f), |
| 15481 |
AccentBaseHeight=readmathvalue(f), |
| 15482 |
FlattenedAccentBaseHeight=readmathvalue(f), |
| 15483 |
SubscriptShiftDown=readmathvalue(f), |
| 15484 |
SubscriptTopMax=readmathvalue(f), |
| 15485 |
SubscriptBaselineDropMin=readmathvalue(f), |
| 15486 |
SuperscriptShiftUp=readmathvalue(f), |
| 15487 |
SuperscriptShiftUpCramped=readmathvalue(f), |
| 15488 |
SuperscriptBottomMin=readmathvalue(f), |
| 15489 |
SuperscriptBaselineDropMax=readmathvalue(f), |
| 15490 |
SubSuperscriptGapMin=readmathvalue(f), |
| 15491 |
SuperscriptBottomMaxWithSubscript=readmathvalue(f), |
| 15492 |
SpaceAfterScript=readmathvalue(f), |
| 15493 |
UpperLimitGapMin=readmathvalue(f), |
| 15494 |
UpperLimitBaselineRiseMin=readmathvalue(f), |
| 15495 |
LowerLimitGapMin=readmathvalue(f), |
| 15496 |
LowerLimitBaselineDropMin=readmathvalue(f), |
| 15497 |
StackTopShiftUp=readmathvalue(f), |
| 15498 |
StackTopDisplayStyleShiftUp=readmathvalue(f), |
| 15499 |
StackBottomShiftDown=readmathvalue(f), |
| 15500 |
StackBottomDisplayStyleShiftDown=readmathvalue(f), |
| 15501 |
StackGapMin=readmathvalue(f), |
| 15502 |
StackDisplayStyleGapMin=readmathvalue(f), |
| 15503 |
StretchStackTopShiftUp=readmathvalue(f), |
| 15504 |
StretchStackBottomShiftDown=readmathvalue(f), |
| 15505 |
StretchStackGapAboveMin=readmathvalue(f), |
| 15506 |
StretchStackGapBelowMin=readmathvalue(f), |
| 15507 |
FractionNumeratorShiftUp=readmathvalue(f), |
| 15508 |
FractionNumeratorDisplayStyleShiftUp=readmathvalue(f), |
| 15509 |
FractionDenominatorShiftDown=readmathvalue(f), |
| 15510 |
FractionDenominatorDisplayStyleShiftDown=readmathvalue(f), |
| 15511 |
FractionNumeratorGapMin=readmathvalue(f), |
| 15512 |
FractionNumeratorDisplayStyleGapMin=readmathvalue(f), |
| 15513 |
FractionRuleThickness=readmathvalue(f), |
| 15514 |
FractionDenominatorGapMin=readmathvalue(f), |
| 15515 |
FractionDenominatorDisplayStyleGapMin=readmathvalue(f), |
| 15516 |
SkewedFractionHorizontalGap=readmathvalue(f), |
| 15517 |
SkewedFractionVerticalGap=readmathvalue(f), |
| 15518 |
OverbarVerticalGap=readmathvalue(f), |
| 15519 |
OverbarRuleThickness=readmathvalue(f), |
| 15520 |
OverbarExtraAscender=readmathvalue(f), |
| 15521 |
UnderbarVerticalGap=readmathvalue(f), |
| 15522 |
UnderbarRuleThickness=readmathvalue(f), |
| 15523 |
UnderbarExtraDescender=readmathvalue(f), |
| 15524 |
RadicalVerticalGap=readmathvalue(f), |
| 15525 |
RadicalDisplayStyleVerticalGap=readmathvalue(f), |
| 15526 |
RadicalRuleThickness=readmathvalue(f), |
| 15527 |
RadicalExtraAscender=readmathvalue(f), |
| 15528 |
RadicalKernBeforeDegree=readmathvalue(f), |
| 15529 |
RadicalKernAfterDegree=readmathvalue(f), |
| 15530 |
RadicalDegreeBottomRaisePercent=readshort(f), |
| 15531 |
} |
| 15532 |
end |
| 15533 |
local function readmathglyphinfo(f,fontdata,offset) |
| 15534 |
setposition(f,offset) |
| 15535 |
local italics=readushort(f) |
| 15536 |
local accents=readushort(f) |
| 15537 |
local extensions=readushort(f) |
| 15538 |
local kerns=readushort(f) |
| 15539 |
local glyphs=fontdata.glyphs |
| 15540 |
if italics~=0 then |
| 15541 |
setposition(f,offset+italics) |
| 15542 |
local coverage=readushort(f) |
| 15543 |
local nofglyphs=readushort(f) |
| 15544 |
coverage=readcoverage(f,offset+italics+coverage,true) |
| 15545 |
setposition(f,offset+italics+4) |
| 15546 |
for i=1,nofglyphs do |
| 15547 |
local italic=readmathvalue(f) |
| 15548 |
if italic~=0 then |
| 15549 |
local glyph=glyphs[coverage[i]] |
| 15550 |
local math=glyph.math |
| 15551 |
if not math then |
| 15552 |
glyph.math={ italic=italic } |
| 15553 |
else |
| 15554 |
math.italic=italic |
| 15555 |
end |
| 15556 |
end |
| 15557 |
end |
| 15558 |
fontdata.hasitalics=true |
| 15559 |
end |
| 15560 |
if accents~=0 then |
| 15561 |
setposition(f,offset+accents) |
| 15562 |
local coverage=readushort(f) |
| 15563 |
local nofglyphs=readushort(f) |
| 15564 |
coverage=readcoverage(f,offset+accents+coverage,true) |
| 15565 |
setposition(f,offset+accents+4) |
| 15566 |
for i=1,nofglyphs do |
| 15567 |
local accent=readmathvalue(f) |
| 15568 |
if accent~=0 then |
| 15569 |
local glyph=glyphs[coverage[i]] |
| 15570 |
local math=glyph.math |
| 15571 |
if not math then |
| 15572 |
glyph.math={ accent=accent } |
| 15573 |
else |
| 15574 |
math.accent=accent |
| 15575 |
end |
| 15576 |
end |
| 15577 |
end |
| 15578 |
end |
| 15579 |
if extensions~=0 then |
| 15580 |
setposition(f,offset+extensions) |
| 15581 |
end |
| 15582 |
if kerns~=0 then |
| 15583 |
local kernoffset=offset+kerns |
| 15584 |
setposition(f,kernoffset) |
| 15585 |
local coverage=readushort(f) |
| 15586 |
local nofglyphs=readushort(f) |
| 15587 |
if nofglyphs>0 then |
| 15588 |
local function get(offset) |
| 15589 |
setposition(f,kernoffset+offset) |
| 15590 |
local n=readushort(f) |
| 15591 |
if n==0 then |
| 15592 |
local k=readmathvalue(f) |
| 15593 |
if k==0 then |
| 15594 |
else |
| 15595 |
return { { kern=k } } |
| 15596 |
end |
| 15597 |
else |
| 15598 |
local l={} |
| 15599 |
for i=1,n do |
| 15600 |
l[i]={ height=readmathvalue(f) } |
| 15601 |
end |
| 15602 |
for i=1,n do |
| 15603 |
l[i].kern=readmathvalue(f) |
| 15604 |
end |
| 15605 |
l[n+1]={ kern=readmathvalue(f) } |
| 15606 |
return l |
| 15607 |
end |
| 15608 |
end |
| 15609 |
local kernsets={} |
| 15610 |
for i=1,nofglyphs do |
| 15611 |
local topright=readushort(f) |
| 15612 |
local topleft=readushort(f) |
| 15613 |
local bottomright=readushort(f) |
| 15614 |
local bottomleft=readushort(f) |
| 15615 |
kernsets[i]={ |
| 15616 |
topright=topright~=0 and topright or nil, |
| 15617 |
topleft=topleft~=0 and topleft or nil, |
| 15618 |
bottomright=bottomright~=0 and bottomright or nil, |
| 15619 |
bottomleft=bottomleft~=0 and bottomleft or nil, |
| 15620 |
} |
| 15621 |
end |
| 15622 |
coverage=readcoverage(f,kernoffset+coverage,true) |
| 15623 |
for i=1,nofglyphs do |
| 15624 |
local kernset=kernsets[i] |
| 15625 |
if next(kernset) then |
| 15626 |
local k=kernset.topright if k then kernset.topright=get(k) end |
| 15627 |
local k=kernset.topleft if k then kernset.topleft=get(k) end |
| 15628 |
local k=kernset.bottomright if k then kernset.bottomright=get(k) end |
| 15629 |
local k=kernset.bottomleft if k then kernset.bottomleft=get(k) end |
| 15630 |
if next(kernset) then |
| 15631 |
local glyph=glyphs[coverage[i]] |
| 15632 |
local math=glyph.math |
| 15633 |
if math then |
| 15634 |
math.kerns=kernset |
| 15635 |
else |
| 15636 |
glyph.math={ kerns=kernset } |
| 15637 |
end |
| 15638 |
end |
| 15639 |
end |
| 15640 |
end |
| 15641 |
end |
| 15642 |
end |
| 15643 |
end |
| 15644 |
local function readmathvariants(f,fontdata,offset) |
| 15645 |
setposition(f,offset) |
| 15646 |
local glyphs=fontdata.glyphs |
| 15647 |
local minoverlap=readushort(f) |
| 15648 |
local vcoverage=readushort(f) |
| 15649 |
local hcoverage=readushort(f) |
| 15650 |
local vnofglyphs=readushort(f) |
| 15651 |
local hnofglyphs=readushort(f) |
| 15652 |
local vconstruction=readcardinaltable(f,vnofglyphs,ushort) |
| 15653 |
local hconstruction=readcardinaltable(f,hnofglyphs,ushort) |
| 15654 |
fontdata.mathconstants.MinConnectorOverlap=minoverlap |
| 15655 |
local function get(offset,coverage,nofglyphs,construction,kvariants,kparts,kitalic,korientation,orientation) |
| 15656 |
if coverage~=0 and nofglyphs>0 then |
| 15657 |
local coverage=readcoverage(f,offset+coverage,true) |
| 15658 |
for i=1,nofglyphs do |
| 15659 |
local c=construction[i] |
| 15660 |
if c~=0 then |
| 15661 |
local index=coverage[i] |
| 15662 |
local glyph=glyphs[index] |
| 15663 |
local math=glyph.math |
| 15664 |
setposition(f,offset+c) |
| 15665 |
local assembly=readushort(f) |
| 15666 |
local nofvariants=readushort(f) |
| 15667 |
if nofvariants>0 then |
| 15668 |
local variants,v=nil,0 |
| 15669 |
for i=1,nofvariants do |
| 15670 |
local variant=readushort(f) |
| 15671 |
if variant==index then |
| 15672 |
elseif variants then |
| 15673 |
v=v+1 |
| 15674 |
variants[v]=variant |
| 15675 |
else |
| 15676 |
v=1 |
| 15677 |
variants={ variant } |
| 15678 |
end |
| 15679 |
skipshort(f) |
| 15680 |
end |
| 15681 |
if not variants then |
| 15682 |
elseif not math then |
| 15683 |
math={ [kvariants]=variants } |
| 15684 |
glyph.math=math |
| 15685 |
else |
| 15686 |
math[kvariants]=variants |
| 15687 |
end |
| 15688 |
end |
| 15689 |
if assembly~=0 then |
| 15690 |
setposition(f,offset+c+assembly) |
| 15691 |
local italic=readmathvalue(f) |
| 15692 |
local nofparts=readushort(f) |
| 15693 |
local parts={} |
| 15694 |
for i=1,nofparts do |
| 15695 |
local p={ |
| 15696 |
glyph=readushort(f), |
| 15697 |
start=readushort(f), |
| 15698 |
["end"]=readushort(f), |
| 15699 |
advance=readushort(f), |
| 15700 |
} |
| 15701 |
local flags=readushort(f) |
| 15702 |
if band(flags,0x0001)~=0 then |
| 15703 |
p.extender=1 |
| 15704 |
end |
| 15705 |
parts[i]=p |
| 15706 |
end |
| 15707 |
if not math then |
| 15708 |
math={ |
| 15709 |
[kparts]=parts |
| 15710 |
} |
| 15711 |
glyph.math=math |
| 15712 |
else |
| 15713 |
math[kparts]=parts |
| 15714 |
end |
| 15715 |
if italic and italic~=0 then |
| 15716 |
math[kitalic]=italic |
| 15717 |
end |
| 15718 |
if orientation then |
| 15719 |
math[korientation]=orientation |
| 15720 |
end |
| 15721 |
end |
| 15722 |
end |
| 15723 |
end |
| 15724 |
end |
| 15725 |
end |
| 15726 |
if CONTEXTLMTXMODE and CONTEXTLMTXMODE>0 then |
| 15727 |
get(offset,hcoverage,hnofglyphs,hconstruction,"variants","parts","partsitalic","partsorientation","horizontal") |
| 15728 |
get(offset,vcoverage,vnofglyphs,vconstruction,"variants","parts","partsitalic","partsorientation","vertical") |
| 15729 |
else |
| 15730 |
get(offset,vcoverage,vnofglyphs,vconstruction,"vvariants","vparts","vitalic") |
| 15731 |
get(offset,hcoverage,hnofglyphs,hconstruction,"hvariants","hparts","hitalic") |
| 15732 |
end |
| 15733 |
end |
| 15734 |
function readers.math(f,fontdata,specification) |
| 15735 |
local tableoffset=gotodatatable(f,fontdata,"math",specification.glyphs) |
| 15736 |
if tableoffset then |
| 15737 |
local version=readulong(f) |
| 15738 |
local constants=readushort(f) |
| 15739 |
local glyphinfo=readushort(f) |
| 15740 |
local variants=readushort(f) |
| 15741 |
if constants==0 then |
| 15742 |
report("the math table of %a has no constants",fontdata.filename) |
| 15743 |
else |
| 15744 |
readmathconstants(f,fontdata,tableoffset+constants) |
| 15745 |
end |
| 15746 |
if glyphinfo~=0 then |
| 15747 |
readmathglyphinfo(f,fontdata,tableoffset+glyphinfo) |
| 15748 |
end |
| 15749 |
if variants~=0 then |
| 15750 |
readmathvariants(f,fontdata,tableoffset+variants) |
| 15751 |
end |
| 15752 |
end |
| 15753 |
end |
| 15754 |
function readers.colr(f,fontdata,specification) |
| 15755 |
local tableoffset=gotodatatable(f,fontdata,"colr",specification.glyphs) |
| 15756 |
if tableoffset then |
| 15757 |
local version=readushort(f) |
| 15758 |
if version~=0 and version~=1 then |
| 15759 |
report("table version %a of %a is not supported (yet), maybe font %s is bad",version,"colr",fontdata.filename) |
| 15760 |
return |
| 15761 |
else |
| 15762 |
end |
| 15763 |
if not fontdata.tables.cpal then |
| 15764 |
report("color table %a in font %a has no mandate %a table","colr",fontdata.filename,"cpal") |
| 15765 |
fontdata.colorpalettes={} |
| 15766 |
end |
| 15767 |
local glyphs=fontdata.glyphs |
| 15768 |
local nofglyphs=readushort(f) |
| 15769 |
local baseoffset=readulong(f) |
| 15770 |
local layeroffset=readulong(f) |
| 15771 |
local noflayers=readushort(f) |
| 15772 |
local layerrecords={} |
| 15773 |
local maxclass=0 |
| 15774 |
setposition(f,tableoffset+layeroffset) |
| 15775 |
for i=1,noflayers do |
| 15776 |
local slot=readushort(f) |
| 15777 |
local class=readushort(f) |
| 15778 |
if class<0xFFFF then |
| 15779 |
class=class+1 |
| 15780 |
if class>maxclass then |
| 15781 |
maxclass=class |
| 15782 |
end |
| 15783 |
end |
| 15784 |
layerrecords[i]={ |
| 15785 |
slot=slot, |
| 15786 |
class=class, |
| 15787 |
} |
| 15788 |
end |
| 15789 |
fontdata.maxcolorclass=maxclass |
| 15790 |
setposition(f,tableoffset+baseoffset) |
| 15791 |
for i=0,nofglyphs-1 do |
| 15792 |
local glyphindex=readushort(f) |
| 15793 |
local firstlayer=readushort(f) |
| 15794 |
local noflayers=readushort(f) |
| 15795 |
local t={} |
| 15796 |
for i=1,noflayers do |
| 15797 |
t[i]=layerrecords[firstlayer+i] |
| 15798 |
end |
| 15799 |
glyphs[glyphindex].colors=t |
| 15800 |
end |
| 15801 |
end |
| 15802 |
fontdata.hascolor=true |
| 15803 |
end |
| 15804 |
function readers.cpal(f,fontdata,specification) |
| 15805 |
local tableoffset=gotodatatable(f,fontdata,"cpal",specification.glyphs) |
| 15806 |
if tableoffset then |
| 15807 |
local version=readushort(f) |
| 15808 |
local nofpaletteentries=readushort(f) |
| 15809 |
local nofpalettes=readushort(f) |
| 15810 |
local nofcolorrecords=readushort(f) |
| 15811 |
local firstcoloroffset=readulong(f) |
| 15812 |
local colorrecords={} |
| 15813 |
local palettes=readcardinaltable(f,nofpalettes,ushort) |
| 15814 |
if version==1 then |
| 15815 |
local palettettypesoffset=readulong(f) |
| 15816 |
local palettelabelsoffset=readulong(f) |
| 15817 |
local paletteentryoffset=readulong(f) |
| 15818 |
end |
| 15819 |
setposition(f,tableoffset+firstcoloroffset) |
| 15820 |
for i=1,nofcolorrecords do |
| 15821 |
local b,g,r,a=readbytes(f,4) |
| 15822 |
colorrecords[i]={ |
| 15823 |
r,g,b,a~=255 and a or nil, |
| 15824 |
} |
| 15825 |
end |
| 15826 |
for i=1,nofpalettes do |
| 15827 |
local p={} |
| 15828 |
local o=palettes[i] |
| 15829 |
for j=1,nofpaletteentries do |
| 15830 |
p[j]=colorrecords[o+j] |
| 15831 |
end |
| 15832 |
palettes[i]=p |
| 15833 |
end |
| 15834 |
fontdata.colorpalettes=palettes |
| 15835 |
end |
| 15836 |
end |
| 15837 |
local compress=gzip and gzip.compress |
| 15838 |
local compressed=compress and gzip.compressed |
| 15839 |
function readers.svg(f,fontdata,specification) |
| 15840 |
local tableoffset=gotodatatable(f,fontdata,"svg",specification.glyphs) |
| 15841 |
if tableoffset then |
| 15842 |
local version=readushort(f) |
| 15843 |
local glyphs=fontdata.glyphs |
| 15844 |
local indexoffset=tableoffset+readulong(f) |
| 15845 |
local reserved=readulong(f) |
| 15846 |
setposition(f,indexoffset) |
| 15847 |
local nofentries=readushort(f) |
| 15848 |
local entries={} |
| 15849 |
for i=1,nofentries do |
| 15850 |
entries[i]={ |
| 15851 |
first=readushort(f), |
| 15852 |
last=readushort(f), |
| 15853 |
offset=indexoffset+readulong(f), |
| 15854 |
length=readulong(f), |
| 15855 |
} |
| 15856 |
end |
| 15857 |
for i=1,nofentries do |
| 15858 |
local entry=entries[i] |
| 15859 |
setposition(f,entry.offset) |
| 15860 |
local data=readstring(f,entry.length) |
| 15861 |
if compressed and not compressed(data) then |
| 15862 |
data=compress(data) |
| 15863 |
end |
| 15864 |
entries[i]={ |
| 15865 |
first=entry.first, |
| 15866 |
last=entry.last, |
| 15867 |
data=data |
| 15868 |
} |
| 15869 |
end |
| 15870 |
fontdata.svgshapes=entries |
| 15871 |
end |
| 15872 |
fontdata.hascolor=true |
| 15873 |
end |
| 15874 |
function readers.sbix(f,fontdata,specification) |
| 15875 |
local tableoffset=gotodatatable(f,fontdata,"sbix",specification.glyphs) |
| 15876 |
if tableoffset then |
| 15877 |
local version=readushort(f) |
| 15878 |
local flags=readushort(f) |
| 15879 |
local nofstrikes=readulong(f) |
| 15880 |
local strikes={} |
| 15881 |
local nofglyphs=fontdata.nofglyphs |
| 15882 |
for i=1,nofstrikes do |
| 15883 |
strikes[i]=readulong(f) |
| 15884 |
end |
| 15885 |
local shapes={} |
| 15886 |
local done=0 |
| 15887 |
for i=1,nofstrikes do |
| 15888 |
local strikeoffset=strikes[i]+tableoffset |
| 15889 |
setposition(f,strikeoffset) |
| 15890 |
strikes[i]={ |
| 15891 |
ppem=readushort(f), |
| 15892 |
ppi=readushort(f), |
| 15893 |
offset=strikeoffset |
| 15894 |
} |
| 15895 |
end |
| 15896 |
sort(strikes,function(a,b) |
| 15897 |
if b.ppem==a.ppem then |
| 15898 |
return b.ppi<a.ppi |
| 15899 |
else |
| 15900 |
return b.ppem<a.ppem |
| 15901 |
end |
| 15902 |
end) |
| 15903 |
local glyphs={} |
| 15904 |
local delayed=CONTEXTLMTXMODE and CONTEXTLMTXMODE>0 or fonts.handlers.typethree |
| 15905 |
for i=1,nofstrikes do |
| 15906 |
local strike=strikes[i] |
| 15907 |
local strikeppem=strike.ppem |
| 15908 |
local strikeppi=strike.ppi |
| 15909 |
local strikeoffset=strike.offset |
| 15910 |
setposition(f,strikeoffset) |
| 15911 |
for i=0,nofglyphs do |
| 15912 |
glyphs[i]=readulong(f) |
| 15913 |
end |
| 15914 |
local glyphoffset=glyphs[0] |
| 15915 |
for i=0,nofglyphs-1 do |
| 15916 |
local nextoffset=glyphs[i+1] |
| 15917 |
if not shapes[i] then |
| 15918 |
local datasize=nextoffset-glyphoffset |
| 15919 |
if datasize>0 then |
| 15920 |
setposition(f,strikeoffset+glyphoffset) |
| 15921 |
local x=readshort(f) |
| 15922 |
local y=readshort(f) |
| 15923 |
local tag=readtag(f) |
| 15924 |
local size=datasize-8 |
| 15925 |
local data=nil |
| 15926 |
local offset=nil |
| 15927 |
if delayed then |
| 15928 |
offset=getposition(f) |
| 15929 |
data=nil |
| 15930 |
else |
| 15931 |
data=readstring(f,size) |
| 15932 |
size=nil |
| 15933 |
end |
| 15934 |
shapes[i]={ |
| 15935 |
x=x, |
| 15936 |
y=y, |
| 15937 |
o=offset, |
| 15938 |
s=size, |
| 15939 |
data=data, |
| 15940 |
} |
| 15941 |
done=done+1 |
| 15942 |
if done==nofglyphs then |
| 15943 |
break |
| 15944 |
end |
| 15945 |
end |
| 15946 |
end |
| 15947 |
glyphoffset=nextoffset |
| 15948 |
end |
| 15949 |
end |
| 15950 |
fontdata.pngshapes=shapes |
| 15951 |
end |
| 15952 |
end |
| 15953 |
do |
| 15954 |
local function getmetrics(f) |
| 15955 |
return { |
| 15956 |
ascender=readinteger(f), |
| 15957 |
descender=readinteger(f), |
| 15958 |
widthmax=readuinteger(f), |
| 15959 |
caretslopedumerator=readinteger(f), |
| 15960 |
caretslopedenominator=readinteger(f), |
| 15961 |
caretoffset=readinteger(f), |
| 15962 |
minorigin=readinteger(f), |
| 15963 |
minadvance=readinteger(f), |
| 15964 |
maxbefore=readinteger(f), |
| 15965 |
minafter=readinteger(f), |
| 15966 |
pad1=readinteger(f), |
| 15967 |
pad2=readinteger(f), |
| 15968 |
} |
| 15969 |
end |
| 15970 |
local function getbigmetrics(f) |
| 15971 |
return { |
| 15972 |
height=readuinteger(f), |
| 15973 |
width=readuinteger(f), |
| 15974 |
horiBearingX=readinteger(f), |
| 15975 |
horiBearingY=readinteger(f), |
| 15976 |
horiAdvance=readuinteger(f), |
| 15977 |
vertBearingX=readinteger(f), |
| 15978 |
vertBearingY=readinteger(f), |
| 15979 |
vertAdvance=readuinteger(f), |
| 15980 |
} |
| 15981 |
end |
| 15982 |
local function getsmallmetrics(f) |
| 15983 |
return { |
| 15984 |
height=readuinteger(f), |
| 15985 |
width=readuinteger(f), |
| 15986 |
bearingX=readinteger(f), |
| 15987 |
bearingY=readinteger(f), |
| 15988 |
advance=readuinteger(f), |
| 15989 |
} |
| 15990 |
end |
| 15991 |
function readers.cblc(f,fontdata,specification) |
| 15992 |
local ctdttableoffset=gotodatatable(f,fontdata,"cbdt",specification.glyphs) |
| 15993 |
if not ctdttableoffset then |
| 15994 |
return |
| 15995 |
end |
| 15996 |
local cblctableoffset=gotodatatable(f,fontdata,"cblc",specification.glyphs) |
| 15997 |
if cblctableoffset then |
| 15998 |
local majorversion=readushort(f) |
| 15999 |
local minorversion=readushort(f) |
| 16000 |
local nofsizetables=readulong(f) |
| 16001 |
local sizetables={} |
| 16002 |
local shapes={} |
| 16003 |
local subtables={} |
| 16004 |
for i=1,nofsizetables do |
| 16005 |
sizetables[i]={ |
| 16006 |
subtables=readulong(f), |
| 16007 |
indexsize=readulong(f), |
| 16008 |
nofsubtables=readulong(f), |
| 16009 |
colorref=readulong(f), |
| 16010 |
hormetrics=getmetrics(f), |
| 16011 |
vermetrics=getmetrics(f), |
| 16012 |
firstindex=readushort(f), |
| 16013 |
lastindex=readushort(f), |
| 16014 |
ppemx=readbyte(f), |
| 16015 |
ppemy=readbyte(f), |
| 16016 |
bitdepth=readbyte(f), |
| 16017 |
flags=readbyte(f), |
| 16018 |
} |
| 16019 |
end |
| 16020 |
sort(sizetables,function(a,b) |
| 16021 |
if b.ppemx==a.ppemx then |
| 16022 |
return b.bitdepth<a.bitdepth |
| 16023 |
else |
| 16024 |
return b.ppemx<a.ppemx |
| 16025 |
end |
| 16026 |
end) |
| 16027 |
for i=1,nofsizetables do |
| 16028 |
local s=sizetables[i] |
| 16029 |
local d=false |
| 16030 |
for j=s.firstindex,s.lastindex do |
| 16031 |
if not shapes[j] then |
| 16032 |
shapes[j]=i |
| 16033 |
d=true |
| 16034 |
end |
| 16035 |
end |
| 16036 |
if d then |
| 16037 |
s.used=true |
| 16038 |
end |
| 16039 |
end |
| 16040 |
for i=1,nofsizetables do |
| 16041 |
local s=sizetables[i] |
| 16042 |
if s.used then |
| 16043 |
local offset=s.subtables |
| 16044 |
setposition(f,cblctableoffset+offset) |
| 16045 |
for j=1,s.nofsubtables do |
| 16046 |
local firstindex=readushort(f) |
| 16047 |
local lastindex=readushort(f) |
| 16048 |
local tableoffset=readulong(f)+offset |
| 16049 |
for k=firstindex,lastindex do |
| 16050 |
if shapes[k]==i then |
| 16051 |
local s=subtables[tableoffset] |
| 16052 |
if not s then |
| 16053 |
s={ |
| 16054 |
firstindex=firstindex, |
| 16055 |
lastindex=lastindex, |
| 16056 |
} |
| 16057 |
subtables[tableoffset]=s |
| 16058 |
end |
| 16059 |
shapes[k]=s |
| 16060 |
end |
| 16061 |
end |
| 16062 |
end |
| 16063 |
end |
| 16064 |
end |
| 16065 |
for offset,subtable in sortedhash(subtables) do |
| 16066 |
local tabletype=readushort(f) |
| 16067 |
subtable.format=readushort(f) |
| 16068 |
local baseoffset=readulong(f)+ctdttableoffset |
| 16069 |
local offsets={} |
| 16070 |
local metrics=nil |
| 16071 |
if tabletype==1 then |
| 16072 |
for i=subtable.firstindex,subtable.lastindex do |
| 16073 |
offsets[i]=readulong(f)+baseoffset |
| 16074 |
end |
| 16075 |
skipbytes(f,4) |
| 16076 |
elseif tabletype==2 then |
| 16077 |
local size=readulong(f) |
| 16078 |
local done=baseoffset |
| 16079 |
metrics=getbigmetrics(f) |
| 16080 |
for i=subtable.firstindex,subtable.lastindex do |
| 16081 |
offsets[i]=done |
| 16082 |
done=done+size |
| 16083 |
end |
| 16084 |
elseif tabletype==3 then |
| 16085 |
local n=subtable.lastindex-subtable.firstindex+2 |
| 16086 |
for i=subtable.firstindex,subtable.lastindex do |
| 16087 |
offsets[i]=readushort(f)+baseoffset |
| 16088 |
end |
| 16089 |
if math.odd(n) then |
| 16090 |
skipbytes(f,4) |
| 16091 |
else |
| 16092 |
skipbytes(f,2) |
| 16093 |
end |
| 16094 |
elseif tabletype==4 then |
| 16095 |
for i=1,readulong(f) do |
| 16096 |
offsets[readushort(f)]=readushort(f)+baseoffset |
| 16097 |
end |
| 16098 |
elseif tabletype==5 then |
| 16099 |
local size=readulong(f) |
| 16100 |
local done=baseoffset |
| 16101 |
metrics=getbigmetrics(f) |
| 16102 |
local n=readulong(f) |
| 16103 |
for i=1,n do |
| 16104 |
offsets[readushort(f)]=done |
| 16105 |
done=done+size |
| 16106 |
end |
| 16107 |
if math.odd(n) then |
| 16108 |
skipbytes(f,2) |
| 16109 |
end |
| 16110 |
else |
| 16111 |
return |
| 16112 |
end |
| 16113 |
subtable.offsets=offsets |
| 16114 |
subtable.metrics=metrics |
| 16115 |
end |
| 16116 |
local default={ width=0,height=0 } |
| 16117 |
local glyphs=fontdata.glyphs |
| 16118 |
local delayed=CONTEXTLMTXMODE and CONTEXTLMTXMODE>0 or fonts.handlers.typethree |
| 16119 |
for index,subtable in sortedhash(shapes) do |
| 16120 |
if type(subtable)=="table" then |
| 16121 |
local data=nil |
| 16122 |
local size=nil |
| 16123 |
local metrics=default |
| 16124 |
local format=subtable.format |
| 16125 |
local offset=subtable.offsets[index] |
| 16126 |
setposition(f,offset) |
| 16127 |
if format==17 then |
| 16128 |
metrics=getsmallmetrics(f) |
| 16129 |
size=true |
| 16130 |
elseif format==18 then |
| 16131 |
metrics=getbigmetrics(f) |
| 16132 |
size=true |
| 16133 |
elseif format==19 then |
| 16134 |
metrics=subtable.metrics |
| 16135 |
size=true |
| 16136 |
else |
| 16137 |
end |
| 16138 |
if size then |
| 16139 |
size=readulong(f) |
| 16140 |
if delayed then |
| 16141 |
offset=getposition(f) |
| 16142 |
data=nil |
| 16143 |
else |
| 16144 |
offset=nil |
| 16145 |
data=readstring(f,size) |
| 16146 |
size=nil |
| 16147 |
end |
| 16148 |
else |
| 16149 |
offset=nil |
| 16150 |
end |
| 16151 |
local x=metrics.width |
| 16152 |
local y=metrics.height |
| 16153 |
shapes[index]={ |
| 16154 |
x=x, |
| 16155 |
y=y, |
| 16156 |
o=offset, |
| 16157 |
s=size, |
| 16158 |
data=data, |
| 16159 |
} |
| 16160 |
local glyph=glyphs[index] |
| 16161 |
if not glyph.boundingbox then |
| 16162 |
local width=glyph.width |
| 16163 |
local height=width*y/x |
| 16164 |
glyph.boundingbox={ 0,0,width,height } |
| 16165 |
end |
| 16166 |
else |
| 16167 |
shapes[index]={ |
| 16168 |
x=0, |
| 16169 |
y=0, |
| 16170 |
data="", |
| 16171 |
} |
| 16172 |
end |
| 16173 |
end |
| 16174 |
fontdata.pngshapes=shapes |
| 16175 |
end |
| 16176 |
end |
| 16177 |
function readers.cbdt(f,fontdata,specification) |
| 16178 |
end |
| 16179 |
end |
| 16180 |
function readers.stat(f,fontdata,specification) |
| 16181 |
local tableoffset=gotodatatable(f,fontdata,"stat",true) |
| 16182 |
if tableoffset then |
| 16183 |
local extras=fontdata.extras |
| 16184 |
local version=readulong(f) |
| 16185 |
local axissize=readushort(f) |
| 16186 |
local nofaxis=readushort(f) |
| 16187 |
local axisoffset=readulong(f) |
| 16188 |
local nofvalues=readushort(f) |
| 16189 |
local valuesoffset=readulong(f) |
| 16190 |
local fallbackname=extras[readushort(f)] |
| 16191 |
local axis={} |
| 16192 |
local values={} |
| 16193 |
setposition(f,tableoffset+axisoffset) |
| 16194 |
for i=1,nofaxis do |
| 16195 |
local tag=readtag(f) |
| 16196 |
axis[i]={ |
| 16197 |
tag=tag, |
| 16198 |
name=lower(extras[readushort(f)] or tag), |
| 16199 |
ordering=readushort(f), |
| 16200 |
variants={} |
| 16201 |
} |
| 16202 |
end |
| 16203 |
setposition(f,tableoffset+valuesoffset) |
| 16204 |
for i=1,nofvalues do |
| 16205 |
values[i]=readushort(f) |
| 16206 |
end |
| 16207 |
for i=1,nofvalues do |
| 16208 |
setposition(f,tableoffset+valuesoffset+values[i]) |
| 16209 |
local format=readushort(f) |
| 16210 |
local index=readushort(f)+1 |
| 16211 |
local flags=readushort(f) |
| 16212 |
local name=lower(extras[readushort(f)] or "no name") |
| 16213 |
local value=readfixed(f) |
| 16214 |
local variant |
| 16215 |
if format==1 then |
| 16216 |
variant={ |
| 16217 |
flags=flags, |
| 16218 |
name=name, |
| 16219 |
value=value, |
| 16220 |
} |
| 16221 |
elseif format==2 then |
| 16222 |
variant={ |
| 16223 |
flags=flags, |
| 16224 |
name=name, |
| 16225 |
value=value, |
| 16226 |
minimum=readfixed(f), |
| 16227 |
maximum=readfixed(f), |
| 16228 |
} |
| 16229 |
elseif format==3 then |
| 16230 |
variant={ |
| 16231 |
flags=flags, |
| 16232 |
name=name, |
| 16233 |
value=value, |
| 16234 |
link=readfixed(f), |
| 16235 |
} |
| 16236 |
end |
| 16237 |
insert(axis[index].variants,variant) |
| 16238 |
end |
| 16239 |
sort(axis,function(a,b) |
| 16240 |
return a.ordering<b.ordering |
| 16241 |
end) |
| 16242 |
for i=1,#axis do |
| 16243 |
local a=axis[i] |
| 16244 |
sort(a.variants,function(a,b) |
| 16245 |
return a.name<b.name |
| 16246 |
end) |
| 16247 |
a.ordering=nil |
| 16248 |
end |
| 16249 |
setvariabledata(fontdata,"designaxis",axis) |
| 16250 |
setvariabledata(fontdata,"fallbackname",fallbackname) |
| 16251 |
end |
| 16252 |
end |
| 16253 |
function readers.avar(f,fontdata,specification) |
| 16254 |
local tableoffset=gotodatatable(f,fontdata,"avar",true) |
| 16255 |
if tableoffset then |
| 16256 |
local function collect() |
| 16257 |
local nofvalues=readushort(f) |
| 16258 |
local values={} |
| 16259 |
local lastfrom=false |
| 16260 |
local lastto=false |
| 16261 |
for i=1,nofvalues do |
| 16262 |
local from=read2dot14(f) |
| 16263 |
local to=read2dot14(f) |
| 16264 |
if lastfrom and from<=lastfrom then |
| 16265 |
elseif lastto and to>=lastto then |
| 16266 |
else |
| 16267 |
values[#values+1]={ from,to } |
| 16268 |
lastfrom,lastto=from,to |
| 16269 |
end |
| 16270 |
end |
| 16271 |
nofvalues=#values |
| 16272 |
if nofvalues>2 then |
| 16273 |
local some=values[1] |
| 16274 |
if some[1]==-1 and some[2]==-1 then |
| 16275 |
some=values[nofvalues] |
| 16276 |
if some[1]==1 and some[2]==1 then |
| 16277 |
for i=2,nofvalues-1 do |
| 16278 |
some=values[i] |
| 16279 |
if some[1]==0 and some[2]==0 then |
| 16280 |
return values |
| 16281 |
end |
| 16282 |
end |
| 16283 |
end |
| 16284 |
end |
| 16285 |
end |
| 16286 |
return false |
| 16287 |
end |
| 16288 |
local version=readulong(f) |
| 16289 |
local reserved=readushort(f) |
| 16290 |
local nofaxis=readushort(f) |
| 16291 |
local segments={} |
| 16292 |
for i=1,nofaxis do |
| 16293 |
segments[i]=collect() |
| 16294 |
end |
| 16295 |
setvariabledata(fontdata,"segments",segments) |
| 16296 |
end |
| 16297 |
end |
| 16298 |
function readers.fvar(f,fontdata,specification) |
| 16299 |
local tableoffset=gotodatatable(f,fontdata,"fvar",true) |
| 16300 |
if tableoffset then |
| 16301 |
local version=readulong(f) |
| 16302 |
local offsettoaxis=tableoffset+readushort(f) |
| 16303 |
local reserved=skipshort(f) |
| 16304 |
local nofaxis=readushort(f) |
| 16305 |
local sizeofaxis=readushort(f) |
| 16306 |
local nofinstances=readushort(f) |
| 16307 |
local sizeofinstances=readushort(f) |
| 16308 |
local extras=fontdata.extras |
| 16309 |
local axis={} |
| 16310 |
local instances={} |
| 16311 |
setposition(f,offsettoaxis) |
| 16312 |
for i=1,nofaxis do |
| 16313 |
axis[i]={ |
| 16314 |
tag=readtag(f), |
| 16315 |
minimum=readfixed(f), |
| 16316 |
default=readfixed(f), |
| 16317 |
maximum=readfixed(f), |
| 16318 |
flags=readushort(f), |
| 16319 |
name=lower(extras[readushort(f)] or "bad name"), |
| 16320 |
} |
| 16321 |
local n=sizeofaxis-20 |
| 16322 |
if n>0 then |
| 16323 |
skipbytes(f,n) |
| 16324 |
elseif n<0 then |
| 16325 |
end |
| 16326 |
end |
| 16327 |
local nofbytes=2+2+2+nofaxis*4 |
| 16328 |
local readpsname=nofbytes<=sizeofinstances |
| 16329 |
local skippable=sizeofinstances-nofbytes |
| 16330 |
for i=1,nofinstances do |
| 16331 |
local subfamid=readushort(f) |
| 16332 |
local flags=readushort(f) |
| 16333 |
local values={} |
| 16334 |
for i=1,nofaxis do |
| 16335 |
values[i]={ |
| 16336 |
axis=axis[i].tag, |
| 16337 |
value=readfixed(f), |
| 16338 |
} |
| 16339 |
end |
| 16340 |
local psnameid=readpsname and readushort(f) or 0xFFFF |
| 16341 |
if subfamid==2 or subfamid==17 then |
| 16342 |
elseif subfamid==0xFFFF then |
| 16343 |
subfamid=nil |
| 16344 |
elseif subfamid<=256 or subfamid>=32768 then |
| 16345 |
subfamid=nil |
| 16346 |
end |
| 16347 |
if psnameid==6 then |
| 16348 |
elseif psnameid==0xFFFF then |
| 16349 |
psnameid=nil |
| 16350 |
elseif psnameid<=256 or psnameid>=32768 then |
| 16351 |
psnameid=nil |
| 16352 |
end |
| 16353 |
instances[i]={ |
| 16354 |
subfamily=extras[subfamid], |
| 16355 |
psname=psnameid and extras[psnameid] or nil, |
| 16356 |
values=values, |
| 16357 |
} |
| 16358 |
if skippable>0 then |
| 16359 |
skipbytes(f,skippable) |
| 16360 |
end |
| 16361 |
end |
| 16362 |
setvariabledata(fontdata,"axis",axis) |
| 16363 |
setvariabledata(fontdata,"instances",instances) |
| 16364 |
end |
| 16365 |
end |
| 16366 |
function readers.hvar(f,fontdata,specification) |
| 16367 |
local factors=specification.factors |
| 16368 |
if not factors then |
| 16369 |
return |
| 16370 |
end |
| 16371 |
local tableoffset=gotodatatable(f,fontdata,"hvar",specification.variable) |
| 16372 |
if not tableoffset then |
| 16373 |
return |
| 16374 |
end |
| 16375 |
local version=readulong(f) |
| 16376 |
local variationoffset=tableoffset+readulong(f) |
| 16377 |
local advanceoffset=tableoffset+readulong(f) |
| 16378 |
local lsboffset=tableoffset+readulong(f) |
| 16379 |
local rsboffset=tableoffset+readulong(f) |
| 16380 |
local regions={} |
| 16381 |
local variations={} |
| 16382 |
local innerindex={} |
| 16383 |
local outerindex={} |
| 16384 |
local deltas={} |
| 16385 |
if variationoffset>0 then |
| 16386 |
regions,deltas=readvariationdata(f,variationoffset,factors) |
| 16387 |
end |
| 16388 |
if not regions then |
| 16389 |
return |
| 16390 |
end |
| 16391 |
if advanceoffset>0 then |
| 16392 |
setposition(f,advanceoffset) |
| 16393 |
local format=readushort(f) |
| 16394 |
local mapcount=readushort(f) |
| 16395 |
local entrysize=rshift(band(format,0x0030),4)+1 |
| 16396 |
local nofinnerbits=band(format,0x000F)+1 |
| 16397 |
local innermask=lshift(1,nofinnerbits)-1 |
| 16398 |
local readcardinal=read_cardinal[entrysize] |
| 16399 |
for i=0,mapcount-1 do |
| 16400 |
local mapdata=readcardinal(f) |
| 16401 |
outerindex[i]=rshift(mapdata,nofinnerbits) |
| 16402 |
innerindex[i]=band(mapdata,innermask) |
| 16403 |
end |
| 16404 |
setvariabledata(fontdata,"hvarwidths",true) |
| 16405 |
local glyphs=fontdata.glyphs |
| 16406 |
for i=0,fontdata.nofglyphs-1 do |
| 16407 |
local glyph=glyphs[i] |
| 16408 |
local width=glyph.width |
| 16409 |
if width then |
| 16410 |
local outer=outerindex[i] or 0 |
| 16411 |
local inner=innerindex[i] or i |
| 16412 |
if outer and inner then |
| 16413 |
local delta=deltas[outer+1] |
| 16414 |
if delta then |
| 16415 |
local d=delta.deltas[inner+1] |
| 16416 |
if d then |
| 16417 |
local scales=delta.scales |
| 16418 |
local deltaw=0 |
| 16419 |
for i=1,#scales do |
| 16420 |
local di=d[i] |
| 16421 |
if di then |
| 16422 |
deltaw=deltaw+scales[i]*di |
| 16423 |
else |
| 16424 |
break |
| 16425 |
end |
| 16426 |
end |
| 16427 |
glyph.width=width+round(deltaw) |
| 16428 |
end |
| 16429 |
end |
| 16430 |
end |
| 16431 |
end |
| 16432 |
end |
| 16433 |
end |
| 16434 |
end |
| 16435 |
function readers.vvar(f,fontdata,specification) |
| 16436 |
if not specification.variable then |
| 16437 |
return |
| 16438 |
end |
| 16439 |
end |
| 16440 |
function readers.mvar(f,fontdata,specification) |
| 16441 |
local tableoffset=gotodatatable(f,fontdata,"mvar",specification.variable) |
| 16442 |
if tableoffset then |
| 16443 |
local version=readulong(f) |
| 16444 |
local reserved=skipshort(f,1) |
| 16445 |
local recordsize=readushort(f) |
| 16446 |
local nofrecords=readushort(f) |
| 16447 |
local offsettostore=tableoffset+readushort(f) |
| 16448 |
local dimensions={} |
| 16449 |
local factors=specification.factors |
| 16450 |
if factors then |
| 16451 |
local regions,deltas=readvariationdata(f,offsettostore,factors) |
| 16452 |
for i=1,nofrecords do |
| 16453 |
local tag=readtag(f) |
| 16454 |
local var=variabletags[tag] |
| 16455 |
if var then |
| 16456 |
local outer=readushort(f) |
| 16457 |
local inner=readushort(f) |
| 16458 |
local delta=deltas[outer+1] |
| 16459 |
if delta then |
| 16460 |
local d=delta.deltas[inner+1] |
| 16461 |
if d then |
| 16462 |
local scales=delta.scales |
| 16463 |
local dd=0 |
| 16464 |
for i=1,#scales do |
| 16465 |
dd=dd+scales[i]*d[i] |
| 16466 |
end |
| 16467 |
var(fontdata,round(dd)) |
| 16468 |
end |
| 16469 |
end |
| 16470 |
else |
| 16471 |
skipshort(f,2) |
| 16472 |
end |
| 16473 |
if recordsize>8 then |
| 16474 |
skipbytes(recordsize-8) |
| 16475 |
end |
| 16476 |
end |
| 16477 |
end |
| 16478 |
end |
| 16479 |
end |
| 16480 |
|
| 16481 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-dsp”] --- |
| 16482 |
|
| 16483 |
|
| 16484 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-oup” aaff9c28233bbea56e6d27ae50e04ff0] --- |
| 16485 |
|
| 16486 |
if not modules then modules={} end modules ['font-oup']={ |
| 16487 |
version=1.001, |
| 16488 |
comment="companion to font-ini.mkiv", |
| 16489 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 16490 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 16491 |
license="see context related readme files" |
| 16492 |
} |
| 16493 |
local next,type=next,type |
| 16494 |
local P,R,S=lpeg.P,lpeg.R,lpeg.S |
| 16495 |
local lpegmatch=lpeg.match |
| 16496 |
local insert,remove,copy,unpack=table.insert,table.remove,table.copy,table.unpack |
| 16497 |
local find=string.find |
| 16498 |
local formatters=string.formatters |
| 16499 |
local sortedkeys=table.sortedkeys |
| 16500 |
local sortedhash=table.sortedhash |
| 16501 |
local tohash=table.tohash |
| 16502 |
local setmetatableindex=table.setmetatableindex |
| 16503 |
local report_error=logs.reporter("otf reader","error") |
| 16504 |
local report_markwidth=logs.reporter("otf reader","markwidth") |
| 16505 |
local report_cleanup=logs.reporter("otf reader","cleanup") |
| 16506 |
local report_optimizations=logs.reporter("otf reader","merges") |
| 16507 |
local report_unicodes=logs.reporter("otf reader","unicodes") |
| 16508 |
local trace_markwidth=false trackers.register("otf.markwidth",function(v) trace_markwidth=v end) |
| 16509 |
local trace_cleanup=false trackers.register("otf.cleanups",function(v) trace_cleanups=v end) |
| 16510 |
local trace_optimizations=false trackers.register("otf.optimizations",function(v) trace_optimizations=v end) |
| 16511 |
local trace_unicodes=false trackers.register("otf.unicodes",function(v) trace_unicodes=v end) |
| 16512 |
local readers=fonts.handlers.otf.readers |
| 16513 |
local privateoffset=fonts.constructors and fonts.constructors.privateoffset or 0xF0000 |
| 16514 |
local f_private=formatters["P%05X"] |
| 16515 |
local f_unicode=formatters["U%05X"] |
| 16516 |
local f_index=formatters["I%05X"] |
| 16517 |
local f_character_y=formatters["%C"] |
| 16518 |
local f_character_n=formatters["[ %C ]"] |
| 16519 |
local check_duplicates=true |
| 16520 |
local check_soft_hyphen=context |
| 16521 |
directives.register("otf.checksofthyphen",function(v) |
| 16522 |
check_soft_hyphen=v |
| 16523 |
end) |
| 16524 |
local function replaced(list,index,replacement) |
| 16525 |
if type(list)=="number" then |
| 16526 |
return replacement |
| 16527 |
elseif type(replacement)=="table" then |
| 16528 |
local t={} |
| 16529 |
local n=index-1 |
| 16530 |
for i=1,n do |
| 16531 |
t[i]=list[i] |
| 16532 |
end |
| 16533 |
for i=1,#replacement do |
| 16534 |
n=n+1 |
| 16535 |
t[n]=replacement[i] |
| 16536 |
end |
| 16537 |
for i=index+1,#list do |
| 16538 |
n=n+1 |
| 16539 |
t[n]=list[i] |
| 16540 |
end |
| 16541 |
else |
| 16542 |
list[index]=replacement |
| 16543 |
return list |
| 16544 |
end |
| 16545 |
end |
| 16546 |
local function unifyresources(fontdata,indices) |
| 16547 |
local descriptions=fontdata.descriptions |
| 16548 |
local resources=fontdata.resources |
| 16549 |
if not descriptions or not resources then |
| 16550 |
return |
| 16551 |
end |
| 16552 |
local nofindices=#indices |
| 16553 |
local variants=fontdata.resources.variants |
| 16554 |
if variants then |
| 16555 |
for selector,unicodes in next,variants do |
| 16556 |
for unicode,index in next,unicodes do |
| 16557 |
unicodes[unicode]=indices[index] |
| 16558 |
end |
| 16559 |
end |
| 16560 |
end |
| 16561 |
local function remark(marks) |
| 16562 |
if marks then |
| 16563 |
local newmarks={} |
| 16564 |
for k,v in next,marks do |
| 16565 |
local u=indices[k] |
| 16566 |
if u then |
| 16567 |
newmarks[u]=v |
| 16568 |
elseif trace_optimizations then |
| 16569 |
report_optimizations("discarding mark %i",k) |
| 16570 |
end |
| 16571 |
end |
| 16572 |
return newmarks |
| 16573 |
end |
| 16574 |
end |
| 16575 |
local marks=resources.marks |
| 16576 |
if marks then |
| 16577 |
resources.marks=remark(marks) |
| 16578 |
end |
| 16579 |
local markclasses=resources.markclasses |
| 16580 |
if markclasses then |
| 16581 |
for class,marks in next,markclasses do |
| 16582 |
markclasses[class]=remark(marks) |
| 16583 |
end |
| 16584 |
end |
| 16585 |
local marksets=resources.marksets |
| 16586 |
if marksets then |
| 16587 |
for class,marks in next,marksets do |
| 16588 |
marksets[class]=remark(marks) |
| 16589 |
end |
| 16590 |
end |
| 16591 |
local done={} |
| 16592 |
local duplicates=check_duplicates and resources.duplicates |
| 16593 |
if duplicates and not next(duplicates) then |
| 16594 |
duplicates=false |
| 16595 |
end |
| 16596 |
local function recover(cover) |
| 16597 |
for i=1,#cover do |
| 16598 |
local c=cover[i] |
| 16599 |
if not done[c] then |
| 16600 |
local t={} |
| 16601 |
for k,v in next,c do |
| 16602 |
local ug=indices[k] |
| 16603 |
if ug then |
| 16604 |
t[ug]=v |
| 16605 |
else |
| 16606 |
report_error("case %i, bad index in unifying %s: %s of %s",1,"coverage",k,nofindices) |
| 16607 |
end |
| 16608 |
end |
| 16609 |
cover[i]=t |
| 16610 |
done[c]=d |
| 16611 |
end |
| 16612 |
end |
| 16613 |
end |
| 16614 |
local function recursed(c,kind) |
| 16615 |
local t={} |
| 16616 |
for g,d in next,c do |
| 16617 |
if type(d)=="table" then |
| 16618 |
local ug=indices[g] |
| 16619 |
if ug then |
| 16620 |
t[ug]=recursed(d,kind) |
| 16621 |
else |
| 16622 |
report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g,nofindices) |
| 16623 |
end |
| 16624 |
else |
| 16625 |
t[g]=indices[d] |
| 16626 |
end |
| 16627 |
end |
| 16628 |
return t |
| 16629 |
end |
| 16630 |
local function unifythem(sequences) |
| 16631 |
if not sequences then |
| 16632 |
return |
| 16633 |
end |
| 16634 |
for i=1,#sequences do |
| 16635 |
local sequence=sequences[i] |
| 16636 |
local kind=sequence.type |
| 16637 |
local steps=sequence.steps |
| 16638 |
local features=sequence.features |
| 16639 |
if steps then |
| 16640 |
for i=1,#steps do |
| 16641 |
local step=steps[i] |
| 16642 |
if kind=="gsub_single" then |
| 16643 |
local c=step.coverage |
| 16644 |
if c then |
| 16645 |
local t1=done[c] |
| 16646 |
if not t1 then |
| 16647 |
t1={} |
| 16648 |
if duplicates then |
| 16649 |
for g1,d1 in next,c do |
| 16650 |
local ug1=indices[g1] |
| 16651 |
if ug1 then |
| 16652 |
local ud1=indices[d1] |
| 16653 |
if ud1 then |
| 16654 |
t1[ug1]=ud1 |
| 16655 |
local dg1=duplicates[ug1] |
| 16656 |
if dg1 then |
| 16657 |
for u in next,dg1 do |
| 16658 |
t1[u]=ud1 |
| 16659 |
end |
| 16660 |
end |
| 16661 |
else |
| 16662 |
report_error("case %i, bad index in unifying %s: %s of %s",3,kind,d1,nofindices) |
| 16663 |
end |
| 16664 |
else |
| 16665 |
report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) |
| 16666 |
end |
| 16667 |
end |
| 16668 |
else |
| 16669 |
for g1,d1 in next,c do |
| 16670 |
local ug1=indices[g1] |
| 16671 |
if ug1 then |
| 16672 |
t1[ug1]=indices[d1] |
| 16673 |
else |
| 16674 |
report_error("fuzzy case %i in unifying %s: %i",2,kind,g1) |
| 16675 |
end |
| 16676 |
end |
| 16677 |
end |
| 16678 |
done[c]=t1 |
| 16679 |
end |
| 16680 |
step.coverage=t1 |
| 16681 |
end |
| 16682 |
elseif kind=="gpos_pair" then |
| 16683 |
local c=step.coverage |
| 16684 |
if c then |
| 16685 |
local t1=done[c] |
| 16686 |
if not t1 then |
| 16687 |
t1={} |
| 16688 |
for g1,d1 in next,c do |
| 16689 |
local ug1=indices[g1] |
| 16690 |
if ug1 then |
| 16691 |
local t2=done[d1] |
| 16692 |
if not t2 then |
| 16693 |
t2={} |
| 16694 |
for g2,d2 in next,d1 do |
| 16695 |
local ug2=indices[g2] |
| 16696 |
if ug2 then |
| 16697 |
t2[ug2]=d2 |
| 16698 |
else |
| 16699 |
report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g2,nofindices,nofindices) |
| 16700 |
end |
| 16701 |
end |
| 16702 |
done[d1]=t2 |
| 16703 |
end |
| 16704 |
t1[ug1]=t2 |
| 16705 |
else |
| 16706 |
report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) |
| 16707 |
end |
| 16708 |
end |
| 16709 |
done[c]=t1 |
| 16710 |
end |
| 16711 |
step.coverage=t1 |
| 16712 |
end |
| 16713 |
elseif kind=="gsub_ligature" then |
| 16714 |
local c=step.coverage |
| 16715 |
if c then |
| 16716 |
step.coverage=recursed(c,kind) |
| 16717 |
end |
| 16718 |
elseif kind=="gsub_alternate" or kind=="gsub_multiple" then |
| 16719 |
local c=step.coverage |
| 16720 |
if c then |
| 16721 |
local t1=done[c] |
| 16722 |
if not t1 then |
| 16723 |
t1={} |
| 16724 |
if duplicates then |
| 16725 |
for g1,d1 in next,c do |
| 16726 |
for i=1,#d1 do |
| 16727 |
local d1i=d1[i] |
| 16728 |
local d1u=indices[d1i] |
| 16729 |
if d1u then |
| 16730 |
d1[i]=d1u |
| 16731 |
else |
| 16732 |
report_error("case %i, bad index in unifying %s: %s of %s",1,kind,i,d1i,nofindices) |
| 16733 |
end |
| 16734 |
end |
| 16735 |
local ug1=indices[g1] |
| 16736 |
if ug1 then |
| 16737 |
t1[ug1]=d1 |
| 16738 |
local dg1=duplicates[ug1] |
| 16739 |
if dg1 then |
| 16740 |
for u in next,dg1 do |
| 16741 |
t1[u]=copy(d1) |
| 16742 |
end |
| 16743 |
end |
| 16744 |
else |
| 16745 |
report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) |
| 16746 |
end |
| 16747 |
end |
| 16748 |
else |
| 16749 |
for g1,d1 in next,c do |
| 16750 |
for i=1,#d1 do |
| 16751 |
local d1i=d1[i] |
| 16752 |
local d1u=indices[d1i] |
| 16753 |
if d1u then |
| 16754 |
d1[i]=d1u |
| 16755 |
else |
| 16756 |
report_error("case %i, bad index in unifying %s: %s of %s",2,kind,d1i,nofindices) |
| 16757 |
end |
| 16758 |
end |
| 16759 |
t1[indices[g1]]=d1 |
| 16760 |
end |
| 16761 |
end |
| 16762 |
done[c]=t1 |
| 16763 |
end |
| 16764 |
step.coverage=t1 |
| 16765 |
end |
| 16766 |
elseif kind=="gpos_single" then |
| 16767 |
local c=step.coverage |
| 16768 |
if c then |
| 16769 |
local t1=done[c] |
| 16770 |
if not t1 then |
| 16771 |
t1={} |
| 16772 |
if duplicates then |
| 16773 |
for g1,d1 in next,c do |
| 16774 |
local ug1=indices[g1] |
| 16775 |
if ug1 then |
| 16776 |
t1[ug1]=d1 |
| 16777 |
local dg1=duplicates[ug1] |
| 16778 |
if dg1 then |
| 16779 |
for u in next,dg1 do |
| 16780 |
t1[u]=d1 |
| 16781 |
end |
| 16782 |
end |
| 16783 |
else |
| 16784 |
report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) |
| 16785 |
end |
| 16786 |
end |
| 16787 |
else |
| 16788 |
for g1,d1 in next,c do |
| 16789 |
local ug1=indices[g1] |
| 16790 |
if ug1 then |
| 16791 |
t1[ug1]=d1 |
| 16792 |
else |
| 16793 |
report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) |
| 16794 |
end |
| 16795 |
end |
| 16796 |
end |
| 16797 |
done[c]=t1 |
| 16798 |
end |
| 16799 |
step.coverage=t1 |
| 16800 |
end |
| 16801 |
elseif kind=="gpos_mark2base" or kind=="gpos_mark2mark" or kind=="gpos_mark2ligature" then |
| 16802 |
local c=step.coverage |
| 16803 |
if c then |
| 16804 |
local t1=done[c] |
| 16805 |
if not t1 then |
| 16806 |
t1={} |
| 16807 |
for g1,d1 in next,c do |
| 16808 |
local ug1=indices[g1] |
| 16809 |
if ug1 then |
| 16810 |
t1[ug1]=d1 |
| 16811 |
else |
| 16812 |
report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) |
| 16813 |
end |
| 16814 |
end |
| 16815 |
done[c]=t1 |
| 16816 |
end |
| 16817 |
step.coverage=t1 |
| 16818 |
end |
| 16819 |
local c=step.baseclasses |
| 16820 |
if c then |
| 16821 |
local t1=done[c] |
| 16822 |
if not t1 then |
| 16823 |
for g1,d1 in next,c do |
| 16824 |
local t2=done[d1] |
| 16825 |
if not t2 then |
| 16826 |
t2={} |
| 16827 |
for g2,d2 in next,d1 do |
| 16828 |
local ug2=indices[g2] |
| 16829 |
if ug2 then |
| 16830 |
t2[ug2]=d2 |
| 16831 |
else |
| 16832 |
report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g2,nofindices) |
| 16833 |
end |
| 16834 |
end |
| 16835 |
done[d1]=t2 |
| 16836 |
end |
| 16837 |
c[g1]=t2 |
| 16838 |
end |
| 16839 |
done[c]=c |
| 16840 |
end |
| 16841 |
end |
| 16842 |
elseif kind=="gpos_cursive" then |
| 16843 |
local c=step.coverage |
| 16844 |
if c then |
| 16845 |
local t1=done[c] |
| 16846 |
if not t1 then |
| 16847 |
t1={} |
| 16848 |
if duplicates then |
| 16849 |
for g1,d1 in next,c do |
| 16850 |
local ug1=indices[g1] |
| 16851 |
if ug1 then |
| 16852 |
t1[ug1]=d1 |
| 16853 |
local dg1=duplicates[ug1] |
| 16854 |
if dg1 then |
| 16855 |
for u in next,dg1 do |
| 16856 |
t1[u]=copy(d1) |
| 16857 |
end |
| 16858 |
end |
| 16859 |
else |
| 16860 |
report_error("case %i, bad index in unifying %s: %s of %s",1,kind,g1,nofindices) |
| 16861 |
end |
| 16862 |
end |
| 16863 |
else |
| 16864 |
for g1,d1 in next,c do |
| 16865 |
local ug1=indices[g1] |
| 16866 |
if ug1 then |
| 16867 |
t1[ug1]=d1 |
| 16868 |
else |
| 16869 |
report_error("case %i, bad index in unifying %s: %s of %s",2,kind,g1,nofindices) |
| 16870 |
end |
| 16871 |
end |
| 16872 |
end |
| 16873 |
done[c]=t1 |
| 16874 |
end |
| 16875 |
step.coverage=t1 |
| 16876 |
end |
| 16877 |
end |
| 16878 |
local rules=step.rules |
| 16879 |
if rules then |
| 16880 |
for i=1,#rules do |
| 16881 |
local rule=rules[i] |
| 16882 |
local before=rule.before if before then recover(before) end |
| 16883 |
local after=rule.after if after then recover(after) end |
| 16884 |
local current=rule.current if current then recover(current) end |
| 16885 |
local replacements=rule.replacements |
| 16886 |
if replacements then |
| 16887 |
if not done[replacements] then |
| 16888 |
local r={} |
| 16889 |
for k,v in next,replacements do |
| 16890 |
r[indices[k]]=indices[v] |
| 16891 |
end |
| 16892 |
rule.replacements=r |
| 16893 |
done[replacements]=r |
| 16894 |
end |
| 16895 |
end |
| 16896 |
end |
| 16897 |
end |
| 16898 |
end |
| 16899 |
end |
| 16900 |
end |
| 16901 |
end |
| 16902 |
unifythem(resources.sequences) |
| 16903 |
unifythem(resources.sublookups) |
| 16904 |
end |
| 16905 |
local function copyduplicates(fontdata) |
| 16906 |
if check_duplicates then |
| 16907 |
local descriptions=fontdata.descriptions |
| 16908 |
local resources=fontdata.resources |
| 16909 |
local duplicates=resources.duplicates |
| 16910 |
if check_soft_hyphen then |
| 16911 |
local dh=descriptions[0x2D] |
| 16912 |
if dh then |
| 16913 |
local ds=descriptions[0xAD] |
| 16914 |
if not ds or ds.width~=dh.width then |
| 16915 |
descriptions[0xAD]=nil |
| 16916 |
if ds then |
| 16917 |
if trace_unicodes then |
| 16918 |
report_unicodes("patching soft hyphen") |
| 16919 |
end |
| 16920 |
else |
| 16921 |
if trace_unicodes then |
| 16922 |
report_unicodes("adding soft hyphen") |
| 16923 |
end |
| 16924 |
end |
| 16925 |
if not duplicates then |
| 16926 |
duplicates={} |
| 16927 |
resources.duplicates=duplicates |
| 16928 |
end |
| 16929 |
local d=duplicates[0x2D] |
| 16930 |
if d then |
| 16931 |
d[0xAD]=true |
| 16932 |
else |
| 16933 |
duplicates[0x2D]={ [0xAD]=true } |
| 16934 |
end |
| 16935 |
end |
| 16936 |
end |
| 16937 |
end |
| 16938 |
if duplicates then |
| 16939 |
for u,d in next,duplicates do |
| 16940 |
local du=descriptions[u] |
| 16941 |
if du then |
| 16942 |
local t={ f_character_y(u),"@",f_index(du.index),"->" } |
| 16943 |
local n=0 |
| 16944 |
local m=25 |
| 16945 |
for u in next,d do |
| 16946 |
if descriptions[u] then |
| 16947 |
if n<m then |
| 16948 |
t[n+4]=f_character_n(u) |
| 16949 |
end |
| 16950 |
else |
| 16951 |
local c=copy(du) |
| 16952 |
c.unicode=u |
| 16953 |
descriptions[u]=c |
| 16954 |
if n<m then |
| 16955 |
t[n+4]=f_character_y(u) |
| 16956 |
end |
| 16957 |
end |
| 16958 |
n=n+1 |
| 16959 |
end |
| 16960 |
if trace_unicodes then |
| 16961 |
if n<=m then |
| 16962 |
report_unicodes("%i : % t",n,t) |
| 16963 |
else |
| 16964 |
report_unicodes("%i : % t ...",n,t) |
| 16965 |
end |
| 16966 |
end |
| 16967 |
else |
| 16968 |
end |
| 16969 |
end |
| 16970 |
end |
| 16971 |
end |
| 16972 |
end |
| 16973 |
local ignore={ |
| 16974 |
["notdef"]=true, |
| 16975 |
[".notdef"]=true, |
| 16976 |
["null"]=true, |
| 16977 |
[".null"]=true, |
| 16978 |
["nonmarkingreturn"]=true, |
| 16979 |
} |
| 16980 |
local function checklookups(fontdata,missing,nofmissing) |
| 16981 |
local descriptions=fontdata.descriptions |
| 16982 |
local resources=fontdata.resources |
| 16983 |
if missing and nofmissing and nofmissing<=0 then |
| 16984 |
return |
| 16985 |
end |
| 16986 |
local singles={} |
| 16987 |
local alternates={} |
| 16988 |
local ligatures={} |
| 16989 |
if not missing then |
| 16990 |
missing={} |
| 16991 |
nofmissing=0 |
| 16992 |
for u,d in next,descriptions do |
| 16993 |
if not d.unicode then |
| 16994 |
nofmissing=nofmissing+1 |
| 16995 |
missing[u]=true |
| 16996 |
end |
| 16997 |
end |
| 16998 |
end |
| 16999 |
local function collectthem(sequences) |
| 17000 |
if not sequences then |
| 17001 |
return |
| 17002 |
end |
| 17003 |
for i=1,#sequences do |
| 17004 |
local sequence=sequences[i] |
| 17005 |
local kind=sequence.type |
| 17006 |
local steps=sequence.steps |
| 17007 |
if steps then |
| 17008 |
for i=1,#steps do |
| 17009 |
local step=steps[i] |
| 17010 |
if kind=="gsub_single" then |
| 17011 |
local c=step.coverage |
| 17012 |
if c then |
| 17013 |
singles[#singles+1]=c |
| 17014 |
end |
| 17015 |
elseif kind=="gsub_alternate" then |
| 17016 |
local c=step.coverage |
| 17017 |
if c then |
| 17018 |
alternates[#alternates+1]=c |
| 17019 |
end |
| 17020 |
elseif kind=="gsub_ligature" then |
| 17021 |
local c=step.coverage |
| 17022 |
if c then |
| 17023 |
ligatures[#ligatures+1]=c |
| 17024 |
end |
| 17025 |
end |
| 17026 |
end |
| 17027 |
end |
| 17028 |
end |
| 17029 |
end |
| 17030 |
collectthem(resources.sequences) |
| 17031 |
collectthem(resources.sublookups) |
| 17032 |
local loops=0 |
| 17033 |
while true do |
| 17034 |
loops=loops+1 |
| 17035 |
local old=nofmissing |
| 17036 |
for i=1,#singles do |
| 17037 |
local c=singles[i] |
| 17038 |
for g1,g2 in next,c do |
| 17039 |
if missing[g1] then |
| 17040 |
local u2=descriptions[g2].unicode |
| 17041 |
if u2 then |
| 17042 |
missing[g1]=false |
| 17043 |
descriptions[g1].unicode=u2 |
| 17044 |
nofmissing=nofmissing-1 |
| 17045 |
end |
| 17046 |
end |
| 17047 |
if missing[g2] then |
| 17048 |
local u1=descriptions[g1].unicode |
| 17049 |
if u1 then |
| 17050 |
missing[g2]=false |
| 17051 |
descriptions[g2].unicode=u1 |
| 17052 |
nofmissing=nofmissing-1 |
| 17053 |
end |
| 17054 |
end |
| 17055 |
end |
| 17056 |
end |
| 17057 |
for i=1,#alternates do |
| 17058 |
local c=alternates[i] |
| 17059 |
for g1,d1 in next,c do |
| 17060 |
if missing[g1] then |
| 17061 |
for i=1,#d1 do |
| 17062 |
local g2=d1[i] |
| 17063 |
local u2=descriptions[g2].unicode |
| 17064 |
if u2 then |
| 17065 |
missing[g1]=false |
| 17066 |
descriptions[g1].unicode=u2 |
| 17067 |
nofmissing=nofmissing-1 |
| 17068 |
end |
| 17069 |
end |
| 17070 |
end |
| 17071 |
if not missing[g1] then |
| 17072 |
for i=1,#d1 do |
| 17073 |
local g2=d1[i] |
| 17074 |
if missing[g2] then |
| 17075 |
local u1=descriptions[g1].unicode |
| 17076 |
if u1 then |
| 17077 |
missing[g2]=false |
| 17078 |
descriptions[g2].unicode=u1 |
| 17079 |
nofmissing=nofmissing-1 |
| 17080 |
end |
| 17081 |
end |
| 17082 |
end |
| 17083 |
end |
| 17084 |
end |
| 17085 |
end |
| 17086 |
if nofmissing<=0 then |
| 17087 |
if trace_unicodes then |
| 17088 |
report_unicodes("all missings done in %s loops",loops) |
| 17089 |
end |
| 17090 |
return |
| 17091 |
elseif old==nofmissing then |
| 17092 |
break |
| 17093 |
end |
| 17094 |
end |
| 17095 |
local t,n |
| 17096 |
local function recursed(c) |
| 17097 |
for g,d in next,c do |
| 17098 |
if g~="ligature" then |
| 17099 |
local u=descriptions[g].unicode |
| 17100 |
if u then |
| 17101 |
n=n+1 |
| 17102 |
t[n]=u |
| 17103 |
recursed(d) |
| 17104 |
n=n-1 |
| 17105 |
end |
| 17106 |
elseif missing[d] then |
| 17107 |
local l={} |
| 17108 |
local m=0 |
| 17109 |
for i=1,n do |
| 17110 |
local u=t[i] |
| 17111 |
if type(u)=="table" then |
| 17112 |
for i=1,#u do |
| 17113 |
m=m+1 |
| 17114 |
l[m]=u[i] |
| 17115 |
end |
| 17116 |
else |
| 17117 |
m=m+1 |
| 17118 |
l[m]=u |
| 17119 |
end |
| 17120 |
end |
| 17121 |
missing[d]=false |
| 17122 |
descriptions[d].unicode=l |
| 17123 |
nofmissing=nofmissing-1 |
| 17124 |
end |
| 17125 |
end |
| 17126 |
end |
| 17127 |
if nofmissing>0 then |
| 17128 |
t={} |
| 17129 |
n=0 |
| 17130 |
local loops=0 |
| 17131 |
while true do |
| 17132 |
loops=loops+1 |
| 17133 |
local old=nofmissing |
| 17134 |
for i=1,#ligatures do |
| 17135 |
recursed(ligatures[i]) |
| 17136 |
end |
| 17137 |
if nofmissing<=0 then |
| 17138 |
if trace_unicodes then |
| 17139 |
report_unicodes("all missings done in %s loops",loops) |
| 17140 |
end |
| 17141 |
return |
| 17142 |
elseif old==nofmissing then |
| 17143 |
break |
| 17144 |
end |
| 17145 |
end |
| 17146 |
t=nil |
| 17147 |
n=0 |
| 17148 |
end |
| 17149 |
if trace_unicodes and nofmissing>0 then |
| 17150 |
local done={} |
| 17151 |
for i,r in next,missing do |
| 17152 |
if r then |
| 17153 |
local data=descriptions[i] |
| 17154 |
local name=data and data.name or f_index(i) |
| 17155 |
if not ignore[name] then |
| 17156 |
done[name]=true |
| 17157 |
end |
| 17158 |
end |
| 17159 |
end |
| 17160 |
if next(done) then |
| 17161 |
report_unicodes("not unicoded: % t",sortedkeys(done)) |
| 17162 |
end |
| 17163 |
end |
| 17164 |
end |
| 17165 |
local firstprivate=fonts.privateoffsets and fonts.privateoffsets.textbase or 0xF0000 |
| 17166 |
local puafirst=0xE000 |
| 17167 |
local pualast=0xF8FF |
| 17168 |
local function unifymissing(fontdata) |
| 17169 |
if not fonts.mappings then |
| 17170 |
require("font-map") |
| 17171 |
require("font-agl") |
| 17172 |
end |
| 17173 |
local unicodes={} |
| 17174 |
local resources=fontdata.resources |
| 17175 |
resources.unicodes=unicodes |
| 17176 |
for unicode,d in next,fontdata.descriptions do |
| 17177 |
if unicode<privateoffset then |
| 17178 |
if unicode>=puafirst and unicode<=pualast then |
| 17179 |
else |
| 17180 |
local name=d.name |
| 17181 |
if name then |
| 17182 |
unicodes[name]=unicode |
| 17183 |
end |
| 17184 |
end |
| 17185 |
else |
| 17186 |
end |
| 17187 |
end |
| 17188 |
fonts.mappings.addtounicode(fontdata,fontdata.filename,checklookups) |
| 17189 |
resources.unicodes=nil |
| 17190 |
end |
| 17191 |
local function unifyglyphs(fontdata,usenames) |
| 17192 |
local private=fontdata.private or privateoffset |
| 17193 |
local glyphs=fontdata.glyphs |
| 17194 |
local indices={} |
| 17195 |
local descriptions={} |
| 17196 |
local names=usenames and {} |
| 17197 |
local resources=fontdata.resources |
| 17198 |
local zero=glyphs[0] |
| 17199 |
local zerocode=zero.unicode |
| 17200 |
local nofglyphs=#glyphs |
| 17201 |
if not zerocode then |
| 17202 |
zerocode=private |
| 17203 |
zero.unicode=zerocode |
| 17204 |
private=private+1 |
| 17205 |
end |
| 17206 |
descriptions[zerocode]=zero |
| 17207 |
if names then |
| 17208 |
local name=glyphs[0].name or f_private(zerocode) |
| 17209 |
indices[0]=name |
| 17210 |
names[name]=zerocode |
| 17211 |
else |
| 17212 |
indices[0]=zerocode |
| 17213 |
end |
| 17214 |
if names then |
| 17215 |
for index=1,nofglyphs do |
| 17216 |
local glyph=glyphs[index] |
| 17217 |
local unicode=glyph.unicode |
| 17218 |
if not unicode then |
| 17219 |
unicode=private |
| 17220 |
local name=glyph.name or f_private(unicode) |
| 17221 |
indices[index]=name |
| 17222 |
names[name]=unicode |
| 17223 |
private=private+1 |
| 17224 |
elseif unicode>=firstprivate then |
| 17225 |
unicode=private |
| 17226 |
local name=glyph.name or f_private(unicode) |
| 17227 |
indices[index]=name |
| 17228 |
names[name]=unicode |
| 17229 |
private=private+1 |
| 17230 |
elseif unicode>=puafirst and unicode<=pualast then |
| 17231 |
local name=glyph.name or f_private(unicode) |
| 17232 |
indices[index]=name |
| 17233 |
names[name]=unicode |
| 17234 |
elseif descriptions[unicode] then |
| 17235 |
unicode=private |
| 17236 |
local name=glyph.name or f_private(unicode) |
| 17237 |
indices[index]=name |
| 17238 |
names[name]=unicode |
| 17239 |
private=private+1 |
| 17240 |
else |
| 17241 |
local name=glyph.name or f_unicode(unicode) |
| 17242 |
indices[index]=name |
| 17243 |
names[name]=unicode |
| 17244 |
end |
| 17245 |
descriptions[unicode]=glyph |
| 17246 |
end |
| 17247 |
elseif trace_unicodes then |
| 17248 |
for index=1,nofglyphs do |
| 17249 |
local glyph=glyphs[index] |
| 17250 |
local unicode=glyph.unicode |
| 17251 |
if not unicode then |
| 17252 |
unicode=private |
| 17253 |
indices[index]=unicode |
| 17254 |
private=private+1 |
| 17255 |
elseif unicode>=firstprivate then |
| 17256 |
local name=glyph.name |
| 17257 |
if name then |
| 17258 |
report_unicodes("moving glyph %a indexed %05X from private %U to %U ",name,index,unicode,private) |
| 17259 |
else |
| 17260 |
report_unicodes("moving glyph indexed %05X from private %U to %U ",index,unicode,private) |
| 17261 |
end |
| 17262 |
unicode=private |
| 17263 |
indices[index]=unicode |
| 17264 |
private=private+1 |
| 17265 |
elseif unicode>=puafirst and unicode<=pualast then |
| 17266 |
local name=glyph.name |
| 17267 |
if name then |
| 17268 |
report_unicodes("keeping private unicode %U for glyph %a indexed %05X",unicode,name,index) |
| 17269 |
else |
| 17270 |
report_unicodes("keeping private unicode %U for glyph indexed %05X",unicode,index) |
| 17271 |
end |
| 17272 |
indices[index]=unicode |
| 17273 |
elseif descriptions[unicode] then |
| 17274 |
local name=glyph.name |
| 17275 |
if name then |
| 17276 |
report_unicodes("assigning duplicate unicode %U to %U for glyph %a indexed %05X ",unicode,private,name,index) |
| 17277 |
else |
| 17278 |
report_unicodes("assigning duplicate unicode %U to %U for glyph indexed %05X ",unicode,private,index) |
| 17279 |
end |
| 17280 |
unicode=private |
| 17281 |
indices[index]=unicode |
| 17282 |
private=private+1 |
| 17283 |
else |
| 17284 |
indices[index]=unicode |
| 17285 |
end |
| 17286 |
descriptions[unicode]=glyph |
| 17287 |
end |
| 17288 |
else |
| 17289 |
for index=1,nofglyphs do |
| 17290 |
local glyph=glyphs[index] |
| 17291 |
local unicode=glyph.unicode |
| 17292 |
if not unicode then |
| 17293 |
unicode=private |
| 17294 |
indices[index]=unicode |
| 17295 |
private=private+1 |
| 17296 |
elseif unicode>=firstprivate then |
| 17297 |
local name=glyph.name |
| 17298 |
unicode=private |
| 17299 |
indices[index]=unicode |
| 17300 |
private=private+1 |
| 17301 |
elseif unicode>=puafirst and unicode<=pualast then |
| 17302 |
local name=glyph.name |
| 17303 |
indices[index]=unicode |
| 17304 |
elseif descriptions[unicode] then |
| 17305 |
local name=glyph.name |
| 17306 |
unicode=private |
| 17307 |
indices[index]=unicode |
| 17308 |
private=private+1 |
| 17309 |
else |
| 17310 |
indices[index]=unicode |
| 17311 |
end |
| 17312 |
descriptions[unicode]=glyph |
| 17313 |
end |
| 17314 |
end |
| 17315 |
if LUATEXENGINE=="luametatex" then |
| 17316 |
for index=1,nofglyphs do |
| 17317 |
local math=glyphs[index].math |
| 17318 |
if math then |
| 17319 |
local list=math.parts |
| 17320 |
if list then |
| 17321 |
for i=1,#list do local l=list[i] l.glyph=indices[l.glyph] end |
| 17322 |
end |
| 17323 |
local list=math.variants |
| 17324 |
if list then |
| 17325 |
for i=1,#list do list[i]=indices[list[i]] end |
| 17326 |
end |
| 17327 |
end |
| 17328 |
end |
| 17329 |
else |
| 17330 |
for index=1,nofglyphs do |
| 17331 |
local math=glyphs[index].math |
| 17332 |
if math then |
| 17333 |
local list=math.vparts |
| 17334 |
if list then |
| 17335 |
for i=1,#list do local l=list[i] l.glyph=indices[l.glyph] end |
| 17336 |
end |
| 17337 |
local list=math.hparts |
| 17338 |
if list then |
| 17339 |
for i=1,#list do local l=list[i] l.glyph=indices[l.glyph] end |
| 17340 |
end |
| 17341 |
local list=math.vvariants |
| 17342 |
if list then |
| 17343 |
for i=1,#list do list[i]=indices[list[i]] end |
| 17344 |
end |
| 17345 |
local list=math.hvariants |
| 17346 |
if list then |
| 17347 |
for i=1,#list do list[i]=indices[list[i]] end |
| 17348 |
end |
| 17349 |
end |
| 17350 |
end |
| 17351 |
end |
| 17352 |
local colorpalettes=resources.colorpalettes |
| 17353 |
if colorpalettes then |
| 17354 |
for index=1,nofglyphs do |
| 17355 |
local colors=glyphs[index].colors |
| 17356 |
if colors then |
| 17357 |
for i=1,#colors do |
| 17358 |
local c=colors[i] |
| 17359 |
if c then |
| 17360 |
c.slot=indices[c.slot] |
| 17361 |
end |
| 17362 |
end |
| 17363 |
end |
| 17364 |
end |
| 17365 |
end |
| 17366 |
fontdata.private=private |
| 17367 |
fontdata.glyphs=nil |
| 17368 |
fontdata.names=names |
| 17369 |
fontdata.descriptions=descriptions |
| 17370 |
fontdata.hashmethod=hashmethod |
| 17371 |
fontdata.nofglyphs=nofglyphs |
| 17372 |
return indices,names |
| 17373 |
end |
| 17374 |
local stripredundant do |
| 17375 |
local p_hex=R("af","AF","09") |
| 17376 |
local p_digit=R("09") |
| 17377 |
local p_done=S("._-")^0+P(-1) |
| 17378 |
local p_style=P(".") |
| 17379 |
local p_alpha=R("az","AZ") |
| 17380 |
local p_ALPHA=R("AZ") |
| 17381 |
local p_crappyname=( |
| 17382 |
lpeg.utfchartabletopattern({ "uni","u" },true)*S("Xx_")^0*p_hex^1 |
| 17383 |
+lpeg.utfchartabletopattern({ "identity","glyph","jamo" },true)*p_hex^1 |
| 17384 |
+lpeg.utfchartabletopattern({ "index","afii" },true)*p_digit^1 |
| 17385 |
+p_digit*p_hex^3+p_alpha*p_digit^1 |
| 17386 |
+P("aj")*p_digit^1+P("eh_")*(p_digit^1+p_ALPHA*p_digit^1)+(1-P("_"))^1*P("_uni")*p_hex^1+P("_")*P(1)^1 |
| 17387 |
)*p_done |
| 17388 |
if context then |
| 17389 |
local forcekeep=false |
| 17390 |
directives.register("otf.keepnames",function(v) |
| 17391 |
report_cleanup("keeping weird glyph names, expect larger files and more memory usage") |
| 17392 |
forcekeep=v |
| 17393 |
end) |
| 17394 |
local function stripvariants(descriptions,list) |
| 17395 |
local n=list and #list or 0 |
| 17396 |
if n>0 then |
| 17397 |
for i=1,n do |
| 17398 |
local g=list[i] |
| 17399 |
if g then |
| 17400 |
local d=descriptions[g] |
| 17401 |
if d and d.name then |
| 17402 |
d.name=nil |
| 17403 |
n=n+1 |
| 17404 |
end |
| 17405 |
end |
| 17406 |
end |
| 17407 |
end |
| 17408 |
return n |
| 17409 |
end |
| 17410 |
local function stripparts(descriptions,list) |
| 17411 |
local n=list and #list or 0 |
| 17412 |
if n>0 then |
| 17413 |
for i=1,n do |
| 17414 |
local g=list[i].glyph |
| 17415 |
if g then |
| 17416 |
local d=descriptions[g] |
| 17417 |
if d and d.name then |
| 17418 |
d.name=nil |
| 17419 |
n=n+1 |
| 17420 |
end |
| 17421 |
end |
| 17422 |
end |
| 17423 |
end |
| 17424 |
return n |
| 17425 |
end |
| 17426 |
local function collectsimple(fontdata) |
| 17427 |
return nil |
| 17428 |
end |
| 17429 |
stripredundant=function(fontdata) |
| 17430 |
local descriptions=fontdata.descriptions |
| 17431 |
if descriptions then |
| 17432 |
local n=0 |
| 17433 |
local c=0 |
| 17434 |
for unicode,d in next,descriptions do |
| 17435 |
local m=d.math |
| 17436 |
if m then |
| 17437 |
n=n+stripvariants(descriptions,m.vvariants) |
| 17438 |
n=n+stripvariants(descriptions,m.hvariants) |
| 17439 |
n=n+stripparts (descriptions,m.vparts) |
| 17440 |
n=n+stripparts (descriptions,m.hparts) |
| 17441 |
end |
| 17442 |
end |
| 17443 |
if forcekeep then |
| 17444 |
for unicode,d in next,descriptions do |
| 17445 |
if d.class=="base" then |
| 17446 |
d.class=nil |
| 17447 |
c=c+1 |
| 17448 |
end |
| 17449 |
end |
| 17450 |
else |
| 17451 |
local keeplist=collectsimple(fontdata) |
| 17452 |
for unicode,d in next,descriptions do |
| 17453 |
local name=d.name |
| 17454 |
if name then |
| 17455 |
if keeplist and keeplist[name] then |
| 17456 |
elseif lpegmatch(p_crappyname,name) then |
| 17457 |
d.name=nil |
| 17458 |
n=n+1 |
| 17459 |
end |
| 17460 |
end |
| 17461 |
if d.class=="base" then |
| 17462 |
d.class=nil |
| 17463 |
c=c+1 |
| 17464 |
end |
| 17465 |
end |
| 17466 |
end |
| 17467 |
if trace_cleanup then |
| 17468 |
if n>0 then |
| 17469 |
report_cleanup("%s bogus names removed (verbose unicode)",n) |
| 17470 |
end |
| 17471 |
if c>0 then |
| 17472 |
report_cleanup("%s base class tags removed (default is base)",c) |
| 17473 |
end |
| 17474 |
end |
| 17475 |
end |
| 17476 |
end |
| 17477 |
else |
| 17478 |
stripredundant=function(fontdata) |
| 17479 |
local descriptions=fontdata.descriptions |
| 17480 |
if descriptions then |
| 17481 |
if fonts.privateoffsets.keepnames then |
| 17482 |
for unicode,d in next,descriptions do |
| 17483 |
if d.class=="base" then |
| 17484 |
d.class=nil |
| 17485 |
end |
| 17486 |
end |
| 17487 |
else |
| 17488 |
for unicode,d in next,descriptions do |
| 17489 |
local name=d.name |
| 17490 |
if name then |
| 17491 |
if lpegmatch(p_crappyname,name) then |
| 17492 |
d.name=nil |
| 17493 |
end |
| 17494 |
end |
| 17495 |
if d.class=="base" then |
| 17496 |
d.class=nil |
| 17497 |
end |
| 17498 |
end |
| 17499 |
end |
| 17500 |
end |
| 17501 |
end |
| 17502 |
end |
| 17503 |
readers.stripredundant=stripredundant |
| 17504 |
end |
| 17505 |
function readers.getcomponents(fontdata) |
| 17506 |
local resources=fontdata.resources |
| 17507 |
if resources then |
| 17508 |
local sequences=resources.sequences |
| 17509 |
if sequences then |
| 17510 |
local collected={} |
| 17511 |
for i=1,#sequences do |
| 17512 |
local sequence=sequences[i] |
| 17513 |
if sequence.type=="gsub_ligature" then |
| 17514 |
local steps=sequence.steps |
| 17515 |
if steps then |
| 17516 |
local l={} |
| 17517 |
local function traverse(p,k,v) |
| 17518 |
if k=="ligature" then |
| 17519 |
collected[v]={ unpack(l) } |
| 17520 |
elseif tonumber(v) then |
| 17521 |
insert(l,k) |
| 17522 |
collected[v]={ unpack(l) } |
| 17523 |
remove(l) |
| 17524 |
else |
| 17525 |
insert(l,k) |
| 17526 |
for k,vv in next,v do |
| 17527 |
traverse(p,k,vv) |
| 17528 |
end |
| 17529 |
remove(l) |
| 17530 |
end |
| 17531 |
end |
| 17532 |
for i=1,#steps do |
| 17533 |
local c=steps[i].coverage |
| 17534 |
if c then |
| 17535 |
for k,v in next,c do |
| 17536 |
traverse(k,k,v) |
| 17537 |
end |
| 17538 |
end |
| 17539 |
end |
| 17540 |
end |
| 17541 |
end |
| 17542 |
end |
| 17543 |
if next(collected) then |
| 17544 |
while true do |
| 17545 |
local done=false |
| 17546 |
for k,v in next,collected do |
| 17547 |
for i=1,#v do |
| 17548 |
local vi=v[i] |
| 17549 |
if vi==k then |
| 17550 |
collected[k]=nil |
| 17551 |
break |
| 17552 |
else |
| 17553 |
local c=collected[vi] |
| 17554 |
if c then |
| 17555 |
done=true |
| 17556 |
local t={} |
| 17557 |
local n=i-1 |
| 17558 |
for j=1,n do |
| 17559 |
t[j]=v[j] |
| 17560 |
end |
| 17561 |
for j=1,#c do |
| 17562 |
n=n+1 |
| 17563 |
t[n]=c[j] |
| 17564 |
end |
| 17565 |
for j=i+1,#v do |
| 17566 |
n=n+1 |
| 17567 |
t[n]=v[j] |
| 17568 |
end |
| 17569 |
collected[k]=t |
| 17570 |
break |
| 17571 |
end |
| 17572 |
end |
| 17573 |
end |
| 17574 |
end |
| 17575 |
if not done then |
| 17576 |
break |
| 17577 |
end |
| 17578 |
end |
| 17579 |
return collected |
| 17580 |
end |
| 17581 |
end |
| 17582 |
end |
| 17583 |
end |
| 17584 |
readers.unifymissing=unifymissing |
| 17585 |
function readers.rehash(fontdata,hashmethod) |
| 17586 |
if not (fontdata and fontdata.glyphs) then |
| 17587 |
return |
| 17588 |
elseif hashmethod=="indices" then |
| 17589 |
fontdata.hashmethod="indices" |
| 17590 |
elseif hashmethod=="names" then |
| 17591 |
fontdata.hashmethod="names" |
| 17592 |
local indices=unifyglyphs(fontdata,true) |
| 17593 |
unifyresources(fontdata,indices) |
| 17594 |
copyduplicates(fontdata) |
| 17595 |
unifymissing(fontdata) |
| 17596 |
else |
| 17597 |
fontdata.hashmethod="unicodes" |
| 17598 |
local indices=unifyglyphs(fontdata) |
| 17599 |
unifyresources(fontdata,indices) |
| 17600 |
copyduplicates(fontdata) |
| 17601 |
unifymissing(fontdata) |
| 17602 |
stripredundant(fontdata) |
| 17603 |
end |
| 17604 |
end |
| 17605 |
function readers.checkhash(fontdata) |
| 17606 |
local hashmethod=fontdata.hashmethod |
| 17607 |
if hashmethod=="unicodes" then |
| 17608 |
fontdata.names=nil |
| 17609 |
elseif hashmethod=="names" and fontdata.names then |
| 17610 |
unifyresources(fontdata,fontdata.names) |
| 17611 |
copyduplicates(fontdata) |
| 17612 |
fontdata.hashmethod="unicodes" |
| 17613 |
fontdata.names=nil |
| 17614 |
else |
| 17615 |
readers.rehash(fontdata,"unicodes") |
| 17616 |
end |
| 17617 |
end |
| 17618 |
function readers.addunicodetable(fontdata) |
| 17619 |
local resources=fontdata.resources |
| 17620 |
local unicodes=resources.unicodes |
| 17621 |
if not unicodes then |
| 17622 |
local descriptions=fontdata.descriptions |
| 17623 |
if descriptions then |
| 17624 |
unicodes={} |
| 17625 |
resources.unicodes=unicodes |
| 17626 |
for u,d in next,descriptions do |
| 17627 |
local n=d.name |
| 17628 |
if n then |
| 17629 |
unicodes[n]=u |
| 17630 |
end |
| 17631 |
end |
| 17632 |
end |
| 17633 |
end |
| 17634 |
end |
| 17635 |
local concat,sort=table.concat,table.sort |
| 17636 |
local next,type,tostring=next,type,tostring |
| 17637 |
local criterium=1 |
| 17638 |
local threshold=0 |
| 17639 |
local trace_packing=false trackers.register("otf.packing",function(v) trace_packing=v end) |
| 17640 |
local trace_loading=false trackers.register("otf.loading",function(v) trace_loading=v end) |
| 17641 |
local report_otf=logs.reporter("fonts","otf loading") |
| 17642 |
local function tabstr_normal(t) |
| 17643 |
local s={} |
| 17644 |
local n=0 |
| 17645 |
for k,v in next,t do |
| 17646 |
n=n+1 |
| 17647 |
if type(v)=="table" then |
| 17648 |
s[n]=k..">"..tabstr_normal(v) |
| 17649 |
elseif v==true then |
| 17650 |
s[n]=k.."+" |
| 17651 |
elseif v then |
| 17652 |
s[n]=k.."="..v |
| 17653 |
else |
| 17654 |
s[n]=k.."-" |
| 17655 |
end |
| 17656 |
end |
| 17657 |
if n==0 then |
| 17658 |
return "" |
| 17659 |
elseif n==1 then |
| 17660 |
return s[1] |
| 17661 |
else |
| 17662 |
sort(s) |
| 17663 |
return concat(s,",") |
| 17664 |
end |
| 17665 |
end |
| 17666 |
local function tabstr_flat(t) |
| 17667 |
local s={} |
| 17668 |
local n=0 |
| 17669 |
for k,v in next,t do |
| 17670 |
n=n+1 |
| 17671 |
s[n]=k.."="..v |
| 17672 |
end |
| 17673 |
if n==0 then |
| 17674 |
return "" |
| 17675 |
elseif n==1 then |
| 17676 |
return s[1] |
| 17677 |
else |
| 17678 |
sort(s) |
| 17679 |
return concat(s,",") |
| 17680 |
end |
| 17681 |
end |
| 17682 |
local function tabstr_mixed(t) |
| 17683 |
local n=#t |
| 17684 |
if n==0 then |
| 17685 |
return "" |
| 17686 |
elseif n==1 then |
| 17687 |
local k=t[1] |
| 17688 |
if k==true then |
| 17689 |
return "++" |
| 17690 |
elseif k==false then |
| 17691 |
return "--" |
| 17692 |
else |
| 17693 |
return tostring(k) |
| 17694 |
end |
| 17695 |
else |
| 17696 |
local s={} |
| 17697 |
for i=1,n do |
| 17698 |
local k=t[i] |
| 17699 |
if k==true then |
| 17700 |
s[i]="++" |
| 17701 |
elseif k==false then |
| 17702 |
s[i]="--" |
| 17703 |
else |
| 17704 |
s[i]=k |
| 17705 |
end |
| 17706 |
end |
| 17707 |
return concat(s,",") |
| 17708 |
end |
| 17709 |
end |
| 17710 |
local function tabstr_boolean(t) |
| 17711 |
local s={} |
| 17712 |
local n=0 |
| 17713 |
for k,v in next,t do |
| 17714 |
n=n+1 |
| 17715 |
if v then |
| 17716 |
s[n]=k.."+" |
| 17717 |
else |
| 17718 |
s[n]=k.."-" |
| 17719 |
end |
| 17720 |
end |
| 17721 |
if n==0 then |
| 17722 |
return "" |
| 17723 |
elseif n==1 then |
| 17724 |
return s[1] |
| 17725 |
else |
| 17726 |
sort(s) |
| 17727 |
return concat(s,",") |
| 17728 |
end |
| 17729 |
end |
| 17730 |
function readers.pack(data) |
| 17731 |
if data then |
| 17732 |
local h,t,c={},{},{} |
| 17733 |
local hh,tt,cc={},{},{} |
| 17734 |
local nt,ntt=0,0 |
| 17735 |
local function pack_normal(v) |
| 17736 |
local tag=tabstr_normal(v) |
| 17737 |
local ht=h[tag] |
| 17738 |
if ht then |
| 17739 |
c[ht]=c[ht]+1 |
| 17740 |
return ht |
| 17741 |
else |
| 17742 |
nt=nt+1 |
| 17743 |
t[nt]=v |
| 17744 |
h[tag]=nt |
| 17745 |
c[nt]=1 |
| 17746 |
return nt |
| 17747 |
end |
| 17748 |
end |
| 17749 |
local function pack_normal_cc(v) |
| 17750 |
local tag=tabstr_normal(v) |
| 17751 |
local ht=h[tag] |
| 17752 |
if ht then |
| 17753 |
c[ht]=c[ht]+1 |
| 17754 |
return ht |
| 17755 |
else |
| 17756 |
v[1]=0 |
| 17757 |
nt=nt+1 |
| 17758 |
t[nt]=v |
| 17759 |
h[tag]=nt |
| 17760 |
c[nt]=1 |
| 17761 |
return nt |
| 17762 |
end |
| 17763 |
end |
| 17764 |
local function pack_flat(v) |
| 17765 |
local tag=tabstr_flat(v) |
| 17766 |
local ht=h[tag] |
| 17767 |
if ht then |
| 17768 |
c[ht]=c[ht]+1 |
| 17769 |
return ht |
| 17770 |
else |
| 17771 |
nt=nt+1 |
| 17772 |
t[nt]=v |
| 17773 |
h[tag]=nt |
| 17774 |
c[nt]=1 |
| 17775 |
return nt |
| 17776 |
end |
| 17777 |
end |
| 17778 |
local function pack_indexed(v) |
| 17779 |
local tag=concat(v," ") |
| 17780 |
local ht=h[tag] |
| 17781 |
if ht then |
| 17782 |
c[ht]=c[ht]+1 |
| 17783 |
return ht |
| 17784 |
else |
| 17785 |
nt=nt+1 |
| 17786 |
t[nt]=v |
| 17787 |
h[tag]=nt |
| 17788 |
c[nt]=1 |
| 17789 |
return nt |
| 17790 |
end |
| 17791 |
end |
| 17792 |
local function pack_mixed(v) |
| 17793 |
local tag=tabstr_mixed(v) |
| 17794 |
local ht=h[tag] |
| 17795 |
if ht then |
| 17796 |
c[ht]=c[ht]+1 |
| 17797 |
return ht |
| 17798 |
else |
| 17799 |
nt=nt+1 |
| 17800 |
t[nt]=v |
| 17801 |
h[tag]=nt |
| 17802 |
c[nt]=1 |
| 17803 |
return nt |
| 17804 |
end |
| 17805 |
end |
| 17806 |
local function pack_boolean(v) |
| 17807 |
local tag=tabstr_boolean(v) |
| 17808 |
local ht=h[tag] |
| 17809 |
if ht then |
| 17810 |
c[ht]=c[ht]+1 |
| 17811 |
return ht |
| 17812 |
else |
| 17813 |
nt=nt+1 |
| 17814 |
t[nt]=v |
| 17815 |
h[tag]=nt |
| 17816 |
c[nt]=1 |
| 17817 |
return nt |
| 17818 |
end |
| 17819 |
end |
| 17820 |
local function pack_final(v) |
| 17821 |
if c[v]<=criterium then |
| 17822 |
return t[v] |
| 17823 |
else |
| 17824 |
local hv=hh[v] |
| 17825 |
if hv then |
| 17826 |
return hv |
| 17827 |
else |
| 17828 |
ntt=ntt+1 |
| 17829 |
tt[ntt]=t[v] |
| 17830 |
hh[v]=ntt |
| 17831 |
cc[ntt]=c[v] |
| 17832 |
return ntt |
| 17833 |
end |
| 17834 |
end |
| 17835 |
end |
| 17836 |
local function pack_final_cc(v) |
| 17837 |
if c[v]<=criterium then |
| 17838 |
return t[v] |
| 17839 |
else |
| 17840 |
local hv=hh[v] |
| 17841 |
if hv then |
| 17842 |
return hv |
| 17843 |
else |
| 17844 |
ntt=ntt+1 |
| 17845 |
tt[ntt]=t[v] |
| 17846 |
hh[v]=ntt |
| 17847 |
cc[ntt]=c[v] |
| 17848 |
return ntt |
| 17849 |
end |
| 17850 |
end |
| 17851 |
end |
| 17852 |
local function success(stage,pass) |
| 17853 |
if nt==0 then |
| 17854 |
if trace_loading or trace_packing then |
| 17855 |
report_otf("pack quality: nothing to pack") |
| 17856 |
end |
| 17857 |
return false |
| 17858 |
elseif nt>=threshold then |
| 17859 |
local one=0 |
| 17860 |
local two=0 |
| 17861 |
local rest=0 |
| 17862 |
if pass==1 then |
| 17863 |
for k,v in next,c do |
| 17864 |
if v==1 then |
| 17865 |
one=one+1 |
| 17866 |
elseif v==2 then |
| 17867 |
two=two+1 |
| 17868 |
else |
| 17869 |
rest=rest+1 |
| 17870 |
end |
| 17871 |
end |
| 17872 |
else |
| 17873 |
for k,v in next,cc do |
| 17874 |
if v>20 then |
| 17875 |
rest=rest+1 |
| 17876 |
elseif v>10 then |
| 17877 |
two=two+1 |
| 17878 |
else |
| 17879 |
one=one+1 |
| 17880 |
end |
| 17881 |
end |
| 17882 |
data.tables=tt |
| 17883 |
end |
| 17884 |
if trace_loading or trace_packing then |
| 17885 |
report_otf("pack quality: stage %s, pass %s, %s packed, 1-10:%s, 11-20:%s, rest:%s (criterium: %s)", |
| 17886 |
stage,pass,one+two+rest,one,two,rest,criterium) |
| 17887 |
end |
| 17888 |
return true |
| 17889 |
else |
| 17890 |
if trace_loading or trace_packing then |
| 17891 |
report_otf("pack quality: stage %s, pass %s, %s packed, aborting pack (threshold: %s)", |
| 17892 |
stage,pass,nt,threshold) |
| 17893 |
end |
| 17894 |
return false |
| 17895 |
end |
| 17896 |
end |
| 17897 |
local function packers(pass) |
| 17898 |
if pass==1 then |
| 17899 |
return pack_normal,pack_indexed,pack_flat,pack_boolean,pack_mixed,pack_normal_cc |
| 17900 |
else |
| 17901 |
return pack_final,pack_final,pack_final,pack_final,pack_final,pack_final_cc |
| 17902 |
end |
| 17903 |
end |
| 17904 |
local resources=data.resources |
| 17905 |
local sequences=resources.sequences |
| 17906 |
local sublookups=resources.sublookups |
| 17907 |
local features=resources.features |
| 17908 |
local palettes=resources.colorpalettes |
| 17909 |
local variable=resources.variabledata |
| 17910 |
local chardata=characters and characters.data |
| 17911 |
local descriptions=data.descriptions or data.glyphs |
| 17912 |
if not descriptions then |
| 17913 |
return |
| 17914 |
end |
| 17915 |
for pass=1,2 do |
| 17916 |
if trace_packing then |
| 17917 |
report_otf("start packing: stage 1, pass %s",pass) |
| 17918 |
end |
| 17919 |
local pack_normal,pack_indexed,pack_flat,pack_boolean,pack_mixed,pack_normal_cc=packers(pass) |
| 17920 |
for unicode,description in next,descriptions do |
| 17921 |
local boundingbox=description.boundingbox |
| 17922 |
if boundingbox then |
| 17923 |
description.boundingbox=pack_indexed(boundingbox) |
| 17924 |
end |
| 17925 |
local math=description.math |
| 17926 |
if math then |
| 17927 |
local kerns=math.kerns |
| 17928 |
if kerns then |
| 17929 |
for tag,kern in next,kerns do |
| 17930 |
kerns[tag]=pack_normal(kern) |
| 17931 |
end |
| 17932 |
end |
| 17933 |
end |
| 17934 |
end |
| 17935 |
local function packthem(sequences) |
| 17936 |
for i=1,#sequences do |
| 17937 |
local sequence=sequences[i] |
| 17938 |
local kind=sequence.type |
| 17939 |
local steps=sequence.steps |
| 17940 |
local order=sequence.order |
| 17941 |
local features=sequence.features |
| 17942 |
local flags=sequence.flags |
| 17943 |
if steps then |
| 17944 |
for i=1,#steps do |
| 17945 |
local step=steps[i] |
| 17946 |
if kind=="gpos_pair" then |
| 17947 |
local c=step.coverage |
| 17948 |
if c then |
| 17949 |
if step.format~="pair" then |
| 17950 |
for g1,d1 in next,c do |
| 17951 |
c[g1]=pack_normal(d1) |
| 17952 |
end |
| 17953 |
elseif step.shared then |
| 17954 |
local shared={} |
| 17955 |
for g1,d1 in next,c do |
| 17956 |
for g2,d2 in next,d1 do |
| 17957 |
if not shared[d2] then |
| 17958 |
local f=d2[1] if f and f~=true then d2[1]=pack_indexed(f) end |
| 17959 |
local s=d2[2] if s and s~=true then d2[2]=pack_indexed(s) end |
| 17960 |
shared[d2]=true |
| 17961 |
end |
| 17962 |
end |
| 17963 |
end |
| 17964 |
if pass==2 then |
| 17965 |
step.shared=nil |
| 17966 |
end |
| 17967 |
else |
| 17968 |
for g1,d1 in next,c do |
| 17969 |
for g2,d2 in next,d1 do |
| 17970 |
local f=d2[1] if f and f~=true then d2[1]=pack_indexed(f) end |
| 17971 |
local s=d2[2] if s and s~=true then d2[2]=pack_indexed(s) end |
| 17972 |
end |
| 17973 |
end |
| 17974 |
end |
| 17975 |
end |
| 17976 |
elseif kind=="gpos_single" then |
| 17977 |
local c=step.coverage |
| 17978 |
if c then |
| 17979 |
if step.format=="single" then |
| 17980 |
for g1,d1 in next,c do |
| 17981 |
if d1 and d1~=true then |
| 17982 |
c[g1]=pack_indexed(d1) |
| 17983 |
end |
| 17984 |
end |
| 17985 |
else |
| 17986 |
step.coverage=pack_normal(c) |
| 17987 |
end |
| 17988 |
end |
| 17989 |
elseif kind=="gpos_cursive" then |
| 17990 |
local c=step.coverage |
| 17991 |
if c then |
| 17992 |
for g1,d1 in next,c do |
| 17993 |
local f=d1[2] if f then d1[2]=pack_indexed(f) end |
| 17994 |
local s=d1[3] if s then d1[3]=pack_indexed(s) end |
| 17995 |
end |
| 17996 |
end |
| 17997 |
elseif kind=="gpos_mark2base" or kind=="gpos_mark2mark" then |
| 17998 |
local c=step.baseclasses |
| 17999 |
if c then |
| 18000 |
for g1,d1 in next,c do |
| 18001 |
for g2,d2 in next,d1 do |
| 18002 |
d1[g2]=pack_indexed(d2) |
| 18003 |
end |
| 18004 |
end |
| 18005 |
end |
| 18006 |
local c=step.coverage |
| 18007 |
if c then |
| 18008 |
for g1,d1 in next,c do |
| 18009 |
d1[2]=pack_indexed(d1[2]) |
| 18010 |
end |
| 18011 |
end |
| 18012 |
elseif kind=="gpos_mark2ligature" then |
| 18013 |
local c=step.baseclasses |
| 18014 |
if c then |
| 18015 |
for g1,d1 in next,c do |
| 18016 |
for g2,d2 in next,d1 do |
| 18017 |
for g3,d3 in next,d2 do |
| 18018 |
d2[g3]=pack_indexed(d3) |
| 18019 |
end |
| 18020 |
end |
| 18021 |
end |
| 18022 |
end |
| 18023 |
local c=step.coverage |
| 18024 |
if c then |
| 18025 |
for g1,d1 in next,c do |
| 18026 |
d1[2]=pack_indexed(d1[2]) |
| 18027 |
end |
| 18028 |
end |
| 18029 |
end |
| 18030 |
local rules=step.rules |
| 18031 |
if rules then |
| 18032 |
for i=1,#rules do |
| 18033 |
local rule=rules[i] |
| 18034 |
local r=rule.before if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end |
| 18035 |
local r=rule.after if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end |
| 18036 |
local r=rule.current if r then for i=1,#r do r[i]=pack_boolean(r[i]) end end |
| 18037 |
local r=rule.replacements if r then rule.replacements=pack_flat (r) end |
| 18038 |
end |
| 18039 |
end |
| 18040 |
end |
| 18041 |
end |
| 18042 |
if order then |
| 18043 |
sequence.order=pack_indexed(order) |
| 18044 |
end |
| 18045 |
if features then |
| 18046 |
for script,feature in next,features do |
| 18047 |
features[script]=pack_normal(feature) |
| 18048 |
end |
| 18049 |
end |
| 18050 |
if flags then |
| 18051 |
sequence.flags=pack_normal(flags) |
| 18052 |
end |
| 18053 |
end |
| 18054 |
end |
| 18055 |
if sequences then |
| 18056 |
packthem(sequences) |
| 18057 |
end |
| 18058 |
if sublookups then |
| 18059 |
packthem(sublookups) |
| 18060 |
end |
| 18061 |
if features then |
| 18062 |
for k,list in next,features do |
| 18063 |
for feature,spec in next,list do |
| 18064 |
list[feature]=pack_normal(spec) |
| 18065 |
end |
| 18066 |
end |
| 18067 |
end |
| 18068 |
if palettes then |
| 18069 |
for i=1,#palettes do |
| 18070 |
local p=palettes[i] |
| 18071 |
for j=1,#p do |
| 18072 |
p[j]=pack_indexed(p[j]) |
| 18073 |
end |
| 18074 |
end |
| 18075 |
end |
| 18076 |
if variable then |
| 18077 |
local instances=variable.instances |
| 18078 |
if instances then |
| 18079 |
for i=1,#instances do |
| 18080 |
local v=instances[i].values |
| 18081 |
for j=1,#v do |
| 18082 |
v[j]=pack_normal(v[j]) |
| 18083 |
end |
| 18084 |
end |
| 18085 |
end |
| 18086 |
local function packdeltas(main) |
| 18087 |
if main then |
| 18088 |
local deltas=main.deltas |
| 18089 |
if deltas then |
| 18090 |
for i=1,#deltas do |
| 18091 |
local di=deltas[i] |
| 18092 |
local d=di.deltas |
| 18093 |
for j=1,#d do |
| 18094 |
d[j]=pack_indexed(d[j]) |
| 18095 |
end |
| 18096 |
di.regions=pack_indexed(di.regions) |
| 18097 |
end |
| 18098 |
end |
| 18099 |
local regions=main.regions |
| 18100 |
if regions then |
| 18101 |
for i=1,#regions do |
| 18102 |
local r=regions[i] |
| 18103 |
for j=1,#r do |
| 18104 |
r[j]=pack_normal(r[j]) |
| 18105 |
end |
| 18106 |
end |
| 18107 |
end |
| 18108 |
end |
| 18109 |
end |
| 18110 |
packdeltas(variable.global) |
| 18111 |
packdeltas(variable.horizontal) |
| 18112 |
packdeltas(variable.vertical) |
| 18113 |
packdeltas(variable.metrics) |
| 18114 |
end |
| 18115 |
if not success(1,pass) then |
| 18116 |
return |
| 18117 |
end |
| 18118 |
end |
| 18119 |
if nt>0 then |
| 18120 |
for pass=1,2 do |
| 18121 |
if trace_packing then |
| 18122 |
report_otf("start packing: stage 2, pass %s",pass) |
| 18123 |
end |
| 18124 |
local pack_normal,pack_indexed,pack_flat,pack_boolean,pack_mixed,pack_normal_cc=packers(pass) |
| 18125 |
for unicode,description in next,descriptions do |
| 18126 |
local math=description.math |
| 18127 |
if math then |
| 18128 |
local kerns=math.kerns |
| 18129 |
if kerns then |
| 18130 |
math.kerns=pack_normal(kerns) |
| 18131 |
end |
| 18132 |
end |
| 18133 |
end |
| 18134 |
local function packthem(sequences) |
| 18135 |
for i=1,#sequences do |
| 18136 |
local sequence=sequences[i] |
| 18137 |
local kind=sequence.type |
| 18138 |
local steps=sequence.steps |
| 18139 |
local features=sequence.features |
| 18140 |
if steps then |
| 18141 |
for i=1,#steps do |
| 18142 |
local step=steps[i] |
| 18143 |
if kind=="gpos_pair" then |
| 18144 |
local c=step.coverage |
| 18145 |
if c then |
| 18146 |
if step.format=="pair" then |
| 18147 |
for g1,d1 in next,c do |
| 18148 |
for g2,d2 in next,d1 do |
| 18149 |
d1[g2]=pack_normal(d2) |
| 18150 |
end |
| 18151 |
end |
| 18152 |
end |
| 18153 |
end |
| 18154 |
elseif kind=="gpos_mark2ligature" then |
| 18155 |
local c=step.baseclasses |
| 18156 |
if c then |
| 18157 |
for g1,d1 in next,c do |
| 18158 |
for g2,d2 in next,d1 do |
| 18159 |
d1[g2]=pack_normal(d2) |
| 18160 |
end |
| 18161 |
end |
| 18162 |
end |
| 18163 |
end |
| 18164 |
local rules=step.rules |
| 18165 |
if rules then |
| 18166 |
for i=1,#rules do |
| 18167 |
local rule=rules[i] |
| 18168 |
local r=rule.before if r then rule.before=pack_normal(r) end |
| 18169 |
local r=rule.after if r then rule.after=pack_normal(r) end |
| 18170 |
local r=rule.current if r then rule.current=pack_normal(r) end |
| 18171 |
end |
| 18172 |
end |
| 18173 |
end |
| 18174 |
end |
| 18175 |
if features then |
| 18176 |
sequence.features=pack_normal(features) |
| 18177 |
end |
| 18178 |
end |
| 18179 |
end |
| 18180 |
if sequences then |
| 18181 |
packthem(sequences) |
| 18182 |
end |
| 18183 |
if sublookups then |
| 18184 |
packthem(sublookups) |
| 18185 |
end |
| 18186 |
if variable then |
| 18187 |
local function unpackdeltas(main) |
| 18188 |
if main then |
| 18189 |
local regions=main.regions |
| 18190 |
if regions then |
| 18191 |
main.regions=pack_normal(regions) |
| 18192 |
end |
| 18193 |
end |
| 18194 |
end |
| 18195 |
unpackdeltas(variable.global) |
| 18196 |
unpackdeltas(variable.horizontal) |
| 18197 |
unpackdeltas(variable.vertical) |
| 18198 |
unpackdeltas(variable.metrics) |
| 18199 |
end |
| 18200 |
end |
| 18201 |
for pass=1,2 do |
| 18202 |
if trace_packing then |
| 18203 |
report_otf("start packing: stage 3, pass %s",pass) |
| 18204 |
end |
| 18205 |
local pack_normal,pack_indexed,pack_flat,pack_boolean,pack_mixed,pack_normal_cc=packers(pass) |
| 18206 |
local function packthem(sequences) |
| 18207 |
for i=1,#sequences do |
| 18208 |
local sequence=sequences[i] |
| 18209 |
local kind=sequence.type |
| 18210 |
local steps=sequence.steps |
| 18211 |
local features=sequence.features |
| 18212 |
if steps then |
| 18213 |
for i=1,#steps do |
| 18214 |
local step=steps[i] |
| 18215 |
if kind=="gpos_pair" then |
| 18216 |
local c=step.coverage |
| 18217 |
if c then |
| 18218 |
if step.format=="pair" then |
| 18219 |
for g1,d1 in next,c do |
| 18220 |
c[g1]=pack_normal(d1) |
| 18221 |
end |
| 18222 |
end |
| 18223 |
end |
| 18224 |
elseif kind=="gpos_cursive" then |
| 18225 |
local c=step.coverage |
| 18226 |
if c then |
| 18227 |
for g1,d1 in next,c do |
| 18228 |
c[g1]=pack_normal_cc(d1) |
| 18229 |
end |
| 18230 |
end |
| 18231 |
end |
| 18232 |
end |
| 18233 |
end |
| 18234 |
end |
| 18235 |
end |
| 18236 |
if sequences then |
| 18237 |
packthem(sequences) |
| 18238 |
end |
| 18239 |
if sublookups then |
| 18240 |
packthem(sublookups) |
| 18241 |
end |
| 18242 |
end |
| 18243 |
end |
| 18244 |
end |
| 18245 |
end |
| 18246 |
local unpacked_mt={ |
| 18247 |
__index=function(t,k) |
| 18248 |
t[k]=false |
| 18249 |
return k |
| 18250 |
end |
| 18251 |
} |
| 18252 |
function readers.unpack(data) |
| 18253 |
if data then |
| 18254 |
local tables=data.tables |
| 18255 |
if tables then |
| 18256 |
local resources=data.resources |
| 18257 |
local descriptions=data.descriptions or data.glyphs |
| 18258 |
local sequences=resources.sequences |
| 18259 |
local sublookups=resources.sublookups |
| 18260 |
local features=resources.features |
| 18261 |
local palettes=resources.colorpalettes |
| 18262 |
local variable=resources.variabledata |
| 18263 |
local unpacked={} |
| 18264 |
setmetatable(unpacked,unpacked_mt) |
| 18265 |
for unicode,description in next,descriptions do |
| 18266 |
local tv=tables[description.boundingbox] |
| 18267 |
if tv then |
| 18268 |
description.boundingbox=tv |
| 18269 |
end |
| 18270 |
local math=description.math |
| 18271 |
if math then |
| 18272 |
local kerns=math.kerns |
| 18273 |
if kerns then |
| 18274 |
local tm=tables[kerns] |
| 18275 |
if tm then |
| 18276 |
math.kerns=tm |
| 18277 |
kerns=unpacked[tm] |
| 18278 |
end |
| 18279 |
if kerns then |
| 18280 |
for k,kern in next,kerns do |
| 18281 |
local tv=tables[kern] |
| 18282 |
if tv then |
| 18283 |
kerns[k]=tv |
| 18284 |
end |
| 18285 |
end |
| 18286 |
end |
| 18287 |
end |
| 18288 |
end |
| 18289 |
end |
| 18290 |
local function unpackthem(sequences) |
| 18291 |
for i=1,#sequences do |
| 18292 |
local sequence=sequences[i] |
| 18293 |
local kind=sequence.type |
| 18294 |
local steps=sequence.steps |
| 18295 |
local order=sequence.order |
| 18296 |
local features=sequence.features |
| 18297 |
local flags=sequence.flags |
| 18298 |
local markclass=sequence.markclass |
| 18299 |
if features then |
| 18300 |
local tv=tables[features] |
| 18301 |
if tv then |
| 18302 |
sequence.features=tv |
| 18303 |
features=tv |
| 18304 |
end |
| 18305 |
for script,feature in next,features do |
| 18306 |
local tv=tables[feature] |
| 18307 |
if tv then |
| 18308 |
features[script]=tv |
| 18309 |
end |
| 18310 |
end |
| 18311 |
end |
| 18312 |
if steps then |
| 18313 |
for i=1,#steps do |
| 18314 |
local step=steps[i] |
| 18315 |
if kind=="gpos_pair" then |
| 18316 |
local c=step.coverage |
| 18317 |
if c then |
| 18318 |
if step.format=="pair" then |
| 18319 |
for g1,d1 in next,c do |
| 18320 |
local tv=tables[d1] |
| 18321 |
if tv then |
| 18322 |
c[g1]=tv |
| 18323 |
d1=tv |
| 18324 |
end |
| 18325 |
for g2,d2 in next,d1 do |
| 18326 |
local tv=tables[d2] |
| 18327 |
if tv then |
| 18328 |
d1[g2]=tv |
| 18329 |
d2=tv |
| 18330 |
end |
| 18331 |
local f=tables[d2[1]] if f then d2[1]=f end |
| 18332 |
local s=tables[d2[2]] if s then d2[2]=s end |
| 18333 |
end |
| 18334 |
end |
| 18335 |
else |
| 18336 |
for g1,d1 in next,c do |
| 18337 |
local tv=tables[d1] |
| 18338 |
if tv then |
| 18339 |
c[g1]=tv |
| 18340 |
end |
| 18341 |
end |
| 18342 |
end |
| 18343 |
end |
| 18344 |
elseif kind=="gpos_single" then |
| 18345 |
local c=step.coverage |
| 18346 |
if c then |
| 18347 |
if step.format=="single" then |
| 18348 |
for g1,d1 in next,c do |
| 18349 |
local tv=tables[d1] |
| 18350 |
if tv then |
| 18351 |
c[g1]=tv |
| 18352 |
end |
| 18353 |
end |
| 18354 |
else |
| 18355 |
local tv=tables[c] |
| 18356 |
if tv then |
| 18357 |
step.coverage=tv |
| 18358 |
end |
| 18359 |
end |
| 18360 |
end |
| 18361 |
elseif kind=="gpos_cursive" then |
| 18362 |
local c=step.coverage |
| 18363 |
if c then |
| 18364 |
for g1,d1 in next,c do |
| 18365 |
local tv=tables[d1] |
| 18366 |
if tv then |
| 18367 |
d1=tv |
| 18368 |
c[g1]=d1 |
| 18369 |
end |
| 18370 |
local f=tables[d1[2]] if f then d1[2]=f end |
| 18371 |
local s=tables[d1[3]] if s then d1[3]=s end |
| 18372 |
end |
| 18373 |
end |
| 18374 |
elseif kind=="gpos_mark2base" or kind=="gpos_mark2mark" then |
| 18375 |
local c=step.baseclasses |
| 18376 |
if c then |
| 18377 |
for g1,d1 in next,c do |
| 18378 |
for g2,d2 in next,d1 do |
| 18379 |
local tv=tables[d2] |
| 18380 |
if tv then |
| 18381 |
d1[g2]=tv |
| 18382 |
end |
| 18383 |
end |
| 18384 |
end |
| 18385 |
end |
| 18386 |
local c=step.coverage |
| 18387 |
if c then |
| 18388 |
for g1,d1 in next,c do |
| 18389 |
local tv=tables[d1[2]] |
| 18390 |
if tv then |
| 18391 |
d1[2]=tv |
| 18392 |
end |
| 18393 |
end |
| 18394 |
end |
| 18395 |
elseif kind=="gpos_mark2ligature" then |
| 18396 |
local c=step.baseclasses |
| 18397 |
if c then |
| 18398 |
for g1,d1 in next,c do |
| 18399 |
for g2,d2 in next,d1 do |
| 18400 |
local tv=tables[d2] |
| 18401 |
if tv then |
| 18402 |
d2=tv |
| 18403 |
d1[g2]=d2 |
| 18404 |
end |
| 18405 |
for g3,d3 in next,d2 do |
| 18406 |
local tv=tables[d2[g3]] |
| 18407 |
if tv then |
| 18408 |
d2[g3]=tv |
| 18409 |
end |
| 18410 |
end |
| 18411 |
end |
| 18412 |
end |
| 18413 |
end |
| 18414 |
local c=step.coverage |
| 18415 |
if c then |
| 18416 |
for g1,d1 in next,c do |
| 18417 |
local tv=tables[d1[2]] |
| 18418 |
if tv then |
| 18419 |
d1[2]=tv |
| 18420 |
end |
| 18421 |
end |
| 18422 |
end |
| 18423 |
end |
| 18424 |
local rules=step.rules |
| 18425 |
if rules then |
| 18426 |
for i=1,#rules do |
| 18427 |
local rule=rules[i] |
| 18428 |
local before=rule.before |
| 18429 |
if before then |
| 18430 |
local tv=tables[before] |
| 18431 |
if tv then |
| 18432 |
rule.before=tv |
| 18433 |
before=tv |
| 18434 |
end |
| 18435 |
for i=1,#before do |
| 18436 |
local tv=tables[before[i]] |
| 18437 |
if tv then |
| 18438 |
before[i]=tv |
| 18439 |
end |
| 18440 |
end |
| 18441 |
end |
| 18442 |
local after=rule.after |
| 18443 |
if after then |
| 18444 |
local tv=tables[after] |
| 18445 |
if tv then |
| 18446 |
rule.after=tv |
| 18447 |
after=tv |
| 18448 |
end |
| 18449 |
for i=1,#after do |
| 18450 |
local tv=tables[after[i]] |
| 18451 |
if tv then |
| 18452 |
after[i]=tv |
| 18453 |
end |
| 18454 |
end |
| 18455 |
end |
| 18456 |
local current=rule.current |
| 18457 |
if current then |
| 18458 |
local tv=tables[current] |
| 18459 |
if tv then |
| 18460 |
rule.current=tv |
| 18461 |
current=tv |
| 18462 |
end |
| 18463 |
for i=1,#current do |
| 18464 |
local tv=tables[current[i]] |
| 18465 |
if tv then |
| 18466 |
current[i]=tv |
| 18467 |
end |
| 18468 |
end |
| 18469 |
end |
| 18470 |
local replacements=rule.replacements |
| 18471 |
if replacements then |
| 18472 |
local tv=tables[replacements] |
| 18473 |
if tv then |
| 18474 |
rule.replacements=tv |
| 18475 |
end |
| 18476 |
end |
| 18477 |
end |
| 18478 |
end |
| 18479 |
end |
| 18480 |
end |
| 18481 |
if order then |
| 18482 |
local tv=tables[order] |
| 18483 |
if tv then |
| 18484 |
sequence.order=tv |
| 18485 |
end |
| 18486 |
end |
| 18487 |
if flags then |
| 18488 |
local tv=tables[flags] |
| 18489 |
if tv then |
| 18490 |
sequence.flags=tv |
| 18491 |
end |
| 18492 |
end |
| 18493 |
end |
| 18494 |
end |
| 18495 |
if sequences then |
| 18496 |
unpackthem(sequences) |
| 18497 |
end |
| 18498 |
if sublookups then |
| 18499 |
unpackthem(sublookups) |
| 18500 |
end |
| 18501 |
if features then |
| 18502 |
for k,list in next,features do |
| 18503 |
for feature,spec in next,list do |
| 18504 |
local tv=tables[spec] |
| 18505 |
if tv then |
| 18506 |
list[feature]=tv |
| 18507 |
end |
| 18508 |
end |
| 18509 |
end |
| 18510 |
end |
| 18511 |
if palettes then |
| 18512 |
for i=1,#palettes do |
| 18513 |
local p=palettes[i] |
| 18514 |
for j=1,#p do |
| 18515 |
local tv=tables[p[j]] |
| 18516 |
if tv then |
| 18517 |
p[j]=tv |
| 18518 |
end |
| 18519 |
end |
| 18520 |
end |
| 18521 |
end |
| 18522 |
if variable then |
| 18523 |
local instances=variable.instances |
| 18524 |
if instances then |
| 18525 |
for i=1,#instances do |
| 18526 |
local v=instances[i].values |
| 18527 |
for j=1,#v do |
| 18528 |
local tv=tables[v[j]] |
| 18529 |
if tv then |
| 18530 |
v[j]=tv |
| 18531 |
end |
| 18532 |
end |
| 18533 |
end |
| 18534 |
end |
| 18535 |
local function unpackdeltas(main) |
| 18536 |
if main then |
| 18537 |
local deltas=main.deltas |
| 18538 |
if deltas then |
| 18539 |
for i=1,#deltas do |
| 18540 |
local di=deltas[i] |
| 18541 |
local d=di.deltas |
| 18542 |
local r=di.regions |
| 18543 |
for j=1,#d do |
| 18544 |
local tv=tables[d[j]] |
| 18545 |
if tv then |
| 18546 |
d[j]=tv |
| 18547 |
end |
| 18548 |
end |
| 18549 |
local tv=di.regions |
| 18550 |
if tv then |
| 18551 |
di.regions=tv |
| 18552 |
end |
| 18553 |
end |
| 18554 |
end |
| 18555 |
local regions=main.regions |
| 18556 |
if regions then |
| 18557 |
local tv=tables[regions] |
| 18558 |
if tv then |
| 18559 |
main.regions=tv |
| 18560 |
regions=tv |
| 18561 |
end |
| 18562 |
for i=1,#regions do |
| 18563 |
local r=regions[i] |
| 18564 |
for j=1,#r do |
| 18565 |
local tv=tables[r[j]] |
| 18566 |
if tv then |
| 18567 |
r[j]=tv |
| 18568 |
end |
| 18569 |
end |
| 18570 |
end |
| 18571 |
end |
| 18572 |
end |
| 18573 |
end |
| 18574 |
unpackdeltas(variable.global) |
| 18575 |
unpackdeltas(variable.horizontal) |
| 18576 |
unpackdeltas(variable.vertical) |
| 18577 |
unpackdeltas(variable.metrics) |
| 18578 |
end |
| 18579 |
data.tables=nil |
| 18580 |
end |
| 18581 |
end |
| 18582 |
end |
| 18583 |
local mt={ |
| 18584 |
__index=function(t,k) |
| 18585 |
if k=="height" then |
| 18586 |
local ht=t.boundingbox[4] |
| 18587 |
return ht<0 and 0 or ht |
| 18588 |
elseif k=="depth" then |
| 18589 |
local dp=-t.boundingbox[2] |
| 18590 |
return dp<0 and 0 or dp |
| 18591 |
elseif k=="width" then |
| 18592 |
return 0 |
| 18593 |
elseif k=="name" then |
| 18594 |
return forcenotdef and ".notdef" |
| 18595 |
end |
| 18596 |
end |
| 18597 |
} |
| 18598 |
local function sameformat(sequence,steps,first,nofsteps,kind) |
| 18599 |
return true |
| 18600 |
end |
| 18601 |
local function mergesteps_1(lookup,strict) |
| 18602 |
local steps=lookup.steps |
| 18603 |
local nofsteps=lookup.nofsteps |
| 18604 |
local first=steps[1] |
| 18605 |
if strict then |
| 18606 |
local f=first.format |
| 18607 |
for i=2,nofsteps do |
| 18608 |
if steps[i].format~=f then |
| 18609 |
if trace_optimizations then |
| 18610 |
report_optimizations("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) |
| 18611 |
end |
| 18612 |
return 0 |
| 18613 |
end |
| 18614 |
end |
| 18615 |
end |
| 18616 |
if trace_optimizations then |
| 18617 |
report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) |
| 18618 |
end |
| 18619 |
local target=first.coverage |
| 18620 |
for i=2,nofsteps do |
| 18621 |
local c=steps[i].coverage |
| 18622 |
if c then |
| 18623 |
for k,v in next,c do |
| 18624 |
if not target[k] then |
| 18625 |
target[k]=v |
| 18626 |
end |
| 18627 |
end |
| 18628 |
end |
| 18629 |
end |
| 18630 |
lookup.nofsteps=1 |
| 18631 |
lookup.merged=true |
| 18632 |
lookup.steps={ first } |
| 18633 |
return nofsteps-1 |
| 18634 |
end |
| 18635 |
local function mergesteps_2(lookup) |
| 18636 |
local steps=lookup.steps |
| 18637 |
local nofsteps=lookup.nofsteps |
| 18638 |
local first=steps[1] |
| 18639 |
if strict then |
| 18640 |
local f=first.format |
| 18641 |
for i=2,nofsteps do |
| 18642 |
if steps[i].format~=f then |
| 18643 |
if trace_optimizations then |
| 18644 |
report_optimizations("not merging %a steps of %a lookup %a, different formats",nofsteps,lookup.type,lookup.name) |
| 18645 |
end |
| 18646 |
return 0 |
| 18647 |
end |
| 18648 |
end |
| 18649 |
end |
| 18650 |
if trace_optimizations then |
| 18651 |
report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) |
| 18652 |
end |
| 18653 |
local target=first.coverage |
| 18654 |
for i=2,nofsteps do |
| 18655 |
local c=steps[i].coverage |
| 18656 |
if c then |
| 18657 |
for k,v in next,c do |
| 18658 |
local tk=target[k] |
| 18659 |
if tk then |
| 18660 |
for kk,vv in next,v do |
| 18661 |
if tk[kk]==nil then |
| 18662 |
tk[kk]=vv |
| 18663 |
end |
| 18664 |
end |
| 18665 |
else |
| 18666 |
target[k]=v |
| 18667 |
end |
| 18668 |
end |
| 18669 |
end |
| 18670 |
end |
| 18671 |
lookup.nofsteps=1 |
| 18672 |
lookup.merged=true |
| 18673 |
lookup.steps={ first } |
| 18674 |
return nofsteps-1 |
| 18675 |
end |
| 18676 |
local function mergesteps_3(lookup,strict) |
| 18677 |
local steps=lookup.steps |
| 18678 |
local nofsteps=lookup.nofsteps |
| 18679 |
if trace_optimizations then |
| 18680 |
report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) |
| 18681 |
end |
| 18682 |
local coverage={} |
| 18683 |
for i=1,nofsteps do |
| 18684 |
local c=steps[i].coverage |
| 18685 |
if c then |
| 18686 |
for k,v in next,c do |
| 18687 |
local tk=coverage[k] |
| 18688 |
if tk then |
| 18689 |
if trace_optimizations then |
| 18690 |
report_optimizations("quitting merge due to multiple checks") |
| 18691 |
end |
| 18692 |
return nofsteps |
| 18693 |
else |
| 18694 |
coverage[k]=v |
| 18695 |
end |
| 18696 |
end |
| 18697 |
end |
| 18698 |
end |
| 18699 |
local first=steps[1] |
| 18700 |
local baseclasses={} |
| 18701 |
for i=1,nofsteps do |
| 18702 |
local offset=i*10 |
| 18703 |
local step=steps[i] |
| 18704 |
for k,v in sortedhash(step.baseclasses) do |
| 18705 |
baseclasses[offset+k]=v |
| 18706 |
end |
| 18707 |
for k,v in next,step.coverage do |
| 18708 |
v[1]=offset+v[1] |
| 18709 |
end |
| 18710 |
end |
| 18711 |
first.baseclasses=baseclasses |
| 18712 |
first.coverage=coverage |
| 18713 |
lookup.nofsteps=1 |
| 18714 |
lookup.merged=true |
| 18715 |
lookup.steps={ first } |
| 18716 |
return nofsteps-1 |
| 18717 |
end |
| 18718 |
local function nested(old,new) |
| 18719 |
for k,v in next,old do |
| 18720 |
if k=="ligature" then |
| 18721 |
if not new.ligature then |
| 18722 |
new.ligature=v |
| 18723 |
end |
| 18724 |
else |
| 18725 |
local n=new[k] |
| 18726 |
if n then |
| 18727 |
nested(v,n) |
| 18728 |
else |
| 18729 |
new[k]=v |
| 18730 |
end |
| 18731 |
end |
| 18732 |
end |
| 18733 |
end |
| 18734 |
local function mergesteps_4(lookup) |
| 18735 |
local steps=lookup.steps |
| 18736 |
local nofsteps=lookup.nofsteps |
| 18737 |
local first=steps[1] |
| 18738 |
if trace_optimizations then |
| 18739 |
report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) |
| 18740 |
end |
| 18741 |
local target=first.coverage |
| 18742 |
for i=2,nofsteps do |
| 18743 |
local c=steps[i].coverage |
| 18744 |
if c then |
| 18745 |
for k,v in next,c do |
| 18746 |
local tk=target[k] |
| 18747 |
if tk then |
| 18748 |
nested(v,tk) |
| 18749 |
else |
| 18750 |
target[k]=v |
| 18751 |
end |
| 18752 |
end |
| 18753 |
end |
| 18754 |
end |
| 18755 |
lookup.nofsteps=1 |
| 18756 |
lookup.steps={ first } |
| 18757 |
return nofsteps-1 |
| 18758 |
end |
| 18759 |
local function mergesteps_5(lookup) |
| 18760 |
local steps=lookup.steps |
| 18761 |
local nofsteps=lookup.nofsteps |
| 18762 |
local first=steps[1] |
| 18763 |
if trace_optimizations then |
| 18764 |
report_optimizations("merging %a steps of %a lookup %a",nofsteps,lookup.type,lookup.name) |
| 18765 |
end |
| 18766 |
local target=first.coverage |
| 18767 |
local hash=nil |
| 18768 |
for k,v in next,target do |
| 18769 |
hash=v[1] |
| 18770 |
break |
| 18771 |
end |
| 18772 |
for i=2,nofsteps do |
| 18773 |
local c=steps[i].coverage |
| 18774 |
if c then |
| 18775 |
for k,v in next,c do |
| 18776 |
local tk=target[k] |
| 18777 |
if tk then |
| 18778 |
if not tk[2] then |
| 18779 |
tk[2]=v[2] |
| 18780 |
end |
| 18781 |
if not tk[3] then |
| 18782 |
tk[3]=v[3] |
| 18783 |
end |
| 18784 |
else |
| 18785 |
target[k]=v |
| 18786 |
v[1]=hash |
| 18787 |
end |
| 18788 |
end |
| 18789 |
end |
| 18790 |
end |
| 18791 |
lookup.nofsteps=1 |
| 18792 |
lookup.merged=true |
| 18793 |
lookup.steps={ first } |
| 18794 |
return nofsteps-1 |
| 18795 |
end |
| 18796 |
local function checkkerns(lookup) |
| 18797 |
local steps=lookup.steps |
| 18798 |
local nofsteps=lookup.nofsteps |
| 18799 |
local kerned=0 |
| 18800 |
for i=1,nofsteps do |
| 18801 |
local step=steps[i] |
| 18802 |
if step.format=="pair" then |
| 18803 |
local coverage=step.coverage |
| 18804 |
local kerns=true |
| 18805 |
for g1,d1 in next,coverage do |
| 18806 |
if d1==true then |
| 18807 |
elseif not d1 then |
| 18808 |
elseif d1[1]~=0 or d1[2]~=0 or d1[4]~=0 then |
| 18809 |
kerns=false |
| 18810 |
break |
| 18811 |
end |
| 18812 |
end |
| 18813 |
if kerns then |
| 18814 |
if trace_optimizations then |
| 18815 |
report_optimizations("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) |
| 18816 |
end |
| 18817 |
local c={} |
| 18818 |
for g1,d1 in next,coverage do |
| 18819 |
if d1 and d1~=true then |
| 18820 |
c[g1]=d1[3] |
| 18821 |
end |
| 18822 |
end |
| 18823 |
step.coverage=c |
| 18824 |
step.format="move" |
| 18825 |
kerned=kerned+1 |
| 18826 |
end |
| 18827 |
end |
| 18828 |
end |
| 18829 |
return kerned |
| 18830 |
end |
| 18831 |
local strip_pairs=true |
| 18832 |
local compact_pairs=true |
| 18833 |
local compact_singles=true |
| 18834 |
local merge_pairs=true |
| 18835 |
local merge_singles=true |
| 18836 |
local merge_substitutions=true |
| 18837 |
local merge_alternates=true |
| 18838 |
local merge_multiples=true |
| 18839 |
local merge_ligatures=true |
| 18840 |
local merge_cursives=true |
| 18841 |
local merge_marks=true |
| 18842 |
directives.register("otf.strip.pairs",function(v) strip_pairs=v end) |
| 18843 |
directives.register("otf.compact.pairs",function(v) compact_pairs=v end) |
| 18844 |
directives.register("otf.compact.singles",function(v) compact_singles=v end) |
| 18845 |
directives.register("otf.merge.pairs",function(v) merge_pairs=v end) |
| 18846 |
directives.register("otf.merge.singles",function(v) merge_singles=v end) |
| 18847 |
directives.register("otf.merge.substitutions",function(v) merge_substitutions=v end) |
| 18848 |
directives.register("otf.merge.alternates",function(v) merge_alternates=v end) |
| 18849 |
directives.register("otf.merge.multiples",function(v) merge_multiples=v end) |
| 18850 |
directives.register("otf.merge.ligatures",function(v) merge_ligatures=v end) |
| 18851 |
directives.register("otf.merge.cursives",function(v) merge_cursives=v end) |
| 18852 |
directives.register("otf.merge.marks",function(v) merge_marks=v end) |
| 18853 |
local function checkpairs(lookup) |
| 18854 |
local steps=lookup.steps |
| 18855 |
local nofsteps=lookup.nofsteps |
| 18856 |
local kerned=0 |
| 18857 |
local function onlykerns(step) |
| 18858 |
local coverage=step.coverage |
| 18859 |
for g1,d1 in next,coverage do |
| 18860 |
for g2,d2 in next,d1 do |
| 18861 |
if d2[2] then |
| 18862 |
return false |
| 18863 |
else |
| 18864 |
local v=d2[1] |
| 18865 |
if v==true then |
| 18866 |
elseif v and (v[1]~=0 or v[2]~=0 or v[4]~=0) then |
| 18867 |
return false |
| 18868 |
end |
| 18869 |
end |
| 18870 |
end |
| 18871 |
end |
| 18872 |
return coverage |
| 18873 |
end |
| 18874 |
for i=1,nofsteps do |
| 18875 |
local step=steps[i] |
| 18876 |
if step.format=="pair" then |
| 18877 |
local coverage=onlykerns(step) |
| 18878 |
if coverage then |
| 18879 |
if trace_optimizations then |
| 18880 |
report_optimizations("turning pairs of step %a of %a lookup %a into kerns",i,lookup.type,lookup.name) |
| 18881 |
end |
| 18882 |
for g1,d1 in next,coverage do |
| 18883 |
local d={} |
| 18884 |
for g2,d2 in next,d1 do |
| 18885 |
local v=d2[1] |
| 18886 |
if v==true then |
| 18887 |
elseif v then |
| 18888 |
d[g2]=v[3] |
| 18889 |
end |
| 18890 |
end |
| 18891 |
coverage[g1]=d |
| 18892 |
end |
| 18893 |
step.format="move" |
| 18894 |
kerned=kerned+1 |
| 18895 |
end |
| 18896 |
end |
| 18897 |
end |
| 18898 |
return kerned |
| 18899 |
end |
| 18900 |
local function strippairs(lookup) |
| 18901 |
local steps=lookup.steps |
| 18902 |
local nofsteps=lookup.nofsteps |
| 18903 |
local stripped=0 |
| 18904 |
for i=1,nofsteps do |
| 18905 |
local step=steps[i] |
| 18906 |
if step.format=="pair" then |
| 18907 |
local coverage=step.coverage |
| 18908 |
for g1,d1 in next,coverage do |
| 18909 |
for g2,d2 in next,d1 do |
| 18910 |
if d2[2] then |
| 18911 |
elseif d2[1]==true then |
| 18912 |
d1[g2]=nil |
| 18913 |
stripped=stripped+1 |
| 18914 |
end |
| 18915 |
end |
| 18916 |
end |
| 18917 |
end |
| 18918 |
end |
| 18919 |
return stripped |
| 18920 |
end |
| 18921 |
function readers.compact(data) |
| 18922 |
if not data or data.compacted then |
| 18923 |
return |
| 18924 |
else |
| 18925 |
data.compacted=true |
| 18926 |
end |
| 18927 |
local resources=data.resources |
| 18928 |
local stripped=0 |
| 18929 |
local merged=0 |
| 18930 |
local kerned=0 |
| 18931 |
local allsteps=0 |
| 18932 |
local function compact(what) |
| 18933 |
local lookups=resources[what] |
| 18934 |
if lookups then |
| 18935 |
for i=1,#lookups do |
| 18936 |
local lookup=lookups[i] |
| 18937 |
local nofsteps=lookup.nofsteps |
| 18938 |
local kind=lookup.type |
| 18939 |
allsteps=allsteps+nofsteps |
| 18940 |
if nofsteps>1 then |
| 18941 |
local merg=merged |
| 18942 |
if kind=="gsub_single" then |
| 18943 |
if merge_substitutions then |
| 18944 |
merged=merged+mergesteps_1(lookup) |
| 18945 |
end |
| 18946 |
elseif kind=="gsub_alternate" then |
| 18947 |
if merge_alternates then |
| 18948 |
merged=merged+mergesteps_1(lookup) |
| 18949 |
end |
| 18950 |
elseif kind=="gsub_multiple" then |
| 18951 |
if merge_multiples then |
| 18952 |
merged=merged+mergesteps_1(lookup) |
| 18953 |
end |
| 18954 |
elseif kind=="gsub_ligature" then |
| 18955 |
if merge_ligatures then |
| 18956 |
merged=merged+mergesteps_4(lookup) |
| 18957 |
end |
| 18958 |
elseif kind=="gpos_single" then |
| 18959 |
if merge_singles then |
| 18960 |
merged=merged+mergesteps_1(lookup,true) |
| 18961 |
end |
| 18962 |
if compact_singles then |
| 18963 |
kerned=kerned+checkkerns(lookup) |
| 18964 |
end |
| 18965 |
elseif kind=="gpos_pair" then |
| 18966 |
if strip_pairs then |
| 18967 |
stripped=stripped+strippairs(lookup) |
| 18968 |
end |
| 18969 |
if merge_pairs then |
| 18970 |
merged=merged+mergesteps_2(lookup) |
| 18971 |
end |
| 18972 |
if compact_pairs then |
| 18973 |
kerned=kerned+checkpairs(lookup) |
| 18974 |
end |
| 18975 |
elseif kind=="gpos_cursive" then |
| 18976 |
if merge_cursives then |
| 18977 |
merged=merged+mergesteps_5(lookup) |
| 18978 |
end |
| 18979 |
elseif kind=="gpos_mark2mark" or kind=="gpos_mark2base" or kind=="gpos_mark2ligature" then |
| 18980 |
if merge_marks then |
| 18981 |
merged=merged+mergesteps_3(lookup) |
| 18982 |
end |
| 18983 |
end |
| 18984 |
if merg~=merged then |
| 18985 |
lookup.merged=true |
| 18986 |
end |
| 18987 |
elseif nofsteps==1 then |
| 18988 |
local kern=kerned |
| 18989 |
if kind=="gpos_single" then |
| 18990 |
if compact_singles then |
| 18991 |
kerned=kerned+checkkerns(lookup) |
| 18992 |
end |
| 18993 |
elseif kind=="gpos_pair" then |
| 18994 |
if compact_pairs then |
| 18995 |
kerned=kerned+checkpairs(lookup) |
| 18996 |
end |
| 18997 |
end |
| 18998 |
if kern~=kerned then |
| 18999 |
end |
| 19000 |
end |
| 19001 |
end |
| 19002 |
elseif trace_optimizations then |
| 19003 |
report_optimizations("no lookups in %a",what) |
| 19004 |
end |
| 19005 |
end |
| 19006 |
compact("sequences") |
| 19007 |
compact("sublookups") |
| 19008 |
if trace_optimizations then |
| 19009 |
if stripped>0 then |
| 19010 |
report_optimizations("%i zero positions stripped before merging",stripped) |
| 19011 |
end |
| 19012 |
if merged>0 then |
| 19013 |
report_optimizations("%i steps of %i removed due to merging",merged,allsteps) |
| 19014 |
end |
| 19015 |
if kerned>0 then |
| 19016 |
report_optimizations("%i steps of %i steps turned from pairs into kerns",kerned,allsteps) |
| 19017 |
end |
| 19018 |
end |
| 19019 |
end |
| 19020 |
if CONTEXTLMTXMODE and CONTEXTLMTXMODE>0 then |
| 19021 |
local done=0 |
| 19022 |
local function condense_1(k,v,t) |
| 19023 |
if type(v)=="table" then |
| 19024 |
local u=false |
| 19025 |
local l=false |
| 19026 |
for k,v in next,v do |
| 19027 |
if k=="ligature" then |
| 19028 |
l=v |
| 19029 |
if u then |
| 19030 |
break |
| 19031 |
end |
| 19032 |
elseif u then |
| 19033 |
break |
| 19034 |
else |
| 19035 |
u=true |
| 19036 |
end |
| 19037 |
end |
| 19038 |
if l and not u then |
| 19039 |
t[k]=l |
| 19040 |
done=done+1 |
| 19041 |
end |
| 19042 |
if u then |
| 19043 |
for k,vv in next,v do |
| 19044 |
if k~="ligature" then |
| 19045 |
condense_1(k,vv,v) |
| 19046 |
end |
| 19047 |
end |
| 19048 |
end |
| 19049 |
end |
| 19050 |
end |
| 19051 |
local function condensesteps_1(lookup) |
| 19052 |
done=0 |
| 19053 |
if lookup.type=="gsub_ligature" then |
| 19054 |
local steps=lookup.steps |
| 19055 |
if steps then |
| 19056 |
for i=1,#steps do |
| 19057 |
local step=steps[i] |
| 19058 |
local coverage=step.coverage |
| 19059 |
if coverage then |
| 19060 |
for k,v in next,coverage do |
| 19061 |
if condense_1(k,v,coverage) then |
| 19062 |
coverage[k]=v.ligature |
| 19063 |
done=done+1 |
| 19064 |
end |
| 19065 |
end |
| 19066 |
end |
| 19067 |
end |
| 19068 |
end |
| 19069 |
end |
| 19070 |
return done |
| 19071 |
end |
| 19072 |
function readers.condense(data) |
| 19073 |
if not data or data.condensed then |
| 19074 |
return |
| 19075 |
else |
| 19076 |
data.condensed=true |
| 19077 |
end |
| 19078 |
local resources=data.resources |
| 19079 |
local condensed=0 |
| 19080 |
local function condense(what) |
| 19081 |
local lookups=resources[what] |
| 19082 |
if lookups then |
| 19083 |
for i=1,#lookups do |
| 19084 |
condensed=condensed+condensesteps_1(lookups[i]) |
| 19085 |
end |
| 19086 |
elseif trace_optimizations then |
| 19087 |
report_optimizations("no lookups in %a",what) |
| 19088 |
end |
| 19089 |
end |
| 19090 |
condense("sequences") |
| 19091 |
condense("sublookups") |
| 19092 |
if trace_optimizations then |
| 19093 |
if condensed>0 then |
| 19094 |
report_optimizations("%i ligatures condensed",condensed) |
| 19095 |
end |
| 19096 |
end |
| 19097 |
end |
| 19098 |
end |
| 19099 |
local function mergesteps(t,k) |
| 19100 |
if k=="merged" then |
| 19101 |
local merged={} |
| 19102 |
for i=1,#t do |
| 19103 |
local step=t[i] |
| 19104 |
local coverage=step.coverage |
| 19105 |
for k in next,coverage do |
| 19106 |
local m=merged[k] |
| 19107 |
if m then |
| 19108 |
m[2]=i |
| 19109 |
else |
| 19110 |
merged[k]={ i,i } |
| 19111 |
end |
| 19112 |
end |
| 19113 |
end |
| 19114 |
t.merged=merged |
| 19115 |
return merged |
| 19116 |
end |
| 19117 |
end |
| 19118 |
local function checkmerge(sequence) |
| 19119 |
local steps=sequence.steps |
| 19120 |
if steps then |
| 19121 |
setmetatableindex(steps,mergesteps) |
| 19122 |
end |
| 19123 |
end |
| 19124 |
local function checkflags(sequence,resources) |
| 19125 |
if not sequence.skiphash then |
| 19126 |
local flags=sequence.flags |
| 19127 |
if flags then |
| 19128 |
local skipmark=flags[1] |
| 19129 |
local skipligature=flags[2] |
| 19130 |
local skipbase=flags[3] |
| 19131 |
local markclass=sequence.markclass |
| 19132 |
local skipsome=skipmark or skipligature or skipbase or markclass or false |
| 19133 |
if skipsome then |
| 19134 |
sequence.skiphash=setmetatableindex(function(t,k) |
| 19135 |
local c=resources.classes[k] |
| 19136 |
local v=c==skipmark |
| 19137 |
or (markclass and c=="mark" and not markclass[k]) |
| 19138 |
or c==skipligature |
| 19139 |
or c==skipbase |
| 19140 |
or false |
| 19141 |
t[k]=v |
| 19142 |
return v |
| 19143 |
end) |
| 19144 |
else |
| 19145 |
sequence.skiphash=false |
| 19146 |
end |
| 19147 |
else |
| 19148 |
sequence.skiphash=false |
| 19149 |
end |
| 19150 |
end |
| 19151 |
end |
| 19152 |
local function checksteps(sequence) |
| 19153 |
local steps=sequence.steps |
| 19154 |
if steps then |
| 19155 |
for i=1,#steps do |
| 19156 |
steps[i].index=i |
| 19157 |
end |
| 19158 |
end |
| 19159 |
end |
| 19160 |
if fonts.helpers then |
| 19161 |
fonts.helpers.checkmerge=checkmerge |
| 19162 |
fonts.helpers.checkflags=checkflags |
| 19163 |
fonts.helpers.checksteps=checksteps |
| 19164 |
end |
| 19165 |
function readers.expand(data) |
| 19166 |
if not data or data.expanded then |
| 19167 |
return |
| 19168 |
else |
| 19169 |
data.expanded=true |
| 19170 |
end |
| 19171 |
local resources=data.resources |
| 19172 |
local sublookups=resources.sublookups |
| 19173 |
local sequences=resources.sequences |
| 19174 |
local markclasses=resources.markclasses |
| 19175 |
local descriptions=data.descriptions |
| 19176 |
if descriptions then |
| 19177 |
local defaultwidth=resources.defaultwidth or 0 |
| 19178 |
local defaultheight=resources.defaultheight or 0 |
| 19179 |
local defaultdepth=resources.defaultdepth or 0 |
| 19180 |
local basename=trace_markwidth and file.basename(resources.filename) |
| 19181 |
for u,d in next,descriptions do |
| 19182 |
local bb=d.boundingbox |
| 19183 |
local wd=d.width |
| 19184 |
if not wd then |
| 19185 |
d.width=defaultwidth |
| 19186 |
elseif trace_markwidth and wd~=0 and d.class=="mark" then |
| 19187 |
report_markwidth("mark %a with width %b found in %a",d.name or "<noname>",wd,basename) |
| 19188 |
end |
| 19189 |
if bb then |
| 19190 |
local ht=bb[4] |
| 19191 |
local dp=-bb[2] |
| 19192 |
if ht==0 or ht<0 then |
| 19193 |
else |
| 19194 |
d.height=ht |
| 19195 |
end |
| 19196 |
if dp==0 or dp<0 then |
| 19197 |
else |
| 19198 |
d.depth=dp |
| 19199 |
end |
| 19200 |
end |
| 19201 |
end |
| 19202 |
end |
| 19203 |
local function expandlookups(sequences,whatever) |
| 19204 |
if sequences then |
| 19205 |
for i=1,#sequences do |
| 19206 |
local sequence=sequences[i] |
| 19207 |
local steps=sequence.steps |
| 19208 |
if steps then |
| 19209 |
local nofsteps=sequence.nofsteps |
| 19210 |
local kind=sequence.type |
| 19211 |
local markclass=sequence.markclass |
| 19212 |
if markclass then |
| 19213 |
if not markclasses then |
| 19214 |
report_warning("missing markclasses") |
| 19215 |
sequence.markclass=false |
| 19216 |
else |
| 19217 |
sequence.markclass=markclasses[markclass] |
| 19218 |
end |
| 19219 |
end |
| 19220 |
for i=1,nofsteps do |
| 19221 |
local step=steps[i] |
| 19222 |
local baseclasses=step.baseclasses |
| 19223 |
if baseclasses then |
| 19224 |
local coverage=step.coverage |
| 19225 |
for k,v in next,coverage do |
| 19226 |
v[1]=baseclasses[v[1]] |
| 19227 |
end |
| 19228 |
elseif kind=="gpos_cursive" then |
| 19229 |
local coverage=step.coverage |
| 19230 |
for k,v in next,coverage do |
| 19231 |
v[1]=coverage |
| 19232 |
end |
| 19233 |
end |
| 19234 |
local rules=step.rules |
| 19235 |
if rules then |
| 19236 |
local rulehash={ n=0 } |
| 19237 |
local rulesize=0 |
| 19238 |
local coverage={} |
| 19239 |
local lookuptype=sequence.type |
| 19240 |
local nofrules=#rules |
| 19241 |
step.coverage=coverage |
| 19242 |
for currentrule=1,nofrules do |
| 19243 |
local rule=rules[currentrule] |
| 19244 |
local current=rule.current |
| 19245 |
local before=rule.before |
| 19246 |
local after=rule.after |
| 19247 |
local replacements=rule.replacements or false |
| 19248 |
local sequence={} |
| 19249 |
local nofsequences=0 |
| 19250 |
if before then |
| 19251 |
for n=1,#before do |
| 19252 |
nofsequences=nofsequences+1 |
| 19253 |
sequence[nofsequences]=before[n] |
| 19254 |
end |
| 19255 |
end |
| 19256 |
local start=nofsequences+1 |
| 19257 |
for n=1,#current do |
| 19258 |
nofsequences=nofsequences+1 |
| 19259 |
sequence[nofsequences]=current[n] |
| 19260 |
end |
| 19261 |
local stop=nofsequences |
| 19262 |
if after then |
| 19263 |
for n=1,#after do |
| 19264 |
nofsequences=nofsequences+1 |
| 19265 |
sequence[nofsequences]=after[n] |
| 19266 |
end |
| 19267 |
end |
| 19268 |
local lookups=rule.lookups or false |
| 19269 |
local subtype=nil |
| 19270 |
if lookups then |
| 19271 |
for i=1,#lookups do |
| 19272 |
local lookups=lookups[i] |
| 19273 |
if lookups then |
| 19274 |
for k,v in next,lookups do |
| 19275 |
local lookup=sublookups[v] |
| 19276 |
if not lookup and whatever then |
| 19277 |
lookup=whatever[v] |
| 19278 |
end |
| 19279 |
if lookup then |
| 19280 |
lookups[k]=lookup |
| 19281 |
if not subtype then |
| 19282 |
subtype=lookup.type |
| 19283 |
end |
| 19284 |
else |
| 19285 |
end |
| 19286 |
end |
| 19287 |
end |
| 19288 |
end |
| 19289 |
end |
| 19290 |
if sequence[1] then |
| 19291 |
sequence.n=#sequence |
| 19292 |
local ruledata={ |
| 19293 |
currentrule, |
| 19294 |
lookuptype, |
| 19295 |
sequence, |
| 19296 |
start, |
| 19297 |
stop, |
| 19298 |
lookups, |
| 19299 |
replacements, |
| 19300 |
subtype, |
| 19301 |
} |
| 19302 |
rulesize=rulesize+1 |
| 19303 |
rulehash[rulesize]=ruledata |
| 19304 |
rulehash.n=rulesize |
| 19305 |
if true then |
| 19306 |
for unic in next,sequence[start] do |
| 19307 |
local cu=coverage[unic] |
| 19308 |
if cu then |
| 19309 |
local n=#cu+1 |
| 19310 |
cu[n]=ruledata |
| 19311 |
cu.n=n |
| 19312 |
else |
| 19313 |
coverage[unic]={ ruledata,n=1 } |
| 19314 |
end |
| 19315 |
end |
| 19316 |
else |
| 19317 |
for unic in next,sequence[start] do |
| 19318 |
local cu=coverage[unic] |
| 19319 |
if cu then |
| 19320 |
else |
| 19321 |
coverage[unic]=rulehash |
| 19322 |
end |
| 19323 |
end |
| 19324 |
end |
| 19325 |
end |
| 19326 |
end |
| 19327 |
end |
| 19328 |
end |
| 19329 |
checkmerge(sequence) |
| 19330 |
checkflags(sequence,resources) |
| 19331 |
checksteps(sequence) |
| 19332 |
end |
| 19333 |
end |
| 19334 |
end |
| 19335 |
end |
| 19336 |
expandlookups(sequences) |
| 19337 |
expandlookups(sublookups,sequences) |
| 19338 |
end |
| 19339 |
|
| 19340 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-oup”] --- |
| 19341 |
|
| 19342 |
|
| 19343 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-otl” 84499d355f82829841b8e304952a9d5d] --- |
| 19344 |
|
| 19345 |
if not modules then modules={} end modules ['font-otl']={ |
| 19346 |
version=1.001, |
| 19347 |
comment="companion to font-ini.mkiv", |
| 19348 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 19349 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 19350 |
license="see context related readme files", |
| 19351 |
} |
| 19352 |
local lower=string.lower |
| 19353 |
local type,next,tonumber,tostring,unpack=type,next,tonumber,tostring,unpack |
| 19354 |
local abs=math.abs |
| 19355 |
local derivetable,sortedhash=table.derive,table.sortedhash |
| 19356 |
local formatters=string.formatters |
| 19357 |
local setmetatableindex=table.setmetatableindex |
| 19358 |
local allocate=utilities.storage.allocate |
| 19359 |
local registertracker=trackers.register |
| 19360 |
local registerdirective=directives.register |
| 19361 |
local starttiming=statistics.starttiming |
| 19362 |
local stoptiming=statistics.stoptiming |
| 19363 |
local elapsedtime=statistics.elapsedtime |
| 19364 |
local findbinfile=resolvers.findbinfile |
| 19365 |
local trace_loading=false registertracker("otf.loading",function(v) trace_loading=v end) |
| 19366 |
local trace_features=false registertracker("otf.features",function(v) trace_features=v end) |
| 19367 |
local trace_defining=false registertracker("fonts.defining",function(v) trace_defining=v end) |
| 19368 |
local report_otf=logs.reporter("fonts","otf loading") |
| 19369 |
local fonts=fonts |
| 19370 |
local otf=fonts.handlers.otf |
| 19371 |
otf.version=3.134 |
| 19372 |
otf.cache=containers.define("fonts","otl",otf.version,true) |
| 19373 |
otf.svgcache=containers.define("fonts","svg",otf.version,true) |
| 19374 |
otf.pngcache=containers.define("fonts","png",otf.version,true) |
| 19375 |
otf.pdfcache=containers.define("fonts","pdf",otf.version,true) |
| 19376 |
otf.mpscache=containers.define("fonts","mps",otf.version,true) |
| 19377 |
otf.svgenabled=false |
| 19378 |
otf.pngenabled=false |
| 19379 |
local otfreaders=otf.readers |
| 19380 |
local hashes=fonts.hashes |
| 19381 |
local definers=fonts.definers |
| 19382 |
local readers=fonts.readers |
| 19383 |
local constructors=fonts.constructors |
| 19384 |
local otffeatures=constructors.features.otf |
| 19385 |
local registerotffeature=otffeatures.register |
| 19386 |
local otfenhancers=constructors.enhancers.otf |
| 19387 |
local registerotfenhancer=otfenhancers.register |
| 19388 |
local forceload=false |
| 19389 |
local cleanup=0 |
| 19390 |
local syncspace=true |
| 19391 |
local forcenotdef=false |
| 19392 |
local privateoffset=fonts.constructors and fonts.constructors.privateoffset or 0xF0000 |
| 19393 |
local applyruntimefixes=fonts.treatments and fonts.treatments.applyfixes |
| 19394 |
local wildcard="*" |
| 19395 |
local default="dflt" |
| 19396 |
local formats=fonts.formats |
| 19397 |
formats.otf="opentype" |
| 19398 |
formats.ttf="truetype" |
| 19399 |
formats.ttc="truetype" |
| 19400 |
registerdirective("fonts.otf.loader.cleanup",function(v) cleanup=tonumber(v) or (v and 1) or 0 end) |
| 19401 |
registerdirective("fonts.otf.loader.force",function(v) forceload=v end) |
| 19402 |
registerdirective("fonts.otf.loader.syncspace",function(v) syncspace=v end) |
| 19403 |
registerdirective("fonts.otf.loader.forcenotdef",function(v) forcenotdef=v end) |
| 19404 |
registerotfenhancer("check extra features",function() end) |
| 19405 |
local checkmemory=utilities.lua and utilities.lua.checkmemory |
| 19406 |
local threshold=100 |
| 19407 |
local tracememory=false |
| 19408 |
registertracker("fonts.otf.loader.memory",function(v) tracememory=v end) |
| 19409 |
if not checkmemory then |
| 19410 |
local collectgarbage=collectgarbage |
| 19411 |
checkmemory=function(previous,threshold) |
| 19412 |
local current=collectgarbage("count") |
| 19413 |
if previous then |
| 19414 |
local checked=(threshold or 64)*1024 |
| 19415 |
if current-previous>checked then |
| 19416 |
collectgarbage("collect") |
| 19417 |
current=collectgarbage("count") |
| 19418 |
end |
| 19419 |
end |
| 19420 |
return current |
| 19421 |
end |
| 19422 |
end |
| 19423 |
function otf.load(filename,sub,instance) |
| 19424 |
local base=file.basename(file.removesuffix(filename)) |
| 19425 |
local name=file.removesuffix(base) |
| 19426 |
local attr=lfs.attributes(filename) |
| 19427 |
local size=attr and attr.size or 0 |
| 19428 |
local time=attr and attr.modification or 0 |
| 19429 |
if sub=="" then |
| 19430 |
sub=false |
| 19431 |
end |
| 19432 |
local hash=name |
| 19433 |
if sub then |
| 19434 |
hash=hash.."-"..sub |
| 19435 |
end |
| 19436 |
if instance then |
| 19437 |
hash=hash.."-"..instance |
| 19438 |
end |
| 19439 |
hash=containers.cleanname(hash) |
| 19440 |
local data=containers.read(otf.cache,hash) |
| 19441 |
local reload=not data or data.size~=size or data.time~=time or data.tableversion~=otfreaders.tableversion |
| 19442 |
if forceload then |
| 19443 |
report_otf("forced reload of %a due to hard coded flag",filename) |
| 19444 |
reload=true |
| 19445 |
end |
| 19446 |
if reload then |
| 19447 |
report_otf("loading %a, hash %a",filename,hash) |
| 19448 |
starttiming(otfreaders,true) |
| 19449 |
data=otfreaders.loadfont(filename,sub or 1,instance) |
| 19450 |
if data then |
| 19451 |
local used=checkmemory() |
| 19452 |
local resources=data.resources |
| 19453 |
local svgshapes=resources.svgshapes |
| 19454 |
local pngshapes=resources.pngshapes |
| 19455 |
if cleanup==0 then |
| 19456 |
checkmemory(used,threshold,tracememory) |
| 19457 |
end |
| 19458 |
if svgshapes then |
| 19459 |
resources.svgshapes=nil |
| 19460 |
if otf.svgenabled then |
| 19461 |
local timestamp=os.date() |
| 19462 |
containers.write(otf.svgcache,hash,{ |
| 19463 |
svgshapes=svgshapes, |
| 19464 |
timestamp=timestamp, |
| 19465 |
}) |
| 19466 |
data.properties.svg={ |
| 19467 |
hash=hash, |
| 19468 |
timestamp=timestamp, |
| 19469 |
} |
| 19470 |
end |
| 19471 |
if cleanup>1 then |
| 19472 |
collectgarbage("collect") |
| 19473 |
else |
| 19474 |
checkmemory(used,threshold,tracememory) |
| 19475 |
end |
| 19476 |
end |
| 19477 |
if pngshapes then |
| 19478 |
resources.pngshapes=nil |
| 19479 |
if otf.pngenabled then |
| 19480 |
local timestamp=os.date() |
| 19481 |
containers.write(otf.pngcache,hash,{ |
| 19482 |
pngshapes=pngshapes, |
| 19483 |
timestamp=timestamp, |
| 19484 |
}) |
| 19485 |
data.properties.png={ |
| 19486 |
hash=hash, |
| 19487 |
timestamp=timestamp, |
| 19488 |
} |
| 19489 |
end |
| 19490 |
if cleanup>1 then |
| 19491 |
collectgarbage("collect") |
| 19492 |
else |
| 19493 |
checkmemory(used,threshold,tracememory) |
| 19494 |
end |
| 19495 |
end |
| 19496 |
otfreaders.compact(data) |
| 19497 |
if cleanup==0 then |
| 19498 |
checkmemory(used,threshold,tracememory) |
| 19499 |
end |
| 19500 |
otfreaders.rehash(data,"unicodes") |
| 19501 |
otfreaders.addunicodetable(data) |
| 19502 |
otfreaders.extend(data) |
| 19503 |
if cleanup==0 then |
| 19504 |
checkmemory(used,threshold,tracememory) |
| 19505 |
end |
| 19506 |
if context then |
| 19507 |
otfreaders.condense(data) |
| 19508 |
end |
| 19509 |
otfreaders.pack(data) |
| 19510 |
report_otf("loading done") |
| 19511 |
report_otf("saving %a in cache",filename) |
| 19512 |
data=containers.write(otf.cache,hash,data) |
| 19513 |
if cleanup>1 then |
| 19514 |
collectgarbage("collect") |
| 19515 |
else |
| 19516 |
checkmemory(used,threshold,tracememory) |
| 19517 |
end |
| 19518 |
stoptiming(otfreaders) |
| 19519 |
if elapsedtime then |
| 19520 |
report_otf("loading, optimizing, packing and caching time %s",elapsedtime(otfreaders)) |
| 19521 |
end |
| 19522 |
if cleanup>3 then |
| 19523 |
collectgarbage("collect") |
| 19524 |
else |
| 19525 |
checkmemory(used,threshold,tracememory) |
| 19526 |
end |
| 19527 |
data=containers.read(otf.cache,hash) |
| 19528 |
if cleanup>2 then |
| 19529 |
collectgarbage("collect") |
| 19530 |
else |
| 19531 |
checkmemory(used,threshold,tracememory) |
| 19532 |
end |
| 19533 |
else |
| 19534 |
stoptiming(otfreaders) |
| 19535 |
data=nil |
| 19536 |
report_otf("loading failed due to read error") |
| 19537 |
end |
| 19538 |
end |
| 19539 |
if data then |
| 19540 |
if trace_defining then |
| 19541 |
report_otf("loading from cache using hash %a",hash) |
| 19542 |
end |
| 19543 |
otfreaders.unpack(data) |
| 19544 |
otfreaders.expand(data) |
| 19545 |
otfreaders.addunicodetable(data) |
| 19546 |
otfenhancers.apply(data,filename,data) |
| 19547 |
if applyruntimefixes then |
| 19548 |
applyruntimefixes(filename,data) |
| 19549 |
end |
| 19550 |
data.metadata.math=data.resources.mathconstants |
| 19551 |
local classes=data.resources.classes |
| 19552 |
if not classes then |
| 19553 |
local descriptions=data.descriptions |
| 19554 |
classes=setmetatableindex(function(t,k) |
| 19555 |
local d=descriptions[k] |
| 19556 |
local v=(d and d.class or "base") or false |
| 19557 |
t[k]=v |
| 19558 |
return v |
| 19559 |
end) |
| 19560 |
data.resources.classes=classes |
| 19561 |
end |
| 19562 |
end |
| 19563 |
return data |
| 19564 |
end |
| 19565 |
function otf.setfeatures(tfmdata,features) |
| 19566 |
local okay=constructors.initializefeatures("otf",tfmdata,features,trace_features,report_otf) |
| 19567 |
if okay then |
| 19568 |
return constructors.collectprocessors("otf",tfmdata,features,trace_features,report_otf) |
| 19569 |
else |
| 19570 |
return {} |
| 19571 |
end |
| 19572 |
end |
| 19573 |
local function copytotfm(data,cache_id) |
| 19574 |
if data then |
| 19575 |
local metadata=data.metadata |
| 19576 |
local properties=derivetable(data.properties) |
| 19577 |
local descriptions=derivetable(data.descriptions) |
| 19578 |
local goodies=derivetable(data.goodies) |
| 19579 |
local characters={} |
| 19580 |
local parameters={} |
| 19581 |
local mathparameters={} |
| 19582 |
local resources=data.resources |
| 19583 |
local unicodes=resources.unicodes |
| 19584 |
local spaceunits=500 |
| 19585 |
local spacer="space" |
| 19586 |
local designsize=metadata.designsize or 100 |
| 19587 |
local minsize=metadata.minsize or designsize |
| 19588 |
local maxsize=metadata.maxsize or designsize |
| 19589 |
local mathspecs=metadata.math |
| 19590 |
if designsize==0 then |
| 19591 |
designsize=100 |
| 19592 |
minsize=100 |
| 19593 |
maxsize=100 |
| 19594 |
end |
| 19595 |
if mathspecs then |
| 19596 |
for name,value in next,mathspecs do |
| 19597 |
mathparameters[name]=value |
| 19598 |
end |
| 19599 |
end |
| 19600 |
for unicode in next,data.descriptions do |
| 19601 |
characters[unicode]={} |
| 19602 |
end |
| 19603 |
if mathspecs then |
| 19604 |
for unicode,character in next,characters do |
| 19605 |
local d=descriptions[unicode] |
| 19606 |
local m=d.math |
| 19607 |
if m then |
| 19608 |
local italic=m.italic |
| 19609 |
local vitalic=m.vitalic |
| 19610 |
local variants=m.hvariants |
| 19611 |
local parts=m.hparts |
| 19612 |
if variants then |
| 19613 |
local c=character |
| 19614 |
for i=1,#variants do |
| 19615 |
local un=variants[i] |
| 19616 |
c.next=un |
| 19617 |
c=characters[un] |
| 19618 |
end |
| 19619 |
c.horiz_variants=parts |
| 19620 |
elseif parts then |
| 19621 |
character.horiz_variants=parts |
| 19622 |
italic=m.hitalic |
| 19623 |
end |
| 19624 |
local variants=m.vvariants |
| 19625 |
local parts=m.vparts |
| 19626 |
if variants then |
| 19627 |
local c=character |
| 19628 |
for i=1,#variants do |
| 19629 |
local un=variants[i] |
| 19630 |
c.next=un |
| 19631 |
c=characters[un] |
| 19632 |
end |
| 19633 |
c.vert_variants=parts |
| 19634 |
elseif parts then |
| 19635 |
character.vert_variants=parts |
| 19636 |
end |
| 19637 |
if italic and italic~=0 then |
| 19638 |
character.italic=italic |
| 19639 |
end |
| 19640 |
if vitalic and vitalic~=0 then |
| 19641 |
character.vert_italic=vitalic |
| 19642 |
end |
| 19643 |
local accent=m.accent |
| 19644 |
if accent then |
| 19645 |
character.accent=accent |
| 19646 |
end |
| 19647 |
local kerns=m.kerns |
| 19648 |
if kerns then |
| 19649 |
character.mathkerns=kerns |
| 19650 |
end |
| 19651 |
end |
| 19652 |
end |
| 19653 |
end |
| 19654 |
local filename=constructors.checkedfilename(resources) |
| 19655 |
local fontname=metadata.fontname |
| 19656 |
local fullname=metadata.fullname or fontname |
| 19657 |
local psname=fontname or fullname |
| 19658 |
local subfont=metadata.subfontindex |
| 19659 |
local units=metadata.units or 1000 |
| 19660 |
if units==0 then |
| 19661 |
units=1000 |
| 19662 |
metadata.units=1000 |
| 19663 |
report_otf("changing %a units to %a",0,units) |
| 19664 |
end |
| 19665 |
local monospaced=metadata.monospaced |
| 19666 |
local charwidth=metadata.averagewidth |
| 19667 |
local charxheight=metadata.xheight |
| 19668 |
local italicangle=metadata.italicangle |
| 19669 |
local hasitalics=metadata.hasitalics |
| 19670 |
properties.monospaced=monospaced |
| 19671 |
properties.hasitalics=hasitalics |
| 19672 |
parameters.italicangle=italicangle |
| 19673 |
parameters.charwidth=charwidth |
| 19674 |
parameters.charxheight=charxheight |
| 19675 |
local space=0x0020 |
| 19676 |
local emdash=0x2014 |
| 19677 |
if monospaced then |
| 19678 |
if descriptions[space] then |
| 19679 |
spaceunits,spacer=descriptions[space].width,"space" |
| 19680 |
end |
| 19681 |
if not spaceunits and descriptions[emdash] then |
| 19682 |
spaceunits,spacer=descriptions[emdash].width,"emdash" |
| 19683 |
end |
| 19684 |
if not spaceunits and charwidth then |
| 19685 |
spaceunits,spacer=charwidth,"charwidth" |
| 19686 |
end |
| 19687 |
else |
| 19688 |
if descriptions[space] then |
| 19689 |
spaceunits,spacer=descriptions[space].width,"space" |
| 19690 |
end |
| 19691 |
if not spaceunits and descriptions[emdash] then |
| 19692 |
spaceunits,spacer=descriptions[emdash].width/2,"emdash/2" |
| 19693 |
end |
| 19694 |
if not spaceunits and charwidth then |
| 19695 |
spaceunits,spacer=charwidth,"charwidth" |
| 19696 |
end |
| 19697 |
end |
| 19698 |
spaceunits=tonumber(spaceunits) or units/2 |
| 19699 |
parameters.slant=0 |
| 19700 |
parameters.space=spaceunits |
| 19701 |
parameters.space_stretch=1*units/2 |
| 19702 |
parameters.space_shrink=1*units/3 |
| 19703 |
parameters.x_height=2*units/5 |
| 19704 |
parameters.quad=units |
| 19705 |
if spaceunits<2*units/5 then |
| 19706 |
end |
| 19707 |
if italicangle and italicangle~=0 then |
| 19708 |
parameters.italicangle=italicangle |
| 19709 |
parameters.italicfactor=math.cos(math.rad(90+italicangle)) |
| 19710 |
parameters.slant=- math.tan(italicangle*math.pi/180) |
| 19711 |
end |
| 19712 |
if monospaced then |
| 19713 |
parameters.space_stretch=0 |
| 19714 |
parameters.space_shrink=0 |
| 19715 |
elseif syncspace then |
| 19716 |
parameters.space_stretch=spaceunits/2 |
| 19717 |
parameters.space_shrink=spaceunits/3 |
| 19718 |
end |
| 19719 |
parameters.extra_space=parameters.space_shrink |
| 19720 |
if charxheight then |
| 19721 |
parameters.x_height=charxheight |
| 19722 |
else |
| 19723 |
local x=0x0078 |
| 19724 |
if x then |
| 19725 |
local x=descriptions[x] |
| 19726 |
if x then |
| 19727 |
parameters.x_height=x.height |
| 19728 |
end |
| 19729 |
end |
| 19730 |
end |
| 19731 |
parameters.designsize=(designsize/10)*65536 |
| 19732 |
parameters.minsize=(minsize/10)*65536 |
| 19733 |
parameters.maxsize=(maxsize/10)*65536 |
| 19734 |
parameters.ascender=abs(metadata.ascender or 0) |
| 19735 |
parameters.descender=abs(metadata.descender or 0) |
| 19736 |
parameters.units=units |
| 19737 |
parameters.vheight=metadata.defaultvheight |
| 19738 |
properties.space=spacer |
| 19739 |
properties.format=data.format or formats.otf |
| 19740 |
properties.filename=filename |
| 19741 |
properties.fontname=fontname |
| 19742 |
properties.fullname=fullname |
| 19743 |
properties.psname=psname |
| 19744 |
properties.name=filename or fullname |
| 19745 |
properties.subfont=subfont |
| 19746 |
if not CONTEXTLMTXMODE or CONTEXTLMTXMODE==0 then |
| 19747 |
properties.encodingbytes=2 |
| 19748 |
elseif CONTEXTLMTXMODE then |
| 19749 |
local duplicates=resources and resources.duplicates |
| 19750 |
if duplicates then |
| 19751 |
local maxindex=data.nofglyphs or metadata.nofglyphs |
| 19752 |
if maxindex then |
| 19753 |
for u,d in sortedhash(duplicates) do |
| 19754 |
local du=descriptions[u] |
| 19755 |
if du then |
| 19756 |
for uu in sortedhash(d) do |
| 19757 |
maxindex=maxindex+1 |
| 19758 |
descriptions[uu].dupindex=du.index |
| 19759 |
descriptions[uu].index=maxindex |
| 19760 |
end |
| 19761 |
else |
| 19762 |
end |
| 19763 |
end |
| 19764 |
end |
| 19765 |
end |
| 19766 |
end |
| 19767 |
properties.private=properties.private or data.private or privateoffset |
| 19768 |
return { |
| 19769 |
characters=characters, |
| 19770 |
descriptions=descriptions, |
| 19771 |
parameters=parameters, |
| 19772 |
mathparameters=mathparameters, |
| 19773 |
resources=resources, |
| 19774 |
properties=properties, |
| 19775 |
goodies=goodies, |
| 19776 |
} |
| 19777 |
end |
| 19778 |
end |
| 19779 |
local converters={ |
| 19780 |
woff={ |
| 19781 |
cachename="webfonts", |
| 19782 |
action=otf.readers.woff2otf, |
| 19783 |
} |
| 19784 |
} |
| 19785 |
local function checkconversion(specification) |
| 19786 |
local filename=specification.filename |
| 19787 |
local converter=converters[lower(file.suffix(filename))] |
| 19788 |
if converter then |
| 19789 |
local base=file.basename(filename) |
| 19790 |
local name=file.removesuffix(base) |
| 19791 |
local attr=lfs.attributes(filename) |
| 19792 |
local size=attr and attr.size or 0 |
| 19793 |
local time=attr and attr.modification or 0 |
| 19794 |
if size>0 then |
| 19795 |
local cleanname=containers.cleanname(name) |
| 19796 |
local cachename=caches.setfirstwritablefile(cleanname,converter.cachename) |
| 19797 |
if not io.exists(cachename) or (time~=lfs.attributes(cachename).modification) then |
| 19798 |
report_otf("caching font %a in %a",filename,cachename) |
| 19799 |
converter.action(filename,cachename) |
| 19800 |
lfs.touch(cachename,time,time) |
| 19801 |
end |
| 19802 |
specification.filename=cachename |
| 19803 |
end |
| 19804 |
end |
| 19805 |
end |
| 19806 |
local function otftotfm(specification) |
| 19807 |
local cache_id=specification.hash |
| 19808 |
local tfmdata=containers.read(constructors.cache,cache_id) |
| 19809 |
if not tfmdata then |
| 19810 |
checkconversion(specification) |
| 19811 |
local name=specification.name |
| 19812 |
local sub=specification.sub |
| 19813 |
local subindex=specification.subindex |
| 19814 |
local filename=specification.filename |
| 19815 |
local features=specification.features.normal |
| 19816 |
local instance=specification.instance or (features and features.axis) |
| 19817 |
local rawdata=otf.load(filename,sub,instance) |
| 19818 |
if rawdata and next(rawdata) then |
| 19819 |
local descriptions=rawdata.descriptions |
| 19820 |
rawdata.lookuphash={} |
| 19821 |
tfmdata=copytotfm(rawdata,cache_id) |
| 19822 |
if tfmdata and next(tfmdata) then |
| 19823 |
local features=constructors.checkedfeatures("otf",features) |
| 19824 |
local shared=tfmdata.shared |
| 19825 |
if not shared then |
| 19826 |
shared={} |
| 19827 |
tfmdata.shared=shared |
| 19828 |
end |
| 19829 |
shared.rawdata=rawdata |
| 19830 |
shared.dynamics={} |
| 19831 |
tfmdata.changed={} |
| 19832 |
shared.features=features |
| 19833 |
shared.processes=otf.setfeatures(tfmdata,features) |
| 19834 |
end |
| 19835 |
end |
| 19836 |
containers.write(constructors.cache,cache_id,tfmdata) |
| 19837 |
end |
| 19838 |
return tfmdata |
| 19839 |
end |
| 19840 |
local function read_from_otf(specification) |
| 19841 |
local tfmdata=otftotfm(specification) |
| 19842 |
if tfmdata then |
| 19843 |
tfmdata.properties.name=specification.name |
| 19844 |
tfmdata.properties.sub=specification.sub |
| 19845 |
tfmdata.properties.id=specification.id |
| 19846 |
tfmdata=constructors.scale(tfmdata,specification) |
| 19847 |
local allfeatures=tfmdata.shared.features or specification.features.normal |
| 19848 |
constructors.applymanipulators("otf",tfmdata,allfeatures,trace_features,report_otf) |
| 19849 |
constructors.setname(tfmdata,specification) |
| 19850 |
fonts.loggers.register(tfmdata,file.suffix(specification.filename),specification) |
| 19851 |
end |
| 19852 |
return tfmdata |
| 19853 |
end |
| 19854 |
function otf.collectlookups(rawdata,kind,script,language) |
| 19855 |
if not kind then |
| 19856 |
return |
| 19857 |
end |
| 19858 |
if not script then |
| 19859 |
script=default |
| 19860 |
end |
| 19861 |
if not language then |
| 19862 |
language=default |
| 19863 |
end |
| 19864 |
local lookupcache=rawdata.lookupcache |
| 19865 |
if not lookupcache then |
| 19866 |
lookupcache={} |
| 19867 |
rawdata.lookupcache=lookupcache |
| 19868 |
end |
| 19869 |
local kindlookup=lookupcache[kind] |
| 19870 |
if not kindlookup then |
| 19871 |
kindlookup={} |
| 19872 |
lookupcache[kind]=kindlookup |
| 19873 |
end |
| 19874 |
local scriptlookup=kindlookup[script] |
| 19875 |
if not scriptlookup then |
| 19876 |
scriptlookup={} |
| 19877 |
kindlookup[script]=scriptlookup |
| 19878 |
end |
| 19879 |
local languagelookup=scriptlookup[language] |
| 19880 |
if not languagelookup then |
| 19881 |
local sequences=rawdata.resources.sequences |
| 19882 |
local featuremap={} |
| 19883 |
local featurelist={} |
| 19884 |
if sequences then |
| 19885 |
for s=1,#sequences do |
| 19886 |
local sequence=sequences[s] |
| 19887 |
local features=sequence.features |
| 19888 |
if features then |
| 19889 |
features=features[kind] |
| 19890 |
if features then |
| 19891 |
features=features[script] or features[wildcard] |
| 19892 |
if features then |
| 19893 |
features=features[language] or features[wildcard] |
| 19894 |
if features then |
| 19895 |
if not featuremap[sequence] then |
| 19896 |
featuremap[sequence]=true |
| 19897 |
featurelist[#featurelist+1]=sequence |
| 19898 |
end |
| 19899 |
end |
| 19900 |
end |
| 19901 |
end |
| 19902 |
end |
| 19903 |
end |
| 19904 |
if #featurelist==0 then |
| 19905 |
featuremap,featurelist=false,false |
| 19906 |
end |
| 19907 |
else |
| 19908 |
featuremap,featurelist=false,false |
| 19909 |
end |
| 19910 |
languagelookup={ featuremap,featurelist } |
| 19911 |
scriptlookup[language]=languagelookup |
| 19912 |
end |
| 19913 |
return unpack(languagelookup) |
| 19914 |
end |
| 19915 |
local function getgsub(tfmdata,k,kind,value) |
| 19916 |
local shared=tfmdata.shared |
| 19917 |
local rawdata=shared and shared.rawdata |
| 19918 |
if rawdata then |
| 19919 |
local sequences=rawdata.resources.sequences |
| 19920 |
if sequences then |
| 19921 |
local properties=tfmdata.properties |
| 19922 |
local validlookups,lookuplist=otf.collectlookups(rawdata,kind,properties.script,properties.language) |
| 19923 |
if validlookups then |
| 19924 |
for i=1,#lookuplist do |
| 19925 |
local lookup=lookuplist[i] |
| 19926 |
local steps=lookup.steps |
| 19927 |
local nofsteps=lookup.nofsteps |
| 19928 |
for i=1,nofsteps do |
| 19929 |
local coverage=steps[i].coverage |
| 19930 |
if coverage then |
| 19931 |
local found=coverage[k] |
| 19932 |
if found then |
| 19933 |
return found,lookup.type |
| 19934 |
end |
| 19935 |
end |
| 19936 |
end |
| 19937 |
end |
| 19938 |
end |
| 19939 |
end |
| 19940 |
end |
| 19941 |
end |
| 19942 |
otf.getgsub=getgsub |
| 19943 |
function otf.getsubstitution(tfmdata,k,kind,value) |
| 19944 |
local found,kind=getgsub(tfmdata,k,kind,value) |
| 19945 |
if not found then |
| 19946 |
elseif kind=="gsub_single" then |
| 19947 |
return found |
| 19948 |
elseif kind=="gsub_alternate" then |
| 19949 |
local choice=tonumber(value) or 1 |
| 19950 |
return found[choice] or found[1] or k |
| 19951 |
end |
| 19952 |
return k |
| 19953 |
end |
| 19954 |
otf.getalternate=otf.getsubstitution |
| 19955 |
function otf.getmultiple(tfmdata,k,kind) |
| 19956 |
local found,kind=getgsub(tfmdata,k,kind) |
| 19957 |
if found and kind=="gsub_multiple" then |
| 19958 |
return found |
| 19959 |
end |
| 19960 |
return { k } |
| 19961 |
end |
| 19962 |
function otf.getkern(tfmdata,left,right,kind) |
| 19963 |
local kerns=getgsub(tfmdata,left,kind or "kern",true) |
| 19964 |
if kerns then |
| 19965 |
local found=kerns[right] |
| 19966 |
local kind=type(found) |
| 19967 |
if kind=="table" then |
| 19968 |
found=found[1][3] |
| 19969 |
elseif kind~="number" then |
| 19970 |
found=false |
| 19971 |
end |
| 19972 |
if found then |
| 19973 |
return found*tfmdata.parameters.factor |
| 19974 |
end |
| 19975 |
end |
| 19976 |
return 0 |
| 19977 |
end |
| 19978 |
local function check_otf(forced,specification,suffix) |
| 19979 |
local name=specification.name |
| 19980 |
if forced then |
| 19981 |
name=specification.forcedname |
| 19982 |
end |
| 19983 |
local fullname=findbinfile(name,suffix) or "" |
| 19984 |
if fullname=="" then |
| 19985 |
fullname=fonts.names.getfilename(name,suffix) or "" |
| 19986 |
end |
| 19987 |
if fullname~="" and not fonts.names.ignoredfile(fullname) then |
| 19988 |
specification.filename=fullname |
| 19989 |
return read_from_otf(specification) |
| 19990 |
end |
| 19991 |
end |
| 19992 |
local function opentypereader(specification,suffix) |
| 19993 |
local forced=specification.forced or "" |
| 19994 |
if formats[forced] then |
| 19995 |
return check_otf(true,specification,forced) |
| 19996 |
else |
| 19997 |
return check_otf(false,specification,suffix) |
| 19998 |
end |
| 19999 |
end |
| 20000 |
readers.opentype=opentypereader |
| 20001 |
function readers.otf(specification) return opentypereader(specification,"otf") end |
| 20002 |
function readers.ttf(specification) return opentypereader(specification,"ttf") end |
| 20003 |
function readers.ttc(specification) return opentypereader(specification,"ttf") end |
| 20004 |
function readers.woff(specification) |
| 20005 |
checkconversion(specification) |
| 20006 |
opentypereader(specification,"") |
| 20007 |
end |
| 20008 |
function otf.scriptandlanguage(tfmdata,attr) |
| 20009 |
local properties=tfmdata.properties |
| 20010 |
return properties.script or "dflt",properties.language or "dflt" |
| 20011 |
end |
| 20012 |
local function justset(coverage,unicode,replacement) |
| 20013 |
coverage[unicode]=replacement |
| 20014 |
end |
| 20015 |
otf.coverup={ |
| 20016 |
stepkey="steps", |
| 20017 |
actions={ |
| 20018 |
chainsubstitution=justset, |
| 20019 |
chainposition=justset, |
| 20020 |
substitution=justset, |
| 20021 |
alternate=justset, |
| 20022 |
multiple=justset, |
| 20023 |
kern=justset, |
| 20024 |
pair=justset, |
| 20025 |
single=justset, |
| 20026 |
ligature=function(coverage,unicode,ligature) |
| 20027 |
local first=ligature[1] |
| 20028 |
local tree=coverage[first] |
| 20029 |
if not tree then |
| 20030 |
tree={} |
| 20031 |
coverage[first]=tree |
| 20032 |
end |
| 20033 |
for i=2,#ligature do |
| 20034 |
local l=ligature[i] |
| 20035 |
local t=tree[l] |
| 20036 |
if not t then |
| 20037 |
t={} |
| 20038 |
tree[l]=t |
| 20039 |
end |
| 20040 |
tree=t |
| 20041 |
end |
| 20042 |
tree.ligature=unicode |
| 20043 |
end, |
| 20044 |
}, |
| 20045 |
register=function(coverage,featuretype,format) |
| 20046 |
return { |
| 20047 |
format=format, |
| 20048 |
coverage=coverage, |
| 20049 |
} |
| 20050 |
end |
| 20051 |
} |
| 20052 |
|
| 20053 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-otl”] --- |
| 20054 |
|
| 20055 |
|
| 20056 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-oto” b148d66f642aaa3d0ddc427f71d6e02d] --- |
| 20057 |
|
| 20058 |
if not modules then modules={} end modules ['font-oto']={ |
| 20059 |
version=1.001, |
| 20060 |
comment="companion to font-ini.mkiv", |
| 20061 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 20062 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 20063 |
license="see context related readme files" |
| 20064 |
} |
| 20065 |
local concat,unpack=table.concat,table.unpack |
| 20066 |
local insert,remove=table.insert,table.remove |
| 20067 |
local format,gmatch,gsub,find,match,lower,strip=string.format,string.gmatch,string.gsub,string.find,string.match,string.lower,string.strip |
| 20068 |
local type,next,tonumber,tostring=type,next,tonumber,tostring |
| 20069 |
local trace_baseinit=false trackers.register("otf.baseinit",function(v) trace_baseinit=v end) |
| 20070 |
local trace_singles=false trackers.register("otf.singles",function(v) trace_singles=v end) |
| 20071 |
local trace_multiples=false trackers.register("otf.multiples",function(v) trace_multiples=v end) |
| 20072 |
local trace_alternatives=false trackers.register("otf.alternatives",function(v) trace_alternatives=v end) |
| 20073 |
local trace_ligatures=false trackers.register("otf.ligatures",function(v) trace_ligatures=v end) |
| 20074 |
local trace_kerns=false trackers.register("otf.kerns",function(v) trace_kerns=v end) |
| 20075 |
local trace_preparing=false trackers.register("otf.preparing",function(v) trace_preparing=v end) |
| 20076 |
local report_prepare=logs.reporter("fonts","otf prepare") |
| 20077 |
local fonts=fonts |
| 20078 |
local otf=fonts.handlers.otf |
| 20079 |
local otffeatures=otf.features |
| 20080 |
local registerotffeature=otffeatures.register |
| 20081 |
otf.defaultbasealternate="none" |
| 20082 |
local getprivate=fonts.constructors.getprivate |
| 20083 |
local wildcard="*" |
| 20084 |
local default="dflt" |
| 20085 |
local formatters=string.formatters |
| 20086 |
local f_unicode=formatters["%U"] |
| 20087 |
local f_uniname=formatters["%U (%s)"] |
| 20088 |
local f_unilist=formatters["% t (% t)"] |
| 20089 |
local function gref(descriptions,n) |
| 20090 |
if type(n)=="number" then |
| 20091 |
local name=descriptions[n].name |
| 20092 |
if name then |
| 20093 |
return f_uniname(n,name) |
| 20094 |
else |
| 20095 |
return f_unicode(n) |
| 20096 |
end |
| 20097 |
elseif n then |
| 20098 |
local num={} |
| 20099 |
local nam={} |
| 20100 |
local j=0 |
| 20101 |
for i=1,#n do |
| 20102 |
local ni=n[i] |
| 20103 |
if tonumber(ni) then |
| 20104 |
j=j+1 |
| 20105 |
local di=descriptions[ni] |
| 20106 |
num[j]=f_unicode(ni) |
| 20107 |
nam[j]=di and di.name or "-" |
| 20108 |
end |
| 20109 |
end |
| 20110 |
return f_unilist(num,nam) |
| 20111 |
else |
| 20112 |
return "<error in base mode tracing>" |
| 20113 |
end |
| 20114 |
end |
| 20115 |
local function cref(feature,sequence) |
| 20116 |
return formatters["feature %a, type %a, (chain) lookup %a"](feature,sequence.type,sequence.name) |
| 20117 |
end |
| 20118 |
local function report_substitution(feature,sequence,descriptions,unicode,substitution) |
| 20119 |
if unicode==substitution then |
| 20120 |
report_prepare("%s: base substitution %s maps onto itself", |
| 20121 |
cref(feature,sequence), |
| 20122 |
gref(descriptions,unicode)) |
| 20123 |
else |
| 20124 |
report_prepare("%s: base substitution %s => %S", |
| 20125 |
cref(feature,sequence), |
| 20126 |
gref(descriptions,unicode), |
| 20127 |
gref(descriptions,substitution)) |
| 20128 |
end |
| 20129 |
end |
| 20130 |
local function report_alternate(feature,sequence,descriptions,unicode,replacement,value,comment) |
| 20131 |
if unicode==replacement then |
| 20132 |
report_prepare("%s: base alternate %s maps onto itself", |
| 20133 |
cref(feature,sequence), |
| 20134 |
gref(descriptions,unicode)) |
| 20135 |
else |
| 20136 |
report_prepare("%s: base alternate %s => %s (%S => %S)", |
| 20137 |
cref(feature,sequence), |
| 20138 |
gref(descriptions,unicode), |
| 20139 |
replacement and gref(descriptions,replacement), |
| 20140 |
value, |
| 20141 |
comment) |
| 20142 |
end |
| 20143 |
end |
| 20144 |
local function report_ligature(feature,sequence,descriptions,unicode,ligature) |
| 20145 |
report_prepare("%s: base ligature %s => %S", |
| 20146 |
cref(feature,sequence), |
| 20147 |
gref(descriptions,ligature), |
| 20148 |
gref(descriptions,unicode)) |
| 20149 |
end |
| 20150 |
local function report_kern(feature,sequence,descriptions,unicode,otherunicode,value) |
| 20151 |
report_prepare("%s: base kern %s + %s => %S", |
| 20152 |
cref(feature,sequence), |
| 20153 |
gref(descriptions,unicode), |
| 20154 |
gref(descriptions,otherunicode), |
| 20155 |
value) |
| 20156 |
end |
| 20157 |
local basehash,basehashes,applied={},1,{} |
| 20158 |
local function registerbasehash(tfmdata) |
| 20159 |
local properties=tfmdata.properties |
| 20160 |
local hash=concat(applied," ") |
| 20161 |
local base=basehash[hash] |
| 20162 |
if not base then |
| 20163 |
basehashes=basehashes+1 |
| 20164 |
base=basehashes |
| 20165 |
basehash[hash]=base |
| 20166 |
end |
| 20167 |
properties.basehash=base |
| 20168 |
properties.fullname=(properties.fullname or properties.name).."-"..base |
| 20169 |
applied={} |
| 20170 |
end |
| 20171 |
local function registerbasefeature(feature,value) |
| 20172 |
applied[#applied+1]=feature.."="..tostring(value) |
| 20173 |
end |
| 20174 |
local function makefake(tfmdata,name,present) |
| 20175 |
local private=getprivate(tfmdata) |
| 20176 |
local character={ intermediate=true,ligatures={} } |
| 20177 |
tfmdata.resources.unicodes[name]=private |
| 20178 |
tfmdata.characters[private]=character |
| 20179 |
tfmdata.descriptions[private]={ name=name } |
| 20180 |
present[name]=private |
| 20181 |
return character |
| 20182 |
end |
| 20183 |
local function make_1(present,tree,name) |
| 20184 |
if tonumber(tree) then |
| 20185 |
present[name]=v |
| 20186 |
else |
| 20187 |
for k,v in next,tree do |
| 20188 |
if k=="ligature" then |
| 20189 |
present[name]=v |
| 20190 |
else |
| 20191 |
make_1(present,v,name.."_"..k) |
| 20192 |
end |
| 20193 |
end |
| 20194 |
end |
| 20195 |
end |
| 20196 |
local function make_3(present,tfmdata,characters,tree,name,preceding,unicode,done,v) |
| 20197 |
local character=characters[preceding] |
| 20198 |
if not character then |
| 20199 |
if trace_baseinit then |
| 20200 |
report_prepare("weird ligature in lookup %a, current %C, preceding %C",sequence.name,v,preceding) |
| 20201 |
end |
| 20202 |
character=makefake(tfmdata,name,present) |
| 20203 |
end |
| 20204 |
local ligatures=character.ligatures |
| 20205 |
if ligatures then |
| 20206 |
ligatures[unicode]={ char=v } |
| 20207 |
else |
| 20208 |
character.ligatures={ [unicode]={ char=v } } |
| 20209 |
end |
| 20210 |
if done then |
| 20211 |
local d=done[name] |
| 20212 |
if not d then |
| 20213 |
done[name]={ "dummy",v } |
| 20214 |
else |
| 20215 |
d[#d+1]=v |
| 20216 |
end |
| 20217 |
end |
| 20218 |
end |
| 20219 |
local function make_2(present,tfmdata,characters,tree,name,preceding,unicode,done) |
| 20220 |
if tonumber(tree) then |
| 20221 |
make_3(present,tfmdata,characters,tree,name,preceding,unicode,done,tree) |
| 20222 |
else |
| 20223 |
for k,v in next,tree do |
| 20224 |
if k=="ligature" then |
| 20225 |
make_3(present,tfmdata,characters,tree,name,preceding,unicode,done,v) |
| 20226 |
else |
| 20227 |
local code=present[name] or unicode |
| 20228 |
local name=name.."_"..k |
| 20229 |
make_2(present,tfmdata,characters,v,name,code,k,done) |
| 20230 |
end |
| 20231 |
end |
| 20232 |
end |
| 20233 |
end |
| 20234 |
local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplist) |
| 20235 |
local characters=tfmdata.characters |
| 20236 |
local descriptions=tfmdata.descriptions |
| 20237 |
local resources=tfmdata.resources |
| 20238 |
local changed=tfmdata.changed |
| 20239 |
local ligatures={} |
| 20240 |
local alternate=tonumber(value) or true and 1 |
| 20241 |
local defaultalt=otf.defaultbasealternate |
| 20242 |
local trace_singles=trace_baseinit and trace_singles |
| 20243 |
local trace_alternatives=trace_baseinit and trace_alternatives |
| 20244 |
local trace_ligatures=trace_baseinit and trace_ligatures |
| 20245 |
if not changed then |
| 20246 |
changed={} |
| 20247 |
tfmdata.changed=changed |
| 20248 |
end |
| 20249 |
for i=1,#lookuplist do |
| 20250 |
local sequence=lookuplist[i] |
| 20251 |
local steps=sequence.steps |
| 20252 |
local kind=sequence.type |
| 20253 |
if kind=="gsub_single" then |
| 20254 |
for i=1,#steps do |
| 20255 |
for unicode,data in next,steps[i].coverage do |
| 20256 |
if unicode~=data then |
| 20257 |
changed[unicode]=changed[unicode] or data |
| 20258 |
end |
| 20259 |
if trace_singles then |
| 20260 |
report_substitution(feature,sequence,descriptions,unicode,data) |
| 20261 |
end |
| 20262 |
end |
| 20263 |
end |
| 20264 |
elseif kind=="gsub_alternate" then |
| 20265 |
for i=1,#steps do |
| 20266 |
for unicode,data in next,steps[i].coverage do |
| 20267 |
local replacement=data[alternate] |
| 20268 |
if replacement then |
| 20269 |
if unicode~=replacement then |
| 20270 |
changed[unicode]=changed[unicode] or replacement |
| 20271 |
end |
| 20272 |
if trace_alternatives then |
| 20273 |
report_alternate(feature,sequence,descriptions,unicode,replacement,value,"normal") |
| 20274 |
end |
| 20275 |
elseif defaultalt=="first" then |
| 20276 |
replacement=data[1] |
| 20277 |
if unicode~=replacement then |
| 20278 |
changed[unicode]=changed[unicode] or replacement |
| 20279 |
end |
| 20280 |
if trace_alternatives then |
| 20281 |
report_alternate(feature,sequence,descriptions,unicode,replacement,value,defaultalt) |
| 20282 |
end |
| 20283 |
elseif defaultalt=="last" then |
| 20284 |
replacement=data[#data] |
| 20285 |
if unicode~=replacement then |
| 20286 |
changed[unicode]=changed[unicode] or replacement |
| 20287 |
end |
| 20288 |
if trace_alternatives then |
| 20289 |
report_alternate(feature,sequence,descriptions,unicode,replacement,value,defaultalt) |
| 20290 |
end |
| 20291 |
else |
| 20292 |
if trace_alternatives then |
| 20293 |
report_alternate(feature,sequence,descriptions,unicode,replacement,value,"unknown") |
| 20294 |
end |
| 20295 |
end |
| 20296 |
end |
| 20297 |
end |
| 20298 |
elseif kind=="gsub_ligature" then |
| 20299 |
for i=1,#steps do |
| 20300 |
for unicode,data in next,steps[i].coverage do |
| 20301 |
ligatures[#ligatures+1]={ unicode,data,"" } |
| 20302 |
if trace_ligatures then |
| 20303 |
report_ligature(feature,sequence,descriptions,unicode,data) |
| 20304 |
end |
| 20305 |
end |
| 20306 |
end |
| 20307 |
end |
| 20308 |
end |
| 20309 |
local nofligatures=#ligatures |
| 20310 |
if nofligatures>0 then |
| 20311 |
local characters=tfmdata.characters |
| 20312 |
local present={} |
| 20313 |
local done=trace_baseinit and trace_ligatures and {} |
| 20314 |
for i=1,nofligatures do |
| 20315 |
local ligature=ligatures[i] |
| 20316 |
local unicode=ligature[1] |
| 20317 |
local tree=ligature[2] |
| 20318 |
make_1(present,tree,"ctx_"..unicode) |
| 20319 |
end |
| 20320 |
for i=1,nofligatures do |
| 20321 |
local ligature=ligatures[i] |
| 20322 |
local unicode=ligature[1] |
| 20323 |
local tree=ligature[2] |
| 20324 |
local lookupname=ligature[3] |
| 20325 |
make_2(present,tfmdata,characters,tree,"ctx_"..unicode,unicode,unicode,done,sequence) |
| 20326 |
end |
| 20327 |
end |
| 20328 |
end |
| 20329 |
local function preparepositionings(tfmdata,feature,value,validlookups,lookuplist) |
| 20330 |
local characters=tfmdata.characters |
| 20331 |
local descriptions=tfmdata.descriptions |
| 20332 |
local resources=tfmdata.resources |
| 20333 |
local properties=tfmdata.properties |
| 20334 |
local traceindeed=trace_baseinit and trace_kerns |
| 20335 |
for i=1,#lookuplist do |
| 20336 |
local sequence=lookuplist[i] |
| 20337 |
local steps=sequence.steps |
| 20338 |
local kind=sequence.type |
| 20339 |
local format=sequence.format |
| 20340 |
if kind=="gpos_pair" then |
| 20341 |
for i=1,#steps do |
| 20342 |
local step=steps[i] |
| 20343 |
local format=step.format |
| 20344 |
if format=="kern" or format=="move" then |
| 20345 |
for unicode,data in next,steps[i].coverage do |
| 20346 |
local character=characters[unicode] |
| 20347 |
local kerns=character.kerns |
| 20348 |
if not kerns then |
| 20349 |
kerns={} |
| 20350 |
character.kerns=kerns |
| 20351 |
end |
| 20352 |
if traceindeed then |
| 20353 |
for otherunicode,kern in next,data do |
| 20354 |
if not kerns[otherunicode] and kern~=0 then |
| 20355 |
kerns[otherunicode]=kern |
| 20356 |
report_kern(feature,sequence,descriptions,unicode,otherunicode,kern) |
| 20357 |
end |
| 20358 |
end |
| 20359 |
else |
| 20360 |
for otherunicode,kern in next,data do |
| 20361 |
if not kerns[otherunicode] and kern~=0 then |
| 20362 |
kerns[otherunicode]=kern |
| 20363 |
end |
| 20364 |
end |
| 20365 |
end |
| 20366 |
end |
| 20367 |
else |
| 20368 |
for unicode,data in next,steps[i].coverage do |
| 20369 |
local character=characters[unicode] |
| 20370 |
local kerns=character.kerns |
| 20371 |
for otherunicode,kern in next,data do |
| 20372 |
local other=kern[2] |
| 20373 |
if other==true or (not other and not (kerns and kerns[otherunicode])) then |
| 20374 |
local kern=kern[1] |
| 20375 |
if kern==true then |
| 20376 |
elseif kern[1]~=0 or kern[2]~=0 or kern[4]~=0 then |
| 20377 |
else |
| 20378 |
kern=kern[3] |
| 20379 |
if kern~=0 then |
| 20380 |
if kerns then |
| 20381 |
kerns[otherunicode]=kern |
| 20382 |
else |
| 20383 |
kerns={ [otherunicode]=kern } |
| 20384 |
character.kerns=kerns |
| 20385 |
end |
| 20386 |
if traceindeed then |
| 20387 |
report_kern(feature,sequence,descriptions,unicode,otherunicode,kern) |
| 20388 |
end |
| 20389 |
end |
| 20390 |
end |
| 20391 |
end |
| 20392 |
end |
| 20393 |
end |
| 20394 |
end |
| 20395 |
end |
| 20396 |
end |
| 20397 |
end |
| 20398 |
end |
| 20399 |
local function initializehashes(tfmdata) |
| 20400 |
end |
| 20401 |
local function checkmathreplacements(tfmdata,fullname,fixitalics) |
| 20402 |
if tfmdata.mathparameters then |
| 20403 |
local characters=tfmdata.characters |
| 20404 |
local changed=tfmdata.changed |
| 20405 |
if next(changed) then |
| 20406 |
if trace_preparing or trace_baseinit then |
| 20407 |
report_prepare("checking math replacements for %a",fullname) |
| 20408 |
end |
| 20409 |
for unicode,replacement in next,changed do |
| 20410 |
local u=characters[unicode] |
| 20411 |
local r=characters[replacement] |
| 20412 |
if u and r then |
| 20413 |
local n=u.next |
| 20414 |
local v=u.vert_variants |
| 20415 |
local h=u.horiz_variants |
| 20416 |
if fixitalics then |
| 20417 |
local ui=u.italic |
| 20418 |
if ui and not r.italic then |
| 20419 |
if trace_preparing then |
| 20420 |
report_prepare("using %i units of italic correction from %C for %U",ui,unicode,replacement) |
| 20421 |
end |
| 20422 |
r.italic=ui |
| 20423 |
end |
| 20424 |
end |
| 20425 |
if n and not r.next then |
| 20426 |
if trace_preparing then |
| 20427 |
report_prepare("forcing %s for %C substituted by %U","incremental step",unicode,replacement) |
| 20428 |
end |
| 20429 |
r.next=n |
| 20430 |
end |
| 20431 |
if v and not r.vert_variants then |
| 20432 |
if trace_preparing then |
| 20433 |
report_prepare("forcing %s for %C substituted by %U","vertical variants",unicode,replacement) |
| 20434 |
end |
| 20435 |
r.vert_variants=v |
| 20436 |
end |
| 20437 |
if h and not r.horiz_variants then |
| 20438 |
if trace_preparing then |
| 20439 |
report_prepare("forcing %s for %C substituted by %U","horizontal variants",unicode,replacement) |
| 20440 |
end |
| 20441 |
r.horiz_variants=h |
| 20442 |
end |
| 20443 |
else |
| 20444 |
if trace_preparing then |
| 20445 |
report_prepare("error replacing %C by %U",unicode,replacement) |
| 20446 |
end |
| 20447 |
end |
| 20448 |
end |
| 20449 |
end |
| 20450 |
end |
| 20451 |
end |
| 20452 |
local function featuresinitializer(tfmdata,value) |
| 20453 |
if true then |
| 20454 |
local starttime=trace_preparing and os.clock() |
| 20455 |
local features=tfmdata.shared.features |
| 20456 |
local fullname=tfmdata.properties.fullname or "?" |
| 20457 |
if features then |
| 20458 |
initializehashes(tfmdata) |
| 20459 |
local collectlookups=otf.collectlookups |
| 20460 |
local rawdata=tfmdata.shared.rawdata |
| 20461 |
local properties=tfmdata.properties |
| 20462 |
local script=properties.script |
| 20463 |
local language=properties.language |
| 20464 |
local rawresources=rawdata.resources |
| 20465 |
local rawfeatures=rawresources and rawresources.features |
| 20466 |
local basesubstitutions=rawfeatures and rawfeatures.gsub |
| 20467 |
local basepositionings=rawfeatures and rawfeatures.gpos |
| 20468 |
local substitutionsdone=false |
| 20469 |
local positioningsdone=false |
| 20470 |
if basesubstitutions or basepositionings then |
| 20471 |
local sequences=tfmdata.resources.sequences |
| 20472 |
for s=1,#sequences do |
| 20473 |
local sequence=sequences[s] |
| 20474 |
local sfeatures=sequence.features |
| 20475 |
if sfeatures then |
| 20476 |
local order=sequence.order |
| 20477 |
if order then |
| 20478 |
for i=1,#order do |
| 20479 |
local feature=order[i] |
| 20480 |
local value=features[feature] |
| 20481 |
if value then |
| 20482 |
local validlookups,lookuplist=collectlookups(rawdata,feature,script,language) |
| 20483 |
if not validlookups then |
| 20484 |
elseif basesubstitutions and basesubstitutions[feature] then |
| 20485 |
if trace_preparing then |
| 20486 |
report_prepare("filtering base %s feature %a for %a with value %a","sub",feature,fullname,value) |
| 20487 |
end |
| 20488 |
preparesubstitutions(tfmdata,feature,value,validlookups,lookuplist) |
| 20489 |
registerbasefeature(feature,value) |
| 20490 |
substitutionsdone=true |
| 20491 |
elseif basepositionings and basepositionings[feature] then |
| 20492 |
if trace_preparing then |
| 20493 |
report_prepare("filtering base %a feature %a for %a with value %a","pos",feature,fullname,value) |
| 20494 |
end |
| 20495 |
preparepositionings(tfmdata,feature,value,validlookups,lookuplist) |
| 20496 |
registerbasefeature(feature,value) |
| 20497 |
positioningsdone=true |
| 20498 |
end |
| 20499 |
end |
| 20500 |
end |
| 20501 |
end |
| 20502 |
end |
| 20503 |
end |
| 20504 |
end |
| 20505 |
if substitutionsdone then |
| 20506 |
checkmathreplacements(tfmdata,fullname,features.fixitalics) |
| 20507 |
end |
| 20508 |
registerbasehash(tfmdata) |
| 20509 |
end |
| 20510 |
if trace_preparing then |
| 20511 |
report_prepare("preparation time is %0.3f seconds for %a",os.clock()-starttime,fullname) |
| 20512 |
end |
| 20513 |
end |
| 20514 |
end |
| 20515 |
registerotffeature { |
| 20516 |
name="features", |
| 20517 |
description="features", |
| 20518 |
default=true, |
| 20519 |
initializers={ |
| 20520 |
base=featuresinitializer, |
| 20521 |
} |
| 20522 |
} |
| 20523 |
otf.basemodeinitializer=featuresinitializer |
| 20524 |
|
| 20525 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-oto”] --- |
| 20526 |
|
| 20527 |
|
| 20528 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-otj” b2c165bd6771a57633f992d07384b739] --- |
| 20529 |
|
| 20530 |
if not modules then modules={} end modules ['font-otj']={ |
| 20531 |
version=1.001, |
| 20532 |
optimize=true, |
| 20533 |
comment="companion to font-lib.mkiv", |
| 20534 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 20535 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 20536 |
license="see context related readme files", |
| 20537 |
} |
| 20538 |
if not nodes.properties then return end |
| 20539 |
local next,rawget,tonumber=next,rawget,tonumber |
| 20540 |
local fastcopy=table.fastcopy |
| 20541 |
local registertracker=trackers.register |
| 20542 |
local registerdirective=directives.register |
| 20543 |
local trace_injections=false registertracker("fonts.injections",function(v) trace_injections=v end) |
| 20544 |
local trace_marks=false registertracker("fonts.injections.marks",function(v) trace_marks=v end) |
| 20545 |
local trace_cursive=false registertracker("fonts.injections.cursive",function(v) trace_cursive=v end) |
| 20546 |
local trace_spaces=false registertracker("fonts.injections.spaces",function(v) trace_spaces=v end) |
| 20547 |
local report_injections=logs.reporter("fonts","injections") |
| 20548 |
local report_spaces=logs.reporter("fonts","spaces") |
| 20549 |
local attributes,nodes,node=attributes,nodes,node |
| 20550 |
fonts=fonts |
| 20551 |
local hashes=fonts.hashes |
| 20552 |
local fontdata=hashes.identifiers |
| 20553 |
local fontmarks=hashes.marks |
| 20554 |
nodes.injections=nodes.injections or {} |
| 20555 |
local injections=nodes.injections |
| 20556 |
local tracers=nodes.tracers |
| 20557 |
local setcolor=tracers and tracers.colors.set |
| 20558 |
local resetcolor=tracers and tracers.colors.reset |
| 20559 |
local nodecodes=nodes.nodecodes |
| 20560 |
local glyph_code=nodecodes.glyph |
| 20561 |
local disc_code=nodecodes.disc |
| 20562 |
local kern_code=nodecodes.kern |
| 20563 |
local glue_code=nodecodes.glue |
| 20564 |
local nuts=nodes.nuts |
| 20565 |
local nodepool=nuts.pool |
| 20566 |
local tonode=nuts.tonode |
| 20567 |
local tonut=nuts.tonut |
| 20568 |
local setfield=nuts.setfield |
| 20569 |
local getnext=nuts.getnext |
| 20570 |
local getprev=nuts.getprev |
| 20571 |
local getid=nuts.getid |
| 20572 |
local getfont=nuts.getfont |
| 20573 |
local getchar=nuts.getchar |
| 20574 |
local getoffsets=nuts.getoffsets |
| 20575 |
local getboth=nuts.getboth |
| 20576 |
local getdisc=nuts.getdisc |
| 20577 |
local setdisc=nuts.setdisc |
| 20578 |
local getreplace=nuts.getreplace |
| 20579 |
local setreplace=nuts.setreplace |
| 20580 |
local setoffsets=nuts.setoffsets |
| 20581 |
local ischar=nuts.ischar |
| 20582 |
local getkern=nuts.getkern |
| 20583 |
local setkern=nuts.setkern |
| 20584 |
local setlink=nuts.setlink |
| 20585 |
local setwidth=nuts.setwidth |
| 20586 |
local getwidth=nuts.getwidth |
| 20587 |
local nextchar=nuts.traversers.char |
| 20588 |
local nextglue=nuts.traversers.glue |
| 20589 |
local insertnodebefore=nuts.insertbefore |
| 20590 |
local insertnodeafter=nuts.insertafter |
| 20591 |
local properties=nodes.properties.data |
| 20592 |
local fontkern=nuts.pool and nuts.pool.fontkern |
| 20593 |
local italickern=nuts.pool and nuts.pool.italickern |
| 20594 |
local useitalickerns=false |
| 20595 |
directives.register("fonts.injections.useitalics",function(v) |
| 20596 |
if v then |
| 20597 |
report_injections("using italics for space kerns (tracing only)") |
| 20598 |
end |
| 20599 |
useitalickerns=v |
| 20600 |
end) |
| 20601 |
if not fontkern then |
| 20602 |
local thekern=nuts.new("kern",0) |
| 20603 |
local setkern=nuts.setkern |
| 20604 |
local copy_node=nuts.copy |
| 20605 |
fontkern=function(k) |
| 20606 |
local n=copy_node(thekern) |
| 20607 |
setkern(n,k) |
| 20608 |
return n |
| 20609 |
end |
| 20610 |
end |
| 20611 |
if not italickern then |
| 20612 |
local thekern=nuts.new("kern",3) |
| 20613 |
local setkern=nuts.setkern |
| 20614 |
local copy_node=nuts.copy |
| 20615 |
italickern=function(k) |
| 20616 |
local n=copy_node(thekern) |
| 20617 |
setkern(n,k) |
| 20618 |
return n |
| 20619 |
end |
| 20620 |
end |
| 20621 |
function injections.installnewkern() end |
| 20622 |
local nofregisteredkerns=0 |
| 20623 |
local nofregisteredpositions=0 |
| 20624 |
local nofregisteredmarks=0 |
| 20625 |
local nofregisteredcursives=0 |
| 20626 |
local keepregisteredcounts=false |
| 20627 |
function injections.keepcounts() |
| 20628 |
keepregisteredcounts=true |
| 20629 |
end |
| 20630 |
function injections.resetcounts() |
| 20631 |
nofregisteredkerns=0 |
| 20632 |
nofregisteredpositions=0 |
| 20633 |
nofregisteredmarks=0 |
| 20634 |
nofregisteredcursives=0 |
| 20635 |
keepregisteredcounts=false |
| 20636 |
end |
| 20637 |
function injections.reset(n) |
| 20638 |
local p=rawget(properties,n) |
| 20639 |
if p then |
| 20640 |
p.injections=false |
| 20641 |
else |
| 20642 |
properties[n]=false |
| 20643 |
end |
| 20644 |
end |
| 20645 |
function injections.copy(target,source) |
| 20646 |
local sp=rawget(properties,source) |
| 20647 |
if sp then |
| 20648 |
local tp=rawget(properties,target) |
| 20649 |
local si=sp.injections |
| 20650 |
if si then |
| 20651 |
si=fastcopy(si) |
| 20652 |
if tp then |
| 20653 |
tp.injections=si |
| 20654 |
else |
| 20655 |
properties[target]={ |
| 20656 |
injections=si, |
| 20657 |
} |
| 20658 |
end |
| 20659 |
elseif tp then |
| 20660 |
tp.injections=false |
| 20661 |
else |
| 20662 |
properties[target]={ injections={} } |
| 20663 |
end |
| 20664 |
else |
| 20665 |
local tp=rawget(properties,target) |
| 20666 |
if tp then |
| 20667 |
tp.injections=false |
| 20668 |
else |
| 20669 |
properties[target]=false |
| 20670 |
end |
| 20671 |
end |
| 20672 |
end |
| 20673 |
function injections.setligaindex(n,index) |
| 20674 |
local p=rawget(properties,n) |
| 20675 |
if p then |
| 20676 |
local i=p.injections |
| 20677 |
if i then |
| 20678 |
i.ligaindex=index |
| 20679 |
else |
| 20680 |
p.injections={ |
| 20681 |
ligaindex=index |
| 20682 |
} |
| 20683 |
end |
| 20684 |
else |
| 20685 |
properties[n]={ |
| 20686 |
injections={ |
| 20687 |
ligaindex=index |
| 20688 |
} |
| 20689 |
} |
| 20690 |
end |
| 20691 |
end |
| 20692 |
function injections.getligaindex(n,default) |
| 20693 |
local p=rawget(properties,n) |
| 20694 |
if p then |
| 20695 |
local i=p.injections |
| 20696 |
if i then |
| 20697 |
return i.ligaindex or default |
| 20698 |
end |
| 20699 |
end |
| 20700 |
return default |
| 20701 |
end |
| 20702 |
function injections.setcursive(start,nxt,factor,rlmode,exit,entry,tfmstart,tfmnext,r2lflag) |
| 20703 |
local dx=factor*(exit[1]-entry[1]) |
| 20704 |
local dy=-factor*(exit[2]-entry[2]) |
| 20705 |
local ws=tfmstart.width |
| 20706 |
local wn=tfmnext.width |
| 20707 |
nofregisteredcursives=nofregisteredcursives+1 |
| 20708 |
if rlmode<0 then |
| 20709 |
dx=-(dx+wn) |
| 20710 |
else |
| 20711 |
dx=dx-ws |
| 20712 |
end |
| 20713 |
if dx==0 then |
| 20714 |
dx=0 |
| 20715 |
end |
| 20716 |
local p=rawget(properties,start) |
| 20717 |
if p then |
| 20718 |
local i=p.injections |
| 20719 |
if i then |
| 20720 |
i.cursiveanchor=true |
| 20721 |
else |
| 20722 |
p.injections={ |
| 20723 |
cursiveanchor=true, |
| 20724 |
} |
| 20725 |
end |
| 20726 |
else |
| 20727 |
properties[start]={ |
| 20728 |
injections={ |
| 20729 |
cursiveanchor=true, |
| 20730 |
}, |
| 20731 |
} |
| 20732 |
end |
| 20733 |
local p=rawget(properties,nxt) |
| 20734 |
if p then |
| 20735 |
local i=p.injections |
| 20736 |
if i then |
| 20737 |
i.cursivex=dx |
| 20738 |
i.cursivey=dy |
| 20739 |
else |
| 20740 |
p.injections={ |
| 20741 |
cursivex=dx, |
| 20742 |
cursivey=dy, |
| 20743 |
} |
| 20744 |
end |
| 20745 |
else |
| 20746 |
properties[nxt]={ |
| 20747 |
injections={ |
| 20748 |
cursivex=dx, |
| 20749 |
cursivey=dy, |
| 20750 |
}, |
| 20751 |
} |
| 20752 |
end |
| 20753 |
return dx,dy,nofregisteredcursives |
| 20754 |
end |
| 20755 |
function injections.setposition(kind,current,factor,rlmode,spec,injection) |
| 20756 |
local x=factor*(spec[1] or 0) |
| 20757 |
local y=factor*(spec[2] or 0) |
| 20758 |
local w=factor*(spec[3] or 0) |
| 20759 |
local h=factor*(spec[4] or 0) |
| 20760 |
if x~=0 or w~=0 or y~=0 or h~=0 then |
| 20761 |
local yoffset=y-h |
| 20762 |
local leftkern=x |
| 20763 |
local rightkern=w-x |
| 20764 |
if leftkern~=0 or rightkern~=0 or yoffset~=0 then |
| 20765 |
nofregisteredpositions=nofregisteredpositions+1 |
| 20766 |
if rlmode and rlmode<0 then |
| 20767 |
leftkern,rightkern=rightkern,leftkern |
| 20768 |
end |
| 20769 |
if not injection then |
| 20770 |
injection="injections" |
| 20771 |
end |
| 20772 |
local p=rawget(properties,current) |
| 20773 |
if p then |
| 20774 |
local i=p[injection] |
| 20775 |
if i then |
| 20776 |
if leftkern~=0 then |
| 20777 |
i.leftkern=(i.leftkern or 0)+leftkern |
| 20778 |
end |
| 20779 |
if rightkern~=0 then |
| 20780 |
i.rightkern=(i.rightkern or 0)+rightkern |
| 20781 |
end |
| 20782 |
if yoffset~=0 then |
| 20783 |
i.yoffset=(i.yoffset or 0)+yoffset |
| 20784 |
end |
| 20785 |
elseif leftkern~=0 or rightkern~=0 then |
| 20786 |
p[injection]={ |
| 20787 |
leftkern=leftkern, |
| 20788 |
rightkern=rightkern, |
| 20789 |
yoffset=yoffset, |
| 20790 |
} |
| 20791 |
else |
| 20792 |
p[injection]={ |
| 20793 |
yoffset=yoffset, |
| 20794 |
} |
| 20795 |
end |
| 20796 |
elseif leftkern~=0 or rightkern~=0 then |
| 20797 |
properties[current]={ |
| 20798 |
[injection]={ |
| 20799 |
leftkern=leftkern, |
| 20800 |
rightkern=rightkern, |
| 20801 |
yoffset=yoffset, |
| 20802 |
}, |
| 20803 |
} |
| 20804 |
else |
| 20805 |
properties[current]={ |
| 20806 |
[injection]={ |
| 20807 |
yoffset=yoffset, |
| 20808 |
}, |
| 20809 |
} |
| 20810 |
end |
| 20811 |
return x,y,w,h,nofregisteredpositions |
| 20812 |
end |
| 20813 |
end |
| 20814 |
return x,y,w,h |
| 20815 |
end |
| 20816 |
function injections.setkern(current,factor,rlmode,x,injection) |
| 20817 |
local dx=factor*x |
| 20818 |
if dx~=0 then |
| 20819 |
nofregisteredkerns=nofregisteredkerns+1 |
| 20820 |
local p=rawget(properties,current) |
| 20821 |
if not injection then |
| 20822 |
injection="injections" |
| 20823 |
end |
| 20824 |
if p then |
| 20825 |
local i=p[injection] |
| 20826 |
if i then |
| 20827 |
i.leftkern=dx+(i.leftkern or 0) |
| 20828 |
else |
| 20829 |
p[injection]={ |
| 20830 |
leftkern=dx, |
| 20831 |
} |
| 20832 |
end |
| 20833 |
else |
| 20834 |
properties[current]={ |
| 20835 |
[injection]={ |
| 20836 |
leftkern=dx, |
| 20837 |
}, |
| 20838 |
} |
| 20839 |
end |
| 20840 |
return dx,nofregisteredkerns |
| 20841 |
else |
| 20842 |
return 0,0 |
| 20843 |
end |
| 20844 |
end |
| 20845 |
function injections.setmove(current,factor,rlmode,x,injection) |
| 20846 |
local dx=factor*x |
| 20847 |
if dx~=0 then |
| 20848 |
nofregisteredkerns=nofregisteredkerns+1 |
| 20849 |
local p=rawget(properties,current) |
| 20850 |
if not injection then |
| 20851 |
injection="injections" |
| 20852 |
end |
| 20853 |
if rlmode and rlmode<0 then |
| 20854 |
if p then |
| 20855 |
local i=p[injection] |
| 20856 |
if i then |
| 20857 |
i.rightkern=dx+(i.rightkern or 0) |
| 20858 |
else |
| 20859 |
p[injection]={ |
| 20860 |
rightkern=dx, |
| 20861 |
} |
| 20862 |
end |
| 20863 |
else |
| 20864 |
properties[current]={ |
| 20865 |
[injection]={ |
| 20866 |
rightkern=dx, |
| 20867 |
}, |
| 20868 |
} |
| 20869 |
end |
| 20870 |
else |
| 20871 |
if p then |
| 20872 |
local i=p[injection] |
| 20873 |
if i then |
| 20874 |
i.leftkern=dx+(i.leftkern or 0) |
| 20875 |
else |
| 20876 |
p[injection]={ |
| 20877 |
leftkern=dx, |
| 20878 |
} |
| 20879 |
end |
| 20880 |
else |
| 20881 |
properties[current]={ |
| 20882 |
[injection]={ |
| 20883 |
leftkern=dx, |
| 20884 |
}, |
| 20885 |
} |
| 20886 |
end |
| 20887 |
end |
| 20888 |
return dx,nofregisteredkerns |
| 20889 |
else |
| 20890 |
return 0,0 |
| 20891 |
end |
| 20892 |
end |
| 20893 |
function injections.setmark(start,base,factor,rlmode,ba,ma,tfmbase,mkmk,checkmark) |
| 20894 |
local dx=factor*(ba[1]-ma[1]) |
| 20895 |
local dy=factor*(ba[2]-ma[2]) |
| 20896 |
nofregisteredmarks=nofregisteredmarks+1 |
| 20897 |
if rlmode>=0 then |
| 20898 |
dx=tfmbase.width-dx |
| 20899 |
end |
| 20900 |
local p=rawget(properties,start) |
| 20901 |
if p then |
| 20902 |
local i=p.injections |
| 20903 |
if i then |
| 20904 |
if i.markmark then |
| 20905 |
else |
| 20906 |
i.markx=dx |
| 20907 |
i.marky=dy |
| 20908 |
i.markdir=rlmode or 0 |
| 20909 |
i.markbase=nofregisteredmarks |
| 20910 |
i.markbasenode=base |
| 20911 |
i.markmark=mkmk |
| 20912 |
i.checkmark=checkmark |
| 20913 |
end |
| 20914 |
else |
| 20915 |
p.injections={ |
| 20916 |
markx=dx, |
| 20917 |
marky=dy, |
| 20918 |
markdir=rlmode or 0, |
| 20919 |
markbase=nofregisteredmarks, |
| 20920 |
markbasenode=base, |
| 20921 |
markmark=mkmk, |
| 20922 |
checkmark=checkmark, |
| 20923 |
} |
| 20924 |
end |
| 20925 |
else |
| 20926 |
properties[start]={ |
| 20927 |
injections={ |
| 20928 |
markx=dx, |
| 20929 |
marky=dy, |
| 20930 |
markdir=rlmode or 0, |
| 20931 |
markbase=nofregisteredmarks, |
| 20932 |
markbasenode=base, |
| 20933 |
markmark=mkmk, |
| 20934 |
checkmark=checkmark, |
| 20935 |
}, |
| 20936 |
} |
| 20937 |
end |
| 20938 |
return dx,dy,nofregisteredmarks |
| 20939 |
end |
| 20940 |
local function dir(n) |
| 20941 |
return (n and n<0 and "r-to-l") or (n and n>0 and "l-to-r") or "unset" |
| 20942 |
end |
| 20943 |
local function showchar(n,nested) |
| 20944 |
local char=getchar(n) |
| 20945 |
report_injections("%wfont %s, char %U, glyph %c",nested and 2 or 0,getfont(n),char,char) |
| 20946 |
end |
| 20947 |
local function show(n,what,nested,symbol) |
| 20948 |
if n then |
| 20949 |
local p=rawget(properties,n) |
| 20950 |
if p then |
| 20951 |
local i=p[what] |
| 20952 |
if i then |
| 20953 |
local leftkern=i.leftkern or 0 |
| 20954 |
local rightkern=i.rightkern or 0 |
| 20955 |
local yoffset=i.yoffset or 0 |
| 20956 |
local markx=i.markx or 0 |
| 20957 |
local marky=i.marky or 0 |
| 20958 |
local markdir=i.markdir or 0 |
| 20959 |
local markbase=i.markbase or 0 |
| 20960 |
local cursivex=i.cursivex or 0 |
| 20961 |
local cursivey=i.cursivey or 0 |
| 20962 |
local ligaindex=i.ligaindex or 0 |
| 20963 |
local cursbase=i.cursiveanchor |
| 20964 |
local margin=nested and 4 or 2 |
| 20965 |
if rightkern~=0 or yoffset~=0 then |
| 20966 |
report_injections("%w%s pair: lx %p, rx %p, dy %p",margin,symbol,leftkern,rightkern,yoffset) |
| 20967 |
elseif leftkern~=0 then |
| 20968 |
report_injections("%w%s kern: dx %p",margin,symbol,leftkern) |
| 20969 |
end |
| 20970 |
if markx~=0 or marky~=0 or markbase~=0 then |
| 20971 |
report_injections("%w%s mark: dx %p, dy %p, dir %s, base %s",margin,symbol,markx,marky,markdir,markbase~=0 and "yes" or "no") |
| 20972 |
end |
| 20973 |
if cursivex~=0 or cursivey~=0 then |
| 20974 |
if cursbase then |
| 20975 |
report_injections("%w%s curs: base dx %p, dy %p",margin,symbol,cursivex,cursivey) |
| 20976 |
else |
| 20977 |
report_injections("%w%s curs: dx %p, dy %p",margin,symbol,cursivex,cursivey) |
| 20978 |
end |
| 20979 |
elseif cursbase then |
| 20980 |
report_injections("%w%s curs: base",margin,symbol) |
| 20981 |
end |
| 20982 |
if ligaindex~=0 then |
| 20983 |
report_injections("%w%s liga: index %i",margin,symbol,ligaindex) |
| 20984 |
end |
| 20985 |
end |
| 20986 |
end |
| 20987 |
end |
| 20988 |
end |
| 20989 |
local function showsub(n,what,where) |
| 20990 |
report_injections("begin subrun: %s",where) |
| 20991 |
for n in nextchar,n do |
| 20992 |
showchar(n,where) |
| 20993 |
show(n,what,where," ") |
| 20994 |
end |
| 20995 |
report_injections("end subrun") |
| 20996 |
end |
| 20997 |
local function trace(head,where) |
| 20998 |
report_injections() |
| 20999 |
report_injections("begin run %s: %s kerns, %s positions, %s marks and %s cursives registered", |
| 21000 |
where or "",nofregisteredkerns,nofregisteredpositions,nofregisteredmarks,nofregisteredcursives) |
| 21001 |
local n=head |
| 21002 |
while n do |
| 21003 |
local id=getid(n) |
| 21004 |
if id==glyph_code then |
| 21005 |
showchar(n) |
| 21006 |
show(n,"injections",false," ") |
| 21007 |
show(n,"preinjections",false,"<") |
| 21008 |
show(n,"postinjections",false,">") |
| 21009 |
show(n,"replaceinjections",false,"=") |
| 21010 |
show(n,"emptyinjections",false,"*") |
| 21011 |
elseif id==disc_code then |
| 21012 |
local pre,post,replace=getdisc(n) |
| 21013 |
if pre then |
| 21014 |
showsub(pre,"preinjections","pre") |
| 21015 |
end |
| 21016 |
if post then |
| 21017 |
showsub(post,"postinjections","post") |
| 21018 |
end |
| 21019 |
if replace then |
| 21020 |
showsub(replace,"replaceinjections","replace") |
| 21021 |
end |
| 21022 |
show(n,"emptyinjections",false,"*") |
| 21023 |
end |
| 21024 |
n=getnext(n) |
| 21025 |
end |
| 21026 |
report_injections("end run") |
| 21027 |
end |
| 21028 |
local function show_result(head) |
| 21029 |
local current=head |
| 21030 |
local skipping=false |
| 21031 |
while current do |
| 21032 |
local id=getid(current) |
| 21033 |
if id==glyph_code then |
| 21034 |
local w=getwidth(current) |
| 21035 |
local x,y=getoffsets(current) |
| 21036 |
report_injections("char: %C, width %p, xoffset %p, yoffset %p",getchar(current),w,x,y) |
| 21037 |
skipping=false |
| 21038 |
elseif id==kern_code then |
| 21039 |
report_injections("kern: %p",getkern(current)) |
| 21040 |
skipping=false |
| 21041 |
elseif not skipping then |
| 21042 |
report_injections() |
| 21043 |
skipping=true |
| 21044 |
end |
| 21045 |
current=getnext(current) |
| 21046 |
end |
| 21047 |
report_injections() |
| 21048 |
end |
| 21049 |
local function inject_kerns_only(head,where) |
| 21050 |
if trace_injections then |
| 21051 |
trace(head,"kerns") |
| 21052 |
end |
| 21053 |
local current=head |
| 21054 |
local prev=nil |
| 21055 |
local next=nil |
| 21056 |
local prevdisc=nil |
| 21057 |
local pre=nil |
| 21058 |
local post=nil |
| 21059 |
local replace=nil |
| 21060 |
local pretail=nil |
| 21061 |
local posttail=nil |
| 21062 |
local replacetail=nil |
| 21063 |
while current do |
| 21064 |
local next=getnext(current) |
| 21065 |
local char,id=ischar(current) |
| 21066 |
if char then |
| 21067 |
local p=rawget(properties,current) |
| 21068 |
if p then |
| 21069 |
local i=p.injections |
| 21070 |
if i then |
| 21071 |
local leftkern=i.leftkern |
| 21072 |
if leftkern and leftkern~=0 then |
| 21073 |
if prev and getid(prev)==glue_code then |
| 21074 |
if useitalickerns then |
| 21075 |
head=insertnodebefore(head,current,italickern(leftkern)) |
| 21076 |
else |
| 21077 |
setwidth(prev,getwidth(prev)+leftkern) |
| 21078 |
end |
| 21079 |
else |
| 21080 |
head=insertnodebefore(head,current,fontkern(leftkern)) |
| 21081 |
end |
| 21082 |
end |
| 21083 |
end |
| 21084 |
if prevdisc then |
| 21085 |
local done=false |
| 21086 |
if post then |
| 21087 |
local i=p.postinjections |
| 21088 |
if i then |
| 21089 |
local leftkern=i.leftkern |
| 21090 |
if leftkern and leftkern~=0 then |
| 21091 |
setlink(posttail,fontkern(leftkern)) |
| 21092 |
done=true |
| 21093 |
end |
| 21094 |
end |
| 21095 |
end |
| 21096 |
if replace then |
| 21097 |
local i=p.replaceinjections |
| 21098 |
if i then |
| 21099 |
local leftkern=i.leftkern |
| 21100 |
if leftkern and leftkern~=0 then |
| 21101 |
setlink(replacetail,fontkern(leftkern)) |
| 21102 |
done=true |
| 21103 |
end |
| 21104 |
end |
| 21105 |
else |
| 21106 |
local i=p.emptyinjections |
| 21107 |
if i then |
| 21108 |
local leftkern=i.leftkern |
| 21109 |
if leftkern and leftkern~=0 then |
| 21110 |
replace=fontkern(leftkern) |
| 21111 |
done=true |
| 21112 |
end |
| 21113 |
end |
| 21114 |
end |
| 21115 |
if done then |
| 21116 |
setdisc(prevdisc,pre,post,replace) |
| 21117 |
end |
| 21118 |
end |
| 21119 |
end |
| 21120 |
prevdisc=nil |
| 21121 |
elseif char==false then |
| 21122 |
prevdisc=nil |
| 21123 |
elseif id==disc_code then |
| 21124 |
pre,post,replace,pretail,posttail,replacetail=getdisc(current,true) |
| 21125 |
local done=false |
| 21126 |
if pre then |
| 21127 |
for n in nextchar,pre do |
| 21128 |
local p=rawget(properties,n) |
| 21129 |
if p then |
| 21130 |
local i=p.injections or p.preinjections |
| 21131 |
if i then |
| 21132 |
local leftkern=i.leftkern |
| 21133 |
if leftkern and leftkern~=0 then |
| 21134 |
pre=insertnodebefore(pre,n,fontkern(leftkern)) |
| 21135 |
done=true |
| 21136 |
end |
| 21137 |
end |
| 21138 |
end |
| 21139 |
end |
| 21140 |
end |
| 21141 |
if post then |
| 21142 |
for n in nextchar,post do |
| 21143 |
local p=rawget(properties,n) |
| 21144 |
if p then |
| 21145 |
local i=p.injections or p.postinjections |
| 21146 |
if i then |
| 21147 |
local leftkern=i.leftkern |
| 21148 |
if leftkern and leftkern~=0 then |
| 21149 |
post=insertnodebefore(post,n,fontkern(leftkern)) |
| 21150 |
done=true |
| 21151 |
end |
| 21152 |
end |
| 21153 |
end |
| 21154 |
end |
| 21155 |
end |
| 21156 |
if replace then |
| 21157 |
for n in nextchar,replace do |
| 21158 |
local p=rawget(properties,n) |
| 21159 |
if p then |
| 21160 |
local i=p.injections or p.replaceinjections |
| 21161 |
if i then |
| 21162 |
local leftkern=i.leftkern |
| 21163 |
if leftkern and leftkern~=0 then |
| 21164 |
replace=insertnodebefore(replace,n,fontkern(leftkern)) |
| 21165 |
done=true |
| 21166 |
end |
| 21167 |
end |
| 21168 |
end |
| 21169 |
end |
| 21170 |
end |
| 21171 |
if done then |
| 21172 |
setdisc(current,pre,post,replace) |
| 21173 |
end |
| 21174 |
prevdisc=current |
| 21175 |
else |
| 21176 |
prevdisc=nil |
| 21177 |
end |
| 21178 |
prev=current |
| 21179 |
current=next |
| 21180 |
end |
| 21181 |
if keepregisteredcounts then |
| 21182 |
keepregisteredcounts=false |
| 21183 |
else |
| 21184 |
nofregisteredkerns=0 |
| 21185 |
end |
| 21186 |
if trace_injections then |
| 21187 |
show_result(head) |
| 21188 |
end |
| 21189 |
return head |
| 21190 |
end |
| 21191 |
local function inject_positions_only(head,where) |
| 21192 |
if trace_injections then |
| 21193 |
trace(head,"positions") |
| 21194 |
end |
| 21195 |
local current=head |
| 21196 |
local prev=nil |
| 21197 |
local next=nil |
| 21198 |
local prevdisc=nil |
| 21199 |
local prevglyph=nil |
| 21200 |
local pre=nil |
| 21201 |
local post=nil |
| 21202 |
local replace=nil |
| 21203 |
local pretail=nil |
| 21204 |
local posttail=nil |
| 21205 |
local replacetail=nil |
| 21206 |
while current do |
| 21207 |
local next=getnext(current) |
| 21208 |
local char,id=ischar(current) |
| 21209 |
if char then |
| 21210 |
local p=rawget(properties,current) |
| 21211 |
if p then |
| 21212 |
local i=p.injections |
| 21213 |
if i then |
| 21214 |
local yoffset=i.yoffset |
| 21215 |
if yoffset and yoffset~=0 then |
| 21216 |
setoffsets(current,false,yoffset) |
| 21217 |
end |
| 21218 |
local leftkern=i.leftkern |
| 21219 |
local rightkern=i.rightkern |
| 21220 |
if leftkern and leftkern~=0 then |
| 21221 |
if rightkern and leftkern==-rightkern then |
| 21222 |
setoffsets(current,leftkern,false) |
| 21223 |
rightkern=0 |
| 21224 |
elseif prev and getid(prev)==glue_code then |
| 21225 |
if useitalickerns then |
| 21226 |
head=insertnodebefore(head,current,italickern(leftkern)) |
| 21227 |
else |
| 21228 |
setwidth(prev,getwidth(prev)+leftkern) |
| 21229 |
end |
| 21230 |
else |
| 21231 |
head=insertnodebefore(head,current,fontkern(leftkern)) |
| 21232 |
end |
| 21233 |
end |
| 21234 |
if rightkern and rightkern~=0 then |
| 21235 |
if next and getid(next)==glue_code then |
| 21236 |
if useitalickerns then |
| 21237 |
insertnodeafter(head,current,italickern(rightkern)) |
| 21238 |
else |
| 21239 |
setwidth(next,getwidth(next)+rightkern) |
| 21240 |
end |
| 21241 |
else |
| 21242 |
insertnodeafter(head,current,fontkern(rightkern)) |
| 21243 |
end |
| 21244 |
end |
| 21245 |
elseif next then |
| 21246 |
local i=p.emptyinjections |
| 21247 |
if i then |
| 21248 |
local rightkern=i.rightkern |
| 21249 |
if rightkern and rightkern~=0 and getid(next)==disc_code then |
| 21250 |
local replace=getreplace(next) |
| 21251 |
if replace then |
| 21252 |
else |
| 21253 |
setreplace(next,fontkern(rightkern)) |
| 21254 |
end |
| 21255 |
end |
| 21256 |
end |
| 21257 |
end |
| 21258 |
if prevdisc then |
| 21259 |
local done=false |
| 21260 |
if post then |
| 21261 |
local i=p.postinjections |
| 21262 |
if i then |
| 21263 |
local leftkern=i.leftkern |
| 21264 |
if leftkern and leftkern~=0 then |
| 21265 |
setlink(posttail,fontkern(leftkern)) |
| 21266 |
done=true |
| 21267 |
end |
| 21268 |
end |
| 21269 |
end |
| 21270 |
if replace then |
| 21271 |
local i=p.replaceinjections |
| 21272 |
if i then |
| 21273 |
local leftkern=i.leftkern |
| 21274 |
if leftkern and leftkern~=0 then |
| 21275 |
setlink(replacetail,fontkern(leftkern)) |
| 21276 |
done=true |
| 21277 |
end |
| 21278 |
end |
| 21279 |
else |
| 21280 |
local i=p.emptyinjections |
| 21281 |
if i then |
| 21282 |
local leftkern=i.leftkern |
| 21283 |
if leftkern and leftkern~=0 then |
| 21284 |
replace=fontkern(leftkern) |
| 21285 |
done=true |
| 21286 |
end |
| 21287 |
end |
| 21288 |
end |
| 21289 |
if done then |
| 21290 |
setdisc(prevdisc,pre,post,replace) |
| 21291 |
end |
| 21292 |
end |
| 21293 |
end |
| 21294 |
prevdisc=nil |
| 21295 |
prevglyph=current |
| 21296 |
elseif char==false then |
| 21297 |
prevdisc=nil |
| 21298 |
prevglyph=current |
| 21299 |
elseif id==disc_code then |
| 21300 |
pre,post,replace,pretail,posttail,replacetail=getdisc(current,true) |
| 21301 |
local done=false |
| 21302 |
if pre then |
| 21303 |
for n in nextchar,pre do |
| 21304 |
local p=rawget(properties,n) |
| 21305 |
if p then |
| 21306 |
local i=p.injections or p.preinjections |
| 21307 |
if i then |
| 21308 |
local yoffset=i.yoffset |
| 21309 |
if yoffset and yoffset~=0 then |
| 21310 |
setoffsets(n,false,yoffset) |
| 21311 |
end |
| 21312 |
local leftkern=i.leftkern |
| 21313 |
if leftkern and leftkern~=0 then |
| 21314 |
pre=insertnodebefore(pre,n,fontkern(leftkern)) |
| 21315 |
done=true |
| 21316 |
end |
| 21317 |
local rightkern=i.rightkern |
| 21318 |
if rightkern and rightkern~=0 then |
| 21319 |
insertnodeafter(pre,n,fontkern(rightkern)) |
| 21320 |
done=true |
| 21321 |
end |
| 21322 |
end |
| 21323 |
end |
| 21324 |
end |
| 21325 |
end |
| 21326 |
if post then |
| 21327 |
for n in nextchar,post do |
| 21328 |
local p=rawget(properties,n) |
| 21329 |
if p then |
| 21330 |
local i=p.injections or p.postinjections |
| 21331 |
if i then |
| 21332 |
local yoffset=i.yoffset |
| 21333 |
if yoffset and yoffset~=0 then |
| 21334 |
setoffsets(n,false,yoffset) |
| 21335 |
end |
| 21336 |
local leftkern=i.leftkern |
| 21337 |
if leftkern and leftkern~=0 then |
| 21338 |
post=insertnodebefore(post,n,fontkern(leftkern)) |
| 21339 |
done=true |
| 21340 |
end |
| 21341 |
local rightkern=i.rightkern |
| 21342 |
if rightkern and rightkern~=0 then |
| 21343 |
insertnodeafter(post,n,fontkern(rightkern)) |
| 21344 |
done=true |
| 21345 |
end |
| 21346 |
end |
| 21347 |
end |
| 21348 |
end |
| 21349 |
end |
| 21350 |
if replace then |
| 21351 |
for n in nextchar,replace do |
| 21352 |
local p=rawget(properties,n) |
| 21353 |
if p then |
| 21354 |
local i=p.injections or p.replaceinjections |
| 21355 |
if i then |
| 21356 |
local yoffset=i.yoffset |
| 21357 |
if yoffset and yoffset~=0 then |
| 21358 |
setoffsets(n,false,yoffset) |
| 21359 |
end |
| 21360 |
local leftkern=i.leftkern |
| 21361 |
if leftkern and leftkern~=0 then |
| 21362 |
replace=insertnodebefore(replace,n,fontkern(leftkern)) |
| 21363 |
done=true |
| 21364 |
end |
| 21365 |
local rightkern=i.rightkern |
| 21366 |
if rightkern and rightkern~=0 then |
| 21367 |
insertnodeafter(replace,n,fontkern(rightkern)) |
| 21368 |
done=true |
| 21369 |
end |
| 21370 |
end |
| 21371 |
end |
| 21372 |
end |
| 21373 |
end |
| 21374 |
if prevglyph then |
| 21375 |
if pre then |
| 21376 |
local p=rawget(properties,prevglyph) |
| 21377 |
if p then |
| 21378 |
local i=p.preinjections |
| 21379 |
if i then |
| 21380 |
local rightkern=i.rightkern |
| 21381 |
if rightkern and rightkern~=0 then |
| 21382 |
pre=insertnodebefore(pre,pre,fontkern(rightkern)) |
| 21383 |
done=true |
| 21384 |
end |
| 21385 |
end |
| 21386 |
end |
| 21387 |
end |
| 21388 |
if replace then |
| 21389 |
local p=rawget(properties,prevglyph) |
| 21390 |
if p then |
| 21391 |
local i=p.replaceinjections |
| 21392 |
if i then |
| 21393 |
local rightkern=i.rightkern |
| 21394 |
if rightkern and rightkern~=0 then |
| 21395 |
replace=insertnodebefore(replace,replace,fontkern(rightkern)) |
| 21396 |
done=true |
| 21397 |
end |
| 21398 |
end |
| 21399 |
end |
| 21400 |
end |
| 21401 |
end |
| 21402 |
if done then |
| 21403 |
setdisc(current,pre,post,replace) |
| 21404 |
end |
| 21405 |
prevglyph=nil |
| 21406 |
prevdisc=current |
| 21407 |
else |
| 21408 |
prevglyph=nil |
| 21409 |
prevdisc=nil |
| 21410 |
end |
| 21411 |
prev=current |
| 21412 |
current=next |
| 21413 |
end |
| 21414 |
if keepregisteredcounts then |
| 21415 |
keepregisteredcounts=false |
| 21416 |
else |
| 21417 |
nofregisteredpositions=0 |
| 21418 |
end |
| 21419 |
if trace_injections then |
| 21420 |
show_result(head) |
| 21421 |
end |
| 21422 |
return head |
| 21423 |
end |
| 21424 |
local function showoffset(n,flag) |
| 21425 |
local x,y=getoffsets(n) |
| 21426 |
if x~=0 or y~=0 then |
| 21427 |
setcolor(n,"darkgray") |
| 21428 |
end |
| 21429 |
end |
| 21430 |
local function inject_everything(head,where) |
| 21431 |
if trace_injections then |
| 21432 |
trace(head,"everything") |
| 21433 |
end |
| 21434 |
local hascursives=nofregisteredcursives>0 |
| 21435 |
local hasmarks=nofregisteredmarks>0 |
| 21436 |
local current=head |
| 21437 |
local last=nil |
| 21438 |
local prev=nil |
| 21439 |
local next=nil |
| 21440 |
local prevdisc=nil |
| 21441 |
local prevglyph=nil |
| 21442 |
local pre=nil |
| 21443 |
local post=nil |
| 21444 |
local replace=nil |
| 21445 |
local pretail=nil |
| 21446 |
local posttail=nil |
| 21447 |
local replacetail=nil |
| 21448 |
local cursiveanchor=nil |
| 21449 |
local minc=0 |
| 21450 |
local maxc=0 |
| 21451 |
local glyphs={} |
| 21452 |
local marks={} |
| 21453 |
local nofmarks=0 |
| 21454 |
local function processmark(p,n,pn) |
| 21455 |
local px,py=getoffsets(p) |
| 21456 |
local nx,ny=getoffsets(n) |
| 21457 |
local ox=0 |
| 21458 |
local rightkern=nil |
| 21459 |
local pp=rawget(properties,p) |
| 21460 |
if pp then |
| 21461 |
pp=pp.injections |
| 21462 |
if pp then |
| 21463 |
rightkern=pp.rightkern |
| 21464 |
end |
| 21465 |
end |
| 21466 |
local markdir=pn.markdir |
| 21467 |
if rightkern then |
| 21468 |
ox=px-(pn.markx or 0)-rightkern |
| 21469 |
if markdir and markdir<0 then |
| 21470 |
if not pn.markmark then |
| 21471 |
ox=ox+(pn.leftkern or 0) |
| 21472 |
end |
| 21473 |
else |
| 21474 |
if false then |
| 21475 |
local leftkern=pp.leftkern |
| 21476 |
if leftkern then |
| 21477 |
ox=ox-leftkern |
| 21478 |
end |
| 21479 |
end |
| 21480 |
end |
| 21481 |
else |
| 21482 |
ox=px-(pn.markx or 0) |
| 21483 |
if markdir and markdir<0 then |
| 21484 |
if not pn.markmark then |
| 21485 |
local leftkern=pn.leftkern |
| 21486 |
if leftkern then |
| 21487 |
ox=ox+leftkern |
| 21488 |
end |
| 21489 |
end |
| 21490 |
end |
| 21491 |
if pn.checkmark then |
| 21492 |
local wn=getwidth(n) |
| 21493 |
if wn and wn~=0 then |
| 21494 |
wn=wn/2 |
| 21495 |
if trace_injections then |
| 21496 |
report_injections("correcting non zero width mark %C",getchar(n)) |
| 21497 |
end |
| 21498 |
insertnodebefore(n,n,fontkern(-wn)) |
| 21499 |
insertnodeafter(n,n,fontkern(-wn)) |
| 21500 |
end |
| 21501 |
end |
| 21502 |
end |
| 21503 |
local oy=ny+py+(pn.marky or 0) |
| 21504 |
if not pn.markmark then |
| 21505 |
local yoffset=pn.yoffset |
| 21506 |
if yoffset then |
| 21507 |
oy=oy+yoffset |
| 21508 |
end |
| 21509 |
end |
| 21510 |
setoffsets(n,ox,oy) |
| 21511 |
if trace_marks then |
| 21512 |
showoffset(n,true) |
| 21513 |
end |
| 21514 |
end |
| 21515 |
while current do |
| 21516 |
local next=getnext(current) |
| 21517 |
local char,id=ischar(current) |
| 21518 |
if char then |
| 21519 |
local p=rawget(properties,current) |
| 21520 |
if p then |
| 21521 |
local i=p.injections |
| 21522 |
if i then |
| 21523 |
local pm=i.markbasenode |
| 21524 |
if pm then |
| 21525 |
nofmarks=nofmarks+1 |
| 21526 |
marks[nofmarks]=current |
| 21527 |
else |
| 21528 |
local yoffset=i.yoffset |
| 21529 |
if yoffset and yoffset~=0 then |
| 21530 |
setoffsets(current,false,yoffset) |
| 21531 |
end |
| 21532 |
if hascursives then |
| 21533 |
local cursivex=i.cursivex |
| 21534 |
if cursivex then |
| 21535 |
if cursiveanchor then |
| 21536 |
if cursivex~=0 then |
| 21537 |
i.leftkern=(i.leftkern or 0)+cursivex |
| 21538 |
end |
| 21539 |
if maxc==0 then |
| 21540 |
minc=1 |
| 21541 |
maxc=1 |
| 21542 |
glyphs[1]=cursiveanchor |
| 21543 |
else |
| 21544 |
maxc=maxc+1 |
| 21545 |
glyphs[maxc]=cursiveanchor |
| 21546 |
end |
| 21547 |
properties[cursiveanchor].cursivedy=i.cursivey |
| 21548 |
last=current |
| 21549 |
else |
| 21550 |
maxc=0 |
| 21551 |
end |
| 21552 |
elseif maxc>0 then |
| 21553 |
local nx,ny=getoffsets(current) |
| 21554 |
for i=maxc,minc,-1 do |
| 21555 |
local ti=glyphs[i] |
| 21556 |
ny=ny+properties[ti].cursivedy |
| 21557 |
setoffsets(ti,false,ny) |
| 21558 |
if trace_cursive then |
| 21559 |
showoffset(ti) |
| 21560 |
end |
| 21561 |
end |
| 21562 |
maxc=0 |
| 21563 |
cursiveanchor=nil |
| 21564 |
end |
| 21565 |
if i.cursiveanchor then |
| 21566 |
cursiveanchor=current |
| 21567 |
else |
| 21568 |
if maxc>0 then |
| 21569 |
local nx,ny=getoffsets(current) |
| 21570 |
for i=maxc,minc,-1 do |
| 21571 |
local ti=glyphs[i] |
| 21572 |
ny=ny+properties[ti].cursivedy |
| 21573 |
setoffsets(ti,false,ny) |
| 21574 |
if trace_cursive then |
| 21575 |
showoffset(ti) |
| 21576 |
end |
| 21577 |
end |
| 21578 |
maxc=0 |
| 21579 |
end |
| 21580 |
cursiveanchor=nil |
| 21581 |
end |
| 21582 |
end |
| 21583 |
local leftkern=i.leftkern |
| 21584 |
local rightkern=i.rightkern |
| 21585 |
if leftkern and leftkern~=0 then |
| 21586 |
if rightkern and leftkern==-rightkern then |
| 21587 |
setoffsets(current,leftkern,false) |
| 21588 |
rightkern=0 |
| 21589 |
elseif prev and getid(prev)==glue_code then |
| 21590 |
if useitalickerns then |
| 21591 |
head=insertnodebefore(head,current,italickern(leftkern)) |
| 21592 |
else |
| 21593 |
setwidth(prev,getwidth(prev)+leftkern) |
| 21594 |
end |
| 21595 |
else |
| 21596 |
head=insertnodebefore(head,current,fontkern(leftkern)) |
| 21597 |
end |
| 21598 |
end |
| 21599 |
if rightkern and rightkern~=0 then |
| 21600 |
if next and getid(next)==glue_code then |
| 21601 |
if useitalickerns then |
| 21602 |
insertnodeafter(head,current,italickern(rightkern)) |
| 21603 |
else |
| 21604 |
setwidth(next,getwidth(next)+rightkern) |
| 21605 |
end |
| 21606 |
else |
| 21607 |
insertnodeafter(head,current,fontkern(rightkern)) |
| 21608 |
end |
| 21609 |
end |
| 21610 |
end |
| 21611 |
elseif next then |
| 21612 |
local i=p.emptyinjections |
| 21613 |
if i then |
| 21614 |
local rightkern=i.rightkern |
| 21615 |
if rightkern and rightkern~=0 and getid(next)==disc_code then |
| 21616 |
local replace=getreplace(next) |
| 21617 |
if replace then |
| 21618 |
else |
| 21619 |
setreplace(next,fontkern(rightkern)) |
| 21620 |
end |
| 21621 |
end |
| 21622 |
end |
| 21623 |
end |
| 21624 |
if prevdisc then |
| 21625 |
if p then |
| 21626 |
local done=false |
| 21627 |
if post then |
| 21628 |
local i=p.postinjections |
| 21629 |
if i then |
| 21630 |
local leftkern=i.leftkern |
| 21631 |
if leftkern and leftkern~=0 then |
| 21632 |
setlink(posttail,fontkern(leftkern)) |
| 21633 |
done=true |
| 21634 |
end |
| 21635 |
end |
| 21636 |
end |
| 21637 |
if replace then |
| 21638 |
local i=p.replaceinjections |
| 21639 |
if i then |
| 21640 |
local leftkern=i.leftkern |
| 21641 |
if leftkern and leftkern~=0 then |
| 21642 |
setlink(replacetail,fontkern(leftkern)) |
| 21643 |
done=true |
| 21644 |
end |
| 21645 |
end |
| 21646 |
else |
| 21647 |
local i=p.emptyinjections |
| 21648 |
if i then |
| 21649 |
local leftkern=i.leftkern |
| 21650 |
if leftkern and leftkern~=0 then |
| 21651 |
replace=fontkern(leftkern) |
| 21652 |
done=true |
| 21653 |
end |
| 21654 |
end |
| 21655 |
end |
| 21656 |
if done then |
| 21657 |
setdisc(prevdisc,pre,post,replace) |
| 21658 |
end |
| 21659 |
end |
| 21660 |
end |
| 21661 |
else |
| 21662 |
if hascursives and maxc>0 then |
| 21663 |
local nx,ny=getoffsets(current) |
| 21664 |
for i=maxc,minc,-1 do |
| 21665 |
local ti=glyphs[i] |
| 21666 |
ny=ny+properties[ti].cursivedy |
| 21667 |
local xi,yi=getoffsets(ti) |
| 21668 |
setoffsets(ti,xi,yi+ny) |
| 21669 |
end |
| 21670 |
maxc=0 |
| 21671 |
cursiveanchor=nil |
| 21672 |
end |
| 21673 |
end |
| 21674 |
prevdisc=nil |
| 21675 |
prevglyph=current |
| 21676 |
elseif char==false then |
| 21677 |
prevdisc=nil |
| 21678 |
prevglyph=current |
| 21679 |
elseif id==disc_code then |
| 21680 |
pre,post,replace,pretail,posttail,replacetail=getdisc(current,true) |
| 21681 |
local done=false |
| 21682 |
if pre then |
| 21683 |
for n in nextchar,pre do |
| 21684 |
local p=rawget(properties,n) |
| 21685 |
if p then |
| 21686 |
local i=p.injections or p.preinjections |
| 21687 |
if i then |
| 21688 |
local yoffset=i.yoffset |
| 21689 |
if yoffset and yoffset~=0 then |
| 21690 |
setoffsets(n,false,yoffset) |
| 21691 |
end |
| 21692 |
local leftkern=i.leftkern |
| 21693 |
if leftkern and leftkern~=0 then |
| 21694 |
pre=insertnodebefore(pre,n,fontkern(leftkern)) |
| 21695 |
done=true |
| 21696 |
end |
| 21697 |
local rightkern=i.rightkern |
| 21698 |
if rightkern and rightkern~=0 then |
| 21699 |
insertnodeafter(pre,n,fontkern(rightkern)) |
| 21700 |
done=true |
| 21701 |
end |
| 21702 |
if hasmarks then |
| 21703 |
local pm=i.markbasenode |
| 21704 |
if pm then |
| 21705 |
processmark(pm,n,i) |
| 21706 |
end |
| 21707 |
end |
| 21708 |
end |
| 21709 |
end |
| 21710 |
end |
| 21711 |
end |
| 21712 |
if post then |
| 21713 |
for n in nextchar,post do |
| 21714 |
local p=rawget(properties,n) |
| 21715 |
if p then |
| 21716 |
local i=p.injections or p.postinjections |
| 21717 |
if i then |
| 21718 |
local yoffset=i.yoffset |
| 21719 |
if yoffset and yoffset~=0 then |
| 21720 |
setoffsets(n,false,yoffset) |
| 21721 |
end |
| 21722 |
local leftkern=i.leftkern |
| 21723 |
if leftkern and leftkern~=0 then |
| 21724 |
post=insertnodebefore(post,n,fontkern(leftkern)) |
| 21725 |
done=true |
| 21726 |
end |
| 21727 |
local rightkern=i.rightkern |
| 21728 |
if rightkern and rightkern~=0 then |
| 21729 |
insertnodeafter(post,n,fontkern(rightkern)) |
| 21730 |
done=true |
| 21731 |
end |
| 21732 |
if hasmarks then |
| 21733 |
local pm=i.markbasenode |
| 21734 |
if pm then |
| 21735 |
processmark(pm,n,i) |
| 21736 |
end |
| 21737 |
end |
| 21738 |
end |
| 21739 |
end |
| 21740 |
end |
| 21741 |
end |
| 21742 |
if replace then |
| 21743 |
for n in nextchar,replace do |
| 21744 |
local p=rawget(properties,n) |
| 21745 |
if p then |
| 21746 |
local i=p.injections or p.replaceinjections |
| 21747 |
if i then |
| 21748 |
local yoffset=i.yoffset |
| 21749 |
if yoffset and yoffset~=0 then |
| 21750 |
setoffsets(n,false,yoffset) |
| 21751 |
end |
| 21752 |
local leftkern=i.leftkern |
| 21753 |
if leftkern and leftkern~=0 then |
| 21754 |
replace=insertnodebefore(replace,n,fontkern(leftkern)) |
| 21755 |
done=true |
| 21756 |
end |
| 21757 |
local rightkern=i.rightkern |
| 21758 |
if rightkern and rightkern~=0 then |
| 21759 |
insertnodeafter(replace,n,fontkern(rightkern)) |
| 21760 |
done=true |
| 21761 |
end |
| 21762 |
if hasmarks then |
| 21763 |
local pm=i.markbasenode |
| 21764 |
if pm then |
| 21765 |
processmark(pm,n,i) |
| 21766 |
end |
| 21767 |
end |
| 21768 |
end |
| 21769 |
end |
| 21770 |
end |
| 21771 |
end |
| 21772 |
if prevglyph then |
| 21773 |
if pre then |
| 21774 |
local p=rawget(properties,prevglyph) |
| 21775 |
if p then |
| 21776 |
local i=p.preinjections |
| 21777 |
if i then |
| 21778 |
local rightkern=i.rightkern |
| 21779 |
if rightkern and rightkern~=0 then |
| 21780 |
pre=insertnodebefore(pre,pre,fontkern(rightkern)) |
| 21781 |
done=true |
| 21782 |
end |
| 21783 |
end |
| 21784 |
end |
| 21785 |
end |
| 21786 |
if replace then |
| 21787 |
local p=rawget(properties,prevglyph) |
| 21788 |
if p then |
| 21789 |
local i=p.replaceinjections |
| 21790 |
if i then |
| 21791 |
local rightkern=i.rightkern |
| 21792 |
if rightkern and rightkern~=0 then |
| 21793 |
replace=insertnodebefore(replace,replace,fontkern(rightkern)) |
| 21794 |
done=true |
| 21795 |
end |
| 21796 |
end |
| 21797 |
end |
| 21798 |
end |
| 21799 |
end |
| 21800 |
if done then |
| 21801 |
setdisc(current,pre,post,replace) |
| 21802 |
end |
| 21803 |
prevglyph=nil |
| 21804 |
prevdisc=current |
| 21805 |
else |
| 21806 |
prevglyph=nil |
| 21807 |
prevdisc=nil |
| 21808 |
end |
| 21809 |
prev=current |
| 21810 |
current=next |
| 21811 |
end |
| 21812 |
if hascursives and maxc>0 then |
| 21813 |
local nx,ny=getoffsets(last) |
| 21814 |
for i=maxc,minc,-1 do |
| 21815 |
local ti=glyphs[i] |
| 21816 |
ny=ny+properties[ti].cursivedy |
| 21817 |
setoffsets(ti,false,ny) |
| 21818 |
if trace_cursive then |
| 21819 |
showoffset(ti) |
| 21820 |
end |
| 21821 |
end |
| 21822 |
end |
| 21823 |
if nofmarks>0 then |
| 21824 |
for i=1,nofmarks do |
| 21825 |
local m=marks[i] |
| 21826 |
local p=rawget(properties,m) |
| 21827 |
local i=p.injections |
| 21828 |
local b=i.markbasenode |
| 21829 |
processmark(b,m,i) |
| 21830 |
end |
| 21831 |
elseif hasmarks then |
| 21832 |
end |
| 21833 |
if keepregisteredcounts then |
| 21834 |
keepregisteredcounts=false |
| 21835 |
else |
| 21836 |
nofregisteredkerns=0 |
| 21837 |
nofregisteredpositions=0 |
| 21838 |
nofregisteredmarks=0 |
| 21839 |
nofregisteredcursives=0 |
| 21840 |
end |
| 21841 |
if trace_injections then |
| 21842 |
show_result(head) |
| 21843 |
end |
| 21844 |
return head |
| 21845 |
end |
| 21846 |
local triggers=false |
| 21847 |
function nodes.injections.setspacekerns(font,sequence) |
| 21848 |
if triggers then |
| 21849 |
triggers[font]=sequence |
| 21850 |
else |
| 21851 |
triggers={ [font]=sequence } |
| 21852 |
end |
| 21853 |
end |
| 21854 |
local getthreshold |
| 21855 |
if context then |
| 21856 |
local threshold=1 |
| 21857 |
local parameters=fonts.hashes.parameters |
| 21858 |
directives.register("otf.threshold",function(v) threshold=tonumber(v) or 1 end) |
| 21859 |
getthreshold=function(font) |
| 21860 |
local p=parameters[font] |
| 21861 |
local f=p.factor |
| 21862 |
local s=p.spacing |
| 21863 |
local t=threshold*(s and s.width or p.space or 0)-2 |
| 21864 |
return t>0 and t or 0,f |
| 21865 |
end |
| 21866 |
else |
| 21867 |
injections.threshold=0 |
| 21868 |
getthreshold=function(font) |
| 21869 |
local p=fontdata[font].parameters |
| 21870 |
local f=p.factor |
| 21871 |
local s=p.spacing |
| 21872 |
local t=injections.threshold*(s and s.width or p.space or 0)-2 |
| 21873 |
return t>0 and t or 0,f |
| 21874 |
end |
| 21875 |
end |
| 21876 |
injections.getthreshold=getthreshold |
| 21877 |
function injections.isspace(n,threshold,id) |
| 21878 |
if (id or getid(n))==glue_code then |
| 21879 |
local w=getwidth(n) |
| 21880 |
if threshold and w>threshold then |
| 21881 |
return 32 |
| 21882 |
end |
| 21883 |
end |
| 21884 |
end |
| 21885 |
local getspaceboth=getboth |
| 21886 |
function injections.installgetspaceboth(gb) |
| 21887 |
getspaceboth=gb or getboth |
| 21888 |
end |
| 21889 |
local function injectspaces(head) |
| 21890 |
if not triggers then |
| 21891 |
return head |
| 21892 |
end |
| 21893 |
local lastfont=nil |
| 21894 |
local spacekerns=nil |
| 21895 |
local leftkerns=nil |
| 21896 |
local rightkerns=nil |
| 21897 |
local factor=0 |
| 21898 |
local threshold=0 |
| 21899 |
local leftkern=false |
| 21900 |
local rightkern=false |
| 21901 |
local function updatefont(font,trig) |
| 21902 |
leftkerns=trig.left |
| 21903 |
rightkerns=trig.right |
| 21904 |
lastfont=font |
| 21905 |
threshold, |
| 21906 |
factor=getthreshold(font) |
| 21907 |
end |
| 21908 |
for n in nextglue,head do |
| 21909 |
local prev,next=getspaceboth(n) |
| 21910 |
local prevchar=prev and ischar(prev) |
| 21911 |
local nextchar=next and ischar(next) |
| 21912 |
if nextchar then |
| 21913 |
local font=getfont(next) |
| 21914 |
local trig=triggers[font] |
| 21915 |
if trig then |
| 21916 |
if lastfont~=font then |
| 21917 |
updatefont(font,trig) |
| 21918 |
end |
| 21919 |
if rightkerns then |
| 21920 |
rightkern=rightkerns[nextchar] |
| 21921 |
end |
| 21922 |
end |
| 21923 |
end |
| 21924 |
if prevchar then |
| 21925 |
local font=getfont(prev) |
| 21926 |
local trig=triggers[font] |
| 21927 |
if trig then |
| 21928 |
if lastfont~=font then |
| 21929 |
updatefont(font,trig) |
| 21930 |
end |
| 21931 |
if leftkerns then |
| 21932 |
leftkern=leftkerns[prevchar] |
| 21933 |
end |
| 21934 |
end |
| 21935 |
end |
| 21936 |
if leftkern then |
| 21937 |
local old=getwidth(n) |
| 21938 |
if old>threshold then |
| 21939 |
if rightkern then |
| 21940 |
if useitalickerns then |
| 21941 |
local lnew=leftkern*factor |
| 21942 |
local rnew=rightkern*factor |
| 21943 |
if trace_spaces then |
| 21944 |
report_spaces("%C [%p + %p + %p] %C",prevchar,lnew,old,rnew,nextchar) |
| 21945 |
end |
| 21946 |
head=insertnodebefore(head,n,italickern(lnew)) |
| 21947 |
insertnodeafter(head,n,italickern(rnew)) |
| 21948 |
else |
| 21949 |
local new=old+(leftkern+rightkern)*factor |
| 21950 |
if trace_spaces then |
| 21951 |
report_spaces("%C [%p -> %p] %C",prevchar,old,new,nextchar) |
| 21952 |
end |
| 21953 |
setwidth(n,new) |
| 21954 |
end |
| 21955 |
rightkern=false |
| 21956 |
else |
| 21957 |
if useitalickerns then |
| 21958 |
local new=leftkern*factor |
| 21959 |
if trace_spaces then |
| 21960 |
report_spaces("%C [%p + %p]",prevchar,old,new) |
| 21961 |
end |
| 21962 |
insertnodeafter(head,n,italickern(new)) |
| 21963 |
else |
| 21964 |
local new=old+leftkern*factor |
| 21965 |
if trace_spaces then |
| 21966 |
report_spaces("%C [%p -> %p]",prevchar,old,new) |
| 21967 |
end |
| 21968 |
setwidth(n,new) |
| 21969 |
end |
| 21970 |
end |
| 21971 |
end |
| 21972 |
leftkern=false |
| 21973 |
elseif rightkern then |
| 21974 |
local old=getwidth(n) |
| 21975 |
if old>threshold then |
| 21976 |
if useitalickerns then |
| 21977 |
local new=rightkern*factor |
| 21978 |
if trace_spaces then |
| 21979 |
report_spaces("[%p + %p] %C",old,new,nextchar) |
| 21980 |
end |
| 21981 |
insertnodeafter(head,n,italickern(new)) |
| 21982 |
else |
| 21983 |
local new=old+rightkern*factor |
| 21984 |
if trace_spaces then |
| 21985 |
report_spaces("[%p -> %p] %C",old,new,nextchar) |
| 21986 |
end |
| 21987 |
setwidth(n,new) |
| 21988 |
end |
| 21989 |
else |
| 21990 |
end |
| 21991 |
rightkern=false |
| 21992 |
end |
| 21993 |
end |
| 21994 |
triggers=false |
| 21995 |
return head |
| 21996 |
end |
| 21997 |
function injections.handler(head,where) |
| 21998 |
if triggers then |
| 21999 |
head=injectspaces(head) |
| 22000 |
end |
| 22001 |
if nofregisteredmarks>0 or nofregisteredcursives>0 then |
| 22002 |
if trace_injections then |
| 22003 |
report_injections("injection variant %a","everything") |
| 22004 |
end |
| 22005 |
return inject_everything(head,where) |
| 22006 |
elseif nofregisteredpositions>0 then |
| 22007 |
if trace_injections then |
| 22008 |
report_injections("injection variant %a","positions") |
| 22009 |
end |
| 22010 |
return inject_positions_only(head,where) |
| 22011 |
elseif nofregisteredkerns>0 then |
| 22012 |
if trace_injections then |
| 22013 |
report_injections("injection variant %a","kerns") |
| 22014 |
end |
| 22015 |
return inject_kerns_only(head,where) |
| 22016 |
else |
| 22017 |
return head |
| 22018 |
end |
| 22019 |
end |
| 22020 |
|
| 22021 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-otj”] --- |
| 22022 |
|
| 22023 |
|
| 22024 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ota” 7407b709ae7b2cdf36f68d5c98d51d12] --- |
| 22025 |
|
| 22026 |
if not modules then modules={} end modules ['font-ota']={ |
| 22027 |
version=1.001, |
| 22028 |
comment="companion to font-ini.mkiv", |
| 22029 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 22030 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 22031 |
license="see context related readme files" |
| 22032 |
} |
| 22033 |
local type=type |
| 22034 |
local setmetatableindex=table.setmetatableindex |
| 22035 |
if not trackers then trackers={ register=function() end } end |
| 22036 |
local fonts,nodes,node=fonts,nodes,node |
| 22037 |
local allocate=utilities.storage.allocate |
| 22038 |
local otf=fonts.handlers.otf |
| 22039 |
local analyzers=fonts.analyzers |
| 22040 |
local initializers=allocate() |
| 22041 |
local methods=allocate() |
| 22042 |
analyzers.initializers=initializers |
| 22043 |
analyzers.methods=methods |
| 22044 |
local nuts=nodes.nuts |
| 22045 |
local tonut=nuts.tonut |
| 22046 |
local getnext=nuts.getnext |
| 22047 |
local getprev=nuts.getprev |
| 22048 |
local getprev=nuts.getprev |
| 22049 |
local getprop=nuts.getprop |
| 22050 |
local setprop=nuts.setprop |
| 22051 |
local getsubtype=nuts.getsubtype |
| 22052 |
local getchar=nuts.getchar |
| 22053 |
local ischar=nuts.ischar |
| 22054 |
local endofmath=nuts.endofmath |
| 22055 |
local nodecodes=nodes.nodecodes |
| 22056 |
local disc_code=nodecodes.disc |
| 22057 |
local math_code=nodecodes.math |
| 22058 |
local fontdata=fonts.hashes.identifiers |
| 22059 |
local categories=characters and characters.categories or {} |
| 22060 |
local chardata=characters and characters.data |
| 22061 |
local otffeatures=fonts.constructors.features.otf |
| 22062 |
local registerotffeature=otffeatures.register |
| 22063 |
local setstate=nuts.setstate |
| 22064 |
local getstate=nuts.getstate |
| 22065 |
if not setstate or not getstate then |
| 22066 |
setstate=function(n,v) |
| 22067 |
setprop(n,"state",v) |
| 22068 |
end |
| 22069 |
getstate=function(n,v) |
| 22070 |
local s=getprop(n,"state") |
| 22071 |
if v then |
| 22072 |
return s==v |
| 22073 |
else |
| 22074 |
return s |
| 22075 |
end |
| 22076 |
end |
| 22077 |
nuts.setstate=setstate |
| 22078 |
nuts.getstate=getstate |
| 22079 |
end |
| 22080 |
local s_init=1 local s_rphf=7 |
| 22081 |
local s_medi=2 local s_half=8 |
| 22082 |
local s_fina=3 local s_pref=9 |
| 22083 |
local s_isol=4 local s_blwf=10 |
| 22084 |
local s_mark=5 local s_pstf=11 |
| 22085 |
local s_rest=6 |
| 22086 |
local states=allocate { |
| 22087 |
init=s_init, |
| 22088 |
medi=s_medi, |
| 22089 |
med2=s_medi, |
| 22090 |
fina=s_fina, |
| 22091 |
fin2=s_fina, |
| 22092 |
fin3=s_fina, |
| 22093 |
isol=s_isol, |
| 22094 |
mark=s_mark, |
| 22095 |
rest=s_rest, |
| 22096 |
rphf=s_rphf, |
| 22097 |
half=s_half, |
| 22098 |
pref=s_pref, |
| 22099 |
blwf=s_blwf, |
| 22100 |
pstf=s_pstf, |
| 22101 |
} |
| 22102 |
local features=allocate { |
| 22103 |
init=s_init, |
| 22104 |
medi=s_medi, |
| 22105 |
med2=s_medi, |
| 22106 |
fina=s_fina, |
| 22107 |
fin2=s_fina, |
| 22108 |
fin3=s_fina, |
| 22109 |
isol=s_isol, |
| 22110 |
rphf=s_rphf, |
| 22111 |
half=s_half, |
| 22112 |
pref=s_pref, |
| 22113 |
blwf=s_blwf, |
| 22114 |
pstf=s_pstf, |
| 22115 |
} |
| 22116 |
analyzers.states=states |
| 22117 |
analyzers.features=features |
| 22118 |
analyzers.useunicodemarks=false |
| 22119 |
function analyzers.setstate(head,font) |
| 22120 |
local useunicodemarks=analyzers.useunicodemarks |
| 22121 |
local tfmdata=fontdata[font] |
| 22122 |
local descriptions=tfmdata.descriptions |
| 22123 |
local first,last,current,n,done=nil,nil,head,0,false |
| 22124 |
current=tonut(current) |
| 22125 |
while current do |
| 22126 |
local char,id=ischar(current,font) |
| 22127 |
if char and not getstate(current) then |
| 22128 |
done=true |
| 22129 |
local d=descriptions[char] |
| 22130 |
if d then |
| 22131 |
if d.class=="mark" then |
| 22132 |
done=true |
| 22133 |
setstate(current,s_mark) |
| 22134 |
elseif useunicodemarks and categories[char]=="mn" then |
| 22135 |
done=true |
| 22136 |
setstate(current,s_mark) |
| 22137 |
elseif n==0 then |
| 22138 |
first,last,n=current,current,1 |
| 22139 |
setstate(current,s_init) |
| 22140 |
else |
| 22141 |
last,n=current,n+1 |
| 22142 |
setstate(current,s_medi) |
| 22143 |
end |
| 22144 |
else |
| 22145 |
if first and first==last then |
| 22146 |
setstate(last,s_isol) |
| 22147 |
elseif last then |
| 22148 |
setstate(last,s_fina) |
| 22149 |
end |
| 22150 |
first,last,n=nil,nil,0 |
| 22151 |
end |
| 22152 |
elseif char==false then |
| 22153 |
if first and first==last then |
| 22154 |
setstate(last,s_isol) |
| 22155 |
elseif last then |
| 22156 |
setstate(last,s_fina) |
| 22157 |
end |
| 22158 |
first,last,n=nil,nil,0 |
| 22159 |
if id==math_code then |
| 22160 |
current=endofmath(current) |
| 22161 |
end |
| 22162 |
elseif id==disc_code then |
| 22163 |
setstate(current,s_medi) |
| 22164 |
last=current |
| 22165 |
else |
| 22166 |
if first and first==last then |
| 22167 |
setstate(last,s_isol) |
| 22168 |
elseif last then |
| 22169 |
setstate(last,s_fina) |
| 22170 |
end |
| 22171 |
first,last,n=nil,nil,0 |
| 22172 |
if id==math_code then |
| 22173 |
current=endofmath(current) |
| 22174 |
end |
| 22175 |
end |
| 22176 |
current=getnext(current) |
| 22177 |
end |
| 22178 |
if first and first==last then |
| 22179 |
setstate(last,s_isol) |
| 22180 |
elseif last then |
| 22181 |
setstate(last,s_fina) |
| 22182 |
end |
| 22183 |
return head,done |
| 22184 |
end |
| 22185 |
local function analyzeinitializer(tfmdata,value) |
| 22186 |
local script,language=otf.scriptandlanguage(tfmdata) |
| 22187 |
local action=initializers[script] |
| 22188 |
if not action then |
| 22189 |
elseif type(action)=="function" then |
| 22190 |
return action(tfmdata,value) |
| 22191 |
else |
| 22192 |
local action=action[language] |
| 22193 |
if action then |
| 22194 |
return action(tfmdata,value) |
| 22195 |
end |
| 22196 |
end |
| 22197 |
end |
| 22198 |
local function analyzeprocessor(head,font,attr) |
| 22199 |
local tfmdata=fontdata[font] |
| 22200 |
local script,language=otf.scriptandlanguage(tfmdata,attr) |
| 22201 |
local action=methods[script] |
| 22202 |
if not action then |
| 22203 |
elseif type(action)=="function" then |
| 22204 |
return action(head,font,attr) |
| 22205 |
else |
| 22206 |
action=action[language] |
| 22207 |
if action then |
| 22208 |
return action(head,font,attr) |
| 22209 |
end |
| 22210 |
end |
| 22211 |
return head,false |
| 22212 |
end |
| 22213 |
registerotffeature { |
| 22214 |
name="analyze", |
| 22215 |
description="analysis of character classes", |
| 22216 |
default=true, |
| 22217 |
initializers={ |
| 22218 |
node=analyzeinitializer, |
| 22219 |
}, |
| 22220 |
processors={ |
| 22221 |
position=1, |
| 22222 |
node=analyzeprocessor, |
| 22223 |
} |
| 22224 |
} |
| 22225 |
methods.latn=analyzers.setstate |
| 22226 |
local arab_warned={} |
| 22227 |
local function warning(current,what) |
| 22228 |
local char=getchar(current) |
| 22229 |
if not arab_warned[char] then |
| 22230 |
log.report("analyze","arab: character %C has no %a class",char,what) |
| 22231 |
arab_warned[char]=true |
| 22232 |
end |
| 22233 |
end |
| 22234 |
local mappers=allocate { |
| 22235 |
l=s_init, |
| 22236 |
d=s_medi, |
| 22237 |
c=s_medi, |
| 22238 |
r=s_fina, |
| 22239 |
u=s_isol, |
| 22240 |
} |
| 22241 |
local classifiers=characters.classifiers |
| 22242 |
if not classifiers then |
| 22243 |
local f_arabic,l_arabic=characters.blockrange("arabic") |
| 22244 |
local f_syriac,l_syriac=characters.blockrange("syriac") |
| 22245 |
local f_mandiac,l_mandiac=characters.blockrange("mandiac") |
| 22246 |
local f_nko,l_nko=characters.blockrange("nko") |
| 22247 |
local f_ext_a,l_ext_a=characters.blockrange("arabicextendeda") |
| 22248 |
classifiers=setmetatableindex(function(t,k) |
| 22249 |
if type(k)=="number" then |
| 22250 |
local c=chardata[k] |
| 22251 |
local v=false |
| 22252 |
if c then |
| 22253 |
local arabic=c.arabic |
| 22254 |
if arabic then |
| 22255 |
v=mappers[arabic] |
| 22256 |
if not v then |
| 22257 |
log.report("analyze","error in mapping arabic %C",k) |
| 22258 |
v=false |
| 22259 |
end |
| 22260 |
elseif (k>=f_arabic and k<=l_arabic) or |
| 22261 |
(k>=f_syriac and k<=l_syriac) or |
| 22262 |
(k>=f_mandiac and k<=l_mandiac) or |
| 22263 |
(k>=f_nko and k<=l_nko) or |
| 22264 |
(k>=f_ext_a and k<=l_ext_a) then |
| 22265 |
if categories[k]=="mn" then |
| 22266 |
v=s_mark |
| 22267 |
else |
| 22268 |
v=s_rest |
| 22269 |
end |
| 22270 |
end |
| 22271 |
end |
| 22272 |
t[k]=v |
| 22273 |
return v |
| 22274 |
end |
| 22275 |
end) |
| 22276 |
characters.classifiers=classifiers |
| 22277 |
end |
| 22278 |
function methods.arab(head,font,attr) |
| 22279 |
local first,last,c_first,c_last |
| 22280 |
local current=head |
| 22281 |
local done=false |
| 22282 |
current=tonut(current) |
| 22283 |
while current do |
| 22284 |
local char,id=ischar(current,font) |
| 22285 |
if char and not getstate(current) then |
| 22286 |
done=true |
| 22287 |
local classifier=classifiers[char] |
| 22288 |
if not classifier then |
| 22289 |
if last then |
| 22290 |
if c_last==s_medi or c_last==s_fina then |
| 22291 |
setstate(last,s_fina) |
| 22292 |
else |
| 22293 |
warning(last,"fina") |
| 22294 |
setstate(last,s_error) |
| 22295 |
end |
| 22296 |
first,last=nil,nil |
| 22297 |
elseif first then |
| 22298 |
if c_first==s_medi or c_first==s_fina then |
| 22299 |
setstate(first,s_isol) |
| 22300 |
else |
| 22301 |
warning(first,"isol") |
| 22302 |
setstate(first,s_error) |
| 22303 |
end |
| 22304 |
first=nil |
| 22305 |
end |
| 22306 |
elseif classifier==s_mark then |
| 22307 |
setstate(current,s_mark) |
| 22308 |
elseif classifier==s_isol then |
| 22309 |
if last then |
| 22310 |
if c_last==s_medi or c_last==s_fina then |
| 22311 |
setstate(last,s_fina) |
| 22312 |
else |
| 22313 |
warning(last,"fina") |
| 22314 |
setstate(last,s_error) |
| 22315 |
end |
| 22316 |
first,last=nil,nil |
| 22317 |
elseif first then |
| 22318 |
if c_first==s_medi or c_first==s_fina then |
| 22319 |
setstate(first,s_isol) |
| 22320 |
else |
| 22321 |
warning(first,"isol") |
| 22322 |
setstate(first,s_error) |
| 22323 |
end |
| 22324 |
first=nil |
| 22325 |
end |
| 22326 |
setstate(current,s_isol) |
| 22327 |
elseif classifier==s_medi then |
| 22328 |
if first then |
| 22329 |
last=current |
| 22330 |
c_last=classifier |
| 22331 |
setstate(current,s_medi) |
| 22332 |
else |
| 22333 |
setstate(current,s_init) |
| 22334 |
first=current |
| 22335 |
c_first=classifier |
| 22336 |
end |
| 22337 |
elseif classifier==s_fina then |
| 22338 |
if last then |
| 22339 |
if getstate(last)~=s_init then |
| 22340 |
setstate(last,s_medi) |
| 22341 |
end |
| 22342 |
setstate(current,s_fina) |
| 22343 |
first,last=nil,nil |
| 22344 |
elseif first then |
| 22345 |
setstate(current,s_fina) |
| 22346 |
first=nil |
| 22347 |
else |
| 22348 |
setstate(current,s_isol) |
| 22349 |
end |
| 22350 |
else |
| 22351 |
setstate(current,s_rest) |
| 22352 |
if last then |
| 22353 |
if c_last==s_medi or c_last==s_fina then |
| 22354 |
setstate(last,s_fina) |
| 22355 |
else |
| 22356 |
warning(last,"fina") |
| 22357 |
setstate(last,s_error) |
| 22358 |
end |
| 22359 |
first,last=nil,nil |
| 22360 |
elseif first then |
| 22361 |
if c_first==s_medi or c_first==s_fina then |
| 22362 |
setstate(first,s_isol) |
| 22363 |
else |
| 22364 |
warning(first,"isol") |
| 22365 |
setstate(first,s_error) |
| 22366 |
end |
| 22367 |
first=nil |
| 22368 |
end |
| 22369 |
end |
| 22370 |
else |
| 22371 |
if last then |
| 22372 |
if c_last==s_medi or c_last==s_fina then |
| 22373 |
setstate(last,s_fina) |
| 22374 |
else |
| 22375 |
warning(last,"fina") |
| 22376 |
setstate(last,s_error) |
| 22377 |
end |
| 22378 |
first,last=nil,nil |
| 22379 |
elseif first then |
| 22380 |
if c_first==s_medi or c_first==s_fina then |
| 22381 |
setstate(first,s_isol) |
| 22382 |
else |
| 22383 |
warning(first,"isol") |
| 22384 |
setstate(first,s_error) |
| 22385 |
end |
| 22386 |
first=nil |
| 22387 |
end |
| 22388 |
if id==math_code then |
| 22389 |
current=endofmath(current) |
| 22390 |
end |
| 22391 |
end |
| 22392 |
current=getnext(current) |
| 22393 |
end |
| 22394 |
if last then |
| 22395 |
if c_last==s_medi or c_last==s_fina then |
| 22396 |
setstate(last,s_fina) |
| 22397 |
else |
| 22398 |
warning(last,"fina") |
| 22399 |
setstate(last,s_error) |
| 22400 |
end |
| 22401 |
elseif first then |
| 22402 |
if c_first==s_medi or c_first==s_fina then |
| 22403 |
setstate(first,s_isol) |
| 22404 |
else |
| 22405 |
warning(first,"isol") |
| 22406 |
setstate(first,s_error) |
| 22407 |
end |
| 22408 |
end |
| 22409 |
return head,done |
| 22410 |
end |
| 22411 |
methods.syrc=methods.arab |
| 22412 |
methods.mand=methods.arab |
| 22413 |
methods.nko=methods.arab |
| 22414 |
do |
| 22415 |
local joining=setmetatableindex(function(t,k) |
| 22416 |
if type(k)=="number" then |
| 22417 |
local c=chardata[k] |
| 22418 |
local v=false |
| 22419 |
if c then |
| 22420 |
local mongolian=c.mongolian |
| 22421 |
v=mongolian |
| 22422 |
end |
| 22423 |
t[k]=v |
| 22424 |
return v |
| 22425 |
end |
| 22426 |
end) |
| 22427 |
function methods.mong(head,font,attr) |
| 22428 |
local first,last |
| 22429 |
local current=head |
| 22430 |
local done=false |
| 22431 |
local prevjoin=nil |
| 22432 |
local prestate=nil |
| 22433 |
current=tonut(current) |
| 22434 |
local function wrapup() |
| 22435 |
if last then |
| 22436 |
if last~=first then |
| 22437 |
local s=getstate(last) |
| 22438 |
if s==s_medi then |
| 22439 |
setstate(last,s_fina) |
| 22440 |
elseif s==s_init then |
| 22441 |
setstate(last,s_isol) |
| 22442 |
end |
| 22443 |
end |
| 22444 |
last=nil |
| 22445 |
first=nil |
| 22446 |
prevjoin=nil |
| 22447 |
prestate=nil |
| 22448 |
end |
| 22449 |
end |
| 22450 |
while current do |
| 22451 |
local char,id=ischar(current,font) |
| 22452 |
if char and not getstate(current) then |
| 22453 |
local currjoin=joining[char] |
| 22454 |
done=true |
| 22455 |
if not last then |
| 22456 |
setstate(current,s_isol) |
| 22457 |
prevjoin=currjoin |
| 22458 |
first=current |
| 22459 |
last=current |
| 22460 |
prevstate=s_isol |
| 22461 |
elseif currjoin=="t" then |
| 22462 |
last=current |
| 22463 |
elseif prevjoin=="d" or prevjoin=="jc" or prevjoin=="l" then |
| 22464 |
if currjoin=="d" or prevjoin=="jc" or prevjoin=="r" then |
| 22465 |
local s=getstate(last) |
| 22466 |
if s==s_isol then |
| 22467 |
setstate(last,s_init) |
| 22468 |
elseif s==s_fina then |
| 22469 |
setstate(last,s_medi) |
| 22470 |
end |
| 22471 |
setstate(current,s_fina) |
| 22472 |
prevstate=s_fina |
| 22473 |
elseif prevjoin=="nj" or prevjoin=="l" then |
| 22474 |
local s=getstate(last) |
| 22475 |
if s==s_medi then |
| 22476 |
setstate(last,s_fina) |
| 22477 |
elseif s==s_init then |
| 22478 |
setstate(last,s_isol) |
| 22479 |
end |
| 22480 |
setstate(current,s_isol) |
| 22481 |
prevstate=s_isol |
| 22482 |
end |
| 22483 |
prevjoin=currjoin |
| 22484 |
last=current |
| 22485 |
elseif prevjoin=="nj" or prevjoin=="r" then |
| 22486 |
if s==s_medi then |
| 22487 |
setstate(last,s_fina) |
| 22488 |
elseif s==s_init then |
| 22489 |
setstate(last,s_isol) |
| 22490 |
end |
| 22491 |
setstate(current,s_isol) |
| 22492 |
prevjoin=currjoin |
| 22493 |
prevstate=s_isol |
| 22494 |
last=current |
| 22495 |
elseif last then |
| 22496 |
wrapup() |
| 22497 |
end |
| 22498 |
else |
| 22499 |
if last then |
| 22500 |
wrapup() |
| 22501 |
end |
| 22502 |
if id==math_code then |
| 22503 |
current=endofmath(current) |
| 22504 |
end |
| 22505 |
end |
| 22506 |
current=getnext(current) |
| 22507 |
end |
| 22508 |
if last then |
| 22509 |
wrapup() |
| 22510 |
end |
| 22511 |
return head,done |
| 22512 |
end |
| 22513 |
end |
| 22514 |
directives.register("otf.analyze.useunicodemarks",function(v) |
| 22515 |
analyzers.useunicodemarks=v |
| 22516 |
end) |
| 22517 |
|
| 22518 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ota”] --- |
| 22519 |
|
| 22520 |
|
| 22521 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ots” 2ba92e909a45b68592f7271d8190f390] --- |
| 22522 |
|
| 22523 |
if not modules then modules={} end modules ['font-ots']={ |
| 22524 |
version=1.001, |
| 22525 |
optimize=true, |
| 22526 |
comment="companion to font-ini.mkiv", |
| 22527 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 22528 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 22529 |
license="see context related readme files", |
| 22530 |
} |
| 22531 |
local type,next,tonumber=type,next,tonumber |
| 22532 |
local random=math.random |
| 22533 |
local formatters=string.formatters |
| 22534 |
local insert=table.insert |
| 22535 |
local registertracker=trackers.register |
| 22536 |
local logs=logs |
| 22537 |
local trackers=trackers |
| 22538 |
local nodes=nodes |
| 22539 |
local attributes=attributes |
| 22540 |
local fonts=fonts |
| 22541 |
local otf=fonts.handlers.otf |
| 22542 |
local tracers=nodes.tracers |
| 22543 |
local trace_singles=false registertracker("otf.singles",function(v) trace_singles=v end) |
| 22544 |
local trace_multiples=false registertracker("otf.multiples",function(v) trace_multiples=v end) |
| 22545 |
local trace_alternatives=false registertracker("otf.alternatives",function(v) trace_alternatives=v end) |
| 22546 |
local trace_ligatures=false registertracker("otf.ligatures",function(v) trace_ligatures=v end) |
| 22547 |
local trace_contexts=false registertracker("otf.contexts",function(v) trace_contexts=v end) |
| 22548 |
local trace_marks=false registertracker("otf.marks",function(v) trace_marks=v end) |
| 22549 |
local trace_kerns=false registertracker("otf.kerns",function(v) trace_kerns=v end) |
| 22550 |
local trace_cursive=false registertracker("otf.cursive",function(v) trace_cursive=v end) |
| 22551 |
local trace_preparing=false registertracker("otf.preparing",function(v) trace_preparing=v end) |
| 22552 |
local trace_bugs=false registertracker("otf.bugs",function(v) trace_bugs=v end) |
| 22553 |
local trace_details=false registertracker("otf.details",function(v) trace_details=v end) |
| 22554 |
local trace_steps=false registertracker("otf.steps",function(v) trace_steps=v end) |
| 22555 |
local trace_skips=false registertracker("otf.skips",function(v) trace_skips=v end) |
| 22556 |
local trace_plugins=false registertracker("otf.plugins",function(v) trace_plugins=v end) |
| 22557 |
local trace_chains=false registertracker("otf.chains",function(v) trace_chains=v end) |
| 22558 |
local trace_kernruns=false registertracker("otf.kernruns",function(v) trace_kernruns=v end) |
| 22559 |
local trace_compruns=false registertracker("otf.compruns",function(v) trace_compruns=v end) |
| 22560 |
local trace_testruns=false registertracker("otf.testruns",function(v) trace_testruns=v end) |
| 22561 |
local forcediscretionaries=false |
| 22562 |
local forcepairadvance=false |
| 22563 |
local repeatablemultiples=context or false |
| 22564 |
directives.register("otf.forcediscretionaries",function(v) forcediscretionaries=v end) |
| 22565 |
directives.register("otf.forcepairadvance",function(v) forcepairadvance=v end) |
| 22566 |
local report_direct=logs.reporter("fonts","otf direct") |
| 22567 |
local report_subchain=logs.reporter("fonts","otf subchain") |
| 22568 |
local report_chain=logs.reporter("fonts","otf chain") |
| 22569 |
local report_process=logs.reporter("fonts","otf process") |
| 22570 |
local report_warning=logs.reporter("fonts","otf warning") |
| 22571 |
local report_run=logs.reporter("fonts","otf run") |
| 22572 |
registertracker("otf.substitutions","otf.singles","otf.multiples","otf.alternatives","otf.ligatures") |
| 22573 |
registertracker("otf.positions","otf.marks","otf.kerns","otf.cursive") |
| 22574 |
registertracker("otf.actions","otf.substitutions","otf.positions") |
| 22575 |
registertracker("otf.sample","otf.steps","otf.substitutions","otf.positions","otf.analyzing") |
| 22576 |
registertracker("otf.sample.silent","otf.steps=silent","otf.substitutions","otf.positions","otf.analyzing") |
| 22577 |
local nuts=nodes.nuts |
| 22578 |
local getnext=nuts.getnext |
| 22579 |
local setnext=nuts.setnext |
| 22580 |
local getprev=nuts.getprev |
| 22581 |
local setprev=nuts.setprev |
| 22582 |
local getboth=nuts.getboth |
| 22583 |
local setboth=nuts.setboth |
| 22584 |
local getid=nuts.getid |
| 22585 |
local getstate=nuts.getstate |
| 22586 |
local getsubtype=nuts.getsubtype |
| 22587 |
local getchar=nuts.getchar |
| 22588 |
local setchar=nuts.setchar |
| 22589 |
local getdisc=nuts.getdisc |
| 22590 |
local setdisc=nuts.setdisc |
| 22591 |
local getreplace=nuts.getreplace |
| 22592 |
local setlink=nuts.setlink |
| 22593 |
local getwidth=nuts.getwidth |
| 22594 |
local getattr=nuts.getattr |
| 22595 |
local getglyphdata=nuts.getglyphdata |
| 22596 |
local components=nuts.components |
| 22597 |
local copynocomponents=components.copynocomponents |
| 22598 |
local copyonlyglyphs=components.copyonlyglyphs |
| 22599 |
local countcomponents=components.count |
| 22600 |
local setcomponents=components.set |
| 22601 |
local getcomponents=components.get |
| 22602 |
local flushcomponents=components.flush |
| 22603 |
local ischar=nuts.ischar |
| 22604 |
local usesfont=nuts.usesfont |
| 22605 |
local insertnodeafter=nuts.insertafter |
| 22606 |
local copynode=nuts.copy |
| 22607 |
local copynodelist=nuts.copylist |
| 22608 |
local removenode=nuts.remove |
| 22609 |
local findnodetail=nuts.tail |
| 22610 |
local flushnodelist=nuts.flushlist |
| 22611 |
local flushnode=nuts.flushnode |
| 22612 |
local endofmath=nuts.endofmath |
| 22613 |
local startofpar=nuts.startofpar |
| 22614 |
local setmetatable=setmetatable |
| 22615 |
local setmetatableindex=table.setmetatableindex |
| 22616 |
local nextnode=nuts.traversers.node |
| 22617 |
local nodecodes=nodes.nodecodes |
| 22618 |
local glyphcodes=nodes.glyphcodes |
| 22619 |
local glyph_code=nodecodes.glyph |
| 22620 |
local glue_code=nodecodes.glue |
| 22621 |
local disc_code=nodecodes.disc |
| 22622 |
local math_code=nodecodes.math |
| 22623 |
local dir_code=nodecodes.dir |
| 22624 |
local par_code=nodecodes.par |
| 22625 |
local lefttoright_code=nodes.dirvalues.lefttoright |
| 22626 |
local righttoleft_code=nodes.dirvalues.righttoleft |
| 22627 |
local discretionarydisc_code=nodes.disccodes.discretionary |
| 22628 |
local a_noligature=attributes.private("noligature") |
| 22629 |
local injections=nodes.injections |
| 22630 |
local setmark=injections.setmark |
| 22631 |
local setcursive=injections.setcursive |
| 22632 |
local setkern=injections.setkern |
| 22633 |
local setmove=injections.setmove |
| 22634 |
local setposition=injections.setposition |
| 22635 |
local resetinjection=injections.reset |
| 22636 |
local copyinjection=injections.copy |
| 22637 |
local setligaindex=injections.setligaindex |
| 22638 |
local getligaindex=injections.getligaindex |
| 22639 |
local fontdata=fonts.hashes.identifiers |
| 22640 |
local fontfeatures=fonts.hashes.features |
| 22641 |
local otffeatures=fonts.constructors.features.otf |
| 22642 |
local registerotffeature=otffeatures.register |
| 22643 |
local onetimemessage=fonts.loggers.onetimemessage or function() end |
| 22644 |
local getrandom=utilities and utilities.randomizer and utilities.randomizer.get |
| 22645 |
otf.defaultnodealternate="none" |
| 22646 |
local tfmdata=false |
| 22647 |
local characters=false |
| 22648 |
local descriptions=false |
| 22649 |
local marks=false |
| 22650 |
local classes=false |
| 22651 |
local currentfont=false |
| 22652 |
local factor=0 |
| 22653 |
local threshold=0 |
| 22654 |
local checkmarks=false |
| 22655 |
local discs=false |
| 22656 |
local spaces=false |
| 22657 |
local sweepnode=nil |
| 22658 |
local sweephead={} |
| 22659 |
local notmatchpre={} |
| 22660 |
local notmatchpost={} |
| 22661 |
local notmatchreplace={} |
| 22662 |
local handlers={} |
| 22663 |
local isspace=injections.isspace |
| 22664 |
local getthreshold=injections.getthreshold |
| 22665 |
local checkstep=(tracers and tracers.steppers.check) or function() end |
| 22666 |
local registerstep=(tracers and tracers.steppers.register) or function() end |
| 22667 |
local registermessage=(tracers and tracers.steppers.message) or function() end |
| 22668 |
local function logprocess(...) |
| 22669 |
if trace_steps then |
| 22670 |
registermessage(...) |
| 22671 |
if trace_steps=="silent" then |
| 22672 |
return |
| 22673 |
end |
| 22674 |
end |
| 22675 |
report_direct(...) |
| 22676 |
end |
| 22677 |
local function logwarning(...) |
| 22678 |
report_direct(...) |
| 22679 |
end |
| 22680 |
local gref do |
| 22681 |
local f_unicode=formatters["U+%X"] |
| 22682 |
local f_uniname=formatters["U+%X (%s)"] |
| 22683 |
local f_unilist=formatters["% t"] |
| 22684 |
gref=function(n) |
| 22685 |
if type(n)=="number" then |
| 22686 |
local description=descriptions[n] |
| 22687 |
local name=description and description.name |
| 22688 |
if name then |
| 22689 |
return f_uniname(n,name) |
| 22690 |
else |
| 22691 |
return f_unicode(n) |
| 22692 |
end |
| 22693 |
elseif n then |
| 22694 |
local t={} |
| 22695 |
for i=1,#n do |
| 22696 |
local ni=n[i] |
| 22697 |
if tonumber(ni) then |
| 22698 |
local di=descriptions[ni] |
| 22699 |
local nn=di and di.name |
| 22700 |
if nn then |
| 22701 |
t[#t+1]=f_uniname(ni,nn) |
| 22702 |
else |
| 22703 |
t[#t+1]=f_unicode(ni) |
| 22704 |
end |
| 22705 |
end |
| 22706 |
end |
| 22707 |
return f_unilist(t) |
| 22708 |
else |
| 22709 |
return "<error in node mode tracing>" |
| 22710 |
end |
| 22711 |
end |
| 22712 |
end |
| 22713 |
local function cref(dataset,sequence,index) |
| 22714 |
if not dataset then |
| 22715 |
return "no valid dataset" |
| 22716 |
end |
| 22717 |
local merged=sequence.merged and "merged " or "" |
| 22718 |
if index and index>1 then |
| 22719 |
return formatters["feature %a, type %a, %schain lookup %a, index %a"]( |
| 22720 |
dataset[4],sequence.type,merged,sequence.name,index) |
| 22721 |
else |
| 22722 |
return formatters["feature %a, type %a, %schain lookup %a"]( |
| 22723 |
dataset[4],sequence.type,merged,sequence.name) |
| 22724 |
end |
| 22725 |
end |
| 22726 |
local function pref(dataset,sequence) |
| 22727 |
return formatters["feature %a, type %a, %slookup %a"]( |
| 22728 |
dataset[4],sequence.type,sequence.merged and "merged " or "",sequence.name) |
| 22729 |
end |
| 22730 |
local function mref(rlmode) |
| 22731 |
if not rlmode or rlmode>=0 then |
| 22732 |
return "l2r" |
| 22733 |
else |
| 22734 |
return "r2l" |
| 22735 |
end |
| 22736 |
end |
| 22737 |
local function flattendisk(head,disc) |
| 22738 |
local pre,post,replace,pretail,posttail,replacetail=getdisc(disc,true) |
| 22739 |
local prev,next=getboth(disc) |
| 22740 |
local ishead=head==disc |
| 22741 |
setdisc(disc) |
| 22742 |
flushnode(disc) |
| 22743 |
if pre then |
| 22744 |
flushnodelist(pre) |
| 22745 |
end |
| 22746 |
if post then |
| 22747 |
flushnodelist(post) |
| 22748 |
end |
| 22749 |
if ishead then |
| 22750 |
if replace then |
| 22751 |
if next then |
| 22752 |
setlink(replacetail,next) |
| 22753 |
end |
| 22754 |
return replace,replace |
| 22755 |
elseif next then |
| 22756 |
return next,next |
| 22757 |
else |
| 22758 |
end |
| 22759 |
else |
| 22760 |
if replace then |
| 22761 |
if next then |
| 22762 |
setlink(replacetail,next) |
| 22763 |
end |
| 22764 |
setlink(prev,replace) |
| 22765 |
return head,replace |
| 22766 |
else |
| 22767 |
setlink(prev,next) |
| 22768 |
return head,next |
| 22769 |
end |
| 22770 |
end |
| 22771 |
end |
| 22772 |
local function appenddisc(disc,list) |
| 22773 |
local pre,post,replace,pretail,posttail,replacetail=getdisc(disc,true) |
| 22774 |
local posthead=list |
| 22775 |
local replacehead=copynodelist(list) |
| 22776 |
if post then |
| 22777 |
setlink(posttail,posthead) |
| 22778 |
else |
| 22779 |
post=posthead |
| 22780 |
end |
| 22781 |
if replace then |
| 22782 |
setlink(replacetail,replacehead) |
| 22783 |
else |
| 22784 |
replace=replacehead |
| 22785 |
end |
| 22786 |
setdisc(disc,pre,post,replace) |
| 22787 |
end |
| 22788 |
local function markstoligature(head,start,stop,char) |
| 22789 |
if start==stop and getchar(start)==char then |
| 22790 |
return head,start |
| 22791 |
else |
| 22792 |
local prev=getprev(start) |
| 22793 |
local next=getnext(stop) |
| 22794 |
setprev(start) |
| 22795 |
setnext(stop) |
| 22796 |
local base=copynocomponents(start,copyinjection) |
| 22797 |
if head==start then |
| 22798 |
head=base |
| 22799 |
end |
| 22800 |
resetinjection(base) |
| 22801 |
setchar(base,char) |
| 22802 |
setcomponents(base,start) |
| 22803 |
setlink(prev,base,next) |
| 22804 |
flushcomponents(start) |
| 22805 |
return head,base |
| 22806 |
end |
| 22807 |
end |
| 22808 |
local no_left_ligature_code=1 |
| 22809 |
local no_right_ligature_code=2 |
| 22810 |
local no_left_kern_code=4 |
| 22811 |
local no_right_kern_code=8 |
| 22812 |
local hasglyphoption=function(n,c) |
| 22813 |
if c==no_left_ligature_code or c==no_right_ligature_code then |
| 22814 |
return getattr(n,a_noligature)==1 |
| 22815 |
else |
| 22816 |
return false |
| 22817 |
end |
| 22818 |
end |
| 22819 |
local function toligature(head,start,stop,char,dataset,sequence,skiphash,discfound,hasmarks) |
| 22820 |
if hasglyphoption(start,no_right_ligature_code) then |
| 22821 |
return head,start |
| 22822 |
end |
| 22823 |
if start==stop and getchar(start)==char then |
| 22824 |
resetinjection(start) |
| 22825 |
setchar(start,char) |
| 22826 |
return head,start |
| 22827 |
end |
| 22828 |
local prev=getprev(start) |
| 22829 |
local next=getnext(stop) |
| 22830 |
local comp=start |
| 22831 |
setprev(start) |
| 22832 |
setnext(stop) |
| 22833 |
local base=copynocomponents(start,copyinjection) |
| 22834 |
if start==head then |
| 22835 |
head=base |
| 22836 |
end |
| 22837 |
resetinjection(base) |
| 22838 |
setchar(base,char) |
| 22839 |
setcomponents(base,comp) |
| 22840 |
setlink(prev,base,next) |
| 22841 |
if not discfound then |
| 22842 |
local deletemarks=not skiphash or hasmarks |
| 22843 |
local components=start |
| 22844 |
local baseindex=0 |
| 22845 |
local componentindex=0 |
| 22846 |
local head=base |
| 22847 |
local current=base |
| 22848 |
while start do |
| 22849 |
local char=getchar(start) |
| 22850 |
if not marks[char] then |
| 22851 |
baseindex=baseindex+componentindex |
| 22852 |
componentindex=countcomponents(start,marks) |
| 22853 |
elseif not deletemarks then |
| 22854 |
setligaindex(start,baseindex+getligaindex(start,componentindex)) |
| 22855 |
if trace_marks then |
| 22856 |
logwarning("%s: keep ligature mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start)) |
| 22857 |
end |
| 22858 |
local n=copynode(start) |
| 22859 |
copyinjection(n,start) |
| 22860 |
head,current=insertnodeafter(head,current,n) |
| 22861 |
elseif trace_marks then |
| 22862 |
logwarning("%s: delete ligature mark %s",pref(dataset,sequence),gref(char)) |
| 22863 |
end |
| 22864 |
start=getnext(start) |
| 22865 |
end |
| 22866 |
local start=getnext(current) |
| 22867 |
while start do |
| 22868 |
local char=ischar(start) |
| 22869 |
if char then |
| 22870 |
if marks[char] then |
| 22871 |
setligaindex(start,baseindex+getligaindex(start,componentindex)) |
| 22872 |
if trace_marks then |
| 22873 |
logwarning("%s: set ligature mark %s, gets index %s",pref(dataset,sequence),gref(char),getligaindex(start)) |
| 22874 |
end |
| 22875 |
start=getnext(start) |
| 22876 |
else |
| 22877 |
break |
| 22878 |
end |
| 22879 |
else |
| 22880 |
break |
| 22881 |
end |
| 22882 |
end |
| 22883 |
flushcomponents(components) |
| 22884 |
else |
| 22885 |
local discprev,discnext=getboth(discfound) |
| 22886 |
if discprev and discnext then |
| 22887 |
local pre,post,replace,pretail,posttail,replacetail=getdisc(discfound,true) |
| 22888 |
if not replace then |
| 22889 |
local prev=getprev(base) |
| 22890 |
local copied=copyonlyglyphs(comp) |
| 22891 |
if pre then |
| 22892 |
setlink(discprev,pre) |
| 22893 |
else |
| 22894 |
setnext(discprev) |
| 22895 |
end |
| 22896 |
pre=comp |
| 22897 |
if post then |
| 22898 |
setlink(posttail,discnext) |
| 22899 |
setprev(post) |
| 22900 |
else |
| 22901 |
post=discnext |
| 22902 |
setprev(discnext) |
| 22903 |
end |
| 22904 |
setlink(prev,discfound,next) |
| 22905 |
setboth(base) |
| 22906 |
setcomponents(base,copied) |
| 22907 |
replace=base |
| 22908 |
if forcediscretionaries then |
| 22909 |
setdisc(discfound,pre,post,replace,discretionarydisc_code) |
| 22910 |
else |
| 22911 |
setdisc(discfound,pre,post,replace) |
| 22912 |
end |
| 22913 |
base=prev |
| 22914 |
end |
| 22915 |
end |
| 22916 |
end |
| 22917 |
return head,base |
| 22918 |
end |
| 22919 |
local function multiple_glyphs(head,start,multiple,skiphash,what,stop) |
| 22920 |
local nofmultiples=#multiple |
| 22921 |
if nofmultiples>0 then |
| 22922 |
local first=start |
| 22923 |
resetinjection(start) |
| 22924 |
setchar(start,multiple[1]) |
| 22925 |
if nofmultiples>1 then |
| 22926 |
for i=2,nofmultiples do |
| 22927 |
local n=copynode(start) |
| 22928 |
resetinjection(n) |
| 22929 |
setchar(n,multiple[i]) |
| 22930 |
insertnodeafter(head,start,n) |
| 22931 |
start=n |
| 22932 |
end |
| 22933 |
end |
| 22934 |
if what~=true and repeatablemultiples then |
| 22935 |
local kind=type(what) |
| 22936 |
local m,f,l |
| 22937 |
if kind=="string" then |
| 22938 |
local what,n=string.match(what,"^repeat(.-)[:=](%d+)$") |
| 22939 |
if what=="middle" then |
| 22940 |
m=tonumber(n) |
| 22941 |
elseif what=="first" then |
| 22942 |
f=tonumber(n) |
| 22943 |
elseif what=="last" then |
| 22944 |
l=tonumber(n) |
| 22945 |
end |
| 22946 |
elseif kind=="table" then |
| 22947 |
m=what.middle |
| 22948 |
f=what.first |
| 22949 |
l=what.last |
| 22950 |
end |
| 22951 |
if f or m or l then |
| 22952 |
if m and m>1 and nofmultiples==3 then |
| 22953 |
local middle=getnext(first) |
| 22954 |
for i=2,m do |
| 22955 |
local n=copynode(middle) |
| 22956 |
resetinjection(n) |
| 22957 |
insertnodeafter(head,first,n) |
| 22958 |
end |
| 22959 |
end |
| 22960 |
if f and f>1 then |
| 22961 |
for i=2,f do |
| 22962 |
local n=copynode(first) |
| 22963 |
resetinjection(n) |
| 22964 |
insertnodeafter(head,first,n) |
| 22965 |
end |
| 22966 |
end |
| 22967 |
if l and l>1 then |
| 22968 |
for i=2,l do |
| 22969 |
local n=copynode(start) |
| 22970 |
resetinjection(n) |
| 22971 |
insertnodeafter(head,start,n) |
| 22972 |
start=n |
| 22973 |
end |
| 22974 |
end |
| 22975 |
end |
| 22976 |
end |
| 22977 |
return head,start,true |
| 22978 |
else |
| 22979 |
if trace_multiples then |
| 22980 |
logprocess("no multiple for %s",gref(getchar(start))) |
| 22981 |
end |
| 22982 |
return head,start,false |
| 22983 |
end |
| 22984 |
end |
| 22985 |
local function get_alternative_glyph(start,alternatives,value) |
| 22986 |
local n=#alternatives |
| 22987 |
if n==1 then |
| 22988 |
return alternatives[1],trace_alternatives and "1 (only one present)" |
| 22989 |
elseif value=="random" then |
| 22990 |
local r=getrandom and getrandom("glyph",1,n) or random(1,n) |
| 22991 |
return alternatives[r],trace_alternatives and formatters["value %a, taking %a"](value,r) |
| 22992 |
elseif value=="first" then |
| 22993 |
return alternatives[1],trace_alternatives and formatters["value %a, taking %a"](value,1) |
| 22994 |
elseif value=="last" then |
| 22995 |
return alternatives[n],trace_alternatives and formatters["value %a, taking %a"](value,n) |
| 22996 |
end |
| 22997 |
value=value==true and 1 or tonumber(value) |
| 22998 |
if type(value)~="number" then |
| 22999 |
return alternatives[1],trace_alternatives and formatters["invalid value %s, taking %a"](value,1) |
| 23000 |
end |
| 23001 |
if value>n then |
| 23002 |
local defaultalt=otf.defaultnodealternate |
| 23003 |
if defaultalt=="first" then |
| 23004 |
return alternatives[n],trace_alternatives and formatters["invalid value %s, taking %a"](value,1) |
| 23005 |
elseif defaultalt=="last" then |
| 23006 |
return alternatives[1],trace_alternatives and formatters["invalid value %s, taking %a"](value,n) |
| 23007 |
else |
| 23008 |
return false,trace_alternatives and formatters["invalid value %a, %s"](value,"out of range") |
| 23009 |
end |
| 23010 |
elseif value==0 then |
| 23011 |
return getchar(start),trace_alternatives and formatters["invalid value %a, %s"](value,"no change") |
| 23012 |
elseif value<1 then |
| 23013 |
return alternatives[1],trace_alternatives and formatters["invalid value %a, taking %a"](value,1) |
| 23014 |
else |
| 23015 |
return alternatives[value],trace_alternatives and formatters["value %a, taking %a"](value,value) |
| 23016 |
end |
| 23017 |
end |
| 23018 |
function handlers.gsub_single(head,start,dataset,sequence,replacement) |
| 23019 |
if trace_singles then |
| 23020 |
logprocess("%s: replacing %s by single %s",pref(dataset,sequence),gref(getchar(start)),gref(replacement)) |
| 23021 |
end |
| 23022 |
resetinjection(start) |
| 23023 |
setchar(start,replacement) |
| 23024 |
return head,start,true |
| 23025 |
end |
| 23026 |
function handlers.gsub_alternate(head,start,dataset,sequence,alternative) |
| 23027 |
local kind=dataset[4] |
| 23028 |
local what=dataset[1] |
| 23029 |
local value=what==true and tfmdata.shared.features[kind] or what |
| 23030 |
local choice,comment=get_alternative_glyph(start,alternative,value) |
| 23031 |
if choice then |
| 23032 |
if trace_alternatives then |
| 23033 |
logprocess("%s: replacing %s by alternative %a to %s, %s",pref(dataset,sequence),gref(getchar(start)),gref(choice),comment) |
| 23034 |
end |
| 23035 |
resetinjection(start) |
| 23036 |
setchar(start,choice) |
| 23037 |
else |
| 23038 |
if trace_alternatives then |
| 23039 |
logwarning("%s: no variant %a for %s, %s",pref(dataset,sequence),value,gref(getchar(start)),comment) |
| 23040 |
end |
| 23041 |
end |
| 23042 |
return head,start,true |
| 23043 |
end |
| 23044 |
function handlers.gsub_multiple(head,start,dataset,sequence,multiple,rlmode,skiphash) |
| 23045 |
if trace_multiples then |
| 23046 |
logprocess("%s: replacing %s by multiple %s",pref(dataset,sequence),gref(getchar(start)),gref(multiple)) |
| 23047 |
end |
| 23048 |
return multiple_glyphs(head,start,multiple,skiphash,dataset[1]) |
| 23049 |
end |
| 23050 |
function handlers.gsub_ligature(head,start,dataset,sequence,ligature,rlmode,skiphash) |
| 23051 |
local current=getnext(start) |
| 23052 |
if not current then |
| 23053 |
return head,start,false,nil |
| 23054 |
end |
| 23055 |
local stop=nil |
| 23056 |
local startchar=getchar(start) |
| 23057 |
if skiphash and skiphash[startchar] then |
| 23058 |
while current do |
| 23059 |
local char=ischar(current,currentfont) |
| 23060 |
if char then |
| 23061 |
local lg=not tonumber(ligature) and ligature[char] |
| 23062 |
if lg then |
| 23063 |
stop=current |
| 23064 |
ligature=lg |
| 23065 |
current=getnext(current) |
| 23066 |
else |
| 23067 |
break |
| 23068 |
end |
| 23069 |
else |
| 23070 |
break |
| 23071 |
end |
| 23072 |
end |
| 23073 |
if stop then |
| 23074 |
local ligature=tonumber(ligature) or ligature.ligature |
| 23075 |
if ligature then |
| 23076 |
if trace_ligatures then |
| 23077 |
local stopchar=getchar(stop) |
| 23078 |
head,start=markstoligature(head,start,stop,ligature) |
| 23079 |
logprocess("%s: replacing %s upto %s by ligature %s case 1",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(getchar(start))) |
| 23080 |
else |
| 23081 |
head,start=markstoligature(head,start,stop,ligature) |
| 23082 |
end |
| 23083 |
return head,start,true,false |
| 23084 |
else |
| 23085 |
end |
| 23086 |
end |
| 23087 |
else |
| 23088 |
local discfound=false |
| 23089 |
local hasmarks=marks[startchar] |
| 23090 |
while current do |
| 23091 |
local char,id=ischar(current,currentfont) |
| 23092 |
if char then |
| 23093 |
if skiphash and skiphash[char] then |
| 23094 |
current=getnext(current) |
| 23095 |
else |
| 23096 |
local lg=not tonumber(ligature) and ligature[char] |
| 23097 |
if lg then |
| 23098 |
if marks[char] then |
| 23099 |
hasmarks=true |
| 23100 |
end |
| 23101 |
stop=current |
| 23102 |
ligature=lg |
| 23103 |
current=getnext(current) |
| 23104 |
else |
| 23105 |
break |
| 23106 |
end |
| 23107 |
end |
| 23108 |
elseif char==false then |
| 23109 |
break |
| 23110 |
elseif id==disc_code then |
| 23111 |
discfound=current |
| 23112 |
break |
| 23113 |
else |
| 23114 |
break |
| 23115 |
end |
| 23116 |
end |
| 23117 |
if discfound then |
| 23118 |
local pre,post,replace=getdisc(discfound) |
| 23119 |
local match |
| 23120 |
if replace then |
| 23121 |
local char=ischar(replace,currentfont) |
| 23122 |
if char and (not tonumber(ligature) and ligature[char]) then |
| 23123 |
match=true |
| 23124 |
end |
| 23125 |
end |
| 23126 |
if not match and pre then |
| 23127 |
local char=ischar(pre,currentfont) |
| 23128 |
if char and (not tonumber(ligature) and ligature[char]) then |
| 23129 |
match=true |
| 23130 |
end |
| 23131 |
end |
| 23132 |
if not match and not pre or not replace then |
| 23133 |
local n=getnext(discfound) |
| 23134 |
local char=ischar(n,currentfont) |
| 23135 |
if char and (not tonumber(ligature) and ligature[char]) then |
| 23136 |
match=true |
| 23137 |
end |
| 23138 |
end |
| 23139 |
if match then |
| 23140 |
local ishead=head==start |
| 23141 |
local prev=getprev(start) |
| 23142 |
if stop then |
| 23143 |
setnext(stop) |
| 23144 |
local copy=copynodelist(start) |
| 23145 |
local tail=stop |
| 23146 |
local liat=findnodetail(copy) |
| 23147 |
if pre then |
| 23148 |
setlink(liat,pre) |
| 23149 |
end |
| 23150 |
if replace then |
| 23151 |
setlink(tail,replace) |
| 23152 |
end |
| 23153 |
pre=copy |
| 23154 |
replace=start |
| 23155 |
else |
| 23156 |
setnext(start) |
| 23157 |
local copy=copynode(start) |
| 23158 |
if pre then |
| 23159 |
setlink(copy,pre) |
| 23160 |
end |
| 23161 |
if replace then |
| 23162 |
setlink(start,replace) |
| 23163 |
end |
| 23164 |
pre=copy |
| 23165 |
replace=start |
| 23166 |
end |
| 23167 |
setdisc(discfound,pre,post,replace) |
| 23168 |
if prev then |
| 23169 |
setlink(prev,discfound) |
| 23170 |
else |
| 23171 |
setprev(discfound) |
| 23172 |
head=discfound |
| 23173 |
end |
| 23174 |
start=discfound |
| 23175 |
return head,start,true,true |
| 23176 |
end |
| 23177 |
end |
| 23178 |
local ligature=tonumber(ligature) or ligature.ligature |
| 23179 |
if ligature then |
| 23180 |
if stop then |
| 23181 |
if trace_ligatures then |
| 23182 |
local stopchar=getchar(stop) |
| 23183 |
head,start=toligature(head,start,stop,ligature,dataset,sequence,skiphash,false,hasmarks) |
| 23184 |
logprocess("%s: replacing %s upto %s by ligature %s case 2",pref(dataset,sequence),gref(startchar),gref(stopchar),gref(ligature)) |
| 23185 |
else |
| 23186 |
head,start=toligature(head,start,stop,ligature,dataset,sequence,skiphash,false,hasmarks) |
| 23187 |
end |
| 23188 |
else |
| 23189 |
resetinjection(start) |
| 23190 |
setchar(start,ligature) |
| 23191 |
if trace_ligatures then |
| 23192 |
logprocess("%s: replacing %s by (no real) ligature %s case 3",pref(dataset,sequence),gref(startchar),gref(ligature)) |
| 23193 |
end |
| 23194 |
end |
| 23195 |
return head,start,true,false |
| 23196 |
else |
| 23197 |
end |
| 23198 |
end |
| 23199 |
return head,start,false,false |
| 23200 |
end |
| 23201 |
function handlers.gpos_single(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) |
| 23202 |
if hasglyphoption(start,no_right_kern_code) then |
| 23203 |
return head,start,false |
| 23204 |
else |
| 23205 |
local startchar=getchar(start) |
| 23206 |
local format=step.format |
| 23207 |
if format=="single" or type(kerns)=="table" then |
| 23208 |
local dx,dy,w,h=setposition(0,start,factor,rlmode,kerns,injection) |
| 23209 |
if trace_kerns then |
| 23210 |
logprocess("%s: shifting single %s by %s xy (%p,%p) and wh (%p,%p)",pref(dataset,sequence),gref(startchar),format,dx,dy,w,h) |
| 23211 |
end |
| 23212 |
else |
| 23213 |
local k=(format=="move" and setmove or setkern)(start,factor,rlmode,kerns,injection) |
| 23214 |
if trace_kerns then |
| 23215 |
logprocess("%s: shifting single %s by %s %p",pref(dataset,sequence),gref(startchar),format,k) |
| 23216 |
end |
| 23217 |
end |
| 23218 |
return head,start,true |
| 23219 |
end |
| 23220 |
end |
| 23221 |
function handlers.gpos_pair(head,start,dataset,sequence,kerns,rlmode,skiphash,step,injection) |
| 23222 |
if hasglyphoption(start,no_right_kern_code) then |
| 23223 |
return head,start,false |
| 23224 |
else |
| 23225 |
local snext=getnext(start) |
| 23226 |
if not snext then |
| 23227 |
return head,start,false |
| 23228 |
else |
| 23229 |
local prev=start |
| 23230 |
while snext do |
| 23231 |
local nextchar=ischar(snext,currentfont) |
| 23232 |
if nextchar then |
| 23233 |
if skiphash and skiphash[nextchar] then |
| 23234 |
prev=snext |
| 23235 |
snext=getnext(snext) |
| 23236 |
else |
| 23237 |
local krn=kerns[nextchar] |
| 23238 |
if not krn then |
| 23239 |
break |
| 23240 |
end |
| 23241 |
local format=step.format |
| 23242 |
if format=="pair" then |
| 23243 |
local a=krn[1] |
| 23244 |
local b=krn[2] |
| 23245 |
if a==true then |
| 23246 |
elseif a then |
| 23247 |
local x,y,w,h=setposition(1,start,factor,rlmode,a,injection) |
| 23248 |
if trace_kerns then |
| 23249 |
local startchar=getchar(start) |
| 23250 |
logprocess("%s: shifting first of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections") |
| 23251 |
end |
| 23252 |
end |
| 23253 |
if b==true then |
| 23254 |
start=snext |
| 23255 |
elseif b then |
| 23256 |
local x,y,w,h=setposition(2,snext,factor,rlmode,b,injection) |
| 23257 |
if trace_kerns then |
| 23258 |
local startchar=getchar(start) |
| 23259 |
logprocess("%s: shifting second of pair %s and %s by xy (%p,%p) and wh (%p,%p) as %s",pref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h,injection or "injections") |
| 23260 |
end |
| 23261 |
start=snext |
| 23262 |
elseif forcepairadvance then |
| 23263 |
start=snext |
| 23264 |
end |
| 23265 |
return head,start,true |
| 23266 |
elseif krn~=0 then |
| 23267 |
local k=(format=="move" and setmove or setkern)(snext,factor,rlmode,krn,injection) |
| 23268 |
if trace_kerns then |
| 23269 |
logprocess("%s: inserting %s %p between %s and %s as %s",pref(dataset,sequence),format,k,gref(getchar(prev)),gref(nextchar),injection or "injections") |
| 23270 |
end |
| 23271 |
return head,start,true |
| 23272 |
else |
| 23273 |
break |
| 23274 |
end |
| 23275 |
end |
| 23276 |
else |
| 23277 |
break |
| 23278 |
end |
| 23279 |
end |
| 23280 |
return head,start,false |
| 23281 |
end |
| 23282 |
end |
| 23283 |
end |
| 23284 |
function handlers.gpos_mark2base(head,start,dataset,sequence,markanchors,rlmode,skiphash) |
| 23285 |
local markchar=getchar(start) |
| 23286 |
if marks[markchar] then |
| 23287 |
local base=getprev(start) |
| 23288 |
if base then |
| 23289 |
local basechar=ischar(base,currentfont) |
| 23290 |
if basechar then |
| 23291 |
if marks[basechar] then |
| 23292 |
while base do |
| 23293 |
base=getprev(base) |
| 23294 |
if base then |
| 23295 |
basechar=ischar(base,currentfont) |
| 23296 |
if basechar then |
| 23297 |
if not marks[basechar] then |
| 23298 |
break |
| 23299 |
end |
| 23300 |
else |
| 23301 |
if trace_bugs then |
| 23302 |
logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),1) |
| 23303 |
end |
| 23304 |
return head,start,false |
| 23305 |
end |
| 23306 |
else |
| 23307 |
if trace_bugs then |
| 23308 |
logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),2) |
| 23309 |
end |
| 23310 |
return head,start,false |
| 23311 |
end |
| 23312 |
end |
| 23313 |
end |
| 23314 |
local ba=markanchors[1][basechar] |
| 23315 |
if ba then |
| 23316 |
local ma=markanchors[2] |
| 23317 |
local dx,dy,bound=setmark(start,base,factor,rlmode,ba,ma,characters[basechar],false,checkmarks) |
| 23318 |
if trace_marks then |
| 23319 |
logprocess("%s, bound %s, anchoring mark %s to basechar %s => (%p,%p)", |
| 23320 |
pref(dataset,sequence),bound,gref(markchar),gref(basechar),dx,dy) |
| 23321 |
end |
| 23322 |
return head,start,true |
| 23323 |
elseif trace_bugs then |
| 23324 |
logwarning("%s: mark %s is not anchored to %s",pref(dataset,sequence),gref(markchar),gref(basechar)) |
| 23325 |
end |
| 23326 |
elseif trace_bugs then |
| 23327 |
logwarning("%s: nothing preceding, case %i",pref(dataset,sequence),1) |
| 23328 |
end |
| 23329 |
elseif trace_bugs then |
| 23330 |
logwarning("%s: nothing preceding, case %i",pref(dataset,sequence),2) |
| 23331 |
end |
| 23332 |
elseif trace_bugs then |
| 23333 |
logwarning("%s: mark %s is no mark",pref(dataset,sequence),gref(markchar)) |
| 23334 |
end |
| 23335 |
return head,start,false |
| 23336 |
end |
| 23337 |
function handlers.gpos_mark2ligature(head,start,dataset,sequence,markanchors,rlmode,skiphash) |
| 23338 |
local markchar=getchar(start) |
| 23339 |
if marks[markchar] then |
| 23340 |
local base=getprev(start) |
| 23341 |
if base then |
| 23342 |
local basechar=ischar(base,currentfont) |
| 23343 |
if basechar then |
| 23344 |
if marks[basechar] then |
| 23345 |
while base do |
| 23346 |
base=getprev(base) |
| 23347 |
if base then |
| 23348 |
basechar=ischar(base,currentfont) |
| 23349 |
if basechar then |
| 23350 |
if not marks[basechar] then |
| 23351 |
break |
| 23352 |
end |
| 23353 |
else |
| 23354 |
if trace_bugs then |
| 23355 |
logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),1) |
| 23356 |
end |
| 23357 |
return head,start,false |
| 23358 |
end |
| 23359 |
else |
| 23360 |
if trace_bugs then |
| 23361 |
logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),2) |
| 23362 |
end |
| 23363 |
return head,start,false |
| 23364 |
end |
| 23365 |
end |
| 23366 |
end |
| 23367 |
local ba=markanchors[1][basechar] |
| 23368 |
if ba then |
| 23369 |
local ma=markanchors[2] |
| 23370 |
if ma then |
| 23371 |
local index=getligaindex(start) |
| 23372 |
ba=ba[index] |
| 23373 |
if ba then |
| 23374 |
local dx,dy,bound=setmark(start,base,factor,rlmode,ba,ma,characters[basechar],false,checkmarks) |
| 23375 |
if trace_marks then |
| 23376 |
logprocess("%s, index %s, bound %s, anchoring mark %s to baselig %s at index %s => (%p,%p)", |
| 23377 |
pref(dataset,sequence),index,bound,gref(markchar),gref(basechar),index,dx,dy) |
| 23378 |
end |
| 23379 |
return head,start,true |
| 23380 |
else |
| 23381 |
if trace_bugs then |
| 23382 |
logwarning("%s: no matching anchors for mark %s and baselig %s with index %a",pref(dataset,sequence),gref(markchar),gref(basechar),index) |
| 23383 |
end |
| 23384 |
end |
| 23385 |
end |
| 23386 |
elseif trace_bugs then |
| 23387 |
onetimemessage(currentfont,basechar,"no base anchors") |
| 23388 |
end |
| 23389 |
elseif trace_bugs then |
| 23390 |
logwarning("%s: prev node is no char, case %i",pref(dataset,sequence),1) |
| 23391 |
end |
| 23392 |
elseif trace_bugs then |
| 23393 |
logwarning("%s: prev node is no char, case %i",pref(dataset,sequence),2) |
| 23394 |
end |
| 23395 |
elseif trace_bugs then |
| 23396 |
logwarning("%s: mark %s is no mark",pref(dataset,sequence),gref(markchar)) |
| 23397 |
end |
| 23398 |
return head,start,false |
| 23399 |
end |
| 23400 |
function handlers.gpos_mark2mark(head,start,dataset,sequence,markanchors,rlmode,skiphash) |
| 23401 |
local markchar=getchar(start) |
| 23402 |
if marks[markchar] then |
| 23403 |
local base=getprev(start) |
| 23404 |
local slc=getligaindex(start) |
| 23405 |
if slc then |
| 23406 |
while base do |
| 23407 |
local blc=getligaindex(base) |
| 23408 |
if blc and blc~=slc then |
| 23409 |
base=getprev(base) |
| 23410 |
else |
| 23411 |
break |
| 23412 |
end |
| 23413 |
end |
| 23414 |
end |
| 23415 |
if base then |
| 23416 |
local basechar=ischar(base,currentfont) |
| 23417 |
if basechar then |
| 23418 |
local ba=markanchors[1][basechar] |
| 23419 |
if ba then |
| 23420 |
local ma=markanchors[2] |
| 23421 |
local dx,dy,bound=setmark(start,base,factor,rlmode,ba,ma,characters[basechar],true,checkmarks) |
| 23422 |
if trace_marks then |
| 23423 |
logprocess("%s, bound %s, anchoring mark %s to basemark %s => (%p,%p)", |
| 23424 |
pref(dataset,sequence),bound,gref(markchar),gref(basechar),dx,dy) |
| 23425 |
end |
| 23426 |
return head,start,true |
| 23427 |
end |
| 23428 |
end |
| 23429 |
end |
| 23430 |
elseif trace_bugs then |
| 23431 |
logwarning("%s: mark %s is no mark",pref(dataset,sequence),gref(markchar)) |
| 23432 |
end |
| 23433 |
return head,start,false |
| 23434 |
end |
| 23435 |
function handlers.gpos_cursive(head,start,dataset,sequence,exitanchors,rlmode,skiphash,step) |
| 23436 |
local startchar=getchar(start) |
| 23437 |
if marks[startchar] then |
| 23438 |
if trace_cursive then |
| 23439 |
logprocess("%s: ignoring cursive for mark %s",pref(dataset,sequence),gref(startchar)) |
| 23440 |
end |
| 23441 |
else |
| 23442 |
local nxt=getnext(start) |
| 23443 |
while nxt do |
| 23444 |
local nextchar=ischar(nxt,currentfont) |
| 23445 |
if not nextchar then |
| 23446 |
break |
| 23447 |
elseif marks[nextchar] then |
| 23448 |
nxt=getnext(nxt) |
| 23449 |
else |
| 23450 |
local exit=exitanchors[3] |
| 23451 |
if exit then |
| 23452 |
local entry=exitanchors[1][nextchar] |
| 23453 |
if entry then |
| 23454 |
entry=entry[2] |
| 23455 |
if entry then |
| 23456 |
local r2lflag=sequence.flags[4] |
| 23457 |
local dx,dy,bound=setcursive(start,nxt,factor,rlmode,exit,entry,characters[startchar],characters[nextchar],r2lflag) |
| 23458 |
if trace_cursive then |
| 23459 |
logprocess("%s: moving %s to %s cursive (%p,%p) using bound %s in %s mode",pref(dataset,sequence),gref(startchar),gref(nextchar),dx,dy,bound,mref(rlmode)) |
| 23460 |
end |
| 23461 |
return head,start,true |
| 23462 |
end |
| 23463 |
end |
| 23464 |
end |
| 23465 |
break |
| 23466 |
end |
| 23467 |
end |
| 23468 |
end |
| 23469 |
return head,start,false |
| 23470 |
end |
| 23471 |
local chainprocs={} |
| 23472 |
local function logprocess(...) |
| 23473 |
if trace_steps then |
| 23474 |
registermessage(...) |
| 23475 |
if trace_steps=="silent" then |
| 23476 |
return |
| 23477 |
end |
| 23478 |
end |
| 23479 |
report_subchain(...) |
| 23480 |
end |
| 23481 |
local logwarning=report_subchain |
| 23482 |
local function logprocess(...) |
| 23483 |
if trace_steps then |
| 23484 |
registermessage(...) |
| 23485 |
if trace_steps=="silent" then |
| 23486 |
return |
| 23487 |
end |
| 23488 |
end |
| 23489 |
report_chain(...) |
| 23490 |
end |
| 23491 |
local logwarning=report_chain |
| 23492 |
local function reversesub(head,start,stop,dataset,sequence,replacements,rlmode,skiphash) |
| 23493 |
local char=getchar(start) |
| 23494 |
local replacement=replacements[char] |
| 23495 |
if replacement then |
| 23496 |
if trace_singles then |
| 23497 |
logprocess("%s: single reverse replacement of %s by %s",cref(dataset,sequence),gref(char),gref(replacement)) |
| 23498 |
end |
| 23499 |
resetinjection(start) |
| 23500 |
setchar(start,replacement) |
| 23501 |
return head,start,true |
| 23502 |
else |
| 23503 |
return head,start,false |
| 23504 |
end |
| 23505 |
end |
| 23506 |
chainprocs.reversesub=reversesub |
| 23507 |
local function reportzerosteps(dataset,sequence) |
| 23508 |
logwarning("%s: no steps",cref(dataset,sequence)) |
| 23509 |
end |
| 23510 |
local function reportmoresteps(dataset,sequence) |
| 23511 |
logwarning("%s: more than 1 step",cref(dataset,sequence)) |
| 23512 |
end |
| 23513 |
local function getmapping(dataset,sequence,currentlookup) |
| 23514 |
local steps=currentlookup.steps |
| 23515 |
local nofsteps=currentlookup.nofsteps |
| 23516 |
if nofsteps==0 then |
| 23517 |
reportzerosteps(dataset,sequence) |
| 23518 |
currentlookup.mapping=false |
| 23519 |
return false |
| 23520 |
else |
| 23521 |
if nofsteps>1 then |
| 23522 |
reportmoresteps(dataset,sequence) |
| 23523 |
end |
| 23524 |
local mapping=steps[1].coverage |
| 23525 |
currentlookup.mapping=mapping |
| 23526 |
currentlookup.format=steps[1].format |
| 23527 |
return mapping |
| 23528 |
end |
| 23529 |
end |
| 23530 |
function chainprocs.gsub_remove(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23531 |
if trace_chains then |
| 23532 |
logprocess("%s: removing character %s",cref(dataset,sequence,chainindex),gref(getchar(start))) |
| 23533 |
end |
| 23534 |
head,start=removenode(head,start,true) |
| 23535 |
return head,getprev(start),true |
| 23536 |
end |
| 23537 |
function chainprocs.gsub_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23538 |
local mapping=currentlookup.mapping |
| 23539 |
if mapping==nil then |
| 23540 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23541 |
end |
| 23542 |
if mapping then |
| 23543 |
local current=start |
| 23544 |
while current do |
| 23545 |
local currentchar=ischar(current) |
| 23546 |
if currentchar then |
| 23547 |
local replacement=mapping[currentchar] |
| 23548 |
if not replacement or replacement=="" then |
| 23549 |
if trace_bugs then |
| 23550 |
logwarning("%s: no single for %s",cref(dataset,sequence,chainindex),gref(currentchar)) |
| 23551 |
end |
| 23552 |
else |
| 23553 |
if trace_singles then |
| 23554 |
logprocess("%s: replacing single %s by %s",cref(dataset,sequence,chainindex),gref(currentchar),gref(replacement)) |
| 23555 |
end |
| 23556 |
resetinjection(current) |
| 23557 |
setchar(current,replacement) |
| 23558 |
end |
| 23559 |
return head,start,true |
| 23560 |
elseif currentchar==false then |
| 23561 |
break |
| 23562 |
elseif current==stop then |
| 23563 |
break |
| 23564 |
else |
| 23565 |
current=getnext(current) |
| 23566 |
end |
| 23567 |
end |
| 23568 |
end |
| 23569 |
return head,start,false |
| 23570 |
end |
| 23571 |
function chainprocs.gsub_alternate(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23572 |
local mapping=currentlookup.mapping |
| 23573 |
if mapping==nil then |
| 23574 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23575 |
end |
| 23576 |
if mapping then |
| 23577 |
local kind=dataset[4] |
| 23578 |
local what=dataset[1] |
| 23579 |
local value=what==true and tfmdata.shared.features[kind] or what |
| 23580 |
local current=start |
| 23581 |
while current do |
| 23582 |
local currentchar=ischar(current) |
| 23583 |
if currentchar then |
| 23584 |
local alternatives=mapping[currentchar] |
| 23585 |
if alternatives then |
| 23586 |
local choice,comment=get_alternative_glyph(current,alternatives,value) |
| 23587 |
if choice then |
| 23588 |
if trace_alternatives then |
| 23589 |
logprocess("%s: replacing %s by alternative %a to %s, %s",cref(dataset,sequence),gref(currentchar),choice,gref(choice),comment) |
| 23590 |
end |
| 23591 |
resetinjection(start) |
| 23592 |
setchar(start,choice) |
| 23593 |
else |
| 23594 |
if trace_alternatives then |
| 23595 |
logwarning("%s: no variant %a for %s, %s",cref(dataset,sequence),value,gref(currentchar),comment) |
| 23596 |
end |
| 23597 |
end |
| 23598 |
end |
| 23599 |
return head,start,true |
| 23600 |
elseif currentchar==false then |
| 23601 |
break |
| 23602 |
elseif current==stop then |
| 23603 |
break |
| 23604 |
else |
| 23605 |
current=getnext(current) |
| 23606 |
end |
| 23607 |
end |
| 23608 |
end |
| 23609 |
return head,start,false |
| 23610 |
end |
| 23611 |
function chainprocs.gsub_multiple(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23612 |
local mapping=currentlookup.mapping |
| 23613 |
if mapping==nil then |
| 23614 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23615 |
end |
| 23616 |
if mapping then |
| 23617 |
local startchar=getchar(start) |
| 23618 |
local replacement=mapping[startchar] |
| 23619 |
if not replacement or replacement=="" then |
| 23620 |
if trace_bugs then |
| 23621 |
logwarning("%s: no multiple for %s",cref(dataset,sequence),gref(startchar)) |
| 23622 |
end |
| 23623 |
else |
| 23624 |
if trace_multiples then |
| 23625 |
logprocess("%s: replacing %s by multiple characters %s",cref(dataset,sequence),gref(startchar),gref(replacement)) |
| 23626 |
end |
| 23627 |
return multiple_glyphs(head,start,replacement,skiphash,dataset[1],stop) |
| 23628 |
end |
| 23629 |
end |
| 23630 |
return head,start,false |
| 23631 |
end |
| 23632 |
function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23633 |
local mapping=currentlookup.mapping |
| 23634 |
if mapping==nil then |
| 23635 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23636 |
end |
| 23637 |
if mapping then |
| 23638 |
local startchar=getchar(start) |
| 23639 |
local ligatures=mapping[startchar] |
| 23640 |
if not ligatures then |
| 23641 |
if trace_bugs then |
| 23642 |
logwarning("%s: no ligatures starting with %s",cref(dataset,sequence,chainindex),gref(startchar)) |
| 23643 |
end |
| 23644 |
else |
| 23645 |
local hasmarks=marks[startchar] |
| 23646 |
local current=getnext(start) |
| 23647 |
local discfound=false |
| 23648 |
local last=stop |
| 23649 |
local nofreplacements=1 |
| 23650 |
while current do |
| 23651 |
local id=getid(current) |
| 23652 |
if id==disc_code then |
| 23653 |
if not discfound then |
| 23654 |
discfound=current |
| 23655 |
end |
| 23656 |
if current==stop then |
| 23657 |
break |
| 23658 |
else |
| 23659 |
current=getnext(current) |
| 23660 |
end |
| 23661 |
else |
| 23662 |
local schar=getchar(current) |
| 23663 |
if skiphash and skiphash[schar] then |
| 23664 |
current=getnext(current) |
| 23665 |
else |
| 23666 |
local lg=not tonumber(ligatures) and ligatures[schar] |
| 23667 |
if lg then |
| 23668 |
ligatures=lg |
| 23669 |
last=current |
| 23670 |
nofreplacements=nofreplacements+1 |
| 23671 |
if marks[char] then |
| 23672 |
hasmarks=true |
| 23673 |
end |
| 23674 |
if current==stop then |
| 23675 |
break |
| 23676 |
else |
| 23677 |
current=getnext(current) |
| 23678 |
end |
| 23679 |
else |
| 23680 |
break |
| 23681 |
end |
| 23682 |
end |
| 23683 |
end |
| 23684 |
end |
| 23685 |
local ligature=tonumber(ligatures) or ligatures.ligature |
| 23686 |
if ligature then |
| 23687 |
if chainindex then |
| 23688 |
stop=last |
| 23689 |
end |
| 23690 |
if trace_ligatures then |
| 23691 |
if start==stop then |
| 23692 |
logprocess("%s: replacing character %s by ligature %s case 3",cref(dataset,sequence,chainindex),gref(startchar),gref(ligature)) |
| 23693 |
else |
| 23694 |
logprocess("%s: replacing character %s upto %s by ligature %s case 4",cref(dataset,sequence,chainindex),gref(startchar),gref(getchar(stop)),gref(ligature)) |
| 23695 |
end |
| 23696 |
end |
| 23697 |
head,start=toligature(head,start,stop,ligature,dataset,sequence,skiphash,discfound,hasmarks) |
| 23698 |
return head,start,true,nofreplacements,discfound |
| 23699 |
elseif trace_bugs then |
| 23700 |
if start==stop then |
| 23701 |
logwarning("%s: replacing character %s by ligature fails",cref(dataset,sequence,chainindex),gref(startchar)) |
| 23702 |
else |
| 23703 |
logwarning("%s: replacing character %s upto %s by ligature fails",cref(dataset,sequence,chainindex),gref(startchar),gref(getchar(stop))) |
| 23704 |
end |
| 23705 |
end |
| 23706 |
end |
| 23707 |
end |
| 23708 |
return head,start,false,0,false |
| 23709 |
end |
| 23710 |
function chainprocs.gpos_single(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23711 |
if not hasglyphoption(start,no_right_kern_code) then |
| 23712 |
local mapping=currentlookup.mapping |
| 23713 |
if mapping==nil then |
| 23714 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23715 |
end |
| 23716 |
if mapping then |
| 23717 |
local startchar=getchar(start) |
| 23718 |
local kerns=mapping[startchar] |
| 23719 |
if kerns then |
| 23720 |
local format=currentlookup.format |
| 23721 |
if format=="single" then |
| 23722 |
local dx,dy,w,h=setposition(0,start,factor,rlmode,kerns) |
| 23723 |
if trace_kerns then |
| 23724 |
logprocess("%s: shifting single %s by %s (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),format,dx,dy,w,h) |
| 23725 |
end |
| 23726 |
else |
| 23727 |
local k=(format=="move" and setmove or setkern)(start,factor,rlmode,kerns,injection) |
| 23728 |
if trace_kerns then |
| 23729 |
logprocess("%s: shifting single %s by %s %p",cref(dataset,sequence),gref(startchar),format,k) |
| 23730 |
end |
| 23731 |
end |
| 23732 |
return head,start,true |
| 23733 |
end |
| 23734 |
end |
| 23735 |
end |
| 23736 |
return head,start,false |
| 23737 |
end |
| 23738 |
function chainprocs.gpos_pair(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23739 |
if not hasglyphoption(start,no_right_kern_code) then |
| 23740 |
local mapping=currentlookup.mapping |
| 23741 |
if mapping==nil then |
| 23742 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23743 |
end |
| 23744 |
if mapping then |
| 23745 |
local snext=getnext(start) |
| 23746 |
if snext then |
| 23747 |
local startchar=getchar(start) |
| 23748 |
local kerns=mapping[startchar] |
| 23749 |
if kerns then |
| 23750 |
local prev=start |
| 23751 |
while snext do |
| 23752 |
local nextchar=ischar(snext,currentfont) |
| 23753 |
if not nextchar then |
| 23754 |
break |
| 23755 |
end |
| 23756 |
if skiphash and skiphash[nextchar] then |
| 23757 |
prev=snext |
| 23758 |
snext=getnext(snext) |
| 23759 |
else |
| 23760 |
local krn=kerns[nextchar] |
| 23761 |
if not krn then |
| 23762 |
break |
| 23763 |
end |
| 23764 |
local format=currentlookup.format |
| 23765 |
if format=="pair" then |
| 23766 |
local a=krn[1] |
| 23767 |
local b=krn[2] |
| 23768 |
if a==true then |
| 23769 |
elseif a then |
| 23770 |
local x,y,w,h=setposition(1,start,factor,rlmode,a,"injections") |
| 23771 |
if trace_kerns then |
| 23772 |
local startchar=getchar(start) |
| 23773 |
logprocess("%s: shifting first of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h) |
| 23774 |
end |
| 23775 |
end |
| 23776 |
if b==true then |
| 23777 |
start=snext |
| 23778 |
elseif b then |
| 23779 |
local x,y,w,h=setposition(2,snext,factor,rlmode,b,"injections") |
| 23780 |
if trace_kerns then |
| 23781 |
local startchar=getchar(start) |
| 23782 |
logprocess("%s: shifting second of pair %s and %s by (%p,%p) and correction (%p,%p)",cref(dataset,sequence),gref(startchar),gref(nextchar),x,y,w,h) |
| 23783 |
end |
| 23784 |
start=snext |
| 23785 |
elseif forcepairadvance then |
| 23786 |
start=snext |
| 23787 |
end |
| 23788 |
return head,start,true |
| 23789 |
elseif krn~=0 then |
| 23790 |
local k=(format=="move" and setmove or setkern)(snext,factor,rlmode,krn) |
| 23791 |
if trace_kerns then |
| 23792 |
logprocess("%s: inserting %s %p between %s and %s",cref(dataset,sequence),format,k,gref(getchar(prev)),gref(nextchar)) |
| 23793 |
end |
| 23794 |
return head,start,true |
| 23795 |
else |
| 23796 |
break |
| 23797 |
end |
| 23798 |
end |
| 23799 |
end |
| 23800 |
end |
| 23801 |
end |
| 23802 |
end |
| 23803 |
end |
| 23804 |
return head,start,false |
| 23805 |
end |
| 23806 |
function chainprocs.gpos_mark2base(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23807 |
local mapping=currentlookup.mapping |
| 23808 |
if mapping==nil then |
| 23809 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23810 |
end |
| 23811 |
if mapping then |
| 23812 |
local markchar=getchar(start) |
| 23813 |
if marks[markchar] then |
| 23814 |
local markanchors=mapping[markchar] |
| 23815 |
if markanchors then |
| 23816 |
local base=getprev(start) |
| 23817 |
if base then |
| 23818 |
local basechar=ischar(base,currentfont) |
| 23819 |
if basechar then |
| 23820 |
if marks[basechar] then |
| 23821 |
while base do |
| 23822 |
base=getprev(base) |
| 23823 |
if base then |
| 23824 |
local basechar=ischar(base,currentfont) |
| 23825 |
if basechar then |
| 23826 |
if not marks[basechar] then |
| 23827 |
break |
| 23828 |
end |
| 23829 |
else |
| 23830 |
if trace_bugs then |
| 23831 |
logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),1) |
| 23832 |
end |
| 23833 |
return head,start,false |
| 23834 |
end |
| 23835 |
else |
| 23836 |
if trace_bugs then |
| 23837 |
logwarning("%s: no base for mark %s, case %i",pref(dataset,sequence),gref(markchar),2) |
| 23838 |
end |
| 23839 |
return head,start,false |
| 23840 |
end |
| 23841 |
end |
| 23842 |
end |
| 23843 |
local ba=markanchors[1][basechar] |
| 23844 |
if ba then |
| 23845 |
local ma=markanchors[2] |
| 23846 |
if ma then |
| 23847 |
local dx,dy,bound=setmark(start,base,factor,rlmode,ba,ma,characters[basechar],false,checkmarks) |
| 23848 |
if trace_marks then |
| 23849 |
logprocess("%s, bound %s, anchoring mark %s to basechar %s => (%p,%p)", |
| 23850 |
cref(dataset,sequence),bound,gref(markchar),gref(basechar),dx,dy) |
| 23851 |
end |
| 23852 |
return head,start,true |
| 23853 |
end |
| 23854 |
end |
| 23855 |
elseif trace_bugs then |
| 23856 |
logwarning("%s: prev node is no char, case %i",cref(dataset,sequence),1) |
| 23857 |
end |
| 23858 |
elseif trace_bugs then |
| 23859 |
logwarning("%s: prev node is no char, case %i",cref(dataset,sequence),2) |
| 23860 |
end |
| 23861 |
elseif trace_bugs then |
| 23862 |
logwarning("%s: mark %s has no anchors",cref(dataset,sequence),gref(markchar)) |
| 23863 |
end |
| 23864 |
elseif trace_bugs then |
| 23865 |
logwarning("%s: mark %s is no mark",cref(dataset,sequence),gref(markchar)) |
| 23866 |
end |
| 23867 |
end |
| 23868 |
return head,start,false |
| 23869 |
end |
| 23870 |
function chainprocs.gpos_mark2ligature(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23871 |
local mapping=currentlookup.mapping |
| 23872 |
if mapping==nil then |
| 23873 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23874 |
end |
| 23875 |
if mapping then |
| 23876 |
local markchar=getchar(start) |
| 23877 |
if marks[markchar] then |
| 23878 |
local markanchors=mapping[markchar] |
| 23879 |
if markanchors then |
| 23880 |
local base=getprev(start) |
| 23881 |
if base then |
| 23882 |
local basechar=ischar(base,currentfont) |
| 23883 |
if basechar then |
| 23884 |
if marks[basechar] then |
| 23885 |
while base do |
| 23886 |
base=getprev(base) |
| 23887 |
if base then |
| 23888 |
local basechar=ischar(base,currentfont) |
| 23889 |
if basechar then |
| 23890 |
if not marks[basechar] then |
| 23891 |
break |
| 23892 |
end |
| 23893 |
else |
| 23894 |
if trace_bugs then |
| 23895 |
logwarning("%s: no base for mark %s, case %i",cref(dataset,sequence),markchar,1) |
| 23896 |
end |
| 23897 |
return head,start,false |
| 23898 |
end |
| 23899 |
else |
| 23900 |
if trace_bugs then |
| 23901 |
logwarning("%s: no base for mark %s, case %i",cref(dataset,sequence),markchar,2) |
| 23902 |
end |
| 23903 |
return head,start,false |
| 23904 |
end |
| 23905 |
end |
| 23906 |
end |
| 23907 |
local ba=markanchors[1][basechar] |
| 23908 |
if ba then |
| 23909 |
local ma=markanchors[2] |
| 23910 |
if ma then |
| 23911 |
local index=getligaindex(start) |
| 23912 |
ba=ba[index] |
| 23913 |
if ba then |
| 23914 |
local dx,dy,bound=setmark(start,base,factor,rlmode,ba,ma,characters[basechar],false,checkmarks) |
| 23915 |
if trace_marks then |
| 23916 |
logprocess("%s, bound %s, anchoring mark %s to baselig %s at index %s => (%p,%p)", |
| 23917 |
cref(dataset,sequence),a or bound,gref(markchar),gref(basechar),index,dx,dy) |
| 23918 |
end |
| 23919 |
return head,start,true |
| 23920 |
end |
| 23921 |
end |
| 23922 |
end |
| 23923 |
elseif trace_bugs then |
| 23924 |
logwarning("%s, prev node is no char, case %i",cref(dataset,sequence),1) |
| 23925 |
end |
| 23926 |
elseif trace_bugs then |
| 23927 |
logwarning("%s, prev node is no char, case %i",cref(dataset,sequence),2) |
| 23928 |
end |
| 23929 |
elseif trace_bugs then |
| 23930 |
logwarning("%s, mark %s has no anchors",cref(dataset,sequence),gref(markchar)) |
| 23931 |
end |
| 23932 |
elseif trace_bugs then |
| 23933 |
logwarning("%s, mark %s is no mark",cref(dataset,sequence),gref(markchar)) |
| 23934 |
end |
| 23935 |
end |
| 23936 |
return head,start,false |
| 23937 |
end |
| 23938 |
function chainprocs.gpos_mark2mark(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23939 |
local mapping=currentlookup.mapping |
| 23940 |
if mapping==nil then |
| 23941 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23942 |
end |
| 23943 |
if mapping then |
| 23944 |
local markchar=getchar(start) |
| 23945 |
if marks[markchar] then |
| 23946 |
local markanchors=mapping[markchar] |
| 23947 |
if markanchors then |
| 23948 |
local base=getprev(start) |
| 23949 |
local slc=getligaindex(start) |
| 23950 |
if slc then |
| 23951 |
while base do |
| 23952 |
local blc=getligaindex(base) |
| 23953 |
if blc and blc~=slc then |
| 23954 |
base=getprev(base) |
| 23955 |
else |
| 23956 |
break |
| 23957 |
end |
| 23958 |
end |
| 23959 |
end |
| 23960 |
if base then |
| 23961 |
local basechar=ischar(base,currentfont) |
| 23962 |
if basechar then |
| 23963 |
local ba=markanchors[1][basechar] |
| 23964 |
if ba then |
| 23965 |
local ma=markanchors[2] |
| 23966 |
if ma then |
| 23967 |
local dx,dy,bound=setmark(start,base,factor,rlmode,ba,ma,characters[basechar],true,checkmarks) |
| 23968 |
if trace_marks then |
| 23969 |
logprocess("%s, bound %s, anchoring mark %s to basemark %s => (%p,%p)", |
| 23970 |
cref(dataset,sequence),bound,gref(markchar),gref(basechar),dx,dy) |
| 23971 |
end |
| 23972 |
return head,start,true |
| 23973 |
end |
| 23974 |
end |
| 23975 |
elseif trace_bugs then |
| 23976 |
logwarning("%s: prev node is no mark, case %i",cref(dataset,sequence),1) |
| 23977 |
end |
| 23978 |
elseif trace_bugs then |
| 23979 |
logwarning("%s: prev node is no mark, case %i",cref(dataset,sequence),2) |
| 23980 |
end |
| 23981 |
elseif trace_bugs then |
| 23982 |
logwarning("%s: mark %s has no anchors",cref(dataset,sequence),gref(markchar)) |
| 23983 |
end |
| 23984 |
elseif trace_bugs then |
| 23985 |
logwarning("%s: mark %s is no mark",cref(dataset,sequence),gref(markchar)) |
| 23986 |
end |
| 23987 |
end |
| 23988 |
return head,start,false |
| 23989 |
end |
| 23990 |
function chainprocs.gpos_cursive(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash,chainindex) |
| 23991 |
local mapping=currentlookup.mapping |
| 23992 |
if mapping==nil then |
| 23993 |
mapping=getmapping(dataset,sequence,currentlookup) |
| 23994 |
end |
| 23995 |
if mapping then |
| 23996 |
local startchar=getchar(start) |
| 23997 |
local exitanchors=mapping[startchar] |
| 23998 |
if exitanchors then |
| 23999 |
if marks[startchar] then |
| 24000 |
if trace_cursive then |
| 24001 |
logprocess("%s: ignoring cursive for mark %s",pref(dataset,sequence),gref(startchar)) |
| 24002 |
end |
| 24003 |
else |
| 24004 |
local nxt=getnext(start) |
| 24005 |
while nxt do |
| 24006 |
local nextchar=ischar(nxt,currentfont) |
| 24007 |
if not nextchar then |
| 24008 |
break |
| 24009 |
elseif marks[nextchar] then |
| 24010 |
nxt=getnext(nxt) |
| 24011 |
else |
| 24012 |
local exit=exitanchors[3] |
| 24013 |
if exit then |
| 24014 |
local entry=exitanchors[1][nextchar] |
| 24015 |
if entry then |
| 24016 |
entry=entry[2] |
| 24017 |
if entry then |
| 24018 |
local r2lflag=sequence.flags[4] |
| 24019 |
local dx,dy,bound=setcursive(start,nxt,factor,rlmode,exit,entry,characters[startchar],characters[nextchar],r2lflag) |
| 24020 |
if trace_cursive then |
| 24021 |
logprocess("%s: moving %s to %s cursive (%p,%p) using bound %s in %s mode",pref(dataset,sequence),gref(startchar),gref(nextchar),dx,dy,bound,mref(rlmode)) |
| 24022 |
end |
| 24023 |
return head,start,true |
| 24024 |
end |
| 24025 |
end |
| 24026 |
elseif trace_bugs then |
| 24027 |
onetimemessage(currentfont,startchar,"no entry anchors") |
| 24028 |
end |
| 24029 |
break |
| 24030 |
end |
| 24031 |
end |
| 24032 |
end |
| 24033 |
elseif trace_cursive and trace_details then |
| 24034 |
logprocess("%s, cursive %s is already done",pref(dataset,sequence),gref(getchar(start)),alreadydone) |
| 24035 |
end |
| 24036 |
end |
| 24037 |
return head,start,false |
| 24038 |
end |
| 24039 |
local function show_skip(dataset,sequence,char,ck,class) |
| 24040 |
logwarning("%s: skipping char %s, class %a, rule %a, lookuptype %a",cref(dataset,sequence),gref(char),class,ck[1],ck[8] or ck[2]) |
| 24041 |
end |
| 24042 |
local userkern=nuts.pool and nuts.pool.newkern |
| 24043 |
do if not userkern then |
| 24044 |
local thekern=nuts.new("kern",1) |
| 24045 |
local setkern=nuts.setkern |
| 24046 |
userkern=function(k) |
| 24047 |
local n=copynode(thekern) |
| 24048 |
setkern(n,k) |
| 24049 |
return n |
| 24050 |
end |
| 24051 |
end end |
| 24052 |
local function checked(head) |
| 24053 |
local current=head |
| 24054 |
while current do |
| 24055 |
if getid(current)==glue_code then |
| 24056 |
local kern=userkern(getwidth(current)) |
| 24057 |
if head==current then |
| 24058 |
local next=getnext(current) |
| 24059 |
if next then |
| 24060 |
setlink(kern,next) |
| 24061 |
end |
| 24062 |
flushnode(current) |
| 24063 |
head=kern |
| 24064 |
current=next |
| 24065 |
else |
| 24066 |
local prev,next=getboth(current) |
| 24067 |
setlink(prev,kern,next) |
| 24068 |
flushnode(current) |
| 24069 |
current=next |
| 24070 |
end |
| 24071 |
else |
| 24072 |
current=getnext(current) |
| 24073 |
end |
| 24074 |
end |
| 24075 |
return head |
| 24076 |
end |
| 24077 |
local function setdiscchecked(d,pre,post,replace) |
| 24078 |
if pre then pre=checked(pre) end |
| 24079 |
if post then post=checked(post) end |
| 24080 |
if replace then replace=checked(replace) end |
| 24081 |
setdisc(d,pre,post,replace) |
| 24082 |
end |
| 24083 |
local noflags={ false,false,false,false } |
| 24084 |
local function chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck,where) |
| 24085 |
local size=ck[5]-ck[4]+1 |
| 24086 |
local chainlookups=ck[6] |
| 24087 |
local done=false |
| 24088 |
if chainlookups then |
| 24089 |
if size==1 then |
| 24090 |
local chainlookup=chainlookups[1] |
| 24091 |
if chainlookup then |
| 24092 |
for j=1,#chainlookup do |
| 24093 |
local chainstep=chainlookup[j] |
| 24094 |
if chainstep then |
| 24095 |
local chainkind=chainstep.type |
| 24096 |
local chainproc=chainprocs[chainkind] |
| 24097 |
if chainproc then |
| 24098 |
local ok |
| 24099 |
head,start,ok=chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash,1) |
| 24100 |
if ok then |
| 24101 |
done=true |
| 24102 |
end |
| 24103 |
else |
| 24104 |
logprocess("%s: %s is not yet supported (1)",cref(dataset,sequence),chainkind) |
| 24105 |
end |
| 24106 |
else |
| 24107 |
logprocess("%s: has an issue (1)",cref(dataset,sequence)) |
| 24108 |
end |
| 24109 |
end |
| 24110 |
else |
| 24111 |
end |
| 24112 |
else |
| 24113 |
local i=1 |
| 24114 |
local laststart=start |
| 24115 |
local nofchainlookups=#chainlookups |
| 24116 |
while start do |
| 24117 |
if skiphash then |
| 24118 |
while start do |
| 24119 |
local char=ischar(start,currentfont) |
| 24120 |
if char then |
| 24121 |
if skiphash and skiphash[char] then |
| 24122 |
start=getnext(start) |
| 24123 |
else |
| 24124 |
break |
| 24125 |
end |
| 24126 |
else |
| 24127 |
break |
| 24128 |
end |
| 24129 |
end |
| 24130 |
end |
| 24131 |
local chainlookup=chainlookups[i] |
| 24132 |
if chainlookup then |
| 24133 |
for j=1,#chainlookup do |
| 24134 |
local chainstep=chainlookup[j] |
| 24135 |
if chainstep then |
| 24136 |
local chainkind=chainstep.type |
| 24137 |
local chainproc=chainprocs[chainkind] |
| 24138 |
if chainproc then |
| 24139 |
local ok,n |
| 24140 |
head,start,ok,n=chainproc(head,start,last,dataset,sequence,chainstep,rlmode,skiphash,i) |
| 24141 |
if ok then |
| 24142 |
done=true |
| 24143 |
if n and n>1 and i+n>nofchainlookups then |
| 24144 |
i=size |
| 24145 |
break |
| 24146 |
end |
| 24147 |
end |
| 24148 |
else |
| 24149 |
logprocess("%s: %s is not yet supported (2)",cref(dataset,sequence),chainkind) |
| 24150 |
end |
| 24151 |
else |
| 24152 |
logprocess("%s: has an issue (2)",cref(dataset,sequence)) |
| 24153 |
end |
| 24154 |
end |
| 24155 |
else |
| 24156 |
end |
| 24157 |
i=i+1 |
| 24158 |
if i>size or not start then |
| 24159 |
break |
| 24160 |
elseif start then |
| 24161 |
laststart=start |
| 24162 |
start=getnext(start) |
| 24163 |
end |
| 24164 |
end |
| 24165 |
if not start then |
| 24166 |
start=laststart |
| 24167 |
end |
| 24168 |
end |
| 24169 |
else |
| 24170 |
local replacements=ck[7] |
| 24171 |
if replacements then |
| 24172 |
head,start,done=reversesub(head,start,last,dataset,sequence,replacements,rlmode,skiphash) |
| 24173 |
else |
| 24174 |
done=true |
| 24175 |
if trace_contexts then |
| 24176 |
logprocess("%s: skipping match @ %i",cref(dataset,sequence),where) |
| 24177 |
end |
| 24178 |
end |
| 24179 |
end |
| 24180 |
return head,start,done |
| 24181 |
end |
| 24182 |
local function chaindisk(head,start,dataset,sequence,rlmode,skiphash,ck) |
| 24183 |
if not start then |
| 24184 |
return head,start,false |
| 24185 |
end |
| 24186 |
local startishead=start==head |
| 24187 |
local seq=ck[3] |
| 24188 |
local f=ck[4] |
| 24189 |
local l=ck[5] |
| 24190 |
local s=#seq |
| 24191 |
local done=false |
| 24192 |
local sweepnode=sweepnode |
| 24193 |
local sweeptype=sweeptype |
| 24194 |
local sweepoverflow=false |
| 24195 |
local checkdisc=getprev(head) |
| 24196 |
local keepdisc=not sweepnode |
| 24197 |
local lookaheaddisc=nil |
| 24198 |
local backtrackdisc=nil |
| 24199 |
local current=start |
| 24200 |
local last=start |
| 24201 |
local prev=getprev(start) |
| 24202 |
local hasglue=false |
| 24203 |
local useddisc=nil |
| 24204 |
local usedstart=start |
| 24205 |
local i=f |
| 24206 |
while i<=l do |
| 24207 |
local id=getid(current) |
| 24208 |
if id==glyph_code then |
| 24209 |
i=i+1 |
| 24210 |
last=current |
| 24211 |
current=getnext(current) |
| 24212 |
elseif id==glue_code then |
| 24213 |
i=i+1 |
| 24214 |
last=current |
| 24215 |
current=getnext(current) |
| 24216 |
hasglue=true |
| 24217 |
elseif id==disc_code then |
| 24218 |
if keepdisc then |
| 24219 |
keepdisc=false |
| 24220 |
lookaheaddisc=current |
| 24221 |
local replace=getreplace(current) |
| 24222 |
if not replace then |
| 24223 |
sweepoverflow=true |
| 24224 |
sweepnode=current |
| 24225 |
current=getnext(current) |
| 24226 |
else |
| 24227 |
while replace and i<=l do |
| 24228 |
if getid(replace)==glyph_code then |
| 24229 |
i=i+1 |
| 24230 |
end |
| 24231 |
replace=getnext(replace) |
| 24232 |
end |
| 24233 |
current=getnext(replace) |
| 24234 |
end |
| 24235 |
last=current |
| 24236 |
else |
| 24237 |
head,current=flattendisk(head,current) |
| 24238 |
end |
| 24239 |
else |
| 24240 |
last=current |
| 24241 |
current=getnext(current) |
| 24242 |
end |
| 24243 |
if current then |
| 24244 |
elseif sweepoverflow then |
| 24245 |
break |
| 24246 |
elseif sweeptype=="post" or sweeptype=="replace" then |
| 24247 |
current=getnext(sweepnode) |
| 24248 |
if current then |
| 24249 |
sweeptype=nil |
| 24250 |
sweepoverflow=true |
| 24251 |
else |
| 24252 |
break |
| 24253 |
end |
| 24254 |
else |
| 24255 |
break |
| 24256 |
end |
| 24257 |
end |
| 24258 |
if sweepoverflow then |
| 24259 |
local prev=current and getprev(current) |
| 24260 |
if not current or prev~=sweepnode then |
| 24261 |
local head=getnext(sweepnode) |
| 24262 |
local tail=nil |
| 24263 |
if prev then |
| 24264 |
tail=prev |
| 24265 |
setprev(current,sweepnode) |
| 24266 |
else |
| 24267 |
tail=findnodetail(head) |
| 24268 |
end |
| 24269 |
setnext(sweepnode,current) |
| 24270 |
setprev(head) |
| 24271 |
setnext(tail) |
| 24272 |
appenddisc(sweepnode,head) |
| 24273 |
end |
| 24274 |
end |
| 24275 |
if l<s then |
| 24276 |
local i=l |
| 24277 |
local t=sweeptype=="post" or sweeptype=="replace" |
| 24278 |
while current and i<s do |
| 24279 |
local id=getid(current) |
| 24280 |
if id==glyph_code then |
| 24281 |
i=i+1 |
| 24282 |
current=getnext(current) |
| 24283 |
elseif id==glue_code then |
| 24284 |
i=i+1 |
| 24285 |
current=getnext(current) |
| 24286 |
hasglue=true |
| 24287 |
elseif id==disc_code then |
| 24288 |
if keepdisc then |
| 24289 |
keepdisc=false |
| 24290 |
if notmatchpre[current]~=notmatchreplace[current] then |
| 24291 |
lookaheaddisc=current |
| 24292 |
end |
| 24293 |
local replace=getreplace(current) |
| 24294 |
while replace and i<s do |
| 24295 |
if getid(replace)==glyph_code then |
| 24296 |
i=i+1 |
| 24297 |
end |
| 24298 |
replace=getnext(replace) |
| 24299 |
end |
| 24300 |
current=getnext(current) |
| 24301 |
elseif notmatchpre[current]~=notmatchreplace[current] then |
| 24302 |
head,current=flattendisk(head,current) |
| 24303 |
else |
| 24304 |
current=getnext(current) |
| 24305 |
end |
| 24306 |
else |
| 24307 |
current=getnext(current) |
| 24308 |
end |
| 24309 |
if not current and t then |
| 24310 |
current=getnext(sweepnode) |
| 24311 |
if current then |
| 24312 |
sweeptype=nil |
| 24313 |
end |
| 24314 |
end |
| 24315 |
end |
| 24316 |
end |
| 24317 |
if f>1 then |
| 24318 |
local current=prev |
| 24319 |
local i=f |
| 24320 |
local t=sweeptype=="pre" or sweeptype=="replace" |
| 24321 |
if not current and t and current==checkdisc then |
| 24322 |
current=getprev(sweepnode) |
| 24323 |
end |
| 24324 |
while current and i>1 do |
| 24325 |
local id=getid(current) |
| 24326 |
if id==glyph_code then |
| 24327 |
i=i-1 |
| 24328 |
elseif id==glue_code then |
| 24329 |
i=i-1 |
| 24330 |
hasglue=true |
| 24331 |
elseif id==disc_code then |
| 24332 |
if keepdisc then |
| 24333 |
keepdisc=false |
| 24334 |
if notmatchpost[current]~=notmatchreplace[current] then |
| 24335 |
backtrackdisc=current |
| 24336 |
end |
| 24337 |
local replace=getreplace(current) |
| 24338 |
while replace and i>1 do |
| 24339 |
if getid(replace)==glyph_code then |
| 24340 |
i=i-1 |
| 24341 |
end |
| 24342 |
replace=getnext(replace) |
| 24343 |
end |
| 24344 |
elseif notmatchpost[current]~=notmatchreplace[current] then |
| 24345 |
head,current=flattendisk(head,current) |
| 24346 |
end |
| 24347 |
end |
| 24348 |
current=getprev(current) |
| 24349 |
if t and current==checkdisc then |
| 24350 |
current=getprev(sweepnode) |
| 24351 |
end |
| 24352 |
end |
| 24353 |
end |
| 24354 |
local done=false |
| 24355 |
if lookaheaddisc then |
| 24356 |
local cf=start |
| 24357 |
local cl=getprev(lookaheaddisc) |
| 24358 |
local cprev=getprev(start) |
| 24359 |
local insertedmarks=0 |
| 24360 |
while cprev do |
| 24361 |
local char=ischar(cf,currentfont) |
| 24362 |
if char and marks[char] then |
| 24363 |
insertedmarks=insertedmarks+1 |
| 24364 |
cf=cprev |
| 24365 |
startishead=cf==head |
| 24366 |
cprev=getprev(cprev) |
| 24367 |
else |
| 24368 |
break |
| 24369 |
end |
| 24370 |
end |
| 24371 |
setlink(cprev,lookaheaddisc) |
| 24372 |
setprev(cf) |
| 24373 |
setnext(cl) |
| 24374 |
if startishead then |
| 24375 |
head=lookaheaddisc |
| 24376 |
end |
| 24377 |
local pre,post,replace=getdisc(lookaheaddisc) |
| 24378 |
local new=copynodelist(cf) |
| 24379 |
local cnew=new |
| 24380 |
if pre then |
| 24381 |
setlink(findnodetail(cf),pre) |
| 24382 |
end |
| 24383 |
if replace then |
| 24384 |
local tail=findnodetail(new) |
| 24385 |
setlink(tail,replace) |
| 24386 |
end |
| 24387 |
for i=1,insertedmarks do |
| 24388 |
cnew=getnext(cnew) |
| 24389 |
end |
| 24390 |
cl=start |
| 24391 |
local clast=cnew |
| 24392 |
for i=f,l do |
| 24393 |
cl=getnext(cl) |
| 24394 |
clast=getnext(clast) |
| 24395 |
end |
| 24396 |
if not notmatchpre[lookaheaddisc] then |
| 24397 |
local ok=false |
| 24398 |
cf,start,ok=chainrun(cf,start,cl,dataset,sequence,rlmode,skiphash,ck,1) |
| 24399 |
if ok then |
| 24400 |
done=true |
| 24401 |
end |
| 24402 |
end |
| 24403 |
if not notmatchreplace[lookaheaddisc] then |
| 24404 |
local ok=false |
| 24405 |
new,cnew,ok=chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck,2) |
| 24406 |
if ok then |
| 24407 |
done=true |
| 24408 |
end |
| 24409 |
end |
| 24410 |
if hasglue then |
| 24411 |
setdiscchecked(lookaheaddisc,cf,post,new) |
| 24412 |
else |
| 24413 |
setdisc(lookaheaddisc,cf,post,new) |
| 24414 |
end |
| 24415 |
start=getprev(lookaheaddisc) |
| 24416 |
useddisc=lookaheaddisc |
| 24417 |
sweephead[cf]=getnext(clast) or false |
| 24418 |
sweephead[new]=getnext(cl) or false |
| 24419 |
elseif backtrackdisc then |
| 24420 |
local cf=getnext(backtrackdisc) |
| 24421 |
local cl=start |
| 24422 |
local cnext=getnext(start) |
| 24423 |
local insertedmarks=0 |
| 24424 |
while cnext do |
| 24425 |
local char=ischar(cnext,currentfont) |
| 24426 |
if char and marks[char] then |
| 24427 |
insertedmarks=insertedmarks+1 |
| 24428 |
cl=cnext |
| 24429 |
cnext=getnext(cnext) |
| 24430 |
else |
| 24431 |
break |
| 24432 |
end |
| 24433 |
end |
| 24434 |
setlink(backtrackdisc,cnext) |
| 24435 |
setprev(cf) |
| 24436 |
setnext(cl) |
| 24437 |
local pre,post,replace,pretail,posttail,replacetail=getdisc(backtrackdisc,true) |
| 24438 |
local new=copynodelist(cf) |
| 24439 |
local cnew=findnodetail(new) |
| 24440 |
for i=1,insertedmarks do |
| 24441 |
cnew=getprev(cnew) |
| 24442 |
end |
| 24443 |
local clast=cnew |
| 24444 |
for i=f,l do |
| 24445 |
clast=getnext(clast) |
| 24446 |
end |
| 24447 |
if not notmatchpost[backtrackdisc] then |
| 24448 |
local ok=false |
| 24449 |
cf,start,ok=chainrun(cf,start,last,dataset,sequence,rlmode,skiphash,ck,3) |
| 24450 |
if ok then |
| 24451 |
done=true |
| 24452 |
end |
| 24453 |
end |
| 24454 |
if not notmatchreplace[backtrackdisc] then |
| 24455 |
local ok=false |
| 24456 |
new,cnew,ok=chainrun(new,cnew,clast,dataset,sequence,rlmode,skiphash,ck,4) |
| 24457 |
if ok then |
| 24458 |
done=true |
| 24459 |
end |
| 24460 |
end |
| 24461 |
if post then |
| 24462 |
setlink(posttail,cf) |
| 24463 |
else |
| 24464 |
post=cf |
| 24465 |
end |
| 24466 |
if replace then |
| 24467 |
setlink(replacetail,new) |
| 24468 |
else |
| 24469 |
replace=new |
| 24470 |
end |
| 24471 |
if hasglue then |
| 24472 |
setdiscchecked(backtrackdisc,pre,post,replace) |
| 24473 |
else |
| 24474 |
setdisc(backtrackdisc,pre,post,replace) |
| 24475 |
end |
| 24476 |
start=getprev(backtrackdisc) |
| 24477 |
useddisc=backtrackdisc |
| 24478 |
sweephead[post]=getnext(clast) or false |
| 24479 |
sweephead[replace]=getnext(last) or false |
| 24480 |
else |
| 24481 |
local ok=false |
| 24482 |
head,start,ok=chainrun(head,start,last,dataset,sequence,rlmode,skiphash,ck,5) |
| 24483 |
if ok then |
| 24484 |
done=true |
| 24485 |
end |
| 24486 |
end |
| 24487 |
if useddisc and start~=usedstart then |
| 24488 |
start=getnext(start) |
| 24489 |
end |
| 24490 |
return head,start,done,useddisc |
| 24491 |
end |
| 24492 |
local chaintrac do |
| 24493 |
local level=0 |
| 24494 |
local last={} |
| 24495 |
chaintrac=function(head,start,dataset,sequence,rlmode,skiphash,ck,match,discseen,sweepnode) |
| 24496 |
if dataset then |
| 24497 |
level=level+1 |
| 24498 |
last[level]=start |
| 24499 |
local rule=ck[1] |
| 24500 |
local lookuptype=ck[8] or ck[2] |
| 24501 |
local nofseq=#ck[3] |
| 24502 |
local first=ck[4] |
| 24503 |
local last=ck[5] |
| 24504 |
local char=getchar(start) |
| 24505 |
logwarning("+ %i : %s: rule %s %s at char %s for (%s,%s,%s) chars, lookuptype %a, %sdisc seen, %ssweeping", |
| 24506 |
level,cref(dataset,sequence),rule,match and "matches" or "nomatch", |
| 24507 |
gref(char),first-1,last-first+1,nofseq-last,lookuptype, |
| 24508 |
discseen and "" or "no ",sweepnode and "" or "not ") |
| 24509 |
else |
| 24510 |
local what=start and "done" or "continue" |
| 24511 |
local where=head==last[level] and "same" or "different" |
| 24512 |
local char=getchar(head) |
| 24513 |
if char then |
| 24514 |
logwarning("- %i : %s at char %s, %s node",level,what,gref(char),where) |
| 24515 |
else |
| 24516 |
logwarning("- %i : %s, %s node",level,what,where) |
| 24517 |
end |
| 24518 |
level=level-1 |
| 24519 |
end |
| 24520 |
end |
| 24521 |
end |
| 24522 |
local function handle_contextchain(head,start,dataset,sequence,contexts,rlmode,skiphash) |
| 24523 |
if not contexts then |
| 24524 |
return head,start,false |
| 24525 |
end |
| 24526 |
local sweepnode=sweepnode |
| 24527 |
local sweeptype=sweeptype |
| 24528 |
local postreplace |
| 24529 |
local prereplace |
| 24530 |
local checkdisc |
| 24531 |
local discseen |
| 24532 |
if sweeptype then |
| 24533 |
if sweeptype=="replace" then |
| 24534 |
postreplace=true |
| 24535 |
prereplace=true |
| 24536 |
else |
| 24537 |
postreplace=sweeptype=="post" |
| 24538 |
prereplace=sweeptype=="pre" |
| 24539 |
end |
| 24540 |
checkdisc=getprev(head) |
| 24541 |
end |
| 24542 |
local currentfont=currentfont |
| 24543 |
local skipped |
| 24544 |
local startprev, |
| 24545 |
startnext=getboth(start) |
| 24546 |
local done |
| 24547 |
local nofcontexts=contexts.n |
| 24548 |
local startchar=nofcontext==1 or ischar(start,currentfont) |
| 24549 |
for k=1,nofcontexts do |
| 24550 |
local ck=contexts[k] |
| 24551 |
local seq=ck[3] |
| 24552 |
local f=ck[4] |
| 24553 |
local last=start |
| 24554 |
if not startchar or not seq[f][startchar] then |
| 24555 |
goto next |
| 24556 |
end |
| 24557 |
local s=seq.n |
| 24558 |
if s==1 then |
| 24559 |
else |
| 24560 |
local l=ck[5] |
| 24561 |
local current=start |
| 24562 |
if l>f then |
| 24563 |
local discfound |
| 24564 |
local n=f+1 |
| 24565 |
last=startnext |
| 24566 |
while n<=l do |
| 24567 |
if postreplace and not last then |
| 24568 |
last=getnext(sweepnode) |
| 24569 |
sweeptype=nil |
| 24570 |
end |
| 24571 |
if last then |
| 24572 |
local char,id=ischar(last,currentfont) |
| 24573 |
if char then |
| 24574 |
if seq[n][char] then |
| 24575 |
if n<l then |
| 24576 |
last=getnext(last) |
| 24577 |
end |
| 24578 |
n=n+1 |
| 24579 |
elseif skiphash and skiphash[char] then |
| 24580 |
skipped=true |
| 24581 |
if trace_skips then |
| 24582 |
show_skip(dataset,sequence,char,ck,classes[char]) |
| 24583 |
end |
| 24584 |
last=getnext(last) |
| 24585 |
elseif discfound then |
| 24586 |
notmatchreplace[discfound]=true |
| 24587 |
if notmatchpre[discfound] then |
| 24588 |
goto next |
| 24589 |
else |
| 24590 |
break |
| 24591 |
end |
| 24592 |
else |
| 24593 |
goto next |
| 24594 |
end |
| 24595 |
elseif char==false then |
| 24596 |
if discfound then |
| 24597 |
notmatchreplace[discfound]=true |
| 24598 |
if notmatchpre[discfound] then |
| 24599 |
goto next |
| 24600 |
else |
| 24601 |
break |
| 24602 |
end |
| 24603 |
else |
| 24604 |
goto next |
| 24605 |
end |
| 24606 |
elseif id==disc_code then |
| 24607 |
discseen=true |
| 24608 |
discfound=last |
| 24609 |
notmatchpre[last]=nil |
| 24610 |
notmatchpost[last]=true |
| 24611 |
notmatchreplace[last]=nil |
| 24612 |
local pre,post,replace=getdisc(last) |
| 24613 |
if pre then |
| 24614 |
local n=n |
| 24615 |
while pre do |
| 24616 |
if seq[n][getchar(pre)] then |
| 24617 |
n=n+1 |
| 24618 |
if n>l then |
| 24619 |
break |
| 24620 |
end |
| 24621 |
pre=getnext(pre) |
| 24622 |
else |
| 24623 |
notmatchpre[last]=true |
| 24624 |
break |
| 24625 |
end |
| 24626 |
end |
| 24627 |
if n<=l then |
| 24628 |
notmatchpre[last]=true |
| 24629 |
end |
| 24630 |
else |
| 24631 |
notmatchpre[last]=true |
| 24632 |
end |
| 24633 |
if replace then |
| 24634 |
while replace do |
| 24635 |
if seq[n][getchar(replace)] then |
| 24636 |
n=n+1 |
| 24637 |
if n>l then |
| 24638 |
break |
| 24639 |
end |
| 24640 |
replace=getnext(replace) |
| 24641 |
else |
| 24642 |
notmatchreplace[last]=true |
| 24643 |
if notmatchpre[last] then |
| 24644 |
goto next |
| 24645 |
else |
| 24646 |
break |
| 24647 |
end |
| 24648 |
end |
| 24649 |
end |
| 24650 |
if notmatchpre[last] then |
| 24651 |
goto next |
| 24652 |
end |
| 24653 |
end |
| 24654 |
last=getnext(last) |
| 24655 |
else |
| 24656 |
goto next |
| 24657 |
end |
| 24658 |
else |
| 24659 |
goto next |
| 24660 |
end |
| 24661 |
end |
| 24662 |
end |
| 24663 |
if f>1 then |
| 24664 |
local prev=startprev |
| 24665 |
if prereplace and prev==checkdisc then |
| 24666 |
prev=getprev(sweepnode) |
| 24667 |
end |
| 24668 |
if prev then |
| 24669 |
local discfound |
| 24670 |
local n=f-1 |
| 24671 |
while n>=1 do |
| 24672 |
if prev then |
| 24673 |
local char,id=ischar(prev,currentfont) |
| 24674 |
if char then |
| 24675 |
if seq[n][char] then |
| 24676 |
if n>1 then |
| 24677 |
prev=getprev(prev) |
| 24678 |
end |
| 24679 |
n=n-1 |
| 24680 |
elseif skiphash and skiphash[char] then |
| 24681 |
skipped=true |
| 24682 |
if trace_skips then |
| 24683 |
show_skip(dataset,sequence,char,ck,classes[char]) |
| 24684 |
end |
| 24685 |
prev=getprev(prev) |
| 24686 |
elseif discfound then |
| 24687 |
notmatchreplace[discfound]=true |
| 24688 |
if notmatchpost[discfound] then |
| 24689 |
goto next |
| 24690 |
else |
| 24691 |
break |
| 24692 |
end |
| 24693 |
else |
| 24694 |
goto next |
| 24695 |
end |
| 24696 |
elseif char==false then |
| 24697 |
if discfound then |
| 24698 |
notmatchreplace[discfound]=true |
| 24699 |
if notmatchpost[discfound] then |
| 24700 |
goto next |
| 24701 |
end |
| 24702 |
else |
| 24703 |
goto next |
| 24704 |
end |
| 24705 |
break |
| 24706 |
elseif id==disc_code then |
| 24707 |
discseen=true |
| 24708 |
discfound=prev |
| 24709 |
notmatchpre[prev]=true |
| 24710 |
notmatchpost[prev]=nil |
| 24711 |
notmatchreplace[prev]=nil |
| 24712 |
local pre,post,replace,pretail,posttail,replacetail=getdisc(prev,true) |
| 24713 |
if pre~=start and post~=start and replace~=start then |
| 24714 |
if post then |
| 24715 |
local n=n |
| 24716 |
while posttail do |
| 24717 |
if seq[n][getchar(posttail)] then |
| 24718 |
n=n-1 |
| 24719 |
if posttail==post or n<1 then |
| 24720 |
break |
| 24721 |
else |
| 24722 |
posttail=getprev(posttail) |
| 24723 |
end |
| 24724 |
else |
| 24725 |
notmatchpost[prev]=true |
| 24726 |
break |
| 24727 |
end |
| 24728 |
end |
| 24729 |
if n>=1 then |
| 24730 |
notmatchpost[prev]=true |
| 24731 |
end |
| 24732 |
else |
| 24733 |
notmatchpost[prev]=true |
| 24734 |
end |
| 24735 |
if replace then |
| 24736 |
while replacetail do |
| 24737 |
if seq[n][getchar(replacetail)] then |
| 24738 |
n=n-1 |
| 24739 |
if replacetail==replace or n<1 then |
| 24740 |
break |
| 24741 |
else |
| 24742 |
replacetail=getprev(replacetail) |
| 24743 |
end |
| 24744 |
else |
| 24745 |
notmatchreplace[prev]=true |
| 24746 |
if notmatchpost[prev] then |
| 24747 |
goto next |
| 24748 |
else |
| 24749 |
break |
| 24750 |
end |
| 24751 |
end |
| 24752 |
end |
| 24753 |
else |
| 24754 |
end |
| 24755 |
end |
| 24756 |
prev=getprev(prev) |
| 24757 |
elseif id==glue_code then |
| 24758 |
local sn=seq[n] |
| 24759 |
if (sn[32] and spaces[prev]) or sn[0xFFFC] then |
| 24760 |
n=n-1 |
| 24761 |
prev=getprev(prev) |
| 24762 |
else |
| 24763 |
goto next |
| 24764 |
end |
| 24765 |
elseif seq[n][0xFFFC] then |
| 24766 |
n=n-1 |
| 24767 |
prev=getprev(prev) |
| 24768 |
else |
| 24769 |
goto next |
| 24770 |
end |
| 24771 |
else |
| 24772 |
goto next |
| 24773 |
end |
| 24774 |
end |
| 24775 |
else |
| 24776 |
goto next |
| 24777 |
end |
| 24778 |
end |
| 24779 |
if s>l then |
| 24780 |
local current=last and getnext(last) |
| 24781 |
if not current and postreplace then |
| 24782 |
current=getnext(sweepnode) |
| 24783 |
end |
| 24784 |
if current then |
| 24785 |
local discfound |
| 24786 |
local n=l+1 |
| 24787 |
while n<=s do |
| 24788 |
if current then |
| 24789 |
local char,id=ischar(current,currentfont) |
| 24790 |
if char then |
| 24791 |
if seq[n][char] then |
| 24792 |
if n<s then |
| 24793 |
current=getnext(current) |
| 24794 |
end |
| 24795 |
n=n+1 |
| 24796 |
elseif skiphash and skiphash[char] then |
| 24797 |
skipped=true |
| 24798 |
if trace_skips then |
| 24799 |
show_skip(dataset,sequence,char,ck,classes[char]) |
| 24800 |
end |
| 24801 |
current=getnext(current) |
| 24802 |
elseif discfound then |
| 24803 |
notmatchreplace[discfound]=true |
| 24804 |
if notmatchpre[discfound] then |
| 24805 |
goto next |
| 24806 |
else |
| 24807 |
break |
| 24808 |
end |
| 24809 |
else |
| 24810 |
goto next |
| 24811 |
end |
| 24812 |
elseif char==false then |
| 24813 |
if discfound then |
| 24814 |
notmatchreplace[discfound]=true |
| 24815 |
if notmatchpre[discfound] then |
| 24816 |
goto next |
| 24817 |
else |
| 24818 |
break |
| 24819 |
end |
| 24820 |
else |
| 24821 |
goto next |
| 24822 |
end |
| 24823 |
elseif id==disc_code then |
| 24824 |
discseen=true |
| 24825 |
discfound=current |
| 24826 |
notmatchpre[current]=nil |
| 24827 |
notmatchpost[current]=true |
| 24828 |
notmatchreplace[current]=nil |
| 24829 |
local pre,post,replace=getdisc(current) |
| 24830 |
if pre then |
| 24831 |
local n=n |
| 24832 |
while pre do |
| 24833 |
if seq[n][getchar(pre)] then |
| 24834 |
n=n+1 |
| 24835 |
if n>s then |
| 24836 |
break |
| 24837 |
else |
| 24838 |
pre=getnext(pre) |
| 24839 |
end |
| 24840 |
else |
| 24841 |
notmatchpre[current]=true |
| 24842 |
break |
| 24843 |
end |
| 24844 |
end |
| 24845 |
if n<=s then |
| 24846 |
notmatchpre[current]=true |
| 24847 |
end |
| 24848 |
else |
| 24849 |
notmatchpre[current]=true |
| 24850 |
end |
| 24851 |
if replace then |
| 24852 |
while replace do |
| 24853 |
if seq[n][getchar(replace)] then |
| 24854 |
n=n+1 |
| 24855 |
if n>s then |
| 24856 |
break |
| 24857 |
else |
| 24858 |
replace=getnext(replace) |
| 24859 |
end |
| 24860 |
else |
| 24861 |
notmatchreplace[current]=true |
| 24862 |
if notmatchpre[current] then |
| 24863 |
goto next |
| 24864 |
else |
| 24865 |
break |
| 24866 |
end |
| 24867 |
end |
| 24868 |
end |
| 24869 |
else |
| 24870 |
end |
| 24871 |
current=getnext(current) |
| 24872 |
elseif id==glue_code then |
| 24873 |
local sn=seq[n] |
| 24874 |
if (sn[32] and spaces[current]) or sn[0xFFFC] then |
| 24875 |
n=n+1 |
| 24876 |
current=getnext(current) |
| 24877 |
else |
| 24878 |
goto next |
| 24879 |
end |
| 24880 |
elseif seq[n][0xFFFC] then |
| 24881 |
n=n+1 |
| 24882 |
current=getnext(current) |
| 24883 |
else |
| 24884 |
goto next |
| 24885 |
end |
| 24886 |
else |
| 24887 |
goto next |
| 24888 |
end |
| 24889 |
end |
| 24890 |
else |
| 24891 |
goto next |
| 24892 |
end |
| 24893 |
end |
| 24894 |
end |
| 24895 |
if trace_contexts then |
| 24896 |
chaintrac(head,start,dataset,sequence,rlmode,skipped and skiphash,ck,true,discseen,sweepnode) |
| 24897 |
end |
| 24898 |
if discseen or sweepnode then |
| 24899 |
head,start,done=chaindisk(head,start,dataset,sequence,rlmode,skipped and skiphash,ck) |
| 24900 |
else |
| 24901 |
head,start,done=chainrun(head,start,last,dataset,sequence,rlmode,skipped and skiphash,ck,6) |
| 24902 |
end |
| 24903 |
if trace_contexts then |
| 24904 |
chaintrac(start,done) |
| 24905 |
end |
| 24906 |
if done then |
| 24907 |
break |
| 24908 |
end |
| 24909 |
::next:: |
| 24910 |
end |
| 24911 |
if discseen then |
| 24912 |
notmatchpre={} |
| 24913 |
notmatchpost={} |
| 24914 |
notmatchreplace={} |
| 24915 |
end |
| 24916 |
return head,start,done |
| 24917 |
end |
| 24918 |
handlers.gsub_context=handle_contextchain |
| 24919 |
handlers.gsub_contextchain=handle_contextchain |
| 24920 |
handlers.gsub_reversecontextchain=handle_contextchain |
| 24921 |
handlers.gpos_contextchain=handle_contextchain |
| 24922 |
handlers.gpos_context=handle_contextchain |
| 24923 |
local function chained_contextchain(head,start,stop,dataset,sequence,currentlookup,rlmode,skiphash) |
| 24924 |
local steps=currentlookup.steps |
| 24925 |
local nofsteps=currentlookup.nofsteps |
| 24926 |
local char=getchar(start) |
| 24927 |
if nofsteps==1 then |
| 24928 |
local s=steps[1] |
| 24929 |
local l=s.coverage[char] |
| 24930 |
if l then |
| 24931 |
return handle_contextchain(head,start,dataset,sequence,l,rlmode,skiphash) |
| 24932 |
end |
| 24933 |
else |
| 24934 |
for i=1,nofsteps do |
| 24935 |
local s=steps[i] |
| 24936 |
local l=s.coverage[char] |
| 24937 |
if l then |
| 24938 |
local h,s,d=handle_contextchain(head,start,dataset,sequence,l,rlmode,skiphash) |
| 24939 |
if d then |
| 24940 |
return h,s,d |
| 24941 |
end |
| 24942 |
end |
| 24943 |
end |
| 24944 |
end |
| 24945 |
return head,start,false |
| 24946 |
end |
| 24947 |
chainprocs.gsub_context=chained_contextchain |
| 24948 |
chainprocs.gsub_contextchain=chained_contextchain |
| 24949 |
chainprocs.gsub_reversecontextchain=chained_contextchain |
| 24950 |
chainprocs.gpos_contextchain=chained_contextchain |
| 24951 |
chainprocs.gpos_context=chained_contextchain |
| 24952 |
local missing=setmetatableindex("table") |
| 24953 |
local logwarning=report_process |
| 24954 |
local resolved={} |
| 24955 |
local function logprocess(...) |
| 24956 |
if trace_steps then |
| 24957 |
registermessage(...) |
| 24958 |
if trace_steps=="silent" then |
| 24959 |
return |
| 24960 |
end |
| 24961 |
end |
| 24962 |
report_process(...) |
| 24963 |
end |
| 24964 |
local sequencelists=setmetatableindex(function(t,font) |
| 24965 |
local sequences=fontdata[font].resources.sequences |
| 24966 |
if not sequences or not next(sequences) then |
| 24967 |
sequences=false |
| 24968 |
end |
| 24969 |
t[font]=sequences |
| 24970 |
return sequences |
| 24971 |
end) |
| 24972 |
do |
| 24973 |
local autofeatures=fonts.analyzers.features |
| 24974 |
local featuretypes=otf.tables.featuretypes |
| 24975 |
local defaultscript=otf.features.checkeddefaultscript |
| 24976 |
local defaultlanguage=otf.features.checkeddefaultlanguage |
| 24977 |
local wildcard="*" |
| 24978 |
local default="dflt" |
| 24979 |
local function initialize(sequence,script,language,enabled,autoscript,autolanguage) |
| 24980 |
local features=sequence.features |
| 24981 |
if features then |
| 24982 |
local order=sequence.order |
| 24983 |
if order then |
| 24984 |
local featuretype=featuretypes[sequence.type or "unknown"] |
| 24985 |
for i=1,#order do |
| 24986 |
local kind=order[i] |
| 24987 |
local valid=enabled[kind] |
| 24988 |
if valid then |
| 24989 |
local scripts=features[kind] |
| 24990 |
local languages=scripts and ( |
| 24991 |
scripts[script] or |
| 24992 |
scripts[wildcard] or |
| 24993 |
(autoscript and defaultscript(featuretype,autoscript,scripts)) |
| 24994 |
) |
| 24995 |
local enabled=languages and ( |
| 24996 |
languages[language] or |
| 24997 |
languages[wildcard] or |
| 24998 |
(autolanguage and defaultlanguage(featuretype,autolanguage,languages)) |
| 24999 |
) |
| 25000 |
if enabled then |
| 25001 |
return { valid,autofeatures[kind] or false,sequence,kind } |
| 25002 |
end |
| 25003 |
end |
| 25004 |
end |
| 25005 |
else |
| 25006 |
end |
| 25007 |
end |
| 25008 |
return false |
| 25009 |
end |
| 25010 |
function otf.dataset(tfmdata,font) |
| 25011 |
local shared=tfmdata.shared |
| 25012 |
local properties=tfmdata.properties |
| 25013 |
local language=properties.language or "dflt" |
| 25014 |
local script=properties.script or "dflt" |
| 25015 |
local enabled=shared.features |
| 25016 |
local autoscript=enabled and enabled.autoscript |
| 25017 |
local autolanguage=enabled and enabled.autolanguage |
| 25018 |
local res=resolved[font] |
| 25019 |
if not res then |
| 25020 |
res={} |
| 25021 |
resolved[font]=res |
| 25022 |
end |
| 25023 |
local rs=res[script] |
| 25024 |
if not rs then |
| 25025 |
rs={} |
| 25026 |
res[script]=rs |
| 25027 |
end |
| 25028 |
local rl=rs[language] |
| 25029 |
if not rl then |
| 25030 |
rl={ |
| 25031 |
} |
| 25032 |
rs[language]=rl |
| 25033 |
local sequences=tfmdata.resources.sequences |
| 25034 |
if sequences then |
| 25035 |
for s=1,#sequences do |
| 25036 |
local v=enabled and initialize(sequences[s],script,language,enabled,autoscript,autolanguage) |
| 25037 |
if v then |
| 25038 |
rl[#rl+1]=v |
| 25039 |
end |
| 25040 |
end |
| 25041 |
end |
| 25042 |
end |
| 25043 |
return rl |
| 25044 |
end |
| 25045 |
end |
| 25046 |
local function report_disc(what,n) |
| 25047 |
report_run("%s: %s > %s",what,n,languages.serializediscretionary(n)) |
| 25048 |
end |
| 25049 |
local function kernrun(disc,k_run,font,attr,...) |
| 25050 |
if trace_kernruns then |
| 25051 |
report_disc("kern",disc) |
| 25052 |
end |
| 25053 |
local prev,next=getboth(disc) |
| 25054 |
local nextstart=next |
| 25055 |
local done=false |
| 25056 |
local pre,post,replace,pretail,posttail,replacetail=getdisc(disc,true) |
| 25057 |
local prevmarks=prev |
| 25058 |
while prevmarks do |
| 25059 |
local char=ischar(prevmarks,font) |
| 25060 |
if char and marks[char] then |
| 25061 |
prevmarks=getprev(prevmarks) |
| 25062 |
else |
| 25063 |
break |
| 25064 |
end |
| 25065 |
end |
| 25066 |
if prev and not ischar(prev,font) then |
| 25067 |
prev=false |
| 25068 |
end |
| 25069 |
if next and not ischar(next,font) then |
| 25070 |
next=false |
| 25071 |
end |
| 25072 |
if pre then |
| 25073 |
if k_run(pre,"injections",nil,font,attr,...) then |
| 25074 |
done=true |
| 25075 |
end |
| 25076 |
if prev then |
| 25077 |
setlink(prev,pre) |
| 25078 |
if k_run(prevmarks,"preinjections",pre,font,attr,...) then |
| 25079 |
done=true |
| 25080 |
end |
| 25081 |
setprev(pre) |
| 25082 |
setlink(prev,disc) |
| 25083 |
end |
| 25084 |
end |
| 25085 |
if post then |
| 25086 |
if k_run(post,"injections",nil,font,attr,...) then |
| 25087 |
done=true |
| 25088 |
end |
| 25089 |
if next then |
| 25090 |
setlink(posttail,next) |
| 25091 |
if k_run(posttail,"postinjections",next,font,attr,...) then |
| 25092 |
done=true |
| 25093 |
end |
| 25094 |
setnext(posttail) |
| 25095 |
setlink(disc,next) |
| 25096 |
end |
| 25097 |
end |
| 25098 |
if replace then |
| 25099 |
if k_run(replace,"injections",nil,font,attr,...) then |
| 25100 |
done=true |
| 25101 |
end |
| 25102 |
if prev then |
| 25103 |
setlink(prev,replace) |
| 25104 |
if k_run(prevmarks,"replaceinjections",replace,font,attr,...) then |
| 25105 |
done=true |
| 25106 |
end |
| 25107 |
setprev(replace) |
| 25108 |
setlink(prev,disc) |
| 25109 |
end |
| 25110 |
if next then |
| 25111 |
setlink(replacetail,next) |
| 25112 |
if k_run(replacetail,"replaceinjections",next,font,attr,...) then |
| 25113 |
done=true |
| 25114 |
end |
| 25115 |
setnext(replacetail) |
| 25116 |
setlink(disc,next) |
| 25117 |
end |
| 25118 |
elseif prev and next then |
| 25119 |
setlink(prev,next) |
| 25120 |
if k_run(prevmarks,"emptyinjections",next,font,attr,...) then |
| 25121 |
done=true |
| 25122 |
end |
| 25123 |
setlink(prev,disc,next) |
| 25124 |
end |
| 25125 |
if done and trace_testruns then |
| 25126 |
report_disc("done",disc) |
| 25127 |
end |
| 25128 |
return nextstart |
| 25129 |
end |
| 25130 |
local function comprun(disc,c_run,...) |
| 25131 |
if trace_compruns then |
| 25132 |
report_disc("comp",disc) |
| 25133 |
end |
| 25134 |
local pre,post,replace=getdisc(disc) |
| 25135 |
local renewed=false |
| 25136 |
if pre then |
| 25137 |
sweepnode=disc |
| 25138 |
sweeptype="pre" |
| 25139 |
local new,done=c_run(pre,...) |
| 25140 |
if done then |
| 25141 |
pre=new |
| 25142 |
renewed=true |
| 25143 |
end |
| 25144 |
end |
| 25145 |
if post then |
| 25146 |
sweepnode=disc |
| 25147 |
sweeptype="post" |
| 25148 |
local new,done=c_run(post,...) |
| 25149 |
if done then |
| 25150 |
post=new |
| 25151 |
renewed=true |
| 25152 |
end |
| 25153 |
end |
| 25154 |
if replace then |
| 25155 |
sweepnode=disc |
| 25156 |
sweeptype="replace" |
| 25157 |
local new,done=c_run(replace,...) |
| 25158 |
if done then |
| 25159 |
replace=new |
| 25160 |
renewed=true |
| 25161 |
end |
| 25162 |
end |
| 25163 |
sweepnode=nil |
| 25164 |
sweeptype=nil |
| 25165 |
if renewed then |
| 25166 |
if trace_testruns then |
| 25167 |
report_disc("done",disc) |
| 25168 |
end |
| 25169 |
setdisc(disc,pre,post,replace) |
| 25170 |
end |
| 25171 |
return getnext(disc) |
| 25172 |
end |
| 25173 |
local test_flatten_start=2 |
| 25174 |
directives.register("otf.testrun.forceflatten",function(v) |
| 25175 |
test_flatten_start=v and 1 or 2 |
| 25176 |
end) |
| 25177 |
local function testrun(disc,t_run,c_run,...) |
| 25178 |
if trace_testruns then |
| 25179 |
report_disc("test",disc) |
| 25180 |
end |
| 25181 |
local prev,next=getboth(disc) |
| 25182 |
if not next then |
| 25183 |
return |
| 25184 |
end |
| 25185 |
local pre,post,replace,pretail,posttail,replacetail=getdisc(disc,true) |
| 25186 |
local renewed=false |
| 25187 |
if post or replace then |
| 25188 |
if post then |
| 25189 |
setlink(posttail,next) |
| 25190 |
else |
| 25191 |
post=next |
| 25192 |
end |
| 25193 |
if replace then |
| 25194 |
setlink(replacetail,next) |
| 25195 |
else |
| 25196 |
replace=next |
| 25197 |
end |
| 25198 |
local d_post=t_run(post,next,...) |
| 25199 |
local d_replace=t_run(replace,next,...) |
| 25200 |
if d_post>0 or d_replace>0 then |
| 25201 |
local d=d_replace>d_post and d_replace or d_post |
| 25202 |
local head=getnext(disc) |
| 25203 |
local tail=head |
| 25204 |
for i=test_flatten_start,d do |
| 25205 |
local nx=getnext(tail) |
| 25206 |
local id=getid(nx) |
| 25207 |
if id==disc_code then |
| 25208 |
head,tail=flattendisk(head,nx) |
| 25209 |
elseif id==glyph_code then |
| 25210 |
tail=nx |
| 25211 |
else |
| 25212 |
break |
| 25213 |
end |
| 25214 |
end |
| 25215 |
next=getnext(tail) |
| 25216 |
setnext(tail) |
| 25217 |
setprev(head) |
| 25218 |
local new=copynodelist(head) |
| 25219 |
if posttail then |
| 25220 |
setlink(posttail,head) |
| 25221 |
else |
| 25222 |
post=head |
| 25223 |
end |
| 25224 |
if replacetail then |
| 25225 |
setlink(replacetail,new) |
| 25226 |
else |
| 25227 |
replace=new |
| 25228 |
end |
| 25229 |
else |
| 25230 |
if posttail then |
| 25231 |
setnext(posttail) |
| 25232 |
else |
| 25233 |
post=nil |
| 25234 |
end |
| 25235 |
if replacetail then |
| 25236 |
setnext(replacetail) |
| 25237 |
else |
| 25238 |
replace=nil |
| 25239 |
end |
| 25240 |
end |
| 25241 |
setlink(disc,next) |
| 25242 |
end |
| 25243 |
if trace_testruns then |
| 25244 |
report_disc("more",disc) |
| 25245 |
end |
| 25246 |
if pre then |
| 25247 |
sweepnode=disc |
| 25248 |
sweeptype="pre" |
| 25249 |
local new,ok=c_run(pre,...) |
| 25250 |
if ok then |
| 25251 |
pre=new |
| 25252 |
renewed=true |
| 25253 |
end |
| 25254 |
end |
| 25255 |
if post then |
| 25256 |
sweepnode=disc |
| 25257 |
sweeptype="post" |
| 25258 |
local new,ok=c_run(post,...) |
| 25259 |
if ok then |
| 25260 |
post=new |
| 25261 |
renewed=true |
| 25262 |
end |
| 25263 |
end |
| 25264 |
if replace then |
| 25265 |
sweepnode=disc |
| 25266 |
sweeptype="replace" |
| 25267 |
local new,ok=c_run(replace,...) |
| 25268 |
if ok then |
| 25269 |
replace=new |
| 25270 |
renewed=true |
| 25271 |
end |
| 25272 |
end |
| 25273 |
sweepnode=nil |
| 25274 |
sweeptype=nil |
| 25275 |
if renewed then |
| 25276 |
setdisc(disc,pre,post,replace) |
| 25277 |
if trace_testruns then |
| 25278 |
report_disc("done",disc) |
| 25279 |
end |
| 25280 |
end |
| 25281 |
return getnext(disc) |
| 25282 |
end |
| 25283 |
local nesting=0 |
| 25284 |
local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) |
| 25285 |
local done=false |
| 25286 |
local sweep=sweephead[head] |
| 25287 |
local start |
| 25288 |
if sweep then |
| 25289 |
start=sweep |
| 25290 |
sweephead[head]=false |
| 25291 |
else |
| 25292 |
start=head |
| 25293 |
end |
| 25294 |
while start do |
| 25295 |
local char,id=ischar(start,font) |
| 25296 |
if char then |
| 25297 |
local a |
| 25298 |
if attr then |
| 25299 |
a=getglyphdata(start) |
| 25300 |
end |
| 25301 |
if not a or (a==attr) then |
| 25302 |
local lookupmatch=lookupcache[char] |
| 25303 |
if lookupmatch then |
| 25304 |
local ok |
| 25305 |
head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) |
| 25306 |
if ok then |
| 25307 |
done=true |
| 25308 |
end |
| 25309 |
end |
| 25310 |
if start then |
| 25311 |
start=getnext(start) |
| 25312 |
end |
| 25313 |
else |
| 25314 |
start=getnext(start) |
| 25315 |
end |
| 25316 |
elseif char==false then |
| 25317 |
return head,done |
| 25318 |
elseif sweep then |
| 25319 |
return head,done |
| 25320 |
else |
| 25321 |
start=getnext(start) |
| 25322 |
end |
| 25323 |
end |
| 25324 |
return head,done |
| 25325 |
end |
| 25326 |
local function t_run_single(start,stop,font,attr,lookupcache) |
| 25327 |
local lastd=nil |
| 25328 |
while start~=stop do |
| 25329 |
local char=ischar(start,font) |
| 25330 |
if char then |
| 25331 |
local a |
| 25332 |
if attr then |
| 25333 |
a=getglyphdata(start) |
| 25334 |
end |
| 25335 |
local startnext=getnext(start) |
| 25336 |
if not a or (a==attr) then |
| 25337 |
local lookupmatch=lookupcache[char] |
| 25338 |
if lookupmatch then |
| 25339 |
local s=startnext |
| 25340 |
local ss=nil |
| 25341 |
local sstop=s==stop |
| 25342 |
if not s then |
| 25343 |
s=ss |
| 25344 |
ss=nil |
| 25345 |
end |
| 25346 |
while getid(s)==disc_code do |
| 25347 |
ss=getnext(s) |
| 25348 |
s=getreplace(s) |
| 25349 |
if not s then |
| 25350 |
s=ss |
| 25351 |
ss=nil |
| 25352 |
end |
| 25353 |
end |
| 25354 |
local l=nil |
| 25355 |
local d=0 |
| 25356 |
while s do |
| 25357 |
local char=ischar(s,font) |
| 25358 |
if char then |
| 25359 |
local lg=not tonumber(lookupmatch) and lookupmatch[char] |
| 25360 |
if lg then |
| 25361 |
if sstop then |
| 25362 |
d=1 |
| 25363 |
elseif d>0 then |
| 25364 |
d=d+1 |
| 25365 |
end |
| 25366 |
l=lg |
| 25367 |
s=getnext(s) |
| 25368 |
sstop=s==stop |
| 25369 |
if not s then |
| 25370 |
s=ss |
| 25371 |
ss=nil |
| 25372 |
end |
| 25373 |
while getid(s)==disc_code do |
| 25374 |
ss=getnext(s) |
| 25375 |
s=getreplace(s) |
| 25376 |
if not s then |
| 25377 |
s=ss |
| 25378 |
ss=nil |
| 25379 |
end |
| 25380 |
end |
| 25381 |
lookupmatch=lg |
| 25382 |
else |
| 25383 |
break |
| 25384 |
end |
| 25385 |
else |
| 25386 |
break |
| 25387 |
end |
| 25388 |
end |
| 25389 |
if l and (tonumber(l) or l.ligature) then |
| 25390 |
lastd=d |
| 25391 |
end |
| 25392 |
else |
| 25393 |
end |
| 25394 |
else |
| 25395 |
end |
| 25396 |
if lastd then |
| 25397 |
return lastd |
| 25398 |
end |
| 25399 |
start=startnext |
| 25400 |
else |
| 25401 |
break |
| 25402 |
end |
| 25403 |
end |
| 25404 |
return 0 |
| 25405 |
end |
| 25406 |
local function k_run_single(sub,injection,last,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) |
| 25407 |
local a |
| 25408 |
if attr then |
| 25409 |
a=getglyphdata(sub) |
| 25410 |
end |
| 25411 |
if not a or (a==attr) then |
| 25412 |
for n in nextnode,sub do |
| 25413 |
if n==last then |
| 25414 |
break |
| 25415 |
end |
| 25416 |
local char=ischar(n,font) |
| 25417 |
if char then |
| 25418 |
local lookupmatch=lookupcache[char] |
| 25419 |
if lookupmatch then |
| 25420 |
local h,d,ok=handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection) |
| 25421 |
if ok then |
| 25422 |
return true |
| 25423 |
end |
| 25424 |
end |
| 25425 |
end |
| 25426 |
end |
| 25427 |
end |
| 25428 |
end |
| 25429 |
local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) |
| 25430 |
local done=false |
| 25431 |
local sweep=sweephead[head] |
| 25432 |
local start |
| 25433 |
if sweep then |
| 25434 |
start=sweep |
| 25435 |
sweephead[head]=false |
| 25436 |
else |
| 25437 |
start=head |
| 25438 |
end |
| 25439 |
while start do |
| 25440 |
local char=ischar(start,font) |
| 25441 |
if char then |
| 25442 |
local a |
| 25443 |
if attr then |
| 25444 |
a=getglyphdata(start) |
| 25445 |
end |
| 25446 |
if not a or (a==attr) then |
| 25447 |
for i=1,nofsteps do |
| 25448 |
local step=steps[i] |
| 25449 |
local lookupcache=step.coverage |
| 25450 |
local lookupmatch=lookupcache[char] |
| 25451 |
if lookupmatch then |
| 25452 |
local ok |
| 25453 |
head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) |
| 25454 |
if ok then |
| 25455 |
done=true |
| 25456 |
break |
| 25457 |
elseif not start then |
| 25458 |
break |
| 25459 |
end |
| 25460 |
end |
| 25461 |
end |
| 25462 |
if start then |
| 25463 |
start=getnext(start) |
| 25464 |
end |
| 25465 |
else |
| 25466 |
start=getnext(start) |
| 25467 |
end |
| 25468 |
elseif char==false then |
| 25469 |
return head,done |
| 25470 |
elseif sweep then |
| 25471 |
return head,done |
| 25472 |
else |
| 25473 |
start=getnext(start) |
| 25474 |
end |
| 25475 |
end |
| 25476 |
return head,done |
| 25477 |
end |
| 25478 |
local function t_run_multiple(start,stop,font,attr,steps,nofsteps) |
| 25479 |
local lastd=nil |
| 25480 |
while start~=stop do |
| 25481 |
local char=ischar(start,font) |
| 25482 |
if char then |
| 25483 |
local a |
| 25484 |
if attr then |
| 25485 |
a=getglyphdata(start) |
| 25486 |
end |
| 25487 |
local startnext=getnext(start) |
| 25488 |
if not a or (a==attr) then |
| 25489 |
for i=1,nofsteps do |
| 25490 |
local step=steps[i] |
| 25491 |
local lookupcache=step.coverage |
| 25492 |
local lookupmatch=lookupcache[char] |
| 25493 |
if lookupmatch then |
| 25494 |
local s=startnext |
| 25495 |
local ss=nil |
| 25496 |
local sstop=s==stop |
| 25497 |
if not s then |
| 25498 |
s=ss |
| 25499 |
ss=nil |
| 25500 |
end |
| 25501 |
while getid(s)==disc_code do |
| 25502 |
ss=getnext(s) |
| 25503 |
s=getreplace(s) |
| 25504 |
if not s then |
| 25505 |
s=ss |
| 25506 |
ss=nil |
| 25507 |
end |
| 25508 |
end |
| 25509 |
local l=nil |
| 25510 |
local d=0 |
| 25511 |
while s do |
| 25512 |
local char=ischar(s) |
| 25513 |
if char then |
| 25514 |
local lg=not tonumber(lookupmatch) and lookupmatch[char] |
| 25515 |
if lg then |
| 25516 |
if sstop then |
| 25517 |
d=1 |
| 25518 |
elseif d>0 then |
| 25519 |
d=d+1 |
| 25520 |
end |
| 25521 |
l=lg |
| 25522 |
s=getnext(s) |
| 25523 |
sstop=s==stop |
| 25524 |
if not s then |
| 25525 |
s=ss |
| 25526 |
ss=nil |
| 25527 |
end |
| 25528 |
while getid(s)==disc_code do |
| 25529 |
ss=getnext(s) |
| 25530 |
s=getreplace(s) |
| 25531 |
if not s then |
| 25532 |
s=ss |
| 25533 |
ss=nil |
| 25534 |
end |
| 25535 |
end |
| 25536 |
lookupmatch=lg |
| 25537 |
else |
| 25538 |
break |
| 25539 |
end |
| 25540 |
else |
| 25541 |
break |
| 25542 |
end |
| 25543 |
end |
| 25544 |
if l and (tonumber(l) or l.ligature) then |
| 25545 |
lastd=d |
| 25546 |
end |
| 25547 |
end |
| 25548 |
end |
| 25549 |
else |
| 25550 |
end |
| 25551 |
if lastd then |
| 25552 |
return lastd |
| 25553 |
end |
| 25554 |
start=startnext |
| 25555 |
else |
| 25556 |
break |
| 25557 |
end |
| 25558 |
end |
| 25559 |
return 0 |
| 25560 |
end |
| 25561 |
local function k_run_multiple(sub,injection,last,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) |
| 25562 |
local a |
| 25563 |
if attr then |
| 25564 |
a=getglyphdata(sub) |
| 25565 |
end |
| 25566 |
if not a or (a==attr) then |
| 25567 |
for n in nextnode,sub do |
| 25568 |
if n==last then |
| 25569 |
break |
| 25570 |
end |
| 25571 |
local char=ischar(n) |
| 25572 |
if char then |
| 25573 |
for i=1,nofsteps do |
| 25574 |
local step=steps[i] |
| 25575 |
local lookupcache=step.coverage |
| 25576 |
local lookupmatch=lookupcache[char] |
| 25577 |
if lookupmatch then |
| 25578 |
local h,d,ok=handler(sub,n,dataset,sequence,lookupmatch,rlmode,skiphash,step,injection) |
| 25579 |
if ok then |
| 25580 |
return true |
| 25581 |
end |
| 25582 |
end |
| 25583 |
end |
| 25584 |
end |
| 25585 |
end |
| 25586 |
end |
| 25587 |
end |
| 25588 |
local txtdirstate,pardirstate do |
| 25589 |
local getdirection=nuts.getdirection |
| 25590 |
txtdirstate=function(start,stack,top,rlparmode) |
| 25591 |
local dir,pop=getdirection(start) |
| 25592 |
if pop then |
| 25593 |
if top==1 then |
| 25594 |
return 0,rlparmode |
| 25595 |
else |
| 25596 |
top=top-1 |
| 25597 |
if stack[top]==righttoleft_code then |
| 25598 |
return top,-1 |
| 25599 |
else |
| 25600 |
return top,1 |
| 25601 |
end |
| 25602 |
end |
| 25603 |
elseif dir==lefttoright_code then |
| 25604 |
top=top+1 |
| 25605 |
stack[top]=lefttoright_code |
| 25606 |
return top,1 |
| 25607 |
elseif dir==righttoleft_code then |
| 25608 |
top=top+1 |
| 25609 |
stack[top]=righttoleft_code |
| 25610 |
return top,-1 |
| 25611 |
else |
| 25612 |
return top,rlparmode |
| 25613 |
end |
| 25614 |
end |
| 25615 |
pardirstate=function(start) |
| 25616 |
local dir=getdirection(start) |
| 25617 |
if dir==lefttoright_code then |
| 25618 |
return 1,1 |
| 25619 |
elseif dir==righttoleft_code then |
| 25620 |
return -1,-1 |
| 25621 |
else |
| 25622 |
return 0,0 |
| 25623 |
end |
| 25624 |
end |
| 25625 |
end |
| 25626 |
otf.helpers=otf.helpers or {} |
| 25627 |
otf.helpers.txtdirstate=txtdirstate |
| 25628 |
otf.helpers.pardirstate=pardirstate |
| 25629 |
do |
| 25630 |
local fastdisc=true |
| 25631 |
local testdics=false |
| 25632 |
directives.register("otf.fastdisc",function(v) fastdisc=v end) |
| 25633 |
local otfdataset=nil |
| 25634 |
local getfastdisc={ __index=function(t,k) |
| 25635 |
local v=usesfont(k,currentfont) |
| 25636 |
t[k]=v |
| 25637 |
return v |
| 25638 |
end } |
| 25639 |
local getfastspace={ __index=function(t,k) |
| 25640 |
local v=isspace(k,threshold) or false |
| 25641 |
t[k]=v |
| 25642 |
return v |
| 25643 |
end } |
| 25644 |
function otf.featuresprocessor(head,font,attr,direction,n) |
| 25645 |
local sequences=sequencelists[font] |
| 25646 |
nesting=nesting+1 |
| 25647 |
if nesting==1 then |
| 25648 |
currentfont=font |
| 25649 |
tfmdata=fontdata[font] |
| 25650 |
descriptions=tfmdata.descriptions |
| 25651 |
characters=tfmdata.characters |
| 25652 |
local resources=tfmdata.resources |
| 25653 |
marks=resources.marks |
| 25654 |
classes=resources.classes |
| 25655 |
threshold, |
| 25656 |
factor=getthreshold(font) |
| 25657 |
checkmarks=tfmdata.properties.checkmarks |
| 25658 |
if not otfdataset then |
| 25659 |
otfdataset=otf.dataset |
| 25660 |
end |
| 25661 |
discs=fastdisc and n and n>1 and setmetatable({},getfastdisc) |
| 25662 |
spaces=setmetatable({},getfastspace) |
| 25663 |
elseif currentfont~=font then |
| 25664 |
report_warning("nested call with a different font, level %s, quitting",nesting) |
| 25665 |
nesting=nesting-1 |
| 25666 |
return head,false |
| 25667 |
end |
| 25668 |
if trace_steps then |
| 25669 |
checkstep(head) |
| 25670 |
end |
| 25671 |
local initialrl=0 |
| 25672 |
if getid(head)==par_code and startofpar(head) then |
| 25673 |
initialrl=pardirstate(head) |
| 25674 |
elseif direction==righttoleft_code then |
| 25675 |
initialrl=-1 |
| 25676 |
end |
| 25677 |
local datasets=otfdataset(tfmdata,font,attr) |
| 25678 |
local dirstack={ nil } |
| 25679 |
sweephead={} |
| 25680 |
for s=1,#datasets do |
| 25681 |
local dataset=datasets[s] |
| 25682 |
local attribute=dataset[2] |
| 25683 |
local sequence=dataset[3] |
| 25684 |
local rlparmode=initialrl |
| 25685 |
local topstack=0 |
| 25686 |
local typ=sequence.type |
| 25687 |
local gpossing=typ=="gpos_single" or typ=="gpos_pair" |
| 25688 |
local forcetestrun=typ=="gsub_ligature" |
| 25689 |
local handler=handlers[typ] |
| 25690 |
local steps=sequence.steps |
| 25691 |
local nofsteps=sequence.nofsteps |
| 25692 |
local skiphash=sequence.skiphash |
| 25693 |
if not steps then |
| 25694 |
local h,ok=handler(head,dataset,sequence,initialrl,font,attr) |
| 25695 |
if h and h~=head then |
| 25696 |
head=h |
| 25697 |
end |
| 25698 |
elseif typ=="gsub_reversecontextchain" then |
| 25699 |
local start=findnodetail(head) |
| 25700 |
local rlmode=0 |
| 25701 |
local merged=steps.merged |
| 25702 |
while start do |
| 25703 |
local char=ischar(start,font) |
| 25704 |
if char then |
| 25705 |
local m=merged[char] |
| 25706 |
if m then |
| 25707 |
local a |
| 25708 |
if attr then |
| 25709 |
a=getglyphdata(start) |
| 25710 |
end |
| 25711 |
if not a or (a==attr) then |
| 25712 |
for i=m[1],m[2] do |
| 25713 |
local step=steps[i] |
| 25714 |
local lookupcache=step.coverage |
| 25715 |
local lookupmatch=lookupcache[char] |
| 25716 |
if lookupmatch then |
| 25717 |
local ok |
| 25718 |
head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) |
| 25719 |
if ok then |
| 25720 |
break |
| 25721 |
end |
| 25722 |
end |
| 25723 |
end |
| 25724 |
if start then |
| 25725 |
start=getprev(start) |
| 25726 |
end |
| 25727 |
else |
| 25728 |
start=getprev(start) |
| 25729 |
end |
| 25730 |
else |
| 25731 |
start=getprev(start) |
| 25732 |
end |
| 25733 |
else |
| 25734 |
start=getprev(start) |
| 25735 |
end |
| 25736 |
end |
| 25737 |
else |
| 25738 |
local start=head |
| 25739 |
local rlmode=initialrl |
| 25740 |
if nofsteps==1 then |
| 25741 |
local step=steps[1] |
| 25742 |
local lookupcache=step.coverage |
| 25743 |
while start do |
| 25744 |
local char,id=ischar(start,font) |
| 25745 |
if char then |
| 25746 |
local lookupmatch=lookupcache[char] |
| 25747 |
if lookupmatch then |
| 25748 |
local a |
| 25749 |
if attr then |
| 25750 |
if getglyphdata(start)==attr and (not attribute or getstate(start,attribute)) then |
| 25751 |
a=true |
| 25752 |
end |
| 25753 |
elseif not attribute or getstate(start,attribute) then |
| 25754 |
a=true |
| 25755 |
end |
| 25756 |
if a then |
| 25757 |
local ok,df |
| 25758 |
head,start,ok,df=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) |
| 25759 |
if df then |
| 25760 |
elseif start then |
| 25761 |
start=getnext(start) |
| 25762 |
end |
| 25763 |
else |
| 25764 |
start=getnext(start) |
| 25765 |
end |
| 25766 |
else |
| 25767 |
start=getnext(start) |
| 25768 |
end |
| 25769 |
elseif char==false or id==glue_code then |
| 25770 |
start=getnext(start) |
| 25771 |
elseif id==disc_code then |
| 25772 |
if not discs or discs[start]==true then |
| 25773 |
if gpossing then |
| 25774 |
start=kernrun(start,k_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) |
| 25775 |
elseif forcetestrun then |
| 25776 |
start=testrun(start,t_run_single,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) |
| 25777 |
else |
| 25778 |
start=comprun(start,c_run_single,font,attr,lookupcache,step,dataset,sequence,rlmode,skiphash,handler) |
| 25779 |
end |
| 25780 |
else |
| 25781 |
start=getnext(start) |
| 25782 |
end |
| 25783 |
elseif id==math_code then |
| 25784 |
start=getnext(endofmath(start)) |
| 25785 |
elseif id==dir_code then |
| 25786 |
topstack,rlmode=txtdirstate(start,dirstack,topstack,rlparmode) |
| 25787 |
start=getnext(start) |
| 25788 |
else |
| 25789 |
start=getnext(start) |
| 25790 |
end |
| 25791 |
end |
| 25792 |
else |
| 25793 |
local merged=steps.merged |
| 25794 |
while start do |
| 25795 |
local char,id=ischar(start,font) |
| 25796 |
if char then |
| 25797 |
local m=merged[char] |
| 25798 |
if m then |
| 25799 |
local a |
| 25800 |
if attr then |
| 25801 |
if getglyphdata(start)==attr and (not attribute or getstate(start,attribute)) then |
| 25802 |
a=true |
| 25803 |
end |
| 25804 |
elseif not attribute or getstate(start,attribute) then |
| 25805 |
a=true |
| 25806 |
end |
| 25807 |
if a then |
| 25808 |
local ok,df |
| 25809 |
for i=m[1],m[2] do |
| 25810 |
local step=steps[i] |
| 25811 |
local lookupcache=step.coverage |
| 25812 |
local lookupmatch=lookupcache[char] |
| 25813 |
if lookupmatch then |
| 25814 |
head,start,ok,df=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) |
| 25815 |
if df then |
| 25816 |
break |
| 25817 |
elseif ok then |
| 25818 |
break |
| 25819 |
elseif not start then |
| 25820 |
break |
| 25821 |
end |
| 25822 |
end |
| 25823 |
end |
| 25824 |
if df then |
| 25825 |
elseif start then |
| 25826 |
start=getnext(start) |
| 25827 |
end |
| 25828 |
else |
| 25829 |
start=getnext(start) |
| 25830 |
end |
| 25831 |
else |
| 25832 |
start=getnext(start) |
| 25833 |
end |
| 25834 |
elseif char==false or id==glue_code then |
| 25835 |
start=getnext(start) |
| 25836 |
elseif id==disc_code then |
| 25837 |
if not discs or discs[start]==true then |
| 25838 |
if gpossing then |
| 25839 |
start=kernrun(start,k_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) |
| 25840 |
elseif forcetestrun then |
| 25841 |
start=testrun(start,t_run_multiple,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) |
| 25842 |
else |
| 25843 |
start=comprun(start,c_run_multiple,font,attr,steps,nofsteps,dataset,sequence,rlmode,skiphash,handler) |
| 25844 |
end |
| 25845 |
else |
| 25846 |
start=getnext(start) |
| 25847 |
end |
| 25848 |
elseif id==math_code then |
| 25849 |
start=getnext(endofmath(start)) |
| 25850 |
elseif id==dir_code then |
| 25851 |
topstack,rlmode=txtdirstate(start,dirstack,topstack,rlparmode) |
| 25852 |
start=getnext(start) |
| 25853 |
else |
| 25854 |
start=getnext(start) |
| 25855 |
end |
| 25856 |
end |
| 25857 |
end |
| 25858 |
end |
| 25859 |
if trace_steps then |
| 25860 |
registerstep(head) |
| 25861 |
end |
| 25862 |
end |
| 25863 |
nesting=nesting-1 |
| 25864 |
return head |
| 25865 |
end |
| 25866 |
function otf.datasetpositionprocessor(head,font,direction,dataset) |
| 25867 |
currentfont=font |
| 25868 |
tfmdata=fontdata[font] |
| 25869 |
descriptions=tfmdata.descriptions |
| 25870 |
characters=tfmdata.characters |
| 25871 |
local resources=tfmdata.resources |
| 25872 |
marks=resources.marks |
| 25873 |
classes=resources.classes |
| 25874 |
threshold, |
| 25875 |
factor=getthreshold(font) |
| 25876 |
checkmarks=tfmdata.properties.checkmarks |
| 25877 |
if type(dataset)=="number" then |
| 25878 |
dataset=otfdataset(tfmdata,font,0)[dataset] |
| 25879 |
end |
| 25880 |
local sequence=dataset[3] |
| 25881 |
local typ=sequence.type |
| 25882 |
local handler=handlers[typ] |
| 25883 |
local steps=sequence.steps |
| 25884 |
local nofsteps=sequence.nofsteps |
| 25885 |
local done=false |
| 25886 |
local dirstack={ nil } |
| 25887 |
local start=head |
| 25888 |
local initialrl=(direction==righttoleft_code) and -1 or 0 |
| 25889 |
local rlmode=initialrl |
| 25890 |
local rlparmode=initialrl |
| 25891 |
local topstack=0 |
| 25892 |
local merged=steps.merged |
| 25893 |
local position=0 |
| 25894 |
while start do |
| 25895 |
local char,id=ischar(start,font) |
| 25896 |
if char then |
| 25897 |
position=position+1 |
| 25898 |
local m=merged[char] |
| 25899 |
if m then |
| 25900 |
for i=m[1],m[2] do |
| 25901 |
local step=steps[i] |
| 25902 |
local lookupcache=step.coverage |
| 25903 |
local lookupmatch=lookupcache[char] |
| 25904 |
if lookupmatch then |
| 25905 |
local ok |
| 25906 |
head,start,ok=handler(head,start,dataset,sequence,lookupmatch,rlmode,skiphash,step) |
| 25907 |
if ok then |
| 25908 |
break |
| 25909 |
elseif not start then |
| 25910 |
break |
| 25911 |
end |
| 25912 |
end |
| 25913 |
end |
| 25914 |
if start then |
| 25915 |
start=getnext(start) |
| 25916 |
end |
| 25917 |
else |
| 25918 |
start=getnext(start) |
| 25919 |
end |
| 25920 |
elseif char==false or id==glue_code then |
| 25921 |
start=getnext(start) |
| 25922 |
elseif id==math_code then |
| 25923 |
start=getnext(endofmath(start)) |
| 25924 |
elseif id==dir_code then |
| 25925 |
topstack,rlmode=txtdirstate(start,dirstack,topstack,rlparmode) |
| 25926 |
start=getnext(start) |
| 25927 |
else |
| 25928 |
start=getnext(start) |
| 25929 |
end |
| 25930 |
end |
| 25931 |
return head |
| 25932 |
end |
| 25933 |
end |
| 25934 |
do |
| 25935 |
local plugins={} |
| 25936 |
otf.plugins=plugins |
| 25937 |
local report=logs.reporter("fonts") |
| 25938 |
local warned=false |
| 25939 |
local okay={ text=true } |
| 25940 |
function otf.registerplugin(name,f) |
| 25941 |
if type(name)=="string" and type(f)=="function" then |
| 25942 |
plugins[name]={ name,f } |
| 25943 |
if okay[name] then |
| 25944 |
else |
| 25945 |
report("plugin %a has been loaded, please be aware of possible side effects",name) |
| 25946 |
if not warned then |
| 25947 |
if logs.pushtarget then |
| 25948 |
logs.pushtarget("log") |
| 25949 |
end |
| 25950 |
report("Plugins are not officially supported unless stated otherwise. This is because") |
| 25951 |
report("they bypass the regular font handling and therefore some features in ConTeXt") |
| 25952 |
report("(especially those related to fonts) might not work as expected or might not work") |
| 25953 |
report("at all. Some plugins are for testing and development only and might change") |
| 25954 |
report("whenever we feel the need for it.") |
| 25955 |
report() |
| 25956 |
if logs.poptarget then |
| 25957 |
logs.poptarget() |
| 25958 |
end |
| 25959 |
warned=true |
| 25960 |
end |
| 25961 |
end |
| 25962 |
end |
| 25963 |
end |
| 25964 |
function otf.plugininitializer(tfmdata,value) |
| 25965 |
if type(value)=="string" then |
| 25966 |
tfmdata.shared.plugin=plugins[value] |
| 25967 |
end |
| 25968 |
end |
| 25969 |
function otf.pluginprocessor(head,font,dynamic,direction) |
| 25970 |
local s=fontdata[font].shared |
| 25971 |
local p=s and s.plugin |
| 25972 |
if p then |
| 25973 |
if trace_plugins then |
| 25974 |
report_process("applying plugin %a",p[1]) |
| 25975 |
end |
| 25976 |
return p[2](head,font,dynamic,direction) |
| 25977 |
else |
| 25978 |
return head,false |
| 25979 |
end |
| 25980 |
end |
| 25981 |
end |
| 25982 |
function otf.featuresinitializer(tfmdata,value) |
| 25983 |
end |
| 25984 |
registerotffeature { |
| 25985 |
name="features", |
| 25986 |
description="features", |
| 25987 |
default=true, |
| 25988 |
initializers={ |
| 25989 |
position=1, |
| 25990 |
node=otf.featuresinitializer, |
| 25991 |
plug=otf.plugininitializer, |
| 25992 |
}, |
| 25993 |
processors={ |
| 25994 |
node=otf.featuresprocessor, |
| 25995 |
plug=otf.pluginprocessor, |
| 25996 |
} |
| 25997 |
} |
| 25998 |
local function markinitializer(tfmdata,value) |
| 25999 |
local properties=tfmdata.properties |
| 26000 |
properties.checkmarks=value |
| 26001 |
end |
| 26002 |
registerotffeature { |
| 26003 |
name="checkmarks", |
| 26004 |
description="check mark widths", |
| 26005 |
default=true, |
| 26006 |
initializers={ |
| 26007 |
node=markinitializer, |
| 26008 |
}, |
| 26009 |
} |
| 26010 |
otf.handlers=handlers |
| 26011 |
if context then |
| 26012 |
return |
| 26013 |
else |
| 26014 |
end |
| 26015 |
local setspacekerns=nodes.injections.setspacekerns if not setspacekerns then os.exit() end |
| 26016 |
local tag="kern" |
| 26017 |
function handlers.trigger_space_kerns(head,dataset,sequence,initialrl,font,attr) |
| 26018 |
local shared=fontdata[font].shared |
| 26019 |
local features=shared and shared.features |
| 26020 |
local enabled=features and features.spacekern and features[tag] |
| 26021 |
if enabled then |
| 26022 |
setspacekerns(font,sequence) |
| 26023 |
end |
| 26024 |
return head,enabled |
| 26025 |
end |
| 26026 |
local function hasspacekerns(data) |
| 26027 |
local resources=data.resources |
| 26028 |
local sequences=resources.sequences |
| 26029 |
local validgpos=resources.features.gpos |
| 26030 |
if validgpos and sequences then |
| 26031 |
for i=1,#sequences do |
| 26032 |
local sequence=sequences[i] |
| 26033 |
local steps=sequence.steps |
| 26034 |
if steps and sequence.features[tag] then |
| 26035 |
local kind=sequence.type |
| 26036 |
if kind=="gpos_pair" or kind=="gpos_single" then |
| 26037 |
for i=1,#steps do |
| 26038 |
local step=steps[i] |
| 26039 |
local coverage=step.coverage |
| 26040 |
local rules=step.rules |
| 26041 |
if rules then |
| 26042 |
elseif not coverage then |
| 26043 |
elseif kind=="gpos_single" then |
| 26044 |
elseif kind=="gpos_pair" then |
| 26045 |
local format=step.format |
| 26046 |
if format=="move" or format=="kern" then |
| 26047 |
local kerns=coverage[32] |
| 26048 |
if kerns then |
| 26049 |
return true |
| 26050 |
end |
| 26051 |
for k,v in next,coverage do |
| 26052 |
if v[32] then |
| 26053 |
return true |
| 26054 |
end |
| 26055 |
end |
| 26056 |
elseif format=="pair" then |
| 26057 |
local kerns=coverage[32] |
| 26058 |
if kerns then |
| 26059 |
for k,v in next,kerns do |
| 26060 |
local one=v[1] |
| 26061 |
if one and one~=true then |
| 26062 |
return true |
| 26063 |
end |
| 26064 |
end |
| 26065 |
end |
| 26066 |
for k,v in next,coverage do |
| 26067 |
local kern=v[32] |
| 26068 |
if kern then |
| 26069 |
local one=kern[1] |
| 26070 |
if one and one~=true then |
| 26071 |
return true |
| 26072 |
end |
| 26073 |
end |
| 26074 |
end |
| 26075 |
end |
| 26076 |
end |
| 26077 |
end |
| 26078 |
end |
| 26079 |
end |
| 26080 |
end |
| 26081 |
end |
| 26082 |
return false |
| 26083 |
end |
| 26084 |
otf.readers.registerextender { |
| 26085 |
name="spacekerns", |
| 26086 |
action=function(data) |
| 26087 |
data.properties.hasspacekerns=hasspacekerns(data) |
| 26088 |
end |
| 26089 |
} |
| 26090 |
local function spaceinitializer(tfmdata,value) |
| 26091 |
local resources=tfmdata.resources |
| 26092 |
local spacekerns=resources and resources.spacekerns |
| 26093 |
if value and spacekerns==nil then |
| 26094 |
local rawdata=tfmdata.shared and tfmdata.shared.rawdata |
| 26095 |
local properties=rawdata.properties |
| 26096 |
if properties and properties.hasspacekerns then |
| 26097 |
local sequences=resources.sequences |
| 26098 |
local validgpos=resources.features.gpos |
| 26099 |
if validgpos and sequences then |
| 26100 |
local left={} |
| 26101 |
local right={} |
| 26102 |
local last=0 |
| 26103 |
local feat=nil |
| 26104 |
for i=1,#sequences do |
| 26105 |
local sequence=sequences[i] |
| 26106 |
local steps=sequence.steps |
| 26107 |
if steps then |
| 26108 |
local kern=sequence.features[tag] |
| 26109 |
if kern then |
| 26110 |
local kind=sequence.type |
| 26111 |
if kind=="gpos_pair" or kind=="gpos_single" then |
| 26112 |
if feat then |
| 26113 |
for script,languages in next,kern do |
| 26114 |
local f=feat[script] |
| 26115 |
if f then |
| 26116 |
for l in next,languages do |
| 26117 |
f[l]=true |
| 26118 |
end |
| 26119 |
else |
| 26120 |
feat[script]=languages |
| 26121 |
end |
| 26122 |
end |
| 26123 |
else |
| 26124 |
feat=kern |
| 26125 |
end |
| 26126 |
for i=1,#steps do |
| 26127 |
local step=steps[i] |
| 26128 |
local coverage=step.coverage |
| 26129 |
local rules=step.rules |
| 26130 |
if rules then |
| 26131 |
elseif not coverage then |
| 26132 |
elseif kind=="gpos_single" then |
| 26133 |
elseif kind=="gpos_pair" then |
| 26134 |
local format=step.format |
| 26135 |
if format=="move" or format=="kern" then |
| 26136 |
local kerns=coverage[32] |
| 26137 |
if kerns then |
| 26138 |
for k,v in next,kerns do |
| 26139 |
right[k]=v |
| 26140 |
end |
| 26141 |
end |
| 26142 |
for k,v in next,coverage do |
| 26143 |
local kern=v[32] |
| 26144 |
if kern then |
| 26145 |
left[k]=kern |
| 26146 |
end |
| 26147 |
end |
| 26148 |
elseif format=="pair" then |
| 26149 |
local kerns=coverage[32] |
| 26150 |
if kerns then |
| 26151 |
for k,v in next,kerns do |
| 26152 |
local one=v[1] |
| 26153 |
if one and one~=true then |
| 26154 |
right[k]=one[3] |
| 26155 |
end |
| 26156 |
end |
| 26157 |
end |
| 26158 |
for k,v in next,coverage do |
| 26159 |
local kern=v[32] |
| 26160 |
if kern then |
| 26161 |
local one=kern[1] |
| 26162 |
if one and one~=true then |
| 26163 |
left[k]=one[3] |
| 26164 |
end |
| 26165 |
end |
| 26166 |
end |
| 26167 |
end |
| 26168 |
end |
| 26169 |
end |
| 26170 |
last=i |
| 26171 |
end |
| 26172 |
else |
| 26173 |
end |
| 26174 |
end |
| 26175 |
end |
| 26176 |
left=next(left) and left or false |
| 26177 |
right=next(right) and right or false |
| 26178 |
if left or right then |
| 26179 |
spacekerns={ |
| 26180 |
left=left, |
| 26181 |
right=right, |
| 26182 |
} |
| 26183 |
if last>0 then |
| 26184 |
local triggersequence={ |
| 26185 |
features={ [tag]=feat or { dflt={ dflt=true,} } }, |
| 26186 |
flags=noflags, |
| 26187 |
name="trigger_space_kerns", |
| 26188 |
order={ tag }, |
| 26189 |
type="trigger_space_kerns", |
| 26190 |
left=left, |
| 26191 |
right=right, |
| 26192 |
} |
| 26193 |
insert(sequences,last,triggersequence) |
| 26194 |
end |
| 26195 |
end |
| 26196 |
end |
| 26197 |
end |
| 26198 |
resources.spacekerns=spacekerns |
| 26199 |
end |
| 26200 |
return spacekerns |
| 26201 |
end |
| 26202 |
registerotffeature { |
| 26203 |
name="spacekern", |
| 26204 |
description="space kern injection", |
| 26205 |
default=true, |
| 26206 |
initializers={ |
| 26207 |
node=spaceinitializer, |
| 26208 |
}, |
| 26209 |
} |
| 26210 |
|
| 26211 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ots”] --- |
| 26212 |
|
| 26213 |
|
| 26214 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-osd” 837039b0dca88edd3f4b54222f7cf54c] --- |
| 26215 |
|
| 26216 |
if not modules then modules={} end modules ['font-osd']={ |
| 26217 |
version=1.001, |
| 26218 |
comment="companion to font-ini.mkiv", |
| 26219 |
author="Kai Eigner, TAT Zetwerk / Hans Hagen, PRAGMA ADE", |
| 26220 |
copyright="TAT Zetwerk / PRAGMA ADE / ConTeXt Development Team", |
| 26221 |
license="see context related readme files" |
| 26222 |
} |
| 26223 |
local insert,remove,imerge,copy,tohash=table.insert,table.remove,table.imerge,table.copy,table.tohash |
| 26224 |
local next,type,rawget=next,type,rawget |
| 26225 |
local formatters=string.formatters |
| 26226 |
local settings_to_hash=utilities.parsers.settings_to_hash |
| 26227 |
local report=logs.reporter("otf","devanagari") |
| 26228 |
fonts=fonts or {} |
| 26229 |
fonts.analyzers=fonts.analyzers or {} |
| 26230 |
fonts.analyzers.methods=fonts.analyzers.methods or { node={ otf={} } } |
| 26231 |
local otf=fonts.handlers.otf |
| 26232 |
local handlers=otf.handlers |
| 26233 |
local methods=fonts.analyzers.methods |
| 26234 |
local otffeatures=fonts.constructors.features.otf |
| 26235 |
local registerotffeature=otffeatures.register |
| 26236 |
local trace_steps=false |
| 26237 |
local nuts=nodes.nuts |
| 26238 |
local getnext=nuts.getnext |
| 26239 |
local getprev=nuts.getprev |
| 26240 |
local getboth=nuts.getboth |
| 26241 |
local getid=nuts.getid |
| 26242 |
local getchar=nuts.getchar |
| 26243 |
local getfont=nuts.getfont |
| 26244 |
local getsubtype=nuts.getsubtype |
| 26245 |
local setlink=nuts.setlink |
| 26246 |
local setnext=nuts.setnext |
| 26247 |
local setprev=nuts.setprev |
| 26248 |
local setchar=nuts.setchar |
| 26249 |
local getprop=nuts.getprop |
| 26250 |
local setprop=nuts.setprop |
| 26251 |
local getstate=nuts.getstate |
| 26252 |
local setstate=nuts.setstate |
| 26253 |
local ischar=nuts.ischar |
| 26254 |
local insertnodeafter=nuts.insertafter |
| 26255 |
local copy_node=nuts.copy |
| 26256 |
local remove_node=nuts.remove |
| 26257 |
local flushlist=nuts.flushlist |
| 26258 |
local flushnode=nuts.flushnode |
| 26259 |
local copyinjection=nodes.injections.copy |
| 26260 |
local unsetvalue=attributes.unsetvalue |
| 26261 |
local fontdata=fonts.hashes.identifiers |
| 26262 |
local a_syllabe="syllable" |
| 26263 |
local a_reordered="reordered" |
| 26264 |
local dotted_circle=0x25CC |
| 26265 |
local c_nbsp=0x00A0 |
| 26266 |
local c_zwnj=0x200C |
| 26267 |
local c_zwj=0x200D |
| 26268 |
local states=fonts.analyzers.states |
| 26269 |
local s_rphf=states.rphf |
| 26270 |
local s_half=states.half |
| 26271 |
local s_pref=states.pref |
| 26272 |
local s_blwf=states.blwf |
| 26273 |
local s_pstf=states.pstf |
| 26274 |
local s_init=states.init |
| 26275 |
local replace_all_nbsp=nil |
| 26276 |
replace_all_nbsp=function(head) |
| 26277 |
replace_all_nbsp=typesetters and typesetters.characters and typesetters.characters.replacenbspaces or function(head) |
| 26278 |
return head |
| 26279 |
end |
| 26280 |
return replace_all_nbsp(head) |
| 26281 |
end |
| 26282 |
local processcharacters=nil |
| 26283 |
local logprocess=nil |
| 26284 |
if context then |
| 26285 |
local fontprocesses=fonts.hashes.processes |
| 26286 |
local tracers=nodes.tracers |
| 26287 |
local registermessage=(tracers and tracers.steppers.message) or function() end |
| 26288 |
function processcharacters(head,font) |
| 26289 |
local processors=fontprocesses[font] |
| 26290 |
for i=1,#processors do |
| 26291 |
head=processors[i](head,font,0) |
| 26292 |
end |
| 26293 |
return head |
| 26294 |
end |
| 26295 |
trackers.register("otf.steps",function(v) trace_steps=v end) |
| 26296 |
logprocess=function(str) |
| 26297 |
if trace_steps then |
| 26298 |
registermessage("devanagari %s",str) |
| 26299 |
if trace_steps=="silent" then |
| 26300 |
return |
| 26301 |
end |
| 26302 |
end |
| 26303 |
report(str) |
| 26304 |
end |
| 26305 |
else |
| 26306 |
function processcharacters(head,font) |
| 26307 |
local processors=fontdata[font].shared.processes |
| 26308 |
for i=1,#processors do |
| 26309 |
head=processors[i](head,font,0) |
| 26310 |
end |
| 26311 |
return head |
| 26312 |
end |
| 26313 |
logprocess=function(str) |
| 26314 |
end |
| 26315 |
end |
| 26316 |
local indicgroups=characters and characters.indicgroups |
| 26317 |
if not indicgroups and characters then |
| 26318 |
local indic={ |
| 26319 |
c={}, |
| 26320 |
i={}, |
| 26321 |
d={}, |
| 26322 |
m={}, |
| 26323 |
s={}, |
| 26324 |
o={}, |
| 26325 |
} |
| 26326 |
local indicmarks={ |
| 26327 |
l={}, |
| 26328 |
t={}, |
| 26329 |
b={}, |
| 26330 |
r={}, |
| 26331 |
s={}, |
| 26332 |
} |
| 26333 |
local indicclasses={ |
| 26334 |
nukta={}, |
| 26335 |
halant={}, |
| 26336 |
ra={}, |
| 26337 |
anudatta={}, |
| 26338 |
} |
| 26339 |
local indicorders={ |
| 26340 |
bp={}, |
| 26341 |
ap={}, |
| 26342 |
bs={}, |
| 26343 |
as={}, |
| 26344 |
bh={}, |
| 26345 |
ah={}, |
| 26346 |
bm={}, |
| 26347 |
am={}, |
| 26348 |
} |
| 26349 |
for k,v in next,characters.data do |
| 26350 |
local i=v.indic |
| 26351 |
if i then |
| 26352 |
indic[i][k]=true |
| 26353 |
i=v.indicmark |
| 26354 |
if i then |
| 26355 |
if i=="s" then |
| 26356 |
local s=v.specials |
| 26357 |
indicmarks[i][k]={ s[2],s[3] } |
| 26358 |
else |
| 26359 |
indicmarks[i][k]=true |
| 26360 |
end |
| 26361 |
end |
| 26362 |
i=v.indicclass |
| 26363 |
if i then |
| 26364 |
indicclasses[i][k]=true |
| 26365 |
end |
| 26366 |
i=v.indicorder |
| 26367 |
if i then |
| 26368 |
indicorders[i][k]=true |
| 26369 |
end |
| 26370 |
end |
| 26371 |
end |
| 26372 |
indicgroups={ |
| 26373 |
consonant=indic.c, |
| 26374 |
independent_vowel=indic.i, |
| 26375 |
dependent_vowel=indic.d, |
| 26376 |
vowel_modifier=indic.m, |
| 26377 |
stress_tone_mark=indic.s, |
| 26378 |
pre_mark=indicmarks.l, |
| 26379 |
above_mark=indicmarks.t, |
| 26380 |
below_mark=indicmarks.b, |
| 26381 |
post_mark=indicmarks.r, |
| 26382 |
twopart_mark=indicmarks.s, |
| 26383 |
nukta=indicclasses.nukta, |
| 26384 |
halant=indicclasses.halant, |
| 26385 |
ra=indicclasses.ra, |
| 26386 |
anudatta=indicclasses.anudatta, |
| 26387 |
before_postscript=indicorders.bp, |
| 26388 |
after_postscript=indicorders.ap, |
| 26389 |
before_half=indicorders.bh, |
| 26390 |
after_half=indicorders.ah, |
| 26391 |
before_subscript=indicorders.bs, |
| 26392 |
after_subscript=indicorders.as, |
| 26393 |
before_main=indicorders.bm, |
| 26394 |
after_main=indicorders.am, |
| 26395 |
} |
| 26396 |
indic=nil |
| 26397 |
indicmarks=nil |
| 26398 |
indicclasses=nil |
| 26399 |
indicorders=nil |
| 26400 |
characters.indicgroups=indicgroups |
| 26401 |
end |
| 26402 |
local consonant=indicgroups.consonant |
| 26403 |
local independent_vowel=indicgroups.independent_vowel |
| 26404 |
local dependent_vowel=indicgroups.dependent_vowel |
| 26405 |
local vowel_modifier=indicgroups.vowel_modifier |
| 26406 |
local stress_tone_mark=indicgroups.stress_tone_mark |
| 26407 |
local pre_mark=indicgroups.pre_mark |
| 26408 |
local above_mark=indicgroups.above_mark |
| 26409 |
local below_mark=indicgroups.below_mark |
| 26410 |
local post_mark=indicgroups.post_mark |
| 26411 |
local twopart_mark=indicgroups.twopart_mark |
| 26412 |
local nukta=indicgroups.nukta |
| 26413 |
local halant=indicgroups.halant |
| 26414 |
local ra=indicgroups.ra |
| 26415 |
local anudatta=indicgroups.anudatta |
| 26416 |
local before_postscript=indicgroups.before_postscript |
| 26417 |
local after_postscript=indicgroups.after_postscript |
| 26418 |
local before_half=indicgroups.before_half |
| 26419 |
local after_half=indicgroups.after_half |
| 26420 |
local before_subscript=indicgroups.before_subscript |
| 26421 |
local after_subscript=indicgroups.after_subscript |
| 26422 |
local before_main=indicgroups.before_main |
| 26423 |
local after_main=indicgroups.after_main |
| 26424 |
local mark_pre_above_below_post=table.merged ( |
| 26425 |
pre_mark, |
| 26426 |
above_mark, |
| 26427 |
below_mark, |
| 26428 |
post_mark |
| 26429 |
) |
| 26430 |
local mark_above_below_post=table.merged ( |
| 26431 |
above_mark, |
| 26432 |
below_mark, |
| 26433 |
post_mark |
| 26434 |
) |
| 26435 |
local devanagarihash=table.setmetatableindex(function(t,k) |
| 26436 |
local v=fontdata[k].resources.devanagari or false |
| 26437 |
t[k]=v |
| 26438 |
return v |
| 26439 |
end) |
| 26440 |
local zw_char={ |
| 26441 |
[c_zwnj]=true, |
| 26442 |
[c_zwj ]=true, |
| 26443 |
} |
| 26444 |
local dflt_true={ |
| 26445 |
dflt=true, |
| 26446 |
} |
| 26447 |
local two_defaults={} |
| 26448 |
local one_defaults={} |
| 26449 |
local false_flags={ false,false,false,false } |
| 26450 |
local sequence_reorder_matras={ |
| 26451 |
features={ dv01=two_defaults }, |
| 26452 |
flags=false_flags, |
| 26453 |
name="dv01_reorder_matras", |
| 26454 |
order={ "dv01" }, |
| 26455 |
type="devanagari_reorder_matras", |
| 26456 |
nofsteps=1, |
| 26457 |
steps={ |
| 26458 |
{ |
| 26459 |
coverage=pre_mark, |
| 26460 |
} |
| 26461 |
} |
| 26462 |
} |
| 26463 |
local sequence_reorder_reph={ |
| 26464 |
features={ dv02=two_defaults }, |
| 26465 |
flags=false_flags, |
| 26466 |
name="dv02_reorder_reph", |
| 26467 |
order={ "dv02" }, |
| 26468 |
type="devanagari_reorder_reph", |
| 26469 |
nofsteps=1, |
| 26470 |
steps={ |
| 26471 |
{ |
| 26472 |
coverage={}, |
| 26473 |
} |
| 26474 |
} |
| 26475 |
} |
| 26476 |
local sequence_reorder_pre_base_reordering_consonants={ |
| 26477 |
features={ dv03=one_defaults }, |
| 26478 |
flags=false_flags, |
| 26479 |
name="dv03_reorder_pre_base_reordering_consonants", |
| 26480 |
order={ "dv03" }, |
| 26481 |
type="devanagari_reorder_pre_base_reordering_consonants", |
| 26482 |
nofsteps=1, |
| 26483 |
steps={ |
| 26484 |
{ |
| 26485 |
coverage={}, |
| 26486 |
} |
| 26487 |
} |
| 26488 |
} |
| 26489 |
local sequence_remove_joiners={ |
| 26490 |
features={ dv04=one_defaults }, |
| 26491 |
flags=false_flags, |
| 26492 |
name="dv04_remove_joiners", |
| 26493 |
order={ "dv04" }, |
| 26494 |
type="devanagari_remove_joiners", |
| 26495 |
nofsteps=1, |
| 26496 |
steps={ |
| 26497 |
{ |
| 26498 |
coverage=zw_char, |
| 26499 |
}, |
| 26500 |
} |
| 26501 |
} |
| 26502 |
local basic_shaping_forms={ |
| 26503 |
akhn=true, |
| 26504 |
blwf=true, |
| 26505 |
cjct=true, |
| 26506 |
half=true, |
| 26507 |
nukt=true, |
| 26508 |
pref=true, |
| 26509 |
pstf=true, |
| 26510 |
rkrf=true, |
| 26511 |
rphf=true, |
| 26512 |
vatu=true, |
| 26513 |
locl=true, |
| 26514 |
} |
| 26515 |
local valid={ |
| 26516 |
abvs=true, |
| 26517 |
akhn=true, |
| 26518 |
blwf=true, |
| 26519 |
calt=true, |
| 26520 |
cjct=true, |
| 26521 |
half=true, |
| 26522 |
haln=true, |
| 26523 |
nukt=true, |
| 26524 |
pref=true, |
| 26525 |
pres=true, |
| 26526 |
pstf=true, |
| 26527 |
psts=true, |
| 26528 |
rkrf=true, |
| 26529 |
rphf=true, |
| 26530 |
vatu=true, |
| 26531 |
pres=true, |
| 26532 |
abvs=true, |
| 26533 |
blws=true, |
| 26534 |
psts=true, |
| 26535 |
haln=true, |
| 26536 |
calt=true, |
| 26537 |
locl=true, |
| 26538 |
} |
| 26539 |
local scripts={} |
| 26540 |
local scripts_one={ "deva","mlym","beng","gujr","guru","knda","orya","taml","telu" } |
| 26541 |
local scripts_two={ "dev2","mlm2","bng2","gjr2","gur2","knd2","ory2","tml2","tel2" } |
| 26542 |
local nofscripts=#scripts_one |
| 26543 |
for i=1,nofscripts do |
| 26544 |
local one=scripts_one[i] |
| 26545 |
local two=scripts_two[i] |
| 26546 |
scripts[one]=true |
| 26547 |
scripts[two]=true |
| 26548 |
two_defaults[two]=dflt_true |
| 26549 |
one_defaults[one]=dflt_true |
| 26550 |
one_defaults[two]=dflt_true |
| 26551 |
end |
| 26552 |
local function valid_one(s) for i=1,nofscripts do if s[scripts_one[i]] then return true end end end |
| 26553 |
local function valid_two(s) for i=1,nofscripts do if s[scripts_two[i]] then return true end end end |
| 26554 |
local function initializedevanagi(tfmdata) |
| 26555 |
local script,language=otf.scriptandlanguage(tfmdata,attr) |
| 26556 |
if scripts[script] then |
| 26557 |
local resources=tfmdata.resources |
| 26558 |
local devanagari=resources.devanagari |
| 26559 |
if not devanagari then |
| 26560 |
report("adding features to font") |
| 26561 |
local gsubfeatures=resources.features.gsub |
| 26562 |
local sequences=resources.sequences |
| 26563 |
local sharedfeatures=tfmdata.shared.features |
| 26564 |
gsubfeatures["dv01"]=two_defaults |
| 26565 |
gsubfeatures["dv02"]=two_defaults |
| 26566 |
gsubfeatures["dv03"]=one_defaults |
| 26567 |
gsubfeatures["dv04"]=one_defaults |
| 26568 |
local reorder_pre_base_reordering_consonants=copy(sequence_reorder_pre_base_reordering_consonants) |
| 26569 |
local reorder_reph=copy(sequence_reorder_reph) |
| 26570 |
local reorder_matras=copy(sequence_reorder_matras) |
| 26571 |
local remove_joiners=copy(sequence_remove_joiners) |
| 26572 |
local lastmatch=0 |
| 26573 |
for s=1,#sequences do |
| 26574 |
local features=sequences[s].features |
| 26575 |
if features then |
| 26576 |
for k,v in next,features do |
| 26577 |
if k=="locl" then |
| 26578 |
local steps=sequences[s].steps |
| 26579 |
local nofsteps=sequences[s].nofsteps |
| 26580 |
for i=1,nofsteps do |
| 26581 |
local step=steps[i] |
| 26582 |
local coverage=step.coverage |
| 26583 |
if coverage then |
| 26584 |
for k,v in next,pre_mark do |
| 26585 |
local locl=coverage[k] |
| 26586 |
if locl then |
| 26587 |
if #locl>0 then |
| 26588 |
for j=1,#locl do |
| 26589 |
local ck=locl[j] |
| 26590 |
local f=ck[4] |
| 26591 |
local chainlookups=ck[6] |
| 26592 |
if chainlookups then |
| 26593 |
local chainlookup=chainlookups[f] |
| 26594 |
for j=1,#chainlookup do |
| 26595 |
local chainstep=chainlookup[j] |
| 26596 |
local steps=chainstep.steps |
| 26597 |
local nofsteps=chainstep.nofsteps |
| 26598 |
for i=1,nofsteps do |
| 26599 |
local step=steps[i] |
| 26600 |
local coverage=step.coverage |
| 26601 |
if coverage then |
| 26602 |
locl=coverage[k] |
| 26603 |
end |
| 26604 |
end |
| 26605 |
end |
| 26606 |
end |
| 26607 |
end |
| 26608 |
else |
| 26609 |
end |
| 26610 |
if locl then |
| 26611 |
reorder_matras.steps[1].coverage[locl]=true |
| 26612 |
end |
| 26613 |
end |
| 26614 |
end |
| 26615 |
end |
| 26616 |
end |
| 26617 |
end |
| 26618 |
if basic_shaping_forms[k] then |
| 26619 |
lastmatch=lastmatch+1 |
| 26620 |
if s~=lastmatch then |
| 26621 |
insert(sequences,lastmatch,remove(sequences,s)) |
| 26622 |
end |
| 26623 |
end |
| 26624 |
end |
| 26625 |
end |
| 26626 |
end |
| 26627 |
local insertindex=lastmatch+1 |
| 26628 |
if tfmdata.properties.language then |
| 26629 |
dflt_true[tfmdata.properties.language]=true |
| 26630 |
end |
| 26631 |
insert(sequences,insertindex,reorder_pre_base_reordering_consonants) |
| 26632 |
insert(sequences,insertindex,reorder_reph) |
| 26633 |
insert(sequences,insertindex,reorder_matras) |
| 26634 |
insert(sequences,insertindex,remove_joiners) |
| 26635 |
local blwfcache={} |
| 26636 |
local vatucache={} |
| 26637 |
local pstfcache={} |
| 26638 |
local seqsubset={} |
| 26639 |
local rephstep={ coverage={} } |
| 26640 |
local devanagari={ |
| 26641 |
reph=false, |
| 26642 |
vattu=false, |
| 26643 |
blwfcache=blwfcache, |
| 26644 |
vatucache=vatucache, |
| 26645 |
pstfcache=pstfcache, |
| 26646 |
seqsubset=seqsubset, |
| 26647 |
reorderreph=rephstep, |
| 26648 |
} |
| 26649 |
reorder_reph.steps={ rephstep } |
| 26650 |
local pre_base_reordering_consonants={} |
| 26651 |
reorder_pre_base_reordering_consonants.steps[1].coverage=pre_base_reordering_consonants |
| 26652 |
resources.devanagari=devanagari |
| 26653 |
for s=1,#sequences do |
| 26654 |
local sequence=sequences[s] |
| 26655 |
local steps=sequence.steps |
| 26656 |
local nofsteps=sequence.nofsteps |
| 26657 |
local features=sequence.features |
| 26658 |
local has_rphf=features.rphf |
| 26659 |
local has_blwf=features.blwf |
| 26660 |
local has_vatu=features.vatu |
| 26661 |
local has_pstf=features.pstf |
| 26662 |
if has_rphf and has_rphf[script] then |
| 26663 |
devanagari.reph=true |
| 26664 |
elseif (has_blwf and has_blwf[script]) or (has_vatu and has_vatu[script]) then |
| 26665 |
devanagari.vattu=true |
| 26666 |
for i=1,nofsteps do |
| 26667 |
local step=steps[i] |
| 26668 |
local coverage=step.coverage |
| 26669 |
if coverage then |
| 26670 |
for k,v in next,coverage do |
| 26671 |
for h,w in next,halant do |
| 26672 |
if v[h] and not blwfcache[k] then |
| 26673 |
blwfcache[k]=v |
| 26674 |
end |
| 26675 |
if has_vatu and has_vatu[script] and not vatucache[k] then |
| 26676 |
vatucache[k]=v |
| 26677 |
end |
| 26678 |
end |
| 26679 |
end |
| 26680 |
end |
| 26681 |
end |
| 26682 |
elseif has_pstf and has_pstf[script] then |
| 26683 |
for i=1,nofsteps do |
| 26684 |
local step=steps[i] |
| 26685 |
local coverage=step.coverage |
| 26686 |
if coverage then |
| 26687 |
for k,v in next,coverage do |
| 26688 |
if not pstfcache[k] then |
| 26689 |
pstfcache[k]=v |
| 26690 |
end |
| 26691 |
end |
| 26692 |
for k,v in next,ra do |
| 26693 |
local r=coverage[k] |
| 26694 |
if r then |
| 26695 |
local found=false |
| 26696 |
if #r>0 then |
| 26697 |
for j=1,#r do |
| 26698 |
local ck=r[j] |
| 26699 |
local f=ck[4] |
| 26700 |
local chainlookups=ck[6] |
| 26701 |
if chainlookups then |
| 26702 |
local chainlookup=chainlookups[f] |
| 26703 |
if chainlookup then |
| 26704 |
for j=1,#chainlookup do |
| 26705 |
local chainstep=chainlookup[j] |
| 26706 |
local steps=chainstep.steps |
| 26707 |
local nofsteps=chainstep.nofsteps |
| 26708 |
for i=1,nofsteps do |
| 26709 |
local step=steps[i] |
| 26710 |
local coverage=step.coverage |
| 26711 |
if coverage then |
| 26712 |
local h=coverage[k] |
| 26713 |
if h then |
| 26714 |
for k,v in next,h do |
| 26715 |
if v then |
| 26716 |
found=tonumber(v) or v.ligature |
| 26717 |
if found then |
| 26718 |
pre_base_reordering_consonants[found]=true |
| 26719 |
break |
| 26720 |
end |
| 26721 |
end |
| 26722 |
end |
| 26723 |
if found then |
| 26724 |
break |
| 26725 |
end |
| 26726 |
end |
| 26727 |
end |
| 26728 |
end |
| 26729 |
end |
| 26730 |
end |
| 26731 |
end |
| 26732 |
end |
| 26733 |
else |
| 26734 |
for k,v in next,r do |
| 26735 |
if v then |
| 26736 |
found=tonumber(v) or v.ligature |
| 26737 |
if found then |
| 26738 |
pre_base_reordering_consonants[found]=true |
| 26739 |
break |
| 26740 |
end |
| 26741 |
end |
| 26742 |
end |
| 26743 |
end |
| 26744 |
if found then |
| 26745 |
break |
| 26746 |
end |
| 26747 |
end |
| 26748 |
end |
| 26749 |
end |
| 26750 |
end |
| 26751 |
end |
| 26752 |
for kind,spec in next,features do |
| 26753 |
if valid[kind] and valid_two(spec)then |
| 26754 |
for i=1,nofsteps do |
| 26755 |
local step=steps[i] |
| 26756 |
local coverage=step.coverage |
| 26757 |
if coverage then |
| 26758 |
local reph=false |
| 26759 |
local base=false |
| 26760 |
if kind=="rphf" then |
| 26761 |
for k,v in next,ra do |
| 26762 |
local r=coverage[k] |
| 26763 |
if r then |
| 26764 |
base=k |
| 26765 |
local h=false |
| 26766 |
if #r>0 then |
| 26767 |
for j=1,#r do |
| 26768 |
local ck=r[j] |
| 26769 |
local f=ck[4] |
| 26770 |
local chainlookups=ck[6] |
| 26771 |
if chainlookups then |
| 26772 |
local chainlookup=chainlookups[f] |
| 26773 |
for j=1,#chainlookup do |
| 26774 |
local chainstep=chainlookup[j] |
| 26775 |
local steps=chainstep.steps |
| 26776 |
local nofsteps=chainstep.nofsteps |
| 26777 |
for i=1,nofsteps do |
| 26778 |
local step=steps[i] |
| 26779 |
local coverage=step.coverage |
| 26780 |
if coverage then |
| 26781 |
local r=coverage[k] |
| 26782 |
if r then |
| 26783 |
for k,v in next,halant do |
| 26784 |
local h=r[k] |
| 26785 |
if h then |
| 26786 |
reph=tonumber(h) or h.ligature or false |
| 26787 |
break |
| 26788 |
end |
| 26789 |
end |
| 26790 |
if h then |
| 26791 |
break |
| 26792 |
end |
| 26793 |
end |
| 26794 |
end |
| 26795 |
end |
| 26796 |
end |
| 26797 |
end |
| 26798 |
end |
| 26799 |
else |
| 26800 |
for k,v in next,halant do |
| 26801 |
local h=r[k] |
| 26802 |
if h then |
| 26803 |
reph=tonumber(h) or h.ligature or false |
| 26804 |
break |
| 26805 |
end |
| 26806 |
end |
| 26807 |
end |
| 26808 |
if reph then |
| 26809 |
break |
| 26810 |
end |
| 26811 |
end |
| 26812 |
end |
| 26813 |
end |
| 26814 |
seqsubset[#seqsubset+1]={ kind,coverage,reph,base } |
| 26815 |
end |
| 26816 |
end |
| 26817 |
end |
| 26818 |
if kind=="pref" then |
| 26819 |
local steps=sequence.steps |
| 26820 |
local nofsteps=sequence.nofsteps |
| 26821 |
for i=1,nofsteps do |
| 26822 |
local step=steps[i] |
| 26823 |
local coverage=step.coverage |
| 26824 |
if coverage then |
| 26825 |
for k,v in next,halant do |
| 26826 |
local h=coverage[k] |
| 26827 |
if h then |
| 26828 |
local found=false |
| 26829 |
if #h>0 then |
| 26830 |
for j=1,#h do |
| 26831 |
local ck=h[j] |
| 26832 |
local f=ck[4] |
| 26833 |
local chainlookups=ck[6] |
| 26834 |
if chainlookups then |
| 26835 |
local chainlookup=chainlookups[f] |
| 26836 |
for j=1,#chainlookup do |
| 26837 |
local chainstep=chainlookup[j] |
| 26838 |
local steps=chainstep.steps |
| 26839 |
local nofsteps=chainstep.nofsteps |
| 26840 |
for i=1,nofsteps do |
| 26841 |
local step=steps[i] |
| 26842 |
local coverage=step.coverage |
| 26843 |
if coverage then |
| 26844 |
local h=coverage[k] |
| 26845 |
if h then |
| 26846 |
for k,v in next,h do |
| 26847 |
if v then |
| 26848 |
found=tonumber(v) or v.ligature |
| 26849 |
if found then |
| 26850 |
pre_base_reordering_consonants[found]=true |
| 26851 |
break |
| 26852 |
end |
| 26853 |
end |
| 26854 |
end |
| 26855 |
if found then |
| 26856 |
break |
| 26857 |
end |
| 26858 |
end |
| 26859 |
end |
| 26860 |
end |
| 26861 |
end |
| 26862 |
end |
| 26863 |
end |
| 26864 |
else |
| 26865 |
for k,v in next,h do |
| 26866 |
found=v and (tonumber(v) or v.ligature) |
| 26867 |
if found then |
| 26868 |
pre_base_reordering_consonants[found]=true |
| 26869 |
break |
| 26870 |
end |
| 26871 |
end |
| 26872 |
end |
| 26873 |
if found then |
| 26874 |
break |
| 26875 |
end |
| 26876 |
end |
| 26877 |
end |
| 26878 |
end |
| 26879 |
end |
| 26880 |
end |
| 26881 |
end |
| 26882 |
end |
| 26883 |
if two_defaults[script] then |
| 26884 |
sharedfeatures["dv01"]=true |
| 26885 |
sharedfeatures["dv02"]=true |
| 26886 |
sharedfeatures["dv03"]=true |
| 26887 |
sharedfeatures["dv04"]=true |
| 26888 |
elseif one_defaults[script] then |
| 26889 |
sharedfeatures["dv03"]=true |
| 26890 |
sharedfeatures["dv04"]=true |
| 26891 |
end |
| 26892 |
end |
| 26893 |
end |
| 26894 |
end |
| 26895 |
registerotffeature { |
| 26896 |
name="devanagari", |
| 26897 |
description="inject additional features", |
| 26898 |
default=true, |
| 26899 |
initializers={ |
| 26900 |
node=initializedevanagi, |
| 26901 |
}, |
| 26902 |
} |
| 26903 |
local function initializeconjuncts(tfmdata,value) |
| 26904 |
if value then |
| 26905 |
local resources=tfmdata.resources |
| 26906 |
local devanagari=resources.devanagari |
| 26907 |
if devanagari then |
| 26908 |
local conjuncts="auto" |
| 26909 |
local movematra="auto" |
| 26910 |
if type(value)=="string" and value~="auto" then |
| 26911 |
value=settings_to_hash(value) |
| 26912 |
conjuncts=rawget(value,"conjuncts") or conjuncts |
| 26913 |
movematra=rawget(value,"movematra") or movematra |
| 26914 |
end |
| 26915 |
if conjuncts=="auto" then |
| 26916 |
conjuncts="mixed" |
| 26917 |
end |
| 26918 |
if movematra=="auto" and |
| 26919 |
script=="mlym" or |
| 26920 |
script=="taml" then |
| 26921 |
movematra="leftbeforebase" |
| 26922 |
else |
| 26923 |
movematra="default" |
| 26924 |
end |
| 26925 |
devanagari.conjuncts=conjuncts |
| 26926 |
devanagari.movematra=movematra |
| 26927 |
if trace_steps then |
| 26928 |
report("conjuncts %a, movematra %a",conjuncts,movematra) |
| 26929 |
end |
| 26930 |
end |
| 26931 |
end |
| 26932 |
end |
| 26933 |
registerotffeature { |
| 26934 |
name="indic", |
| 26935 |
description="control indic", |
| 26936 |
default="auto", |
| 26937 |
initializers={ |
| 26938 |
node=initializeconjuncts, |
| 26939 |
}, |
| 26940 |
} |
| 26941 |
local show_syntax_errors=false |
| 26942 |
local function inject_syntax_error(head,current,char) |
| 26943 |
local signal=copy_node(current) |
| 26944 |
copyinjection(signal,current) |
| 26945 |
if pre_mark[char] then |
| 26946 |
setchar(signal,dotted_circle) |
| 26947 |
else |
| 26948 |
setchar(current,dotted_circle) |
| 26949 |
end |
| 26950 |
return insertnodeafter(head,current,signal) |
| 26951 |
end |
| 26952 |
local function initialize_one(font,attr) |
| 26953 |
local tfmdata=fontdata[font] |
| 26954 |
local datasets=otf.dataset(tfmdata,font,attr) |
| 26955 |
local devanagaridata=datasets.devanagari |
| 26956 |
if not devanagaridata then |
| 26957 |
devanagaridata={ |
| 26958 |
reph=false, |
| 26959 |
vattu=false, |
| 26960 |
blwfcache={}, |
| 26961 |
vatucache={}, |
| 26962 |
pstfcache={}, |
| 26963 |
} |
| 26964 |
datasets.devanagari=devanagaridata |
| 26965 |
local resources=tfmdata.resources |
| 26966 |
local devanagari=resources.devanagari |
| 26967 |
for s=1,#datasets do |
| 26968 |
local dataset=datasets[s] |
| 26969 |
if dataset and dataset[1] then |
| 26970 |
local kind=dataset[4] |
| 26971 |
if kind=="rphf" then |
| 26972 |
devanagaridata.reph=true |
| 26973 |
elseif kind=="blwf" or kind=="vatu" then |
| 26974 |
devanagaridata.vattu=true |
| 26975 |
devanagaridata.blwfcache=devanagari.blwfcache |
| 26976 |
devanagaridata.vatucache=devanagari.vatucache |
| 26977 |
devanagaridata.pstfcache=devanagari.pstfcache |
| 26978 |
end |
| 26979 |
end |
| 26980 |
end |
| 26981 |
end |
| 26982 |
return devanagaridata.reph,devanagaridata.vattu,devanagaridata.blwfcache,devanagaridata.vatucache,devanagaridata.pstfcache |
| 26983 |
end |
| 26984 |
local function contextchain(contexts,n) |
| 26985 |
local char=getchar(n) |
| 26986 |
if not contexts.n then |
| 26987 |
return contexts[char] |
| 26988 |
else |
| 26989 |
for k=1,#contexts do |
| 26990 |
local ck=contexts[k] |
| 26991 |
local seq=ck[3] |
| 26992 |
local f=ck[4] |
| 26993 |
local l=ck[5] |
| 26994 |
if (l-f)==1 and seq[f+1][char] then |
| 26995 |
local ok=true |
| 26996 |
local c=n |
| 26997 |
for i=l+1,#seq do |
| 26998 |
c=getnext(c) |
| 26999 |
if not c or not seq[i][ischar(c)] then |
| 27000 |
ok=false |
| 27001 |
break |
| 27002 |
end |
| 27003 |
end |
| 27004 |
if ok then |
| 27005 |
c=getprev(n) |
| 27006 |
for i=1,f-1 do |
| 27007 |
c=getprev(c) |
| 27008 |
if not c or not seq[f-i][ischar(c)] then |
| 27009 |
ok=false |
| 27010 |
end |
| 27011 |
end |
| 27012 |
end |
| 27013 |
if ok then |
| 27014 |
return true |
| 27015 |
end |
| 27016 |
end |
| 27017 |
end |
| 27018 |
return false |
| 27019 |
end |
| 27020 |
end |
| 27021 |
local function order_matras(c) |
| 27022 |
local cn=getnext(c) |
| 27023 |
local char=getchar(cn) |
| 27024 |
while dependent_vowel[char] do |
| 27025 |
local next=getnext(cn) |
| 27026 |
local cc=c |
| 27027 |
local cchar=getchar(cc) |
| 27028 |
while cc~=cn do |
| 27029 |
if (above_mark[char] and (below_mark[cchar] or post_mark[cchar])) or (below_mark[char] and (post_mark[cchar])) then |
| 27030 |
local prev,next=getboth(cn) |
| 27031 |
if next then |
| 27032 |
setprev(next,prev) |
| 27033 |
end |
| 27034 |
setnext(prev,next) |
| 27035 |
setnext(getprev(cc),cn) |
| 27036 |
setprev(cn,getprev(cc)) |
| 27037 |
setnext(cn,cc) |
| 27038 |
setprev(cc,cn) |
| 27039 |
break |
| 27040 |
end |
| 27041 |
cc=getnext(cc) |
| 27042 |
cchar=getchar(cc) |
| 27043 |
end |
| 27044 |
cn=next |
| 27045 |
char=getchar(cn) |
| 27046 |
end |
| 27047 |
end |
| 27048 |
local swapped=table.swapped(states) |
| 27049 |
local function reorder_one(head,start,stop,font,attr,nbspaces) |
| 27050 |
local reph,vattu,blwfcache,vatucache,pstfcache=initialize_one(font,attr) |
| 27051 |
local current=start |
| 27052 |
local n=getnext(start) |
| 27053 |
local base=nil |
| 27054 |
local firstcons=nil |
| 27055 |
local lastcons=nil |
| 27056 |
local basefound=false |
| 27057 |
if reph and ra[getchar(start)] and halant[getchar(n)] then |
| 27058 |
if n==stop then |
| 27059 |
return head,stop,nbspaces |
| 27060 |
end |
| 27061 |
if getchar(getnext(n))==c_zwj then |
| 27062 |
current=start |
| 27063 |
else |
| 27064 |
current=getnext(n) |
| 27065 |
setstate(start,s_rphf) |
| 27066 |
end |
| 27067 |
end |
| 27068 |
if getchar(current)==c_nbsp then |
| 27069 |
if current==stop then |
| 27070 |
stop=getprev(stop) |
| 27071 |
head=remove_node(head,current) |
| 27072 |
flushnode(current) |
| 27073 |
if trace_steps then |
| 27074 |
logprocess("reorder one, remove nbsp") |
| 27075 |
end |
| 27076 |
return head,stop,nbspaces |
| 27077 |
else |
| 27078 |
nbspaces=nbspaces+1 |
| 27079 |
base=current |
| 27080 |
firstcons=current |
| 27081 |
lastcons=current |
| 27082 |
current=getnext(current) |
| 27083 |
if current~=stop then |
| 27084 |
local char=getchar(current) |
| 27085 |
if nukta[char] then |
| 27086 |
current=getnext(current) |
| 27087 |
char=getchar(current) |
| 27088 |
end |
| 27089 |
if char==c_zwj and current~=stop then |
| 27090 |
local next=getnext(current) |
| 27091 |
if next~=stop and halant[getchar(next)] then |
| 27092 |
current=next |
| 27093 |
next=getnext(current) |
| 27094 |
local tmp=next and getnext(next) or nil |
| 27095 |
local changestop=next==stop |
| 27096 |
local tempcurrent=copy_node(next) |
| 27097 |
copyinjection(tempcurrent,next) |
| 27098 |
local nextcurrent=copy_node(current) |
| 27099 |
copyinjection(nextcurrent,current) |
| 27100 |
setlink(tempcurrent,nextcurrent) |
| 27101 |
setstate(tempcurrent,s_blwf) |
| 27102 |
tempcurrent=processcharacters(tempcurrent,font) |
| 27103 |
setstate(tempcurrent,unsetvalue) |
| 27104 |
if getchar(next)==getchar(tempcurrent) then |
| 27105 |
flushlist(tempcurrent) |
| 27106 |
if show_syntax_errors then |
| 27107 |
head,current=inject_syntax_error(head,current,char) |
| 27108 |
end |
| 27109 |
else |
| 27110 |
setchar(current,getchar(tempcurrent)) |
| 27111 |
local freenode=getnext(current) |
| 27112 |
setlink(current,tmp) |
| 27113 |
flushnode(freenode) |
| 27114 |
flushlist(tempcurrent) |
| 27115 |
if changestop then |
| 27116 |
stop=current |
| 27117 |
end |
| 27118 |
end |
| 27119 |
if trace_steps then |
| 27120 |
logprocess("reorder one, handle nbsp") |
| 27121 |
end |
| 27122 |
end |
| 27123 |
end |
| 27124 |
end |
| 27125 |
end |
| 27126 |
end |
| 27127 |
while not basefound do |
| 27128 |
local char=getchar(current) |
| 27129 |
if consonant[char] then |
| 27130 |
setstate(current,s_half) |
| 27131 |
if not firstcons then |
| 27132 |
firstcons=current |
| 27133 |
end |
| 27134 |
lastcons=current |
| 27135 |
if not base then |
| 27136 |
base=current |
| 27137 |
elseif blwfcache[char] then |
| 27138 |
setstate(current,s_blwf) |
| 27139 |
elseif pstfcache[char] then |
| 27140 |
setstate(current,s_pstf) |
| 27141 |
else |
| 27142 |
base=current |
| 27143 |
end |
| 27144 |
end |
| 27145 |
basefound=current==stop |
| 27146 |
current=getnext(current) |
| 27147 |
end |
| 27148 |
if base~=lastcons then |
| 27149 |
local np=base |
| 27150 |
local n=getnext(base) |
| 27151 |
local ch=getchar(n) |
| 27152 |
if nukta[ch] then |
| 27153 |
np=n |
| 27154 |
n=getnext(n) |
| 27155 |
ch=getchar(n) |
| 27156 |
end |
| 27157 |
if halant[ch] then |
| 27158 |
if lastcons~=stop then |
| 27159 |
local ln=getnext(lastcons) |
| 27160 |
if nukta[getchar(ln)] then |
| 27161 |
lastcons=ln |
| 27162 |
end |
| 27163 |
end |
| 27164 |
local nn=getnext(n) |
| 27165 |
local ln=getnext(lastcons) |
| 27166 |
setlink(np,nn) |
| 27167 |
setnext(lastcons,n) |
| 27168 |
if ln then |
| 27169 |
setprev(ln,n) |
| 27170 |
end |
| 27171 |
setnext(n,ln) |
| 27172 |
setprev(n,lastcons) |
| 27173 |
if lastcons==stop then |
| 27174 |
stop=n |
| 27175 |
end |
| 27176 |
if trace_steps then |
| 27177 |
logprocess("reorder one, handle halant") |
| 27178 |
end |
| 27179 |
end |
| 27180 |
end |
| 27181 |
n=getnext(start) |
| 27182 |
if n~=stop and ra[getchar(start)] and halant[getchar(n)] and not zw_char[getchar(getnext(n))] then |
| 27183 |
local matra=base |
| 27184 |
if base~=stop then |
| 27185 |
local next=getnext(base) |
| 27186 |
if dependent_vowel[getchar(next)] then |
| 27187 |
matra=next |
| 27188 |
end |
| 27189 |
end |
| 27190 |
local sp=getprev(start) |
| 27191 |
local nn=getnext(n) |
| 27192 |
local mn=getnext(matra) |
| 27193 |
setlink(sp,nn) |
| 27194 |
setlink(matra,start) |
| 27195 |
setlink(n,mn) |
| 27196 |
if head==start then |
| 27197 |
head=nn |
| 27198 |
end |
| 27199 |
start=nn |
| 27200 |
if matra==stop then |
| 27201 |
stop=n |
| 27202 |
end |
| 27203 |
if trace_steps then |
| 27204 |
logprocess("reorder one, handle matra") |
| 27205 |
end |
| 27206 |
end |
| 27207 |
local current=start |
| 27208 |
while current~=stop do |
| 27209 |
local next=getnext(current) |
| 27210 |
if next~=stop and halant[getchar(next)] and getchar(getnext(next))==c_zwnj then |
| 27211 |
setstate(current,unsetvalue) |
| 27212 |
end |
| 27213 |
current=next |
| 27214 |
end |
| 27215 |
if base~=stop and getstate(base) then |
| 27216 |
local next=getnext(base) |
| 27217 |
if halant[getchar(next)] and not (next~=stop and getchar(getnext(next))==c_zwj) then |
| 27218 |
setstate(base,unsetvalue) |
| 27219 |
end |
| 27220 |
end |
| 27221 |
local current,allreordered,moved=start,false,{ [base]=true } |
| 27222 |
local a,b,p,bn=base,base,base,getnext(base) |
| 27223 |
if base~=stop and nukta[getchar(bn)] then |
| 27224 |
a,b,p=bn,bn,bn |
| 27225 |
end |
| 27226 |
while not allreordered do |
| 27227 |
local c=current |
| 27228 |
local n=getnext(current) |
| 27229 |
local l=nil |
| 27230 |
if c~=stop then |
| 27231 |
local ch=getchar(n) |
| 27232 |
if nukta[ch] then |
| 27233 |
c=n |
| 27234 |
n=getnext(n) |
| 27235 |
ch=getchar(n) |
| 27236 |
end |
| 27237 |
if c~=stop then |
| 27238 |
if halant[ch] then |
| 27239 |
c=n |
| 27240 |
n=getnext(n) |
| 27241 |
ch=getchar(n) |
| 27242 |
end |
| 27243 |
local tpm=twopart_mark[ch] |
| 27244 |
if tpm then |
| 27245 |
while tpm do |
| 27246 |
local extra=copy_node(n) |
| 27247 |
copyinjection(extra,n) |
| 27248 |
ch=tpm[1] |
| 27249 |
setchar(n,ch) |
| 27250 |
setchar(extra,tpm[2]) |
| 27251 |
head=insertnodeafter(head,current,extra) |
| 27252 |
tpm=twopart_mark[ch] |
| 27253 |
end |
| 27254 |
if trace_steps then |
| 27255 |
logprocess("reorder one, handle mark") |
| 27256 |
end |
| 27257 |
end |
| 27258 |
while c~=stop and dependent_vowel[ch] do |
| 27259 |
c=n |
| 27260 |
n=getnext(n) |
| 27261 |
ch=getchar(n) |
| 27262 |
end |
| 27263 |
if c~=stop then |
| 27264 |
if vowel_modifier[ch] then |
| 27265 |
c=n |
| 27266 |
n=getnext(n) |
| 27267 |
ch=getchar(n) |
| 27268 |
end |
| 27269 |
if c~=stop and stress_tone_mark[ch] then |
| 27270 |
c=n |
| 27271 |
n=getnext(n) |
| 27272 |
end |
| 27273 |
end |
| 27274 |
end |
| 27275 |
end |
| 27276 |
local bp=getprev(firstcons) |
| 27277 |
local cn=getnext(current) |
| 27278 |
local last=getnext(c) |
| 27279 |
local done=false |
| 27280 |
while cn~=last do |
| 27281 |
if pre_mark[getchar(cn)] then |
| 27282 |
if devanagarihash[font].movematra=="leftbeforebase" then |
| 27283 |
local prev,next=getboth(cn) |
| 27284 |
setlink(prev,next) |
| 27285 |
if cn==stop then |
| 27286 |
stop=getprev(cn) |
| 27287 |
end |
| 27288 |
if base==start then |
| 27289 |
if head==start then |
| 27290 |
head=cn |
| 27291 |
end |
| 27292 |
start=cn |
| 27293 |
end |
| 27294 |
setlink(getprev(base),cn) |
| 27295 |
setlink(cn,base) |
| 27296 |
cn=next |
| 27297 |
else |
| 27298 |
if bp then |
| 27299 |
setnext(bp,cn) |
| 27300 |
end |
| 27301 |
local prev,next=getboth(cn) |
| 27302 |
if next then |
| 27303 |
setprev(next,prev) |
| 27304 |
end |
| 27305 |
setnext(prev,next) |
| 27306 |
if cn==stop then |
| 27307 |
stop=prev |
| 27308 |
end |
| 27309 |
setprev(cn,bp) |
| 27310 |
setlink(cn,firstcons) |
| 27311 |
if firstcons==start then |
| 27312 |
if head==start then |
| 27313 |
head=cn |
| 27314 |
end |
| 27315 |
start=cn |
| 27316 |
end |
| 27317 |
cn=next |
| 27318 |
end |
| 27319 |
done=true |
| 27320 |
elseif current~=base and dependent_vowel[getchar(cn)] then |
| 27321 |
local prev,next=getboth(cn) |
| 27322 |
if next then |
| 27323 |
setprev(next,prev) |
| 27324 |
end |
| 27325 |
setnext(prev,next) |
| 27326 |
if cn==stop then |
| 27327 |
stop=prev |
| 27328 |
end |
| 27329 |
setlink(b,cn,getnext(b)) |
| 27330 |
order_matras(cn) |
| 27331 |
cn=next |
| 27332 |
done=true |
| 27333 |
elseif current==base and dependent_vowel[getchar(cn)] then |
| 27334 |
local cnn=getnext(cn) |
| 27335 |
order_matras(cn) |
| 27336 |
cn=cnn |
| 27337 |
while cn~=last and dependent_vowel[getchar(cn)] do |
| 27338 |
cn=getnext(cn) |
| 27339 |
end |
| 27340 |
else |
| 27341 |
cn=getnext(cn) |
| 27342 |
end |
| 27343 |
end |
| 27344 |
allreordered=c==stop |
| 27345 |
current=getnext(c) |
| 27346 |
if done and trace_steps then |
| 27347 |
logprocess("reorder one, matra") |
| 27348 |
end |
| 27349 |
end |
| 27350 |
if reph or vattu then |
| 27351 |
local current=start |
| 27352 |
local cns=nil |
| 27353 |
local done=false |
| 27354 |
while current~=stop do |
| 27355 |
local c=current |
| 27356 |
local n=getnext(current) |
| 27357 |
if ra[getchar(current)] and halant[getchar(n)] then |
| 27358 |
c=n |
| 27359 |
n=getnext(n) |
| 27360 |
local b,bn=base,base |
| 27361 |
while bn~=stop do |
| 27362 |
local next=getnext(bn) |
| 27363 |
if dependent_vowel[getchar(next)] then |
| 27364 |
b=next |
| 27365 |
end |
| 27366 |
bn=next |
| 27367 |
end |
| 27368 |
if getstate(current,s_rphf) then |
| 27369 |
if b~=current then |
| 27370 |
if current==start then |
| 27371 |
if head==start then |
| 27372 |
head=n |
| 27373 |
end |
| 27374 |
start=n |
| 27375 |
end |
| 27376 |
if b==stop then |
| 27377 |
stop=c |
| 27378 |
end |
| 27379 |
local prev=getprev(current) |
| 27380 |
setlink(prev,n) |
| 27381 |
local next=getnext(b) |
| 27382 |
setlink(c,next) |
| 27383 |
setlink(b,current) |
| 27384 |
done=true |
| 27385 |
end |
| 27386 |
elseif cns and getnext(cns)~=current then |
| 27387 |
local cp=getprev(current) |
| 27388 |
local cnsn=getnext(cns) |
| 27389 |
setlink(cp,n) |
| 27390 |
setlink(cns,current) |
| 27391 |
setlink(c,cnsn) |
| 27392 |
done=true |
| 27393 |
if c==stop then |
| 27394 |
stop=cp |
| 27395 |
break |
| 27396 |
end |
| 27397 |
current=getprev(n) |
| 27398 |
end |
| 27399 |
else |
| 27400 |
local char=getchar(current) |
| 27401 |
if consonant[char] then |
| 27402 |
cns=current |
| 27403 |
local next=getnext(cns) |
| 27404 |
if halant[getchar(next)] then |
| 27405 |
cns=next |
| 27406 |
end |
| 27407 |
if not vatucache[char] then |
| 27408 |
next=getnext(cns) |
| 27409 |
while dependent_vowel[getchar(next)] do |
| 27410 |
cns=next |
| 27411 |
next=getnext(cns) |
| 27412 |
end |
| 27413 |
end |
| 27414 |
elseif char==c_nbsp then |
| 27415 |
nbspaces=nbspaces+1 |
| 27416 |
cns=current |
| 27417 |
local next=getnext(cns) |
| 27418 |
if halant[getchar(next)] then |
| 27419 |
cns=next |
| 27420 |
end |
| 27421 |
if not vatucache[char] then |
| 27422 |
next=getnext(cns) |
| 27423 |
while dependent_vowel[getchar(next)] do |
| 27424 |
cns=next |
| 27425 |
next=getnext(cns) |
| 27426 |
end |
| 27427 |
end |
| 27428 |
end |
| 27429 |
end |
| 27430 |
current=getnext(current) |
| 27431 |
end |
| 27432 |
if done and trace_steps then |
| 27433 |
logprocess("reorder one, handle reph and vata") |
| 27434 |
end |
| 27435 |
end |
| 27436 |
if getchar(base)==c_nbsp then |
| 27437 |
nbspaces=nbspaces-1 |
| 27438 |
if base==stop then |
| 27439 |
stop=getprev(stop) |
| 27440 |
end |
| 27441 |
head=remove_node(head,base) |
| 27442 |
flushnode(base) |
| 27443 |
end |
| 27444 |
return head,stop,nbspaces |
| 27445 |
end |
| 27446 |
function handlers.devanagari_reorder_matras(head,start) |
| 27447 |
local current=start |
| 27448 |
local startfont=getfont(start) |
| 27449 |
local startattr=getprop(start,a_syllabe) |
| 27450 |
while current do |
| 27451 |
local char=ischar(current,startfont) |
| 27452 |
local next=getnext(current) |
| 27453 |
if char and getprop(current,a_syllabe)==startattr then |
| 27454 |
if halant[char] then |
| 27455 |
if next then |
| 27456 |
local char=ischar(next,startfont) |
| 27457 |
if char and zw_char[char] and getprop(next,a_syllabe)==startattr then |
| 27458 |
current=next |
| 27459 |
next=getnext(current) |
| 27460 |
end |
| 27461 |
end |
| 27462 |
local startnext=getnext(start) |
| 27463 |
head=remove_node(head,start) |
| 27464 |
setlink(start,next) |
| 27465 |
setlink(current,start) |
| 27466 |
start=startnext |
| 27467 |
if trace_steps then |
| 27468 |
logprocess("reorder matra") |
| 27469 |
end |
| 27470 |
break |
| 27471 |
end |
| 27472 |
else |
| 27473 |
break |
| 27474 |
end |
| 27475 |
current=next |
| 27476 |
end |
| 27477 |
return head,start,true |
| 27478 |
end |
| 27479 |
local rephbase={} |
| 27480 |
function handlers.devanagari_reorder_reph(head,start) |
| 27481 |
local current=getnext(start) |
| 27482 |
local startnext=nil |
| 27483 |
local startprev=nil |
| 27484 |
local startfont=getfont(start) |
| 27485 |
local startattr=getprop(start,a_syllabe) |
| 27486 |
::step_1:: |
| 27487 |
local char=ischar(start,startfont) |
| 27488 |
local rephbase=rephbase[startfont][char] |
| 27489 |
if char and after_subscript[rephbase] then |
| 27490 |
goto step_5 |
| 27491 |
end |
| 27492 |
::step_2:: |
| 27493 |
if char and not after_postscript[rephbase] then |
| 27494 |
while current do |
| 27495 |
local char=ischar(current,startfont) |
| 27496 |
if char and getprop(current,a_syllabe)==startattr then |
| 27497 |
if halant[char] then |
| 27498 |
if trace_steps then |
| 27499 |
logprocess("reorder reph, handling halant") |
| 27500 |
end |
| 27501 |
local next=getnext(current) |
| 27502 |
if next then |
| 27503 |
local nextchar=ischar(next,startfont) |
| 27504 |
if nextchar and zw_char[nextchar] and getprop(next,a_syllabe)==startattr then |
| 27505 |
current=next |
| 27506 |
next=getnext(current) |
| 27507 |
end |
| 27508 |
end |
| 27509 |
startnext=getnext(start) |
| 27510 |
head=remove_node(head,start) |
| 27511 |
setlink(start,next) |
| 27512 |
setlink(current,start) |
| 27513 |
start=startnext |
| 27514 |
startattr=getprop(start,a_syllabe) |
| 27515 |
break |
| 27516 |
end |
| 27517 |
current=getnext(current) |
| 27518 |
else |
| 27519 |
break |
| 27520 |
end |
| 27521 |
end |
| 27522 |
end |
| 27523 |
::step_3:: |
| 27524 |
if not startnext then |
| 27525 |
if char and after_main[rephbase] then |
| 27526 |
current=getnext(start) |
| 27527 |
while current do |
| 27528 |
local char=ischar(current,startfont) |
| 27529 |
if char and getprop(current,a_syllabe)==startattr then |
| 27530 |
if consonant[char] and not getstate(current,s_pref) then |
| 27531 |
if trace_steps then |
| 27532 |
logprocess("reorder reph, handling consonant") |
| 27533 |
end |
| 27534 |
startnext=getnext(start) |
| 27535 |
head=remove_node(head,start) |
| 27536 |
setlink(current,start) |
| 27537 |
setlink(start,getnext(current)) |
| 27538 |
start=startnext |
| 27539 |
startattr=getprop(start,a_syllabe) |
| 27540 |
break |
| 27541 |
end |
| 27542 |
current=getnext(current) |
| 27543 |
else |
| 27544 |
break |
| 27545 |
end |
| 27546 |
end |
| 27547 |
end |
| 27548 |
end |
| 27549 |
::step_4:: |
| 27550 |
if not startnext then |
| 27551 |
if char and before_postscript[rephbase] then |
| 27552 |
current=getnext(start) |
| 27553 |
local c=nil |
| 27554 |
while current do |
| 27555 |
local char=ischar(current,startfont) |
| 27556 |
if char and getprop(current,a_syllabe)==startattr then |
| 27557 |
if getstate(current,s_pstf) then |
| 27558 |
if trace_steps then |
| 27559 |
logprocess("reorder reph, before postscript, post base") |
| 27560 |
end |
| 27561 |
startnext=getnext(start) |
| 27562 |
head=remove_node(head,start) |
| 27563 |
setlink(getprev(current),start) |
| 27564 |
setlink(start,current) |
| 27565 |
start=startnext |
| 27566 |
startattr=getprop(start,a_syllabe) |
| 27567 |
break |
| 27568 |
elseif not c and (vowel_modifier[char] or stress_tone_mark[char]) then |
| 27569 |
c=current |
| 27570 |
end |
| 27571 |
current=getnext(current) |
| 27572 |
else |
| 27573 |
if c then |
| 27574 |
if trace_steps then |
| 27575 |
logprocess("reorder reph, before postscript") |
| 27576 |
end |
| 27577 |
startnext=getnext(start) |
| 27578 |
head=remove_node(head,start) |
| 27579 |
setlink(getprev(c),start) |
| 27580 |
setlink(start,c) |
| 27581 |
start=startnext |
| 27582 |
startattr=getprop(start,a_syllabe) |
| 27583 |
end |
| 27584 |
break |
| 27585 |
end |
| 27586 |
end |
| 27587 |
end |
| 27588 |
end |
| 27589 |
::step_5:: |
| 27590 |
if not startnext then |
| 27591 |
current=getnext(start) |
| 27592 |
local c=nil |
| 27593 |
while current do |
| 27594 |
local char=ischar(current,startfont) |
| 27595 |
if char and getprop(current,a_syllabe)==startattr then |
| 27596 |
local state=getstate(current) |
| 27597 |
if before_subscript[rephbase] and (state==s_blwf or state==s_pstf) then |
| 27598 |
c=current |
| 27599 |
if trace_steps then |
| 27600 |
logprocess("reorder reph, before subscript") |
| 27601 |
end |
| 27602 |
elseif after_subscript[rephbase] and (state==s_pstf) then |
| 27603 |
if trace_steps then |
| 27604 |
logprocess("reorder reph, after subscript") |
| 27605 |
end |
| 27606 |
c=current |
| 27607 |
end |
| 27608 |
current=getnext(current) |
| 27609 |
else |
| 27610 |
break |
| 27611 |
end |
| 27612 |
end |
| 27613 |
if c then |
| 27614 |
startnext=getnext(start) |
| 27615 |
head=remove_node(head,start) |
| 27616 |
setlink(getprev(c),start) |
| 27617 |
setlink(start,c) |
| 27618 |
start=startnext |
| 27619 |
startattr=getprop(start,a_syllabe) |
| 27620 |
end |
| 27621 |
end |
| 27622 |
::step_6:: |
| 27623 |
if not startnext then |
| 27624 |
current=start |
| 27625 |
local next=getnext(current) |
| 27626 |
while next do |
| 27627 |
local nextchar=ischar(next,startfont) |
| 27628 |
if nextchar and getprop(next,a_syllabe)==startattr then |
| 27629 |
current=next |
| 27630 |
next=getnext(current) |
| 27631 |
else |
| 27632 |
break |
| 27633 |
end |
| 27634 |
end |
| 27635 |
if start~=current then |
| 27636 |
if trace_steps then |
| 27637 |
logprocess("reorder reph, to end") |
| 27638 |
end |
| 27639 |
startnext=getnext(start) |
| 27640 |
head=remove_node(head,start) |
| 27641 |
setlink(start,getnext(current)) |
| 27642 |
setlink(current,start) |
| 27643 |
start=startnext |
| 27644 |
end |
| 27645 |
end |
| 27646 |
return head,start,true |
| 27647 |
end |
| 27648 |
function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start) |
| 27649 |
if getprop(start,a_reordered) then |
| 27650 |
return head,start,true |
| 27651 |
end |
| 27652 |
local current=start |
| 27653 |
local startfont=getfont(start) |
| 27654 |
local startattr=getprop(start,a_syllabe) |
| 27655 |
while current do |
| 27656 |
local char=ischar(current,startfont) |
| 27657 |
local next=getnext(current) |
| 27658 |
if char and getprop(current,a_syllabe)==startattr then |
| 27659 |
if halant[char] then |
| 27660 |
if trace_steps then |
| 27661 |
logprocess("reorder pre base consonants, handle halant") |
| 27662 |
end |
| 27663 |
if next then |
| 27664 |
local char=ischar(next,startfont) |
| 27665 |
if char and zw_char[char] and getprop(next,a_syllabe)==startattr then |
| 27666 |
current=next |
| 27667 |
next=getnext(current) |
| 27668 |
end |
| 27669 |
end |
| 27670 |
local startnext=getnext(start) |
| 27671 |
head=remove_node(head,start) |
| 27672 |
setlink(start,next) |
| 27673 |
setlink(current,start) |
| 27674 |
setprop(start,"reordered",true) |
| 27675 |
start=startnext |
| 27676 |
return head,start,true |
| 27677 |
end |
| 27678 |
else |
| 27679 |
break |
| 27680 |
end |
| 27681 |
current=next |
| 27682 |
end |
| 27683 |
local startattr=getprop(start,a_syllabe) |
| 27684 |
local current=getprev(start) |
| 27685 |
while current and getprop(current,a_syllabe)==startattr do |
| 27686 |
local char=ischar(current) |
| 27687 |
if (not dependent_vowel[char] and (not getstate(current) or getstate(current,s_init))) then |
| 27688 |
if trace_steps then |
| 27689 |
logprocess("reorder pre base consonants, handle vowel or initial") |
| 27690 |
end |
| 27691 |
startnext=getnext(start) |
| 27692 |
head=remove_node(head,start) |
| 27693 |
if current==head then |
| 27694 |
setlink(start,current) |
| 27695 |
head=start |
| 27696 |
else |
| 27697 |
setlink(getprev(current),start) |
| 27698 |
setlink(start,current) |
| 27699 |
end |
| 27700 |
setprop(start,"reordered",true) |
| 27701 |
start=startnext |
| 27702 |
break |
| 27703 |
end |
| 27704 |
current=getprev(current) |
| 27705 |
end |
| 27706 |
return head,start,true |
| 27707 |
end |
| 27708 |
function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replacement) |
| 27709 |
local stop=getnext(start) |
| 27710 |
local font=getfont(start) |
| 27711 |
local last=start |
| 27712 |
while stop do |
| 27713 |
local char=ischar(stop,font) |
| 27714 |
if char and (char==c_zwnj or char==c_zwj) then |
| 27715 |
last=stop |
| 27716 |
stop=getnext(stop) |
| 27717 |
else |
| 27718 |
break |
| 27719 |
end |
| 27720 |
end |
| 27721 |
local prev=getprev(start) |
| 27722 |
if stop then |
| 27723 |
setnext(last) |
| 27724 |
setlink(prev,stop) |
| 27725 |
elseif prev then |
| 27726 |
setnext(prev) |
| 27727 |
end |
| 27728 |
if head==start then |
| 27729 |
head=stop |
| 27730 |
end |
| 27731 |
flushlist(start) |
| 27732 |
if trace_steps then |
| 27733 |
logprocess("remove joiners") |
| 27734 |
end |
| 27735 |
return head,stop,true |
| 27736 |
end |
| 27737 |
local function initialize_two(font,attr) |
| 27738 |
local devanagari=fontdata[font].resources.devanagari |
| 27739 |
if devanagari then |
| 27740 |
return devanagari.seqsubset or {},devanagari.reorderreph or {} |
| 27741 |
else |
| 27742 |
return {},{} |
| 27743 |
end |
| 27744 |
end |
| 27745 |
local function reorder_two(head,start,stop,font,attr,nbspaces) |
| 27746 |
local seqsubset,reorderreph=initialize_two(font,attr) |
| 27747 |
local halfpos=nil |
| 27748 |
local basepos=nil |
| 27749 |
local subpos=nil |
| 27750 |
local postpos=nil |
| 27751 |
reorderreph.coverage={} |
| 27752 |
rephbase[font]={} |
| 27753 |
for i=1,#seqsubset do |
| 27754 |
local subset=seqsubset[i] |
| 27755 |
local kind=subset[1] |
| 27756 |
local lookupcache=subset[2] |
| 27757 |
if kind=="rphf" then |
| 27758 |
local reph=subset[3] |
| 27759 |
local base=subset[4] |
| 27760 |
reorderreph.coverage[reph]=true |
| 27761 |
rephbase[font][reph]=base |
| 27762 |
local current=start |
| 27763 |
local last=getnext(stop) |
| 27764 |
while current~=last do |
| 27765 |
if current~=stop then |
| 27766 |
local c=getchar(current) |
| 27767 |
local found=lookupcache[c] |
| 27768 |
if found then |
| 27769 |
local next=getnext(current) |
| 27770 |
if contextchain(found,next) then |
| 27771 |
local afternext=next~=stop and getnext(next) |
| 27772 |
if afternext and zw_char[getchar(afternext)] then |
| 27773 |
current=afternext |
| 27774 |
elseif current==start then |
| 27775 |
setstate(current,s_rphf) |
| 27776 |
current=next |
| 27777 |
else |
| 27778 |
current=next |
| 27779 |
end |
| 27780 |
end |
| 27781 |
end |
| 27782 |
end |
| 27783 |
current=getnext(current) |
| 27784 |
end |
| 27785 |
elseif kind=="pref" then |
| 27786 |
local current=start |
| 27787 |
local last=getnext(stop) |
| 27788 |
while current~=last do |
| 27789 |
if current~=stop then |
| 27790 |
local c=getchar(current) |
| 27791 |
local found=lookupcache[c] |
| 27792 |
if found then |
| 27793 |
local next=getnext(current) |
| 27794 |
if contextchain(found,next) then |
| 27795 |
if not getstate(current) and not getstate(next) then |
| 27796 |
setstate(current,s_pref) |
| 27797 |
setstate(next,s_pref) |
| 27798 |
current=next |
| 27799 |
end |
| 27800 |
end |
| 27801 |
end |
| 27802 |
end |
| 27803 |
current=getnext(current) |
| 27804 |
end |
| 27805 |
elseif kind=="half" then |
| 27806 |
local current=start |
| 27807 |
local last=getnext(stop) |
| 27808 |
while current~=last do |
| 27809 |
if current~=stop then |
| 27810 |
local c=getchar(current) |
| 27811 |
local found=lookupcache[c] |
| 27812 |
if found then |
| 27813 |
local next=getnext(current) |
| 27814 |
if contextchain(found,next) then |
| 27815 |
if next~=stop and getchar(getnext(next))==c_zwnj then |
| 27816 |
current=next |
| 27817 |
elseif not getstate(current) then |
| 27818 |
setstate(current,s_half) |
| 27819 |
if not halfpos then |
| 27820 |
halfpos=current |
| 27821 |
end |
| 27822 |
end |
| 27823 |
current=getnext(current) |
| 27824 |
end |
| 27825 |
end |
| 27826 |
end |
| 27827 |
current=getnext(current) |
| 27828 |
end |
| 27829 |
elseif kind=="blwf" or kind=="vatu" then |
| 27830 |
local current=start |
| 27831 |
local last=getnext(stop) |
| 27832 |
while current~=last do |
| 27833 |
if current~=stop then |
| 27834 |
local c=getchar(current) |
| 27835 |
local found=lookupcache[c] |
| 27836 |
if found then |
| 27837 |
local next=getnext(current) |
| 27838 |
if contextchain(found,next) then |
| 27839 |
if not getstate(current) and not getstate(next) then |
| 27840 |
setstate(current,s_blwf) |
| 27841 |
setstate(next,s_blwf) |
| 27842 |
current=next |
| 27843 |
subpos=current |
| 27844 |
end |
| 27845 |
end |
| 27846 |
end |
| 27847 |
end |
| 27848 |
current=getnext(current) |
| 27849 |
end |
| 27850 |
elseif kind=="pstf" then |
| 27851 |
local current=start |
| 27852 |
local last=getnext(stop) |
| 27853 |
while current~=last do |
| 27854 |
if current~=stop then |
| 27855 |
local c=getchar(current) |
| 27856 |
local found=lookupcache[c] |
| 27857 |
if found then |
| 27858 |
local next=getnext(current) |
| 27859 |
if contextchain(found,next) then |
| 27860 |
if not getstate(current) and not getstate(next) then |
| 27861 |
setstate(current,s_pstf) |
| 27862 |
setstate(next,s_pstf) |
| 27863 |
current=next |
| 27864 |
postpos=current |
| 27865 |
end |
| 27866 |
end |
| 27867 |
end |
| 27868 |
end |
| 27869 |
current=getnext(current) |
| 27870 |
end |
| 27871 |
end |
| 27872 |
end |
| 27873 |
local current,base,firstcons,subnotafterbase,postnotafterbase=start,nil,nil,nil,nil |
| 27874 |
if getstate(start,s_rphf) then |
| 27875 |
current=getnext(getnext(start)) |
| 27876 |
end |
| 27877 |
if current~=getnext(stop) and getchar(current)==c_nbsp then |
| 27878 |
if current==stop then |
| 27879 |
stop=getprev(stop) |
| 27880 |
head=remove_node(head,current) |
| 27881 |
flushnode(current) |
| 27882 |
if trace_steps then |
| 27883 |
logprocess("reorder two, remove nbsp") |
| 27884 |
end |
| 27885 |
return head,stop,nbspaces |
| 27886 |
else |
| 27887 |
nbspaces=nbspaces+1 |
| 27888 |
base=current |
| 27889 |
current=getnext(current) |
| 27890 |
if current~=stop then |
| 27891 |
local char=getchar(current) |
| 27892 |
if nukta[char] then |
| 27893 |
current=getnext(current) |
| 27894 |
char=getchar(current) |
| 27895 |
end |
| 27896 |
if char==c_zwj then |
| 27897 |
local next=getnext(current) |
| 27898 |
if current~=stop and next~=stop and halant[getchar(next)] then |
| 27899 |
current=next |
| 27900 |
next=getnext(current) |
| 27901 |
local tmp=getnext(next) |
| 27902 |
local changestop=next==stop |
| 27903 |
setnext(next) |
| 27904 |
setstate(current,s_pref) |
| 27905 |
current=processcharacters(current,font) |
| 27906 |
setstate(current,s_blwf) |
| 27907 |
current=processcharacters(current,font) |
| 27908 |
setstate(current,s_pstf) |
| 27909 |
current=processcharacters(current,font) |
| 27910 |
setstate(current,unsetvalue) |
| 27911 |
if halant[getchar(current)] then |
| 27912 |
setnext(getnext(current),tmp) |
| 27913 |
if show_syntax_errors then |
| 27914 |
head,current=inject_syntax_error(head,current,char) |
| 27915 |
end |
| 27916 |
else |
| 27917 |
setnext(current,tmp) |
| 27918 |
if changestop then |
| 27919 |
stop=current |
| 27920 |
end |
| 27921 |
end |
| 27922 |
end |
| 27923 |
end |
| 27924 |
end |
| 27925 |
if trace_steps then |
| 27926 |
logprocess("reorder two, handle nbsp") |
| 27927 |
end |
| 27928 |
end |
| 27929 |
else |
| 27930 |
local last=getnext(stop) |
| 27931 |
while current~=last do |
| 27932 |
local next=getnext(current) |
| 27933 |
if current==subpos then |
| 27934 |
subnotafterbase=current |
| 27935 |
end |
| 27936 |
if current==postpos then |
| 27937 |
postnotafterbase=current |
| 27938 |
end |
| 27939 |
if consonant[getchar(current)] then |
| 27940 |
if not (current~=stop and next~=stop and halant[getchar(next)] and getchar(getnext(next))==c_zwj) then |
| 27941 |
if not firstcons then |
| 27942 |
firstcons=current |
| 27943 |
end |
| 27944 |
local a=getstate(current) |
| 27945 |
if not (a==s_blwf or a==s_pstf or (a~=s_rphf and a~=s_blwf and ra[getchar(current)])) then |
| 27946 |
base=current |
| 27947 |
if subnotafterbase then |
| 27948 |
subpos=base |
| 27949 |
end |
| 27950 |
if postnotafterbase then |
| 27951 |
postpos=base |
| 27952 |
end |
| 27953 |
end |
| 27954 |
end |
| 27955 |
end |
| 27956 |
current=next |
| 27957 |
end |
| 27958 |
if not base then |
| 27959 |
base=firstcons |
| 27960 |
end |
| 27961 |
end |
| 27962 |
if not base then |
| 27963 |
if getstate(start,s_rphf) then |
| 27964 |
setstate(start,unsetvalue) |
| 27965 |
end |
| 27966 |
return head,stop,nbspaces |
| 27967 |
else |
| 27968 |
if getstate(base) then |
| 27969 |
setstate(base,unsetvalue) |
| 27970 |
end |
| 27971 |
basepos=base |
| 27972 |
end |
| 27973 |
if not halfpos then |
| 27974 |
halfpos=base |
| 27975 |
end |
| 27976 |
if not subpos then |
| 27977 |
subpos=base |
| 27978 |
end |
| 27979 |
if not postpos then |
| 27980 |
postpos=subpos or base |
| 27981 |
end |
| 27982 |
local moved={} |
| 27983 |
local current=start |
| 27984 |
local last=getnext(stop) |
| 27985 |
while current~=last do |
| 27986 |
local char=getchar(current) |
| 27987 |
local target=nil |
| 27988 |
local cn=getnext(current) |
| 27989 |
local tpm=twopart_mark[char] |
| 27990 |
if tpm then |
| 27991 |
while tpm do |
| 27992 |
local extra=copy_node(current) |
| 27993 |
copyinjection(extra,current) |
| 27994 |
char=tpm[1] |
| 27995 |
setchar(current,char) |
| 27996 |
setchar(extra,tpm[2]) |
| 27997 |
head=insertnodeafter(head,current,extra) |
| 27998 |
tpm=twopart_mark[char] |
| 27999 |
end |
| 28000 |
if tpm and trace_steps then |
| 28001 |
logprocess("reorder two, handle matra") |
| 28002 |
end |
| 28003 |
end |
| 28004 |
if not moved[current] and dependent_vowel[char] then |
| 28005 |
if pre_mark[char] then |
| 28006 |
moved[current]=true |
| 28007 |
local prev,next=getboth(current) |
| 28008 |
setlink(prev,next) |
| 28009 |
if current==stop then |
| 28010 |
stop=getprev(current) |
| 28011 |
end |
| 28012 |
local pos |
| 28013 |
if before_main[char] then |
| 28014 |
pos=basepos |
| 28015 |
else |
| 28016 |
pos=halfpos |
| 28017 |
end |
| 28018 |
local ppos=getprev(pos) |
| 28019 |
while ppos and getprop(ppos,a_syllabe)==getprop(pos,a_syllabe) do |
| 28020 |
if getstate(ppos,s_pref) then |
| 28021 |
pos=ppos |
| 28022 |
end |
| 28023 |
ppos=getprev(ppos) |
| 28024 |
end |
| 28025 |
local ppos=getprev(pos) |
| 28026 |
while ppos and getprop(ppos,a_syllabe)==getprop(pos,a_syllabe) and halant[ischar(ppos)] do |
| 28027 |
ppos=getprev(ppos) |
| 28028 |
if ppos and getprop(ppos,a_syllabe)==getprop(pos,a_syllabe) and consonant[ischar(ppos)] then |
| 28029 |
pos=ppos |
| 28030 |
ppos=getprev(ppos) |
| 28031 |
else |
| 28032 |
break |
| 28033 |
end |
| 28034 |
end |
| 28035 |
if pos==start then |
| 28036 |
if head==start then |
| 28037 |
head=current |
| 28038 |
end |
| 28039 |
start=current |
| 28040 |
end |
| 28041 |
setlink(getprev(pos),current) |
| 28042 |
setlink(current,pos) |
| 28043 |
if trace_steps then |
| 28044 |
logprocess("reorder two, handle pre mark") |
| 28045 |
end |
| 28046 |
elseif above_mark[char] then |
| 28047 |
target=subpos |
| 28048 |
if postpos==subpos then |
| 28049 |
postpos=current |
| 28050 |
end |
| 28051 |
subpos=current |
| 28052 |
elseif below_mark[char] then |
| 28053 |
target=subpos |
| 28054 |
if postpos==subpos then |
| 28055 |
postpos=current |
| 28056 |
end |
| 28057 |
subpos=current |
| 28058 |
elseif post_mark[char] then |
| 28059 |
local n=getnext(postpos) |
| 28060 |
while n do |
| 28061 |
local v=ischar(n,font) |
| 28062 |
if nukta[v] or stress_tone_mark[v] or vowel_modifier[v] then |
| 28063 |
postpos=n |
| 28064 |
else |
| 28065 |
break |
| 28066 |
end |
| 28067 |
n=getnext(n) |
| 28068 |
end |
| 28069 |
target=postpos |
| 28070 |
postpos=current |
| 28071 |
end |
| 28072 |
if mark_above_below_post[char] then |
| 28073 |
local prev=getprev(current) |
| 28074 |
if prev~=target then |
| 28075 |
local next=getnext(current) |
| 28076 |
setlink(prev,next) |
| 28077 |
if current==stop then |
| 28078 |
stop=prev |
| 28079 |
end |
| 28080 |
setlink(current,getnext(target)) |
| 28081 |
setlink(target,current) |
| 28082 |
if trace_steps then |
| 28083 |
logprocess("reorder two, handle mark") |
| 28084 |
end |
| 28085 |
end |
| 28086 |
end |
| 28087 |
end |
| 28088 |
current=cn |
| 28089 |
end |
| 28090 |
local current=getnext(start) |
| 28091 |
local last=getnext(stop) |
| 28092 |
while current~=last do |
| 28093 |
local char=getchar(current) |
| 28094 |
local cn=getnext(current) |
| 28095 |
if halant[char] and ra[ischar(cn)] and (not getstate(cn,s_rphf)) and (not getstate(cn,s_blwf)) then |
| 28096 |
if after_main[ischar(cn)] then |
| 28097 |
local prev=getprev(current) |
| 28098 |
local next=getnext(cn) |
| 28099 |
local bpn=getnext(basepos) |
| 28100 |
while bpn and dependent_vowel[ischar(bpn)] do |
| 28101 |
basepos=bpn |
| 28102 |
bpn=getnext(bpn) |
| 28103 |
end |
| 28104 |
if basepos~=prev then |
| 28105 |
setlink(prev,next) |
| 28106 |
setlink(cn,getnext(basepos)) |
| 28107 |
setlink(basepos,current) |
| 28108 |
if cn==stop then |
| 28109 |
stop=prev |
| 28110 |
end |
| 28111 |
cn=next |
| 28112 |
if trace_steps then |
| 28113 |
logprocess("reorder two, handle halant and ra") |
| 28114 |
end |
| 28115 |
end |
| 28116 |
end |
| 28117 |
end |
| 28118 |
current=cn |
| 28119 |
end |
| 28120 |
local current=start |
| 28121 |
local c=nil |
| 28122 |
while current~=stop do |
| 28123 |
local char=getchar(current) |
| 28124 |
if halant[char] or stress_tone_mark[char] then |
| 28125 |
if not c then |
| 28126 |
c=current |
| 28127 |
end |
| 28128 |
else |
| 28129 |
c=nil |
| 28130 |
end |
| 28131 |
local next=getnext(current) |
| 28132 |
if c and nukta[getchar(next)] then |
| 28133 |
if head==c then |
| 28134 |
head=next |
| 28135 |
end |
| 28136 |
if stop==next then |
| 28137 |
stop=current |
| 28138 |
end |
| 28139 |
setlink(getprev(c),next) |
| 28140 |
local nextnext=getnext(next) |
| 28141 |
setnext(current,nextnext) |
| 28142 |
local nextnextnext=getnext(nextnext) |
| 28143 |
if nextnextnext then |
| 28144 |
setprev(nextnextnext,current) |
| 28145 |
end |
| 28146 |
setlink(nextnext,c) |
| 28147 |
if trace_steps then |
| 28148 |
logprocess("reorder two, handle nukta") |
| 28149 |
end |
| 28150 |
end |
| 28151 |
if stop==current then break end |
| 28152 |
current=getnext(current) |
| 28153 |
end |
| 28154 |
if getchar(base)==c_nbsp then |
| 28155 |
if base==stop then |
| 28156 |
stop=getprev(stop) |
| 28157 |
end |
| 28158 |
nbspaces=nbspaces-1 |
| 28159 |
head=remove_node(head,base) |
| 28160 |
flushnode(base) |
| 28161 |
if trace_steps then |
| 28162 |
logprocess("reorder two, handle nbsp") |
| 28163 |
end |
| 28164 |
end |
| 28165 |
return head,stop,nbspaces |
| 28166 |
end |
| 28167 |
local separator={} |
| 28168 |
imerge(separator,consonant) |
| 28169 |
imerge(separator,independent_vowel) |
| 28170 |
imerge(separator,dependent_vowel) |
| 28171 |
imerge(separator,vowel_modifier) |
| 28172 |
imerge(separator,stress_tone_mark) |
| 28173 |
for k,v in next,nukta do separator[k]=true end |
| 28174 |
for k,v in next,halant do separator[k]=true end |
| 28175 |
local function analyze_next_chars_one(c,font,variant) |
| 28176 |
local n=getnext(c) |
| 28177 |
if not n then |
| 28178 |
return c |
| 28179 |
end |
| 28180 |
local v=ischar(n,font) |
| 28181 |
if variant==1 then |
| 28182 |
if v and nukta[v] then |
| 28183 |
n=getnext(n) |
| 28184 |
if n then |
| 28185 |
v=ischar(n,font) |
| 28186 |
end |
| 28187 |
end |
| 28188 |
if n and v then |
| 28189 |
local nn=getnext(n) |
| 28190 |
if nn then |
| 28191 |
local vv=ischar(nn,font) |
| 28192 |
if vv then |
| 28193 |
local nnn=getnext(nn) |
| 28194 |
if nnn then |
| 28195 |
local vvv=ischar(nnn,font) |
| 28196 |
if vvv then |
| 28197 |
if vv==c_zwj and consonant[vvv] then |
| 28198 |
c=nnn |
| 28199 |
elseif (vv==c_zwnj or vv==c_zwj) and halant[vvv] then |
| 28200 |
local nnnn=getnext(nnn) |
| 28201 |
if nnnn then |
| 28202 |
local vvvv=ischar(nnnn,font) |
| 28203 |
if vvvv and consonant[vvvv] then |
| 28204 |
c=nnnn |
| 28205 |
end |
| 28206 |
end |
| 28207 |
end |
| 28208 |
end |
| 28209 |
end |
| 28210 |
end |
| 28211 |
end |
| 28212 |
end |
| 28213 |
elseif variant==2 then |
| 28214 |
if v and nukta[v] then |
| 28215 |
c=n |
| 28216 |
end |
| 28217 |
n=getnext(c) |
| 28218 |
if n then |
| 28219 |
v=ischar(n,font) |
| 28220 |
if v then |
| 28221 |
local nn=getnext(n) |
| 28222 |
if nn then |
| 28223 |
local vv=ischar(nn,font) |
| 28224 |
if vv and zw_char[v] then |
| 28225 |
n=nn |
| 28226 |
v=vv |
| 28227 |
nn=getnext(nn) |
| 28228 |
vv=nn and ischar(nn,font) |
| 28229 |
end |
| 28230 |
if vv and halant[v] and consonant[vv] then |
| 28231 |
c=nn |
| 28232 |
end |
| 28233 |
end |
| 28234 |
end |
| 28235 |
end |
| 28236 |
end |
| 28237 |
n=getnext(c) |
| 28238 |
if not n then |
| 28239 |
return c |
| 28240 |
end |
| 28241 |
v=ischar(n,font) |
| 28242 |
if not v then |
| 28243 |
return c |
| 28244 |
end |
| 28245 |
local already_pre_mark |
| 28246 |
local already_above_mark |
| 28247 |
local already_below_mark |
| 28248 |
local already_post_mark |
| 28249 |
while dependent_vowel[v] do |
| 28250 |
local vowels=twopart_mark[v] |
| 28251 |
if vowels then |
| 28252 |
for k=1,#vowels do |
| 28253 |
local v=vowels[k] |
| 28254 |
if pre_mark[v] and not already_pre_mark then |
| 28255 |
already_pre_mark=true |
| 28256 |
elseif above_mark[v] and not already_above_mark then |
| 28257 |
already_above_mark=true |
| 28258 |
elseif below_mark[v] and not already_below_mark then |
| 28259 |
already_below_mark=true |
| 28260 |
elseif post_mark[v] and not already_post_mark then |
| 28261 |
already_post_mark=true |
| 28262 |
elseif devanagarihash[font].conjuncts=="continue" then |
| 28263 |
else |
| 28264 |
return c |
| 28265 |
end |
| 28266 |
end |
| 28267 |
else |
| 28268 |
if pre_mark[v] and not already_pre_mark then |
| 28269 |
already_pre_mark=true |
| 28270 |
elseif post_mark[v] and not already_post_mark then |
| 28271 |
already_post_mark=true |
| 28272 |
elseif below_mark[v] and not already_below_mark then |
| 28273 |
already_below_mark=true |
| 28274 |
elseif above_mark[v] and not already_above_mark then |
| 28275 |
already_above_mark=true |
| 28276 |
elseif devanagarihash[font].conjuncts=="continue" then |
| 28277 |
else |
| 28278 |
return c |
| 28279 |
end |
| 28280 |
end |
| 28281 |
c=n |
| 28282 |
n=getnext(c) |
| 28283 |
if not n then |
| 28284 |
return c |
| 28285 |
end |
| 28286 |
v=ischar(n,font) |
| 28287 |
if not v then |
| 28288 |
return c |
| 28289 |
end |
| 28290 |
end |
| 28291 |
if nukta[v] then |
| 28292 |
c=n |
| 28293 |
n=getnext(c) |
| 28294 |
if not n then |
| 28295 |
return c |
| 28296 |
end |
| 28297 |
v=ischar(n,font) |
| 28298 |
if not v then |
| 28299 |
return c |
| 28300 |
end |
| 28301 |
end |
| 28302 |
if halant[v] then |
| 28303 |
c=n |
| 28304 |
n=getnext(c) |
| 28305 |
if not n then |
| 28306 |
return c |
| 28307 |
end |
| 28308 |
v=ischar(n,font) |
| 28309 |
if not v then |
| 28310 |
return c |
| 28311 |
end |
| 28312 |
end |
| 28313 |
if vowel_modifier[v] then |
| 28314 |
c=n |
| 28315 |
n=getnext(c) |
| 28316 |
if not n then |
| 28317 |
return c |
| 28318 |
end |
| 28319 |
v=ischar(n,font) |
| 28320 |
if not v then |
| 28321 |
return c |
| 28322 |
end |
| 28323 |
end |
| 28324 |
if stress_tone_mark[v] then |
| 28325 |
c=n |
| 28326 |
n=getnext(c) |
| 28327 |
if not n then |
| 28328 |
return c |
| 28329 |
end |
| 28330 |
v=ischar(n,font) |
| 28331 |
if not v then |
| 28332 |
return c |
| 28333 |
end |
| 28334 |
end |
| 28335 |
if stress_tone_mark[v] then |
| 28336 |
return n |
| 28337 |
else |
| 28338 |
return c |
| 28339 |
end |
| 28340 |
end |
| 28341 |
local function analyze_next_chars_two(c,font) |
| 28342 |
local n=getnext(c) |
| 28343 |
if not n then |
| 28344 |
return c |
| 28345 |
end |
| 28346 |
local v=ischar(n,font) |
| 28347 |
if v and nukta[v] then |
| 28348 |
c=n |
| 28349 |
end |
| 28350 |
n=c |
| 28351 |
while true do |
| 28352 |
local nn=getnext(n) |
| 28353 |
if nn then |
| 28354 |
local vv=ischar(nn,font) |
| 28355 |
if vv then |
| 28356 |
if halant[vv] then |
| 28357 |
n=nn |
| 28358 |
local nnn=getnext(nn) |
| 28359 |
if nnn then |
| 28360 |
local vvv=ischar(nnn,font) |
| 28361 |
if vvv and zw_char[vvv] then |
| 28362 |
n=nnn |
| 28363 |
end |
| 28364 |
end |
| 28365 |
elseif vv==c_zwnj or vv==c_zwj then |
| 28366 |
local nnn=getnext(nn) |
| 28367 |
if nnn then |
| 28368 |
local vvv=ischar(nnn,font) |
| 28369 |
if vvv and halant[vvv] then |
| 28370 |
n=nnn |
| 28371 |
end |
| 28372 |
end |
| 28373 |
else |
| 28374 |
break |
| 28375 |
end |
| 28376 |
local nn=getnext(n) |
| 28377 |
if nn then |
| 28378 |
local vv=ischar(nn,font) |
| 28379 |
if vv and consonant[vv] then |
| 28380 |
n=nn |
| 28381 |
local nnn=getnext(nn) |
| 28382 |
if nnn then |
| 28383 |
local vvv=ischar(nnn,font) |
| 28384 |
if vvv and nukta[vvv] then |
| 28385 |
n=nnn |
| 28386 |
end |
| 28387 |
end |
| 28388 |
c=n |
| 28389 |
else |
| 28390 |
break |
| 28391 |
end |
| 28392 |
else |
| 28393 |
break |
| 28394 |
end |
| 28395 |
else |
| 28396 |
break |
| 28397 |
end |
| 28398 |
else |
| 28399 |
break |
| 28400 |
end |
| 28401 |
end |
| 28402 |
if not c then |
| 28403 |
return |
| 28404 |
end |
| 28405 |
n=getnext(c) |
| 28406 |
if not n then |
| 28407 |
return c |
| 28408 |
end |
| 28409 |
v=ischar(n,font) |
| 28410 |
if not v then |
| 28411 |
return c |
| 28412 |
end |
| 28413 |
if anudatta[v] then |
| 28414 |
c=n |
| 28415 |
n=getnext(c) |
| 28416 |
if not n then |
| 28417 |
return c |
| 28418 |
end |
| 28419 |
v=ischar(n,font) |
| 28420 |
if not v then |
| 28421 |
return c |
| 28422 |
end |
| 28423 |
end |
| 28424 |
if halant[v] then |
| 28425 |
c=n |
| 28426 |
n=getnext(c) |
| 28427 |
if not n then |
| 28428 |
return c |
| 28429 |
end |
| 28430 |
v=ischar(n,font) |
| 28431 |
if not v then |
| 28432 |
return c |
| 28433 |
end |
| 28434 |
if v==c_zwnj or v==c_zwj then |
| 28435 |
c=n |
| 28436 |
n=getnext(c) |
| 28437 |
if not n then |
| 28438 |
return c |
| 28439 |
end |
| 28440 |
v=ischar(n,font) |
| 28441 |
if not v then |
| 28442 |
return c |
| 28443 |
end |
| 28444 |
end |
| 28445 |
else |
| 28446 |
local already_pre_mark |
| 28447 |
local already_above_mark |
| 28448 |
local already_below_mark |
| 28449 |
local already_post_mark |
| 28450 |
while dependent_vowel[v] do |
| 28451 |
local vowels=twopart_mark[v] |
| 28452 |
if vowels then |
| 28453 |
for k=1,#vowels do |
| 28454 |
local v=vowels[k] |
| 28455 |
if pre_mark[v] and not already_pre_mark then |
| 28456 |
already_pre_mark=true |
| 28457 |
elseif above_mark[v] and not already_above_mark then |
| 28458 |
already_above_mark=true |
| 28459 |
elseif below_mark[v] and not already_below_mark then |
| 28460 |
already_below_mark=true |
| 28461 |
elseif post_mark[v] and not already_post_mark then |
| 28462 |
already_post_mark=true |
| 28463 |
elseif devanagarihash[font].conjuncts=="continue" then |
| 28464 |
else |
| 28465 |
return c |
| 28466 |
end |
| 28467 |
end |
| 28468 |
else |
| 28469 |
if pre_mark[v] and not already_pre_mark then |
| 28470 |
already_pre_mark=true |
| 28471 |
elseif post_mark[v] and not already_post_mark then |
| 28472 |
already_post_mark=true |
| 28473 |
elseif below_mark[v] and not already_below_mark then |
| 28474 |
already_below_mark=true |
| 28475 |
elseif above_mark[v] and not already_above_mark then |
| 28476 |
already_above_mark=true |
| 28477 |
elseif devanagarihash[font].conjuncts=="continue" then |
| 28478 |
else |
| 28479 |
return c |
| 28480 |
end |
| 28481 |
end |
| 28482 |
c=n |
| 28483 |
n=getnext(c) |
| 28484 |
if not n then |
| 28485 |
return c |
| 28486 |
end |
| 28487 |
v=ischar(n,font) |
| 28488 |
if not v then |
| 28489 |
return c |
| 28490 |
end |
| 28491 |
end |
| 28492 |
if nukta[v] then |
| 28493 |
c=n |
| 28494 |
n=getnext(c) |
| 28495 |
if not n then |
| 28496 |
return c |
| 28497 |
end |
| 28498 |
v=ischar(n,font) |
| 28499 |
if not v then |
| 28500 |
return c |
| 28501 |
end |
| 28502 |
end |
| 28503 |
if halant[v] then |
| 28504 |
c=n |
| 28505 |
n=getnext(c) |
| 28506 |
if not n then |
| 28507 |
return c |
| 28508 |
end |
| 28509 |
v=ischar(n,font) |
| 28510 |
if not v then |
| 28511 |
return c |
| 28512 |
end |
| 28513 |
end |
| 28514 |
end |
| 28515 |
if vowel_modifier[v] then |
| 28516 |
c=n |
| 28517 |
n=getnext(c) |
| 28518 |
if not n then |
| 28519 |
return c |
| 28520 |
end |
| 28521 |
v=ischar(n,font) |
| 28522 |
if not v then |
| 28523 |
return c |
| 28524 |
end |
| 28525 |
end |
| 28526 |
if stress_tone_mark[v] then |
| 28527 |
c=n |
| 28528 |
n=getnext(c) |
| 28529 |
if not n then |
| 28530 |
return c |
| 28531 |
end |
| 28532 |
v=ischar(n,font) |
| 28533 |
if not v then |
| 28534 |
return c |
| 28535 |
end |
| 28536 |
end |
| 28537 |
if stress_tone_mark[v] then |
| 28538 |
return n |
| 28539 |
else |
| 28540 |
return c |
| 28541 |
end |
| 28542 |
end |
| 28543 |
local function method_one(head,font,attr) |
| 28544 |
local current=head |
| 28545 |
local start=true |
| 28546 |
local done=false |
| 28547 |
local nbspaces=0 |
| 28548 |
local syllabe=0 |
| 28549 |
while current do |
| 28550 |
local char=ischar(current,font) |
| 28551 |
if char then |
| 28552 |
done=true |
| 28553 |
local syllablestart=current |
| 28554 |
local syllableend=nil |
| 28555 |
local c=current |
| 28556 |
local n=getnext(c) |
| 28557 |
local first=char |
| 28558 |
if n and ra[first] then |
| 28559 |
local second=ischar(n,font) |
| 28560 |
if second and halant[second] then |
| 28561 |
local n=getnext(n) |
| 28562 |
if n then |
| 28563 |
local third=ischar(n,font) |
| 28564 |
if third then |
| 28565 |
c=n |
| 28566 |
first=third |
| 28567 |
end |
| 28568 |
end |
| 28569 |
end |
| 28570 |
end |
| 28571 |
local standalone=first==c_nbsp |
| 28572 |
if standalone then |
| 28573 |
local prev=getprev(current) |
| 28574 |
if prev then |
| 28575 |
local prevchar=ischar(prev,font) |
| 28576 |
if not prevchar then |
| 28577 |
elseif not separator[prevchar] then |
| 28578 |
else |
| 28579 |
standalone=false |
| 28580 |
end |
| 28581 |
else |
| 28582 |
end |
| 28583 |
end |
| 28584 |
if standalone then |
| 28585 |
local syllableend=analyze_next_chars_one(c,font,2) |
| 28586 |
current=getnext(syllableend) |
| 28587 |
if syllablestart~=syllableend then |
| 28588 |
head,current,nbspaces=reorder_one(head,syllablestart,syllableend,font,attr,nbspaces) |
| 28589 |
current=getnext(current) |
| 28590 |
end |
| 28591 |
else |
| 28592 |
if consonant[char] then |
| 28593 |
local prevc=true |
| 28594 |
while prevc do |
| 28595 |
prevc=false |
| 28596 |
local n=getnext(current) |
| 28597 |
if not n then |
| 28598 |
break |
| 28599 |
end |
| 28600 |
local v=ischar(n,font) |
| 28601 |
if not v then |
| 28602 |
break |
| 28603 |
end |
| 28604 |
if nukta[v] then |
| 28605 |
n=getnext(n) |
| 28606 |
if not n then |
| 28607 |
break |
| 28608 |
end |
| 28609 |
v=ischar(n,font) |
| 28610 |
if not v then |
| 28611 |
break |
| 28612 |
end |
| 28613 |
end |
| 28614 |
if halant[v] then |
| 28615 |
n=getnext(n) |
| 28616 |
if not n then |
| 28617 |
break |
| 28618 |
end |
| 28619 |
v=ischar(n,font) |
| 28620 |
if not v then |
| 28621 |
break |
| 28622 |
end |
| 28623 |
if v==c_zwnj or v==c_zwj then |
| 28624 |
n=getnext(n) |
| 28625 |
if not n then |
| 28626 |
break |
| 28627 |
end |
| 28628 |
v=ischar(n,font) |
| 28629 |
if not v then |
| 28630 |
break |
| 28631 |
end |
| 28632 |
end |
| 28633 |
if consonant[v] then |
| 28634 |
prevc=true |
| 28635 |
current=n |
| 28636 |
end |
| 28637 |
end |
| 28638 |
end |
| 28639 |
local n=getnext(current) |
| 28640 |
if n then |
| 28641 |
local v=ischar(n,font) |
| 28642 |
if v and nukta[v] then |
| 28643 |
current=n |
| 28644 |
n=getnext(current) |
| 28645 |
end |
| 28646 |
end |
| 28647 |
syllableend=current |
| 28648 |
current=n |
| 28649 |
if current then |
| 28650 |
local v=ischar(current,font) |
| 28651 |
if not v then |
| 28652 |
elseif halant[v] then |
| 28653 |
local n=getnext(current) |
| 28654 |
if n then |
| 28655 |
local v=ischar(n,font) |
| 28656 |
if v and zw_char[v] then |
| 28657 |
syllableend=n |
| 28658 |
current=getnext(n) |
| 28659 |
else |
| 28660 |
syllableend=current |
| 28661 |
current=n |
| 28662 |
end |
| 28663 |
else |
| 28664 |
syllableend=current |
| 28665 |
current=n |
| 28666 |
end |
| 28667 |
else |
| 28668 |
if dependent_vowel[v] then |
| 28669 |
syllableend=current |
| 28670 |
current=getnext(current) |
| 28671 |
v=ischar(current,font) |
| 28672 |
end |
| 28673 |
if v and vowel_modifier[v] then |
| 28674 |
syllableend=current |
| 28675 |
current=getnext(current) |
| 28676 |
v=ischar(current,font) |
| 28677 |
end |
| 28678 |
if v and stress_tone_mark[v] then |
| 28679 |
syllableend=current |
| 28680 |
current=getnext(current) |
| 28681 |
end |
| 28682 |
end |
| 28683 |
end |
| 28684 |
if syllablestart~=syllableend then |
| 28685 |
if syllableend then |
| 28686 |
syllabe=syllabe+1 |
| 28687 |
local c=syllablestart |
| 28688 |
local n=getnext(syllableend) |
| 28689 |
while c~=n do |
| 28690 |
setprop(c,a_syllabe,syllabe) |
| 28691 |
c=getnext(c) |
| 28692 |
end |
| 28693 |
end |
| 28694 |
head,current,nbspaces=reorder_one(head,syllablestart,syllableend,font,attr,nbspaces) |
| 28695 |
current=getnext(current) |
| 28696 |
end |
| 28697 |
elseif independent_vowel[char] then |
| 28698 |
syllableend=current |
| 28699 |
current=getnext(current) |
| 28700 |
if current then |
| 28701 |
local v=ischar(current,font) |
| 28702 |
if v then |
| 28703 |
if vowel_modifier[v] then |
| 28704 |
syllableend=current |
| 28705 |
current=getnext(current) |
| 28706 |
v=ischar(current,font) |
| 28707 |
end |
| 28708 |
if v and stress_tone_mark[v] then |
| 28709 |
syllableend=current |
| 28710 |
current=getnext(current) |
| 28711 |
end |
| 28712 |
end |
| 28713 |
end |
| 28714 |
else |
| 28715 |
if show_syntax_errors then |
| 28716 |
local mark=mark_pre_above_below_post[char] |
| 28717 |
if mark then |
| 28718 |
head,current=inject_syntax_error(head,current,char) |
| 28719 |
end |
| 28720 |
end |
| 28721 |
current=getnext(current) |
| 28722 |
end |
| 28723 |
end |
| 28724 |
else |
| 28725 |
current=getnext(current) |
| 28726 |
end |
| 28727 |
start=false |
| 28728 |
end |
| 28729 |
if nbspaces>0 then |
| 28730 |
head=replace_all_nbsp(head) |
| 28731 |
end |
| 28732 |
current=head |
| 28733 |
local n=0 |
| 28734 |
while current do |
| 28735 |
local char=ischar(current,font) |
| 28736 |
if char then |
| 28737 |
if n==0 and not getstate(current) then |
| 28738 |
setstate(current,s_init) |
| 28739 |
end |
| 28740 |
n=n+1 |
| 28741 |
else |
| 28742 |
n=0 |
| 28743 |
end |
| 28744 |
current=getnext(current) |
| 28745 |
end |
| 28746 |
return head,done |
| 28747 |
end |
| 28748 |
local function method_two(head,font,attr) |
| 28749 |
local current=head |
| 28750 |
local start=true |
| 28751 |
local done=false |
| 28752 |
local syllabe=0 |
| 28753 |
local nbspaces=0 |
| 28754 |
while current do |
| 28755 |
local syllablestart=nil |
| 28756 |
local syllableend=nil |
| 28757 |
local char=ischar(current,font) |
| 28758 |
if char then |
| 28759 |
done=true |
| 28760 |
syllablestart=current |
| 28761 |
local c=current |
| 28762 |
local n=getnext(current) |
| 28763 |
if n and ra[char] then |
| 28764 |
local nextchar=ischar(n,font) |
| 28765 |
if nextchar and halant[nextchar] then |
| 28766 |
local n=getnext(n) |
| 28767 |
if n then |
| 28768 |
local nextnextchar=ischar(n,font) |
| 28769 |
if nextnextchar then |
| 28770 |
c=n |
| 28771 |
char=nextnextchar |
| 28772 |
end |
| 28773 |
end |
| 28774 |
end |
| 28775 |
end |
| 28776 |
if independent_vowel[char] then |
| 28777 |
current=analyze_next_chars_one(c,font,1) |
| 28778 |
syllableend=current |
| 28779 |
else |
| 28780 |
local standalone=char==c_nbsp |
| 28781 |
if standalone then |
| 28782 |
nbspaces=nbspaces+1 |
| 28783 |
local p=getprev(current) |
| 28784 |
if not p then |
| 28785 |
elseif ischar(p,font) then |
| 28786 |
elseif not separator[getchar(p)] then |
| 28787 |
else |
| 28788 |
standalone=false |
| 28789 |
end |
| 28790 |
end |
| 28791 |
if standalone then |
| 28792 |
current=analyze_next_chars_one(c,font,2) |
| 28793 |
syllableend=current |
| 28794 |
elseif consonant[getchar(current)] then |
| 28795 |
current=analyze_next_chars_two(current,font) |
| 28796 |
syllableend=current |
| 28797 |
end |
| 28798 |
end |
| 28799 |
end |
| 28800 |
if syllableend then |
| 28801 |
syllabe=syllabe+1 |
| 28802 |
local c=syllablestart |
| 28803 |
local n=getnext(syllableend) |
| 28804 |
while c~=n do |
| 28805 |
setprop(c,a_syllabe,syllabe) |
| 28806 |
c=getnext(c) |
| 28807 |
end |
| 28808 |
end |
| 28809 |
if syllableend and syllablestart~=syllableend then |
| 28810 |
head,current,nbspaces=reorder_two(head,syllablestart,syllableend,font,attr,nbspaces) |
| 28811 |
end |
| 28812 |
if not syllableend and show_syntax_errors then |
| 28813 |
local char=ischar(current,font) |
| 28814 |
if char and not getstate(current) then |
| 28815 |
local mark=mark_pre_above_below_post[char] |
| 28816 |
if mark then |
| 28817 |
head,current=inject_syntax_error(head,current,char) |
| 28818 |
end |
| 28819 |
end |
| 28820 |
end |
| 28821 |
start=false |
| 28822 |
current=getnext(current) |
| 28823 |
end |
| 28824 |
if nbspaces>0 then |
| 28825 |
head=replace_all_nbsp(head) |
| 28826 |
end |
| 28827 |
current=head |
| 28828 |
local n=0 |
| 28829 |
while current do |
| 28830 |
local char=ischar(current,font) |
| 28831 |
if char then |
| 28832 |
if n==0 and not getstate(current) then |
| 28833 |
setstate(current,s_init) |
| 28834 |
end |
| 28835 |
n=n+1 |
| 28836 |
else |
| 28837 |
n=0 |
| 28838 |
end |
| 28839 |
current=getnext(current) |
| 28840 |
end |
| 28841 |
return head,done |
| 28842 |
end |
| 28843 |
for i=1,nofscripts do |
| 28844 |
methods[scripts_one[i]]=method_one |
| 28845 |
methods[scripts_two[i]]=method_two |
| 28846 |
end |
| 28847 |
|
| 28848 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-osd”] --- |
| 28849 |
|
| 28850 |
|
| 28851 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ocl” 2a377351ae23c339764ec8ce2e8e9164] --- |
| 28852 |
|
| 28853 |
if not modules then modules={} end modules ['font-ocl']={ |
| 28854 |
version=1.001, |
| 28855 |
comment="companion to font-ini.mkiv", |
| 28856 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 28857 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 28858 |
license="see context related readme files" |
| 28859 |
} |
| 28860 |
local tostring,tonumber,next=tostring,tonumber,next |
| 28861 |
local round,max=math.round,math.round |
| 28862 |
local gsub,find=string.gsub,string.find |
| 28863 |
local sortedkeys,sortedhash,concat=table.sortedkeys,table.sortedhash,table.concat |
| 28864 |
local setmetatableindex=table.setmetatableindex |
| 28865 |
local formatters=string.formatters |
| 28866 |
local tounicode=fonts.mappings.tounicode |
| 28867 |
local helpers=fonts.helpers |
| 28868 |
local charcommand=helpers.commands.char |
| 28869 |
local rightcommand=helpers.commands.right |
| 28870 |
local leftcommand=helpers.commands.left |
| 28871 |
local downcommand=helpers.commands.down |
| 28872 |
local otf=fonts.handlers.otf |
| 28873 |
local otfregister=otf.features.register |
| 28874 |
local f_color=formatters["%.3f %.3f %.3f rg"] |
| 28875 |
local f_gray=formatters["%.3f g"] |
| 28876 |
if context then |
| 28877 |
local startactualtext=nil |
| 28878 |
local stopactualtext=nil |
| 28879 |
function otf.getactualtext(s) |
| 28880 |
if not startactualtext then |
| 28881 |
startactualtext=backends.codeinjections.startunicodetoactualtextdirect |
| 28882 |
stopactualtext=backends.codeinjections.stopunicodetoactualtextdirect |
| 28883 |
end |
| 28884 |
return startactualtext(s),stopactualtext() |
| 28885 |
end |
| 28886 |
else |
| 28887 |
local tounicode=fonts.mappings.tounicode16 |
| 28888 |
function otf.getactualtext(s) |
| 28889 |
return |
| 28890 |
"/Span << /ActualText <feff"..s.."> >> BDC", |
| 28891 |
"EMC" |
| 28892 |
end |
| 28893 |
end |
| 28894 |
local sharedpalettes={} |
| 28895 |
local hash=setmetatableindex(function(t,k) |
| 28896 |
local v={ "pdf","direct",k } |
| 28897 |
t[k]=v |
| 28898 |
return v |
| 28899 |
end) |
| 28900 |
if context then |
| 28901 |
local colors=attributes.list[attributes.private('color')] or {} |
| 28902 |
local transparencies=attributes.list[attributes.private('transparency')] or {} |
| 28903 |
function otf.registerpalette(name,values) |
| 28904 |
sharedpalettes[name]=values |
| 28905 |
local color=lpdf.color |
| 28906 |
local transparency=lpdf.transparency |
| 28907 |
local register=colors.register |
| 28908 |
for i=1,#values do |
| 28909 |
local v=values[i] |
| 28910 |
if v=="textcolor" then |
| 28911 |
values[i]=false |
| 28912 |
else |
| 28913 |
local c=nil |
| 28914 |
local t=nil |
| 28915 |
if type(v)=="table" then |
| 28916 |
c=register(name,"rgb", |
| 28917 |
max(round((v.r or 0)*255),255)/255, |
| 28918 |
max(round((v.g or 0)*255),255)/255, |
| 28919 |
max(round((v.b or 0)*255),255)/255 |
| 28920 |
) |
| 28921 |
else |
| 28922 |
c=colors[v] |
| 28923 |
t=transparencies[v] |
| 28924 |
end |
| 28925 |
if c and t then |
| 28926 |
values[i]=hash[color(1,c).." "..transparency(t)] |
| 28927 |
elseif c then |
| 28928 |
values[i]=hash[color(1,c)] |
| 28929 |
elseif t then |
| 28930 |
values[i]=hash[color(1,t)] |
| 28931 |
end |
| 28932 |
end |
| 28933 |
end |
| 28934 |
end |
| 28935 |
else |
| 28936 |
function otf.registerpalette(name,values) |
| 28937 |
sharedpalettes[name]=values |
| 28938 |
for i=1,#values do |
| 28939 |
local v=values[i] |
| 28940 |
if v then |
| 28941 |
values[i]=hash[f_color( |
| 28942 |
max(round((v.r or 0)*255),255)/255, |
| 28943 |
max(round((v.g or 0)*255),255)/255, |
| 28944 |
max(round((v.b or 0)*255),255)/255 |
| 28945 |
)] |
| 28946 |
end |
| 28947 |
end |
| 28948 |
end |
| 28949 |
end |
| 28950 |
local function convert(t,k) |
| 28951 |
local v={} |
| 28952 |
for i=1,#k do |
| 28953 |
local p=k[i] |
| 28954 |
local r,g,b=p[1],p[2],p[3] |
| 28955 |
if r==g and g==b then |
| 28956 |
v[i]=hash[f_gray(r/255)] |
| 28957 |
else |
| 28958 |
v[i]=hash[f_color(r/255,g/255,b/255)] |
| 28959 |
end |
| 28960 |
end |
| 28961 |
t[k]=v |
| 28962 |
return v |
| 28963 |
end |
| 28964 |
local mode={ "pdf","mode","font" } |
| 28965 |
local push={ "pdf","page","q" } |
| 28966 |
local pop={ "pdf","page","Q" } |
| 28967 |
local function initializeoverlay(tfmdata,kind,value) |
| 28968 |
if value then |
| 28969 |
local resources=tfmdata.resources |
| 28970 |
local palettes=resources.colorpalettes |
| 28971 |
if palettes then |
| 28972 |
local converted=resources.converted |
| 28973 |
if not converted then |
| 28974 |
converted=setmetatableindex(convert) |
| 28975 |
resources.converted=converted |
| 28976 |
end |
| 28977 |
local colorvalues=sharedpalettes[value] |
| 28978 |
local default=false |
| 28979 |
if colorvalues then |
| 28980 |
default=colorvalues[#colorvalues] |
| 28981 |
else |
| 28982 |
colorvalues=converted[palettes[tonumber(value) or 1] or palettes[1]] or {} |
| 28983 |
end |
| 28984 |
local classes=#colorvalues |
| 28985 |
if classes==0 then |
| 28986 |
return |
| 28987 |
end |
| 28988 |
local characters=tfmdata.characters |
| 28989 |
local descriptions=tfmdata.descriptions |
| 28990 |
local properties=tfmdata.properties |
| 28991 |
properties.virtualized=true |
| 28992 |
tfmdata.fonts={ |
| 28993 |
{ id=0 } |
| 28994 |
} |
| 28995 |
local getactualtext=otf.getactualtext |
| 28996 |
local b,e=getactualtext(tounicode(0xFFFD)) |
| 28997 |
local actualb={ "pdf","page",b } |
| 28998 |
local actuale={ "pdf","page",e } |
| 28999 |
for unicode,character in next,characters do |
| 29000 |
local description=descriptions[unicode] |
| 29001 |
if description then |
| 29002 |
local colorlist=description.colors |
| 29003 |
if colorlist then |
| 29004 |
local u=description.unicode or characters[unicode].unicode |
| 29005 |
local w=character.width or 0 |
| 29006 |
local s=#colorlist |
| 29007 |
local goback=w~=0 and leftcommand[w] or nil |
| 29008 |
local t={ |
| 29009 |
mode, |
| 29010 |
not u and actualb or { "pdf","page",(getactualtext(tounicode(u))) }, |
| 29011 |
push, |
| 29012 |
} |
| 29013 |
local n=3 |
| 29014 |
local l=nil |
| 29015 |
for i=1,s do |
| 29016 |
local entry=colorlist[i] |
| 29017 |
local v=colorvalues[entry.class] or default |
| 29018 |
if v and l~=v then |
| 29019 |
n=n+1 t[n]=v |
| 29020 |
l=v |
| 29021 |
end |
| 29022 |
n=n+1 t[n]=charcommand[entry.slot] |
| 29023 |
if s>1 and i<s and goback then |
| 29024 |
n=n+1 t[n]=goback |
| 29025 |
end |
| 29026 |
end |
| 29027 |
n=n+1 t[n]=pop |
| 29028 |
n=n+1 t[n]=actuale |
| 29029 |
character.commands=t |
| 29030 |
end |
| 29031 |
end |
| 29032 |
end |
| 29033 |
return true |
| 29034 |
end |
| 29035 |
end |
| 29036 |
end |
| 29037 |
otfregister { |
| 29038 |
name="colr", |
| 29039 |
description="color glyphs", |
| 29040 |
manipulators={ |
| 29041 |
base=initializeoverlay, |
| 29042 |
node=initializeoverlay, |
| 29043 |
} |
| 29044 |
} |
| 29045 |
do |
| 29046 |
local nofstreams=0 |
| 29047 |
local f_name=formatters[ [[pdf-glyph-%05i]] ] |
| 29048 |
local f_used=context and formatters[ [[original:///%s]] ] or formatters[ [[%s]] ] |
| 29049 |
local hashed={} |
| 29050 |
local cache={} |
| 29051 |
local openpdf=pdfe.new |
| 29052 |
function otf.storepdfdata(pdf) |
| 29053 |
local done=hashed[pdf] |
| 29054 |
if not done then |
| 29055 |
nofstreams=nofstreams+1 |
| 29056 |
local f=f_name(nofstreams) |
| 29057 |
local n=openpdf(pdf,#pdf,f) |
| 29058 |
done=f_used(n) |
| 29059 |
hashed[pdf]=done |
| 29060 |
end |
| 29061 |
return done |
| 29062 |
end |
| 29063 |
end |
| 29064 |
local function pdftovirtual(tfmdata,pdfshapes,kind) |
| 29065 |
if not tfmdata or not pdfshapes or not kind then |
| 29066 |
return |
| 29067 |
end |
| 29068 |
local characters=tfmdata.characters |
| 29069 |
local properties=tfmdata.properties |
| 29070 |
local parameters=tfmdata.parameters |
| 29071 |
local hfactor=parameters.hfactor |
| 29072 |
properties.virtualized=true |
| 29073 |
tfmdata.fonts={ |
| 29074 |
{ id=0 } |
| 29075 |
} |
| 29076 |
local getactualtext=otf.getactualtext |
| 29077 |
local storepdfdata=otf.storepdfdata |
| 29078 |
local b,e=getactualtext(tounicode(0xFFFD)) |
| 29079 |
local actualb={ "pdf","page",b } |
| 29080 |
local actuale={ "pdf","page",e } |
| 29081 |
local vfimage=lpdf and lpdf.vfimage or function(wd,ht,dp,data,name) |
| 29082 |
local name=storepdfdata(data) |
| 29083 |
return { "image",{ filename=name,width=wd,height=ht,depth=dp } } |
| 29084 |
end |
| 29085 |
for unicode,character in sortedhash(characters) do |
| 29086 |
local index=character.index |
| 29087 |
if index then |
| 29088 |
local pdf=pdfshapes[index] |
| 29089 |
local typ=type(pdf) |
| 29090 |
local data=nil |
| 29091 |
local dx=nil |
| 29092 |
local dy=nil |
| 29093 |
local scale=1 |
| 29094 |
if typ=="table" then |
| 29095 |
data=pdf.data |
| 29096 |
dx=pdf.x or pdf.dx or 0 |
| 29097 |
dy=pdf.y or pdf.dy or 0 |
| 29098 |
scale=pdf.scale or 1 |
| 29099 |
elseif typ=="string" then |
| 29100 |
data=pdf |
| 29101 |
dx=0 |
| 29102 |
dy=0 |
| 29103 |
elseif typ=="number" then |
| 29104 |
data=pdf |
| 29105 |
dx=0 |
| 29106 |
dy=0 |
| 29107 |
end |
| 29108 |
if data then |
| 29109 |
local bt=unicode and getactualtext(unicode) |
| 29110 |
local wd=character.width or 0 |
| 29111 |
local ht=character.height or 0 |
| 29112 |
local dp=character.depth or 0 |
| 29113 |
character.commands={ |
| 29114 |
not unicode and actualb or { "pdf","page",(getactualtext(unicode)) }, |
| 29115 |
downcommand [dp+dy*hfactor], |
| 29116 |
rightcommand[ dx*hfactor], |
| 29117 |
vfimage(scale*wd,ht,dp,data,pdfshapes.filename or ""), |
| 29118 |
actuale, |
| 29119 |
} |
| 29120 |
character[kind]=true |
| 29121 |
end |
| 29122 |
end |
| 29123 |
end |
| 29124 |
end |
| 29125 |
local otfsvg=otf.svg or {} |
| 29126 |
otf.svg=otfsvg |
| 29127 |
otf.svgenabled=true |
| 29128 |
do |
| 29129 |
local report_svg=logs.reporter("fonts","svg conversion") |
| 29130 |
local loaddata=io.loaddata |
| 29131 |
local savedata=io.savedata |
| 29132 |
local remove=os.remove |
| 29133 |
if context then |
| 29134 |
local xmlconvert=xml.convert |
| 29135 |
local xmlfirst=xml.first |
| 29136 |
function otfsvg.filterglyph(entry,index) |
| 29137 |
local d=entry.data |
| 29138 |
if gzip.compressed(d) then |
| 29139 |
d=gzip.decompress(d) or d |
| 29140 |
end |
| 29141 |
local svg=xmlconvert(d) |
| 29142 |
local root=svg and xmlfirst(svg,"/svg[@id='glyph"..index.."']") |
| 29143 |
local data=root and tostring(root) |
| 29144 |
return data |
| 29145 |
end |
| 29146 |
else |
| 29147 |
function otfsvg.filterglyph(entry,index) |
| 29148 |
return entry.data |
| 29149 |
end |
| 29150 |
end |
| 29151 |
local runner=sandbox and sandbox.registerrunner { |
| 29152 |
name="otfsvg", |
| 29153 |
program="inkscape", |
| 29154 |
method="pipeto", |
| 29155 |
template="--export-area-drawing --shell > temp-otf-svg-shape.log", |
| 29156 |
reporter=report_svg, |
| 29157 |
} |
| 29158 |
if not runner then |
| 29159 |
runner=function() |
| 29160 |
return io.popen("inkscape --export-area-drawing --shell > temp-otf-svg-shape.log","w") |
| 29161 |
end |
| 29162 |
end |
| 29163 |
local new=nil |
| 29164 |
local function inkscapeformat(suffix) |
| 29165 |
if new==nil then |
| 29166 |
new=os.resultof("inkscape --version") or "" |
| 29167 |
new=new=="" or not find(new,"Inkscape%s*0") |
| 29168 |
end |
| 29169 |
return new and "filename" or suffix |
| 29170 |
end |
| 29171 |
function otfsvg.topdf(svgshapes,tfmdata) |
| 29172 |
local pdfshapes={} |
| 29173 |
local inkscape=runner() |
| 29174 |
if inkscape then |
| 29175 |
local descriptions=tfmdata.descriptions |
| 29176 |
local nofshapes=#svgshapes |
| 29177 |
local s_format=inkscapeformat("pdf") |
| 29178 |
local f_svgfile=formatters["temp-otf-svg-shape-%i.svg"] |
| 29179 |
local f_pdffile=formatters["temp-otf-svg-shape-%i.pdf"] |
| 29180 |
local f_convert=formatters[new and "file-open:%s; export-%s:%s; export-do\n" or "%s --export-%s=%s\n"] |
| 29181 |
local filterglyph=otfsvg.filterglyph |
| 29182 |
local nofdone=0 |
| 29183 |
local processed={} |
| 29184 |
report_svg("processing %i svg containers",nofshapes) |
| 29185 |
statistics.starttiming() |
| 29186 |
for i=1,nofshapes do |
| 29187 |
local entry=svgshapes[i] |
| 29188 |
for index=entry.first,entry.last do |
| 29189 |
local data=filterglyph(entry,index) |
| 29190 |
if data and data~="" then |
| 29191 |
local svgfile=f_svgfile(index) |
| 29192 |
local pdffile=f_pdffile(index) |
| 29193 |
savedata(svgfile,data) |
| 29194 |
inkscape:write(f_convert(svgfile,s_format,pdffile)) |
| 29195 |
processed[index]=true |
| 29196 |
nofdone=nofdone+1 |
| 29197 |
if nofdone%25==0 then |
| 29198 |
report_svg("%i shapes submitted",nofdone) |
| 29199 |
end |
| 29200 |
end |
| 29201 |
end |
| 29202 |
end |
| 29203 |
if nofdone%25~=0 then |
| 29204 |
report_svg("%i shapes submitted",nofdone) |
| 29205 |
end |
| 29206 |
report_svg("processing can be going on for a while") |
| 29207 |
inkscape:write("quit\n") |
| 29208 |
inkscape:close() |
| 29209 |
report_svg("processing %i pdf results",nofshapes) |
| 29210 |
for index in next,processed do |
| 29211 |
local svgfile=f_svgfile(index) |
| 29212 |
local pdffile=f_pdffile(index) |
| 29213 |
local pdfdata=loaddata(pdffile) |
| 29214 |
if pdfdata and pdfdata~="" then |
| 29215 |
pdfshapes[index]={ |
| 29216 |
data=pdfdata, |
| 29217 |
} |
| 29218 |
end |
| 29219 |
remove(svgfile) |
| 29220 |
remove(pdffile) |
| 29221 |
end |
| 29222 |
local characters=tfmdata.characters |
| 29223 |
for k,v in next,characters do |
| 29224 |
local d=descriptions[k] |
| 29225 |
local i=d.index |
| 29226 |
if i then |
| 29227 |
local p=pdfshapes[i] |
| 29228 |
if p then |
| 29229 |
local w=d.width |
| 29230 |
local l=d.boundingbox[1] |
| 29231 |
local r=d.boundingbox[3] |
| 29232 |
p.scale=(r-l)/w |
| 29233 |
p.x=l |
| 29234 |
end |
| 29235 |
end |
| 29236 |
end |
| 29237 |
if not next(pdfshapes) then |
| 29238 |
report_svg("there are no converted shapes, fix your setup") |
| 29239 |
end |
| 29240 |
statistics.stoptiming() |
| 29241 |
if statistics.elapsedseconds then |
| 29242 |
report_svg("svg conversion time %s",statistics.elapsedseconds() or "-") |
| 29243 |
end |
| 29244 |
end |
| 29245 |
return pdfshapes |
| 29246 |
end |
| 29247 |
end |
| 29248 |
local function initializesvg(tfmdata,kind,value) |
| 29249 |
if value and otf.svgenabled then |
| 29250 |
local svg=tfmdata.properties.svg |
| 29251 |
local hash=svg and svg.hash |
| 29252 |
local timestamp=svg and svg.timestamp |
| 29253 |
if not hash then |
| 29254 |
return |
| 29255 |
end |
| 29256 |
local pdffile=containers.read(otf.pdfcache,hash) |
| 29257 |
local pdfshapes=pdffile and pdffile.pdfshapes |
| 29258 |
if not pdfshapes or pdffile.timestamp~=timestamp or not next(pdfshapes) then |
| 29259 |
local svgfile=containers.read(otf.svgcache,hash) |
| 29260 |
local svgshapes=svgfile and svgfile.svgshapes |
| 29261 |
pdfshapes=svgshapes and otfsvg.topdf(svgshapes,tfmdata,otf.pdfcache.writable,hash) or {} |
| 29262 |
containers.write(otf.pdfcache,hash,{ |
| 29263 |
pdfshapes=pdfshapes, |
| 29264 |
timestamp=timestamp, |
| 29265 |
}) |
| 29266 |
end |
| 29267 |
pdftovirtual(tfmdata,pdfshapes,"svg") |
| 29268 |
return true |
| 29269 |
end |
| 29270 |
end |
| 29271 |
otfregister { |
| 29272 |
name="svg", |
| 29273 |
description="svg glyphs", |
| 29274 |
manipulators={ |
| 29275 |
base=initializesvg, |
| 29276 |
node=initializesvg, |
| 29277 |
} |
| 29278 |
} |
| 29279 |
local otfpng=otf.png or {} |
| 29280 |
otf.png=otfpng |
| 29281 |
otf.pngenabled=true |
| 29282 |
do |
| 29283 |
local report_png=logs.reporter("fonts","png conversion") |
| 29284 |
local loaddata=io.loaddata |
| 29285 |
local savedata=io.savedata |
| 29286 |
local remove=os.remove |
| 29287 |
local runner=sandbox and sandbox.registerrunner { |
| 29288 |
name="otfpng", |
| 29289 |
program="gm", |
| 29290 |
template="convert -quality 100 temp-otf-png-shape.png temp-otf-png-shape.pdf > temp-otf-svg-shape.log", |
| 29291 |
} |
| 29292 |
if not runner then |
| 29293 |
runner=function() |
| 29294 |
return os.execute("gm convert -quality 100 temp-otf-png-shape.png temp-otf-png-shape.pdf > temp-otf-svg-shape.log") |
| 29295 |
end |
| 29296 |
end |
| 29297 |
function otfpng.topdf(pngshapes) |
| 29298 |
local pdfshapes={} |
| 29299 |
local pngfile="temp-otf-png-shape.png" |
| 29300 |
local pdffile="temp-otf-png-shape.pdf" |
| 29301 |
local nofdone=0 |
| 29302 |
local indices=sortedkeys(pngshapes) |
| 29303 |
local nofindices=#indices |
| 29304 |
report_png("processing %i png containers",nofindices) |
| 29305 |
statistics.starttiming() |
| 29306 |
for i=1,nofindices do |
| 29307 |
local index=indices[i] |
| 29308 |
local entry=pngshapes[index] |
| 29309 |
local data=entry.data |
| 29310 |
local x=entry.x |
| 29311 |
local y=entry.y |
| 29312 |
savedata(pngfile,data) |
| 29313 |
runner() |
| 29314 |
pdfshapes[index]={ |
| 29315 |
x=x~=0 and x or nil, |
| 29316 |
y=y~=0 and y or nil, |
| 29317 |
data=loaddata(pdffile), |
| 29318 |
} |
| 29319 |
nofdone=nofdone+1 |
| 29320 |
if nofdone%100==0 then |
| 29321 |
report_png("%i shapes processed",nofdone) |
| 29322 |
end |
| 29323 |
end |
| 29324 |
report_png("processing %i pdf results",nofindices) |
| 29325 |
remove(pngfile) |
| 29326 |
remove(pdffile) |
| 29327 |
statistics.stoptiming() |
| 29328 |
if statistics.elapsedseconds then |
| 29329 |
report_png("png conversion time %s",statistics.elapsedseconds() or "-") |
| 29330 |
end |
| 29331 |
return pdfshapes |
| 29332 |
end |
| 29333 |
end |
| 29334 |
local function initializepng(tfmdata,kind,value) |
| 29335 |
if value and otf.pngenabled then |
| 29336 |
local png=tfmdata.properties.png |
| 29337 |
local hash=png and png.hash |
| 29338 |
local timestamp=png and png.timestamp |
| 29339 |
if not hash then |
| 29340 |
return |
| 29341 |
end |
| 29342 |
local pdffile=containers.read(otf.pdfcache,hash) |
| 29343 |
local pdfshapes=pdffile and pdffile.pdfshapes |
| 29344 |
if not pdfshapes or pdffile.timestamp~=timestamp then |
| 29345 |
local pngfile=containers.read(otf.pngcache,hash) |
| 29346 |
local pngshapes=pngfile and pngfile.pngshapes |
| 29347 |
pdfshapes=pngshapes and otfpng.topdf(pngshapes) or {} |
| 29348 |
containers.write(otf.pdfcache,hash,{ |
| 29349 |
pdfshapes=pdfshapes, |
| 29350 |
timestamp=timestamp, |
| 29351 |
}) |
| 29352 |
end |
| 29353 |
pdftovirtual(tfmdata,pdfshapes,"png") |
| 29354 |
return true |
| 29355 |
end |
| 29356 |
end |
| 29357 |
otfregister { |
| 29358 |
name="sbix", |
| 29359 |
description="sbix glyphs", |
| 29360 |
manipulators={ |
| 29361 |
base=initializepng, |
| 29362 |
node=initializepng, |
| 29363 |
} |
| 29364 |
} |
| 29365 |
otfregister { |
| 29366 |
name="cblc", |
| 29367 |
description="cblc glyphs", |
| 29368 |
manipulators={ |
| 29369 |
base=initializepng, |
| 29370 |
node=initializepng, |
| 29371 |
} |
| 29372 |
} |
| 29373 |
if context then |
| 29374 |
local function initializecolor(tfmdata,kind,value) |
| 29375 |
if value=="auto" then |
| 29376 |
return |
| 29377 |
initializeoverlay(tfmdata,kind,value) or |
| 29378 |
initializesvg(tfmdata,kind,value) or |
| 29379 |
initializepng(tfmdata,kind,value) |
| 29380 |
elseif value=="overlay" then |
| 29381 |
return initializeoverlay(tfmdata,kind,value) |
| 29382 |
elseif value=="svg" then |
| 29383 |
return initializesvg(tfmdata,kind,value) |
| 29384 |
elseif value=="png" or value=="bitmap" then |
| 29385 |
return initializepng(tfmdata,kind,value) |
| 29386 |
else |
| 29387 |
end |
| 29388 |
end |
| 29389 |
otfregister { |
| 29390 |
name="color", |
| 29391 |
description="color glyphs", |
| 29392 |
manipulators={ |
| 29393 |
base=initializecolor, |
| 29394 |
node=initializecolor, |
| 29395 |
} |
| 29396 |
} |
| 29397 |
end |
| 29398 |
|
| 29399 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-ocl”] --- |
| 29400 |
|
| 29401 |
|
| 29402 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-otc” 0ad931eec679ebeceed5d4f02f4ba31b] --- |
| 29403 |
|
| 29404 |
if not modules then modules={} end modules ['font-otc']={ |
| 29405 |
version=1.001, |
| 29406 |
comment="companion to font-ini.mkiv", |
| 29407 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 29408 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 29409 |
license="see context related readme files" |
| 29410 |
} |
| 29411 |
local insert,sortedkeys,sortedhash,tohash=table.insert,table.sortedkeys,table.sortedhash,table.tohash |
| 29412 |
local type,next,tonumber=type,next,tonumber |
| 29413 |
local lpegmatch=lpeg.match |
| 29414 |
local utfbyte,utflen=utf.byte,utf.len |
| 29415 |
local sortedhash=table.sortedhash |
| 29416 |
local trace_loading=false trackers.register("otf.loading",function(v) trace_loading=v end) |
| 29417 |
local report_otf=logs.reporter("fonts","otf loading") |
| 29418 |
local fonts=fonts |
| 29419 |
local otf=fonts.handlers.otf |
| 29420 |
local registerotffeature=otf.features.register |
| 29421 |
local setmetatableindex=table.setmetatableindex |
| 29422 |
local fonthelpers=fonts.helpers |
| 29423 |
local checkmerge=fonthelpers.checkmerge |
| 29424 |
local checkflags=fonthelpers.checkflags |
| 29425 |
local checksteps=fonthelpers.checksteps |
| 29426 |
local normalized={ |
| 29427 |
substitution="substitution", |
| 29428 |
single="substitution", |
| 29429 |
ligature="ligature", |
| 29430 |
alternate="alternate", |
| 29431 |
multiple="multiple", |
| 29432 |
kern="kern", |
| 29433 |
pair="pair", |
| 29434 |
single="single", |
| 29435 |
chainsubstitution="chainsubstitution", |
| 29436 |
chainposition="chainposition", |
| 29437 |
} |
| 29438 |
local types={ |
| 29439 |
substitution="gsub_single", |
| 29440 |
ligature="gsub_ligature", |
| 29441 |
alternate="gsub_alternate", |
| 29442 |
multiple="gsub_multiple", |
| 29443 |
kern="gpos_pair", |
| 29444 |
pair="gpos_pair", |
| 29445 |
single="gpos_single", |
| 29446 |
chainsubstitution="gsub_contextchain", |
| 29447 |
chainposition="gpos_contextchain", |
| 29448 |
} |
| 29449 |
local names={ |
| 29450 |
gsub_single="gsub", |
| 29451 |
gsub_multiple="gsub", |
| 29452 |
gsub_alternate="gsub", |
| 29453 |
gsub_ligature="gsub", |
| 29454 |
gsub_context="gsub", |
| 29455 |
gsub_contextchain="gsub", |
| 29456 |
gsub_reversecontextchain="gsub", |
| 29457 |
gpos_single="gpos", |
| 29458 |
gpos_pair="gpos", |
| 29459 |
gpos_cursive="gpos", |
| 29460 |
gpos_mark2base="gpos", |
| 29461 |
gpos_mark2ligature="gpos", |
| 29462 |
gpos_mark2mark="gpos", |
| 29463 |
gpos_context="gpos", |
| 29464 |
gpos_contextchain="gpos", |
| 29465 |
} |
| 29466 |
setmetatableindex(types,function(t,k) t[k]=k return k end) |
| 29467 |
local everywhere={ ["*"]={ ["*"]=true } } |
| 29468 |
local noflags={ false,false,false,false } |
| 29469 |
local function getrange(sequences,category) |
| 29470 |
local count=#sequences |
| 29471 |
local first=nil |
| 29472 |
local last=nil |
| 29473 |
for i=1,count do |
| 29474 |
local t=sequences[i].type |
| 29475 |
if t and names[t]==category then |
| 29476 |
if not first then |
| 29477 |
first=i |
| 29478 |
end |
| 29479 |
last=i |
| 29480 |
end |
| 29481 |
end |
| 29482 |
return first or 1,last or count |
| 29483 |
end |
| 29484 |
local function validspecification(specification,name) |
| 29485 |
local dataset=specification.dataset |
| 29486 |
if dataset then |
| 29487 |
elseif specification[1] then |
| 29488 |
dataset=specification |
| 29489 |
specification={ dataset=dataset } |
| 29490 |
else |
| 29491 |
dataset={ { data=specification.data } } |
| 29492 |
specification.data=nil |
| 29493 |
specification.coverage=dataset |
| 29494 |
specification.dataset=dataset |
| 29495 |
end |
| 29496 |
local first=dataset[1] |
| 29497 |
if first then |
| 29498 |
first=first.data |
| 29499 |
end |
| 29500 |
if not first then |
| 29501 |
report_otf("invalid feature specification, no dataset") |
| 29502 |
return |
| 29503 |
end |
| 29504 |
if type(name)~="string" then |
| 29505 |
name=specification.name or first.name |
| 29506 |
end |
| 29507 |
if type(name)~="string" then |
| 29508 |
report_otf("invalid feature specification, no name") |
| 29509 |
return |
| 29510 |
end |
| 29511 |
local n=#dataset |
| 29512 |
if n>0 then |
| 29513 |
for i=1,n do |
| 29514 |
setmetatableindex(dataset[i],specification) |
| 29515 |
end |
| 29516 |
return specification,name |
| 29517 |
end |
| 29518 |
end |
| 29519 |
local function addfeature(data,feature,specifications,prepareonly) |
| 29520 |
if not specifications then |
| 29521 |
report_otf("missing specification") |
| 29522 |
return |
| 29523 |
end |
| 29524 |
local descriptions=data.descriptions |
| 29525 |
local resources=data.resources |
| 29526 |
if not descriptions or not resources then |
| 29527 |
report_otf("missing specification") |
| 29528 |
return |
| 29529 |
end |
| 29530 |
local features=resources.features |
| 29531 |
local sequences=resources.sequences |
| 29532 |
if not features or not sequences then |
| 29533 |
report_otf("missing specification") |
| 29534 |
return |
| 29535 |
end |
| 29536 |
local alreadydone=resources.alreadydone |
| 29537 |
if not alreadydone then |
| 29538 |
alreadydone={} |
| 29539 |
resources.alreadydone=alreadydone |
| 29540 |
end |
| 29541 |
if alreadydone[specifications] then |
| 29542 |
return |
| 29543 |
else |
| 29544 |
alreadydone[specifications]=true |
| 29545 |
end |
| 29546 |
local fontfeatures=resources.features or everywhere |
| 29547 |
local unicodes=resources.unicodes |
| 29548 |
local splitter=lpeg.splitter(" ",unicodes) |
| 29549 |
local done=0 |
| 29550 |
local skip=0 |
| 29551 |
local aglunicodes=false |
| 29552 |
local privateslot=fonthelpers.privateslot |
| 29553 |
local specifications=validspecification(specifications,feature) |
| 29554 |
if not specifications then |
| 29555 |
return |
| 29556 |
end |
| 29557 |
local p=lpeg.P("P")*(lpeg.patterns.hexdigit^1/function(s) return tonumber(s,16) end)*lpeg.P(-1) |
| 29558 |
local function tounicode(code) |
| 29559 |
if not code then |
| 29560 |
return |
| 29561 |
end |
| 29562 |
if type(code)=="number" then |
| 29563 |
return code |
| 29564 |
end |
| 29565 |
local u=unicodes[code] |
| 29566 |
if u then |
| 29567 |
return u |
| 29568 |
end |
| 29569 |
if utflen(code)==1 then |
| 29570 |
u=utfbyte(code) |
| 29571 |
if u then |
| 29572 |
return u |
| 29573 |
end |
| 29574 |
end |
| 29575 |
if privateslot then |
| 29576 |
u=privateslot(code) |
| 29577 |
if u then |
| 29578 |
return u |
| 29579 |
end |
| 29580 |
end |
| 29581 |
local u=lpegmatch(p,code) |
| 29582 |
if u then |
| 29583 |
return u |
| 29584 |
end |
| 29585 |
if not aglunicodes then |
| 29586 |
aglunicodes=fonts.encodings.agl.unicodes |
| 29587 |
end |
| 29588 |
local u=aglunicodes[code] |
| 29589 |
if u then |
| 29590 |
return u |
| 29591 |
end |
| 29592 |
end |
| 29593 |
local coverup=otf.coverup |
| 29594 |
local coveractions=coverup.actions |
| 29595 |
local stepkey=coverup.stepkey |
| 29596 |
local register=coverup.register |
| 29597 |
local function prepare_substitution(list,featuretype,nocheck) |
| 29598 |
local coverage={} |
| 29599 |
local cover=coveractions[featuretype] |
| 29600 |
for code,replacement in next,list do |
| 29601 |
local unicode=tounicode(code) |
| 29602 |
local description=descriptions[unicode] |
| 29603 |
if not nocheck and not description then |
| 29604 |
skip=skip+1 |
| 29605 |
else |
| 29606 |
if type(replacement)=="table" then |
| 29607 |
replacement=replacement[1] |
| 29608 |
end |
| 29609 |
replacement=tounicode(replacement) |
| 29610 |
if replacement and (nocheck or descriptions[replacement]) then |
| 29611 |
cover(coverage,unicode,replacement) |
| 29612 |
done=done+1 |
| 29613 |
else |
| 29614 |
skip=skip+1 |
| 29615 |
end |
| 29616 |
end |
| 29617 |
end |
| 29618 |
return coverage |
| 29619 |
end |
| 29620 |
local function prepare_alternate(list,featuretype,nocheck) |
| 29621 |
local coverage={} |
| 29622 |
local cover=coveractions[featuretype] |
| 29623 |
for code,replacement in next,list do |
| 29624 |
local unicode=tounicode(code) |
| 29625 |
local description=descriptions[unicode] |
| 29626 |
if not nocheck and not description then |
| 29627 |
skip=skip+1 |
| 29628 |
elseif type(replacement)=="table" then |
| 29629 |
local r={} |
| 29630 |
for i=1,#replacement do |
| 29631 |
local u=tounicode(replacement[i]) |
| 29632 |
r[i]=(nocheck or descriptions[u]) and u or unicode |
| 29633 |
end |
| 29634 |
cover(coverage,unicode,r) |
| 29635 |
done=done+1 |
| 29636 |
else |
| 29637 |
local u=tounicode(replacement) |
| 29638 |
if u then |
| 29639 |
cover(coverage,unicode,{ u }) |
| 29640 |
done=done+1 |
| 29641 |
else |
| 29642 |
skip=skip+1 |
| 29643 |
end |
| 29644 |
end |
| 29645 |
end |
| 29646 |
return coverage |
| 29647 |
end |
| 29648 |
local function prepare_multiple(list,featuretype,nocheck) |
| 29649 |
local coverage={} |
| 29650 |
local cover=coveractions[featuretype] |
| 29651 |
for code,replacement in next,list do |
| 29652 |
local unicode=tounicode(code) |
| 29653 |
local description=descriptions[unicode] |
| 29654 |
if not nocheck and not description then |
| 29655 |
skip=skip+1 |
| 29656 |
elseif type(replacement)=="table" then |
| 29657 |
local r={} |
| 29658 |
local n=0 |
| 29659 |
for i=1,#replacement do |
| 29660 |
local u=tounicode(replacement[i]) |
| 29661 |
if nocheck or descriptions[u] then |
| 29662 |
n=n+1 |
| 29663 |
r[n]=u |
| 29664 |
end |
| 29665 |
end |
| 29666 |
if n>0 then |
| 29667 |
cover(coverage,unicode,r) |
| 29668 |
done=done+1 |
| 29669 |
else |
| 29670 |
skip=skip+1 |
| 29671 |
end |
| 29672 |
else |
| 29673 |
local u=tounicode(replacement) |
| 29674 |
if u then |
| 29675 |
cover(coverage,unicode,{ u }) |
| 29676 |
done=done+1 |
| 29677 |
else |
| 29678 |
skip=skip+1 |
| 29679 |
end |
| 29680 |
end |
| 29681 |
end |
| 29682 |
return coverage |
| 29683 |
end |
| 29684 |
local function prepare_ligature(list,featuretype,nocheck) |
| 29685 |
local coverage={} |
| 29686 |
local cover=coveractions[featuretype] |
| 29687 |
for code,ligature in next,list do |
| 29688 |
local unicode=tounicode(code) |
| 29689 |
local description=descriptions[unicode] |
| 29690 |
if not nocheck and not description then |
| 29691 |
skip=skip+1 |
| 29692 |
else |
| 29693 |
if type(ligature)=="string" then |
| 29694 |
ligature={ lpegmatch(splitter,ligature) } |
| 29695 |
end |
| 29696 |
local present=true |
| 29697 |
for i=1,#ligature do |
| 29698 |
local l=ligature[i] |
| 29699 |
local u=tounicode(l) |
| 29700 |
if nocheck or descriptions[u] then |
| 29701 |
ligature[i]=u |
| 29702 |
else |
| 29703 |
present=false |
| 29704 |
break |
| 29705 |
end |
| 29706 |
end |
| 29707 |
if present then |
| 29708 |
cover(coverage,unicode,ligature) |
| 29709 |
done=done+1 |
| 29710 |
else |
| 29711 |
skip=skip+1 |
| 29712 |
end |
| 29713 |
end |
| 29714 |
end |
| 29715 |
return coverage |
| 29716 |
end |
| 29717 |
local function resetspacekerns() |
| 29718 |
data.properties.hasspacekerns=true |
| 29719 |
data.resources .spacekerns=nil |
| 29720 |
end |
| 29721 |
local function prepare_kern(list,featuretype) |
| 29722 |
local coverage={} |
| 29723 |
local cover=coveractions[featuretype] |
| 29724 |
local isspace=false |
| 29725 |
for code,replacement in next,list do |
| 29726 |
local unicode=tounicode(code) |
| 29727 |
local description=descriptions[unicode] |
| 29728 |
if description and type(replacement)=="table" then |
| 29729 |
local r={} |
| 29730 |
for k,v in next,replacement do |
| 29731 |
local u=tounicode(k) |
| 29732 |
if u then |
| 29733 |
r[u]=v |
| 29734 |
if u==32 then |
| 29735 |
isspace=true |
| 29736 |
end |
| 29737 |
end |
| 29738 |
end |
| 29739 |
if next(r) then |
| 29740 |
cover(coverage,unicode,r) |
| 29741 |
done=done+1 |
| 29742 |
if unicode==32 then |
| 29743 |
isspace=true |
| 29744 |
end |
| 29745 |
else |
| 29746 |
skip=skip+1 |
| 29747 |
end |
| 29748 |
else |
| 29749 |
skip=skip+1 |
| 29750 |
end |
| 29751 |
end |
| 29752 |
if isspace then |
| 29753 |
resetspacekerns() |
| 29754 |
end |
| 29755 |
return coverage |
| 29756 |
end |
| 29757 |
local function prepare_pair(list,featuretype) |
| 29758 |
local coverage={} |
| 29759 |
local cover=coveractions[featuretype] |
| 29760 |
if cover then |
| 29761 |
for code,replacement in next,list do |
| 29762 |
local unicode=tounicode(code) |
| 29763 |
local description=descriptions[unicode] |
| 29764 |
if description and type(replacement)=="table" then |
| 29765 |
local r={} |
| 29766 |
for k,v in next,replacement do |
| 29767 |
local u=tounicode(k) |
| 29768 |
if u then |
| 29769 |
r[u]=v |
| 29770 |
if u==32 then |
| 29771 |
isspace=true |
| 29772 |
end |
| 29773 |
end |
| 29774 |
end |
| 29775 |
if next(r) then |
| 29776 |
cover(coverage,unicode,r) |
| 29777 |
done=done+1 |
| 29778 |
if unicode==32 then |
| 29779 |
isspace=true |
| 29780 |
end |
| 29781 |
else |
| 29782 |
skip=skip+1 |
| 29783 |
end |
| 29784 |
else |
| 29785 |
skip=skip+1 |
| 29786 |
end |
| 29787 |
end |
| 29788 |
if isspace then |
| 29789 |
resetspacekerns() |
| 29790 |
end |
| 29791 |
else |
| 29792 |
report_otf("unknown cover type %a",featuretype) |
| 29793 |
end |
| 29794 |
return coverage |
| 29795 |
end |
| 29796 |
local prepare_single=prepare_pair |
| 29797 |
local function hassteps(lookups) |
| 29798 |
if lookups then |
| 29799 |
for i=1,#lookups do |
| 29800 |
local l=lookups[i] |
| 29801 |
if l then |
| 29802 |
for j=1,#l do |
| 29803 |
local l=l[j] |
| 29804 |
if l then |
| 29805 |
local n=l.nofsteps |
| 29806 |
if not n then |
| 29807 |
return true |
| 29808 |
elseif n>0 then |
| 29809 |
return true |
| 29810 |
end |
| 29811 |
end |
| 29812 |
end |
| 29813 |
end |
| 29814 |
end |
| 29815 |
end |
| 29816 |
return false |
| 29817 |
end |
| 29818 |
local function prepare_chain(list,featuretype,sublookups,nocheck) |
| 29819 |
local rules=list.rules |
| 29820 |
local coverage={} |
| 29821 |
if rules then |
| 29822 |
local lookuptype=types[featuretype] |
| 29823 |
for nofrules=1,#rules do |
| 29824 |
local rule=rules[nofrules] |
| 29825 |
local current=rule.current |
| 29826 |
local before=rule.before |
| 29827 |
local after=rule.after |
| 29828 |
local replacements=rule.replacements or false |
| 29829 |
local sequence={} |
| 29830 |
local nofsequences=0 |
| 29831 |
if before then |
| 29832 |
for n=1,#before do |
| 29833 |
nofsequences=nofsequences+1 |
| 29834 |
sequence[nofsequences]=before[n] |
| 29835 |
end |
| 29836 |
end |
| 29837 |
local start=nofsequences+1 |
| 29838 |
for n=1,#current do |
| 29839 |
nofsequences=nofsequences+1 |
| 29840 |
sequence[nofsequences]=current[n] |
| 29841 |
end |
| 29842 |
local stop=nofsequences |
| 29843 |
if after then |
| 29844 |
for n=1,#after do |
| 29845 |
nofsequences=nofsequences+1 |
| 29846 |
sequence[nofsequences]=after[n] |
| 29847 |
end |
| 29848 |
end |
| 29849 |
local lookups=rule.lookups or false |
| 29850 |
local subtype=nil |
| 29851 |
if lookups and sublookups then |
| 29852 |
if #lookups>0 then |
| 29853 |
local ns=stop-start+1 |
| 29854 |
for i=1,ns do |
| 29855 |
if lookups[i]==nil then |
| 29856 |
lookups[i]=0 |
| 29857 |
end |
| 29858 |
end |
| 29859 |
end |
| 29860 |
local l={} |
| 29861 |
for k,v in sortedhash(lookups) do |
| 29862 |
local t=type(v) |
| 29863 |
if t=="table" then |
| 29864 |
for i=1,#v do |
| 29865 |
local vi=v[i] |
| 29866 |
if type(vi)~="table" then |
| 29867 |
v[i]={ vi } |
| 29868 |
end |
| 29869 |
end |
| 29870 |
l[k]=v |
| 29871 |
elseif t=="number" then |
| 29872 |
local lookup=sublookups[v] |
| 29873 |
if lookup then |
| 29874 |
l[k]={ lookup } |
| 29875 |
if not subtype then |
| 29876 |
subtype=lookup.type |
| 29877 |
end |
| 29878 |
elseif v==0 then |
| 29879 |
l[k]={ { type="gsub_remove",nosteps=true } } |
| 29880 |
else |
| 29881 |
l[k]=false |
| 29882 |
end |
| 29883 |
else |
| 29884 |
l[k]=false |
| 29885 |
end |
| 29886 |
end |
| 29887 |
if nocheck then |
| 29888 |
rule.lookups=l |
| 29889 |
end |
| 29890 |
lookups=l |
| 29891 |
end |
| 29892 |
if nofsequences>0 then |
| 29893 |
if hassteps(lookups) then |
| 29894 |
local hashed={} |
| 29895 |
for i=1,nofsequences do |
| 29896 |
local t={} |
| 29897 |
local s=sequence[i] |
| 29898 |
for i=1,#s do |
| 29899 |
local u=tounicode(s[i]) |
| 29900 |
if u then |
| 29901 |
t[u]=true |
| 29902 |
end |
| 29903 |
end |
| 29904 |
hashed[i]=t |
| 29905 |
end |
| 29906 |
sequence=hashed |
| 29907 |
local ruleset={ |
| 29908 |
nofrules, |
| 29909 |
lookuptype, |
| 29910 |
sequence, |
| 29911 |
start, |
| 29912 |
stop, |
| 29913 |
lookups, |
| 29914 |
replacements, |
| 29915 |
subtype, |
| 29916 |
} |
| 29917 |
for unic in sortedhash(sequence[start]) do |
| 29918 |
local cu=coverage[unic] |
| 29919 |
if cu then |
| 29920 |
local n=cu.n+1 |
| 29921 |
cu[n]=ruleset |
| 29922 |
cu.n=n |
| 29923 |
else |
| 29924 |
coverage[unic]={ |
| 29925 |
ruleset, |
| 29926 |
n=1, |
| 29927 |
} |
| 29928 |
end |
| 29929 |
end |
| 29930 |
sequence.n=nofsequences |
| 29931 |
else |
| 29932 |
end |
| 29933 |
end |
| 29934 |
end |
| 29935 |
end |
| 29936 |
return coverage |
| 29937 |
end |
| 29938 |
local dataset=specifications.dataset |
| 29939 |
local function report(name,category,position,first,last,sequences) |
| 29940 |
report_otf("injecting name %a of category %a at position %i in [%i,%i] of [%i,%i]", |
| 29941 |
name,category,position,first,last,1,#sequences) |
| 29942 |
end |
| 29943 |
local function inject(specification,sequences,sequence,first,last,category,name) |
| 29944 |
local position=specification.position or false |
| 29945 |
if not position then |
| 29946 |
position=specification.prepend |
| 29947 |
if position==true then |
| 29948 |
if trace_loading then |
| 29949 |
report(name,category,first,first,last,sequences) |
| 29950 |
end |
| 29951 |
insert(sequences,first,sequence) |
| 29952 |
return |
| 29953 |
end |
| 29954 |
end |
| 29955 |
if not position then |
| 29956 |
position=specification.append |
| 29957 |
if position==true then |
| 29958 |
if trace_loading then |
| 29959 |
report(name,category,last+1,first,last,sequences) |
| 29960 |
end |
| 29961 |
insert(sequences,last+1,sequence) |
| 29962 |
return |
| 29963 |
end |
| 29964 |
end |
| 29965 |
local kind=type(position) |
| 29966 |
if kind=="string" then |
| 29967 |
local index=false |
| 29968 |
for i=first,last do |
| 29969 |
local s=sequences[i] |
| 29970 |
local f=s.features |
| 29971 |
if f then |
| 29972 |
for k in sortedhash(f) do |
| 29973 |
if k==position then |
| 29974 |
index=i |
| 29975 |
break |
| 29976 |
end |
| 29977 |
end |
| 29978 |
if index then |
| 29979 |
break |
| 29980 |
end |
| 29981 |
end |
| 29982 |
end |
| 29983 |
if index then |
| 29984 |
position=index |
| 29985 |
else |
| 29986 |
position=last+1 |
| 29987 |
end |
| 29988 |
elseif kind=="number" then |
| 29989 |
if position<0 then |
| 29990 |
position=last-position+1 |
| 29991 |
end |
| 29992 |
if position>last then |
| 29993 |
position=last+1 |
| 29994 |
elseif position<first then |
| 29995 |
position=first |
| 29996 |
end |
| 29997 |
else |
| 29998 |
position=last+1 |
| 29999 |
end |
| 30000 |
if trace_loading then |
| 30001 |
report(name,category,position,first,last,sequences) |
| 30002 |
end |
| 30003 |
insert(sequences,position,sequence) |
| 30004 |
end |
| 30005 |
for s=1,#dataset do |
| 30006 |
local specification=dataset[s] |
| 30007 |
local valid=specification.valid |
| 30008 |
local feature=specification.name or feature |
| 30009 |
if not feature or feature=="" then |
| 30010 |
report_otf("no valid name given for extra feature") |
| 30011 |
elseif not valid or valid(data,specification,feature) then |
| 30012 |
local initialize=specification.initialize |
| 30013 |
if initialize then |
| 30014 |
specification.initialize=initialize(specification,data) and initialize or nil |
| 30015 |
end |
| 30016 |
local askedfeatures=specification.features or everywhere |
| 30017 |
local askedsteps=specification.steps or specification.subtables or { specification.data } or {} |
| 30018 |
local featuretype=specification.type or "substitution" |
| 30019 |
local featureaction=false |
| 30020 |
local featureflags=specification.flags or noflags |
| 30021 |
local nocheck=specification.nocheck |
| 30022 |
local mapping=specification.mapping |
| 30023 |
local featureorder=specification.order or { feature } |
| 30024 |
local featurechain=(featuretype=="chainsubstitution" or featuretype=="chainposition") and 1 or 0 |
| 30025 |
local nofsteps=0 |
| 30026 |
local steps={} |
| 30027 |
local sublookups=specification.lookups |
| 30028 |
local category=nil |
| 30029 |
local steptype=nil |
| 30030 |
local sequence=nil |
| 30031 |
if fonts.handlers.otf.handlers[featuretype] then |
| 30032 |
featureaction=true |
| 30033 |
else |
| 30034 |
featuretype=normalized[specification.type or "substitution"] or "substitution" |
| 30035 |
end |
| 30036 |
checkflags(specification,resources) |
| 30037 |
for k,v in next,askedfeatures do |
| 30038 |
if v[1] then |
| 30039 |
askedfeatures[k]=tohash(v) |
| 30040 |
end |
| 30041 |
end |
| 30042 |
if featureflags[1] then featureflags[1]="mark" end |
| 30043 |
if featureflags[2] then featureflags[2]="ligature" end |
| 30044 |
if featureflags[3] then featureflags[3]="base" end |
| 30045 |
if featureaction then |
| 30046 |
category="gsub" |
| 30047 |
sequence={ |
| 30048 |
features={ [feature]=askedfeatures }, |
| 30049 |
flags=featureflags, |
| 30050 |
name=feature, |
| 30051 |
order=featureorder, |
| 30052 |
type=featuretype, |
| 30053 |
nofsteps=0, |
| 30054 |
} |
| 30055 |
else |
| 30056 |
if sublookups then |
| 30057 |
local s={} |
| 30058 |
for i=1,#sublookups do |
| 30059 |
local specification=sublookups[i] |
| 30060 |
local askedsteps=specification.steps or specification.subtables or { specification.data } or {} |
| 30061 |
local featuretype=normalized[specification.type or "substitution"] or "substitution" |
| 30062 |
local featureflags=specification.flags or noflags |
| 30063 |
local nofsteps=0 |
| 30064 |
local steps={} |
| 30065 |
for i=1,#askedsteps do |
| 30066 |
local list=askedsteps[i] |
| 30067 |
local coverage=nil |
| 30068 |
local format=nil |
| 30069 |
if featuretype=="substitution" then |
| 30070 |
coverage=prepare_substitution(list,featuretype,nocheck) |
| 30071 |
elseif featuretype=="ligature" then |
| 30072 |
coverage=prepare_ligature(list,featuretype,nocheck) |
| 30073 |
elseif featuretype=="alternate" then |
| 30074 |
coverage=prepare_alternate(list,featuretype,nocheck) |
| 30075 |
elseif featuretype=="multiple" then |
| 30076 |
coverage=prepare_multiple(list,featuretype,nocheck) |
| 30077 |
elseif featuretype=="kern" or featuretype=="move" then |
| 30078 |
format=featuretype |
| 30079 |
coverage=prepare_kern(list,featuretype) |
| 30080 |
elseif featuretype=="pair" then |
| 30081 |
format="pair" |
| 30082 |
coverage=prepare_pair(list,featuretype) |
| 30083 |
elseif featuretype=="single" then |
| 30084 |
format="single" |
| 30085 |
coverage=prepare_single(list,featuretype) |
| 30086 |
end |
| 30087 |
if coverage and next(coverage) then |
| 30088 |
nofsteps=nofsteps+1 |
| 30089 |
steps[nofsteps]=register(coverage,featuretype,format,feature,nofsteps,descriptions,resources) |
| 30090 |
end |
| 30091 |
end |
| 30092 |
checkmerge(specification) |
| 30093 |
checksteps(specification) |
| 30094 |
s[i]={ |
| 30095 |
[stepkey]=steps, |
| 30096 |
nofsteps=nofsteps, |
| 30097 |
flags=featureflags, |
| 30098 |
type=types[featuretype], |
| 30099 |
} |
| 30100 |
end |
| 30101 |
sublookups=s |
| 30102 |
end |
| 30103 |
for i=1,#askedsteps do |
| 30104 |
local list=askedsteps[i] |
| 30105 |
local coverage=nil |
| 30106 |
local format=nil |
| 30107 |
if type(list)=="function" then |
| 30108 |
list=list(data,specification,list,i) |
| 30109 |
end |
| 30110 |
if not list then |
| 30111 |
elseif featuretype=="substitution" then |
| 30112 |
category="gsub" |
| 30113 |
coverage=(mapping and list) or prepare_substitution(list,featuretype,nocheck) |
| 30114 |
elseif featuretype=="ligature" then |
| 30115 |
category="gsub" |
| 30116 |
coverage=prepare_ligature(list,featuretype,nocheck) |
| 30117 |
elseif featuretype=="alternate" then |
| 30118 |
category="gsub" |
| 30119 |
coverage=prepare_alternate(list,featuretype,nocheck) |
| 30120 |
elseif featuretype=="multiple" then |
| 30121 |
category="gsub" |
| 30122 |
coverage=prepare_multiple(list,featuretype,nocheck) |
| 30123 |
elseif featuretype=="kern" or featuretype=="move" then |
| 30124 |
category="gpos" |
| 30125 |
format=featuretype |
| 30126 |
coverage=prepare_kern(list,featuretype) |
| 30127 |
elseif featuretype=="pair" then |
| 30128 |
category="gpos" |
| 30129 |
format="pair" |
| 30130 |
coverage=prepare_pair(list,featuretype) |
| 30131 |
elseif featuretype=="single" then |
| 30132 |
category="gpos" |
| 30133 |
format="single" |
| 30134 |
coverage=prepare_single(list,featuretype) |
| 30135 |
elseif featuretype=="chainsubstitution" then |
| 30136 |
category="gsub" |
| 30137 |
coverage=prepare_chain(list,featuretype,sublookups,nocheck) |
| 30138 |
elseif featuretype=="chainposition" then |
| 30139 |
category="gpos" |
| 30140 |
coverage=prepare_chain(list,featuretype,sublookups,nocheck) |
| 30141 |
else |
| 30142 |
report_otf("not registering feature %a, unknown category",feature) |
| 30143 |
return |
| 30144 |
end |
| 30145 |
if coverage and next(coverage) then |
| 30146 |
nofsteps=nofsteps+1 |
| 30147 |
steps[nofsteps]=register(coverage,featuretype,format,feature,nofsteps,descriptions,resources) |
| 30148 |
end |
| 30149 |
end |
| 30150 |
if nofsteps>0 then |
| 30151 |
sequence={ |
| 30152 |
chain=featurechain, |
| 30153 |
features={ [feature]=askedfeatures }, |
| 30154 |
flags=featureflags, |
| 30155 |
name=feature, |
| 30156 |
order=featureorder, |
| 30157 |
[stepkey]=steps, |
| 30158 |
nofsteps=nofsteps, |
| 30159 |
type=specification.handler or types[featuretype], |
| 30160 |
} |
| 30161 |
if prepareonly then |
| 30162 |
return sequence |
| 30163 |
end |
| 30164 |
end |
| 30165 |
end |
| 30166 |
if sequence then |
| 30167 |
checkflags(sequence,resources) |
| 30168 |
checkmerge(sequence) |
| 30169 |
checksteps(sequence) |
| 30170 |
local first,last=getrange(sequences,category) |
| 30171 |
inject(specification,sequences,sequence,first,last,category,feature) |
| 30172 |
local features=fontfeatures[category] |
| 30173 |
if not features then |
| 30174 |
features={} |
| 30175 |
fontfeatures[category]=features |
| 30176 |
end |
| 30177 |
local k=features[feature] |
| 30178 |
if not k then |
| 30179 |
k={} |
| 30180 |
features[feature]=k |
| 30181 |
end |
| 30182 |
for script,languages in next,askedfeatures do |
| 30183 |
local kk=k[script] |
| 30184 |
if not kk then |
| 30185 |
kk={} |
| 30186 |
k[script]=kk |
| 30187 |
end |
| 30188 |
for language,value in next,languages do |
| 30189 |
kk[language]=value |
| 30190 |
end |
| 30191 |
end |
| 30192 |
end |
| 30193 |
end |
| 30194 |
end |
| 30195 |
if trace_loading then |
| 30196 |
report_otf("registering feature %a, affected glyphs %a, skipped glyphs %a",feature,done,skip) |
| 30197 |
end |
| 30198 |
end |
| 30199 |
otf.enhancers.addfeature=addfeature |
| 30200 |
local extrafeatures={} |
| 30201 |
local knownfeatures={} |
| 30202 |
function otf.addfeature(name,specification) |
| 30203 |
if type(name)=="table" then |
| 30204 |
specification=name |
| 30205 |
end |
| 30206 |
if type(specification)~="table" then |
| 30207 |
report_otf("invalid feature specification, no valid table") |
| 30208 |
return |
| 30209 |
end |
| 30210 |
specification,name=validspecification(specification,name) |
| 30211 |
if name and specification then |
| 30212 |
local slot=knownfeatures[name] |
| 30213 |
if not slot then |
| 30214 |
slot=#extrafeatures+1 |
| 30215 |
knownfeatures[name]=slot |
| 30216 |
elseif specification.overload==false then |
| 30217 |
slot=#extrafeatures+1 |
| 30218 |
knownfeatures[name]=slot |
| 30219 |
else |
| 30220 |
end |
| 30221 |
specification.name=name |
| 30222 |
extrafeatures[slot]=specification |
| 30223 |
end |
| 30224 |
end |
| 30225 |
local function enhance(data,filename,raw) |
| 30226 |
for slot=1,#extrafeatures do |
| 30227 |
local specification=extrafeatures[slot] |
| 30228 |
addfeature(data,specification.name,specification) |
| 30229 |
end |
| 30230 |
end |
| 30231 |
otf.enhancers.enhance=enhance |
| 30232 |
otf.enhancers.register("check extra features",enhance) |
| 30233 |
|
| 30234 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-otc”] --- |
| 30235 |
|
| 30236 |
|
| 30237 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-onr” a3f85c886cf22fb27760d98603d51ffd] --- |
| 30238 |
|
| 30239 |
if not modules then modules={} end modules ['font-onr']={ |
| 30240 |
version=1.001, |
| 30241 |
optimize=true, |
| 30242 |
comment="companion to font-ini.mkiv", |
| 30243 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 30244 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 30245 |
license="see context related readme files" |
| 30246 |
} |
| 30247 |
local fonts,logs,trackers,resolvers=fonts,logs,trackers,resolvers |
| 30248 |
local next,type,tonumber,rawset=next,type,tonumber,rawset |
| 30249 |
local match,lower,gsub,strip,find=string.match,string.lower,string.gsub,string.strip,string.find |
| 30250 |
local char,byte,sub=string.char,string.byte,string.sub |
| 30251 |
local abs=math.abs |
| 30252 |
local bxor,rshift=bit32.bxor,bit32.rshift |
| 30253 |
local P,S,R,V,Cmt,C,Ct,Cs,Carg,Cf,Cg,Cc=lpeg.P,lpeg.S,lpeg.R,lpeg.V,lpeg.Cmt,lpeg.C,lpeg.Ct,lpeg.Cs,lpeg.Carg,lpeg.Cf,lpeg.Cg,lpeg.Cc |
| 30254 |
local lpegmatch,patterns=lpeg.match,lpeg.patterns |
| 30255 |
local trace_indexing=false trackers.register("afm.indexing",function(v) trace_indexing=v end) |
| 30256 |
local trace_loading=false trackers.register("afm.loading",function(v) trace_loading=v end) |
| 30257 |
local report_afm=logs.reporter("fonts","afm loading") |
| 30258 |
local report_pfb=logs.reporter("fonts","pfb loading") |
| 30259 |
local handlers=fonts.handlers |
| 30260 |
local afm=handlers.afm or {} |
| 30261 |
handlers.afm=afm |
| 30262 |
local readers=afm.readers or {} |
| 30263 |
afm.readers=readers |
| 30264 |
afm.version=1.513 |
| 30265 |
local get_indexes,get_shapes |
| 30266 |
do |
| 30267 |
local decrypt |
| 30268 |
do |
| 30269 |
local r,c1,c2,n=0,0,0,0 |
| 30270 |
local function step(c) |
| 30271 |
local cipher=byte(c) |
| 30272 |
local plain=bxor(cipher,rshift(r,8)) |
| 30273 |
r=((cipher+r)*c1+c2)%65536 |
| 30274 |
return char(plain) |
| 30275 |
end |
| 30276 |
decrypt=function(binary,initial,seed) |
| 30277 |
r,c1,c2,n=initial,52845,22719,seed |
| 30278 |
binary=gsub(binary,".",step) |
| 30279 |
return sub(binary,n+1) |
| 30280 |
end |
| 30281 |
end |
| 30282 |
local charstrings=P("/CharStrings") |
| 30283 |
local subroutines=P("/Subrs") |
| 30284 |
local encoding=P("/Encoding") |
| 30285 |
local dup=P("dup") |
| 30286 |
local put=P("put") |
| 30287 |
local array=P("array") |
| 30288 |
local name=P("/")*C((R("az","AZ","09")+S("-_."))^1) |
| 30289 |
local digits=R("09")^1 |
| 30290 |
local cardinal=digits/tonumber |
| 30291 |
local spaces=P(" ")^1 |
| 30292 |
local spacing=patterns.whitespace^0 |
| 30293 |
local routines,vector,chars,n,m |
| 30294 |
local initialize=function(str,position,size) |
| 30295 |
n=0 |
| 30296 |
m=size |
| 30297 |
return position+1 |
| 30298 |
end |
| 30299 |
local setroutine=function(str,position,index,size,filename) |
| 30300 |
if routines[index] then |
| 30301 |
return false |
| 30302 |
end |
| 30303 |
local forward=position+size |
| 30304 |
local stream=decrypt(sub(str,position+1,forward),4330,4) |
| 30305 |
routines[index]={ byte(stream,1,#stream) } |
| 30306 |
n=n+1 |
| 30307 |
if n>=m then |
| 30308 |
return #str |
| 30309 |
end |
| 30310 |
return forward+1 |
| 30311 |
end |
| 30312 |
local setvector=function(str,position,name,size,filename) |
| 30313 |
local forward=position+tonumber(size) |
| 30314 |
if n>=m then |
| 30315 |
return #str |
| 30316 |
elseif forward<#str then |
| 30317 |
if n==0 and name~=".notdef" then |
| 30318 |
report_pfb("reserving .notdef at index 0 in %a",filename) |
| 30319 |
n=n+1 |
| 30320 |
end |
| 30321 |
vector[n]=name |
| 30322 |
n=n+1 |
| 30323 |
return forward |
| 30324 |
else |
| 30325 |
return #str |
| 30326 |
end |
| 30327 |
end |
| 30328 |
local setshapes=function(str,position,name,size,filename) |
| 30329 |
local forward=position+tonumber(size) |
| 30330 |
local stream=sub(str,position+1,forward) |
| 30331 |
if n>m then |
| 30332 |
return #str |
| 30333 |
elseif forward<#str then |
| 30334 |
if n==0 and name~=".notdef" then |
| 30335 |
report_pfb("reserving .notdef at index 0 in %a",filename) |
| 30336 |
n=n+1 |
| 30337 |
end |
| 30338 |
vector[n]=name |
| 30339 |
n=n+1 |
| 30340 |
chars [n]=decrypt(stream,4330,4) |
| 30341 |
return forward |
| 30342 |
else |
| 30343 |
return #str |
| 30344 |
end |
| 30345 |
end |
| 30346 |
local p_rd=spacing*(P("RD")+P("-|")) |
| 30347 |
local p_np=spacing*(P("NP")+P("|")) |
| 30348 |
local p_nd=spacing*(P("ND")+P("|")) |
| 30349 |
local p_filterroutines= |
| 30350 |
(1-subroutines)^0*subroutines*spaces*Cmt(cardinal,initialize)*(Cmt(cardinal*spaces*cardinal*p_rd*Carg(1),setroutine)*p_np+(1-p_nd))^1 |
| 30351 |
local p_filtershapes= |
| 30352 |
(1-charstrings)^0*charstrings*spaces*Cmt(cardinal,initialize)*(Cmt(name*spaces*cardinal*p_rd*Carg(1),setshapes)*p_nd+P(1))^1 |
| 30353 |
local p_filternames=Ct ( |
| 30354 |
(1-charstrings)^0*charstrings*spaces*Cmt(cardinal,initialize)*(Cmt(name*spaces*cardinal*Carg(1),setvector)+P(1))^1 |
| 30355 |
) |
| 30356 |
local p_filterencoding=(1-encoding)^0*encoding*spaces*digits*spaces*array*(1-dup)^0*Cf( |
| 30357 |
Ct("")*Cg(spacing*dup*spaces*cardinal*spaces*name*spaces*put)^1 |
| 30358 |
,rawset) |
| 30359 |
local key=spacing*P("/")*R("az","AZ") |
| 30360 |
local str=spacing*Cs { (P("(")/"")*((1-P("\\(")-P("\\)")-S("()"))+V(1))^0*(P(")")/"") } |
| 30361 |
local num=spacing*(R("09")+S("+-."))^1/tonumber |
| 30362 |
local arr=spacing*Ct (S("[{")*(num)^0*spacing*S("]}")) |
| 30363 |
local boo=spacing*(P("true")*Cc(true)+P("false")*Cc(false)) |
| 30364 |
local nam=spacing*P("/")*Cs(R("az","AZ")^1) |
| 30365 |
local p_filtermetadata=( |
| 30366 |
P("/")*Carg(1)*(( |
| 30367 |
C("version")*str+C("Copyright")*str+C("Notice")*str+C("FullName")*str+C("FamilyName")*str+C("Weight")*str+C("ItalicAngle")*num+C("isFixedPitch")*boo+C("UnderlinePosition")*num+C("UnderlineThickness")*num+C("FontName")*nam+C("FontMatrix")*arr+C("FontBBox")*arr |
| 30368 |
) )/function(t,k,v) t[lower(k)]=v end+P(1) |
| 30369 |
)^0*Carg(1) |
| 30370 |
local function loadpfbvector(filename,shapestoo,streams) |
| 30371 |
local data=io.loaddata(resolvers.findfile(filename)) |
| 30372 |
if not data then |
| 30373 |
report_pfb("no data in %a",filename) |
| 30374 |
return |
| 30375 |
end |
| 30376 |
if not (find(data,"!PS-AdobeFont-",1,true) or find(data,"%!FontType1",1,true)) then |
| 30377 |
report_pfb("no font in %a",filename) |
| 30378 |
return |
| 30379 |
end |
| 30380 |
local ascii,binary=match(data,"(.*)eexec%s+......(.*)") |
| 30381 |
if not binary then |
| 30382 |
report_pfb("no binary data in %a",filename) |
| 30383 |
return |
| 30384 |
end |
| 30385 |
binary=decrypt(binary,55665,4) |
| 30386 |
local names={} |
| 30387 |
local encoding=lpegmatch(p_filterencoding,ascii) |
| 30388 |
local metadata=lpegmatch(p_filtermetadata,ascii,1,{}) |
| 30389 |
local glyphs={} |
| 30390 |
routines,vector,chars={},{},{} |
| 30391 |
if shapestoo or streams then |
| 30392 |
lpegmatch(p_filterroutines,binary,1,filename) |
| 30393 |
lpegmatch(p_filtershapes,binary,1,filename) |
| 30394 |
local data={ |
| 30395 |
dictionaries={ |
| 30396 |
{ |
| 30397 |
charstrings=chars, |
| 30398 |
charset=vector, |
| 30399 |
subroutines=routines, |
| 30400 |
} |
| 30401 |
}, |
| 30402 |
} |
| 30403 |
fonts.handlers.otf.readers.parsecharstrings(false,data,glyphs,true,"cff",streams,true) |
| 30404 |
else |
| 30405 |
lpegmatch(p_filternames,binary,1,filename) |
| 30406 |
end |
| 30407 |
names=vector |
| 30408 |
routines,vector,chars=nil,nil,nil |
| 30409 |
return names,encoding,glyphs,metadata |
| 30410 |
end |
| 30411 |
local pfb=handlers.pfb or {} |
| 30412 |
handlers.pfb=pfb |
| 30413 |
pfb.loadvector=loadpfbvector |
| 30414 |
get_indexes=function(data,pfbname) |
| 30415 |
local vector=loadpfbvector(pfbname) |
| 30416 |
if vector then |
| 30417 |
local characters=data.characters |
| 30418 |
if trace_loading then |
| 30419 |
report_afm("getting index data from %a",pfbname) |
| 30420 |
end |
| 30421 |
for index=0,#vector do |
| 30422 |
local name=vector[index] |
| 30423 |
local char=characters[name] |
| 30424 |
if char then |
| 30425 |
if trace_indexing then |
| 30426 |
report_afm("glyph %a has index %a",name,index) |
| 30427 |
end |
| 30428 |
char.index=index |
| 30429 |
else |
| 30430 |
if trace_indexing then |
| 30431 |
report_afm("glyph %a has index %a but no data",name,index) |
| 30432 |
end |
| 30433 |
end |
| 30434 |
end |
| 30435 |
end |
| 30436 |
end |
| 30437 |
get_shapes=function(pfbname) |
| 30438 |
local vector,encoding,glyphs=loadpfbvector(pfbname,true) |
| 30439 |
return glyphs |
| 30440 |
end |
| 30441 |
end |
| 30442 |
local spacer=patterns.spacer |
| 30443 |
local whitespace=patterns.whitespace |
| 30444 |
local lineend=patterns.newline |
| 30445 |
local spacing=spacer^0 |
| 30446 |
local number=spacing*S("+-")^-1*(R("09")+S("."))^1/tonumber |
| 30447 |
local name=spacing*C((1-whitespace)^1) |
| 30448 |
local words=spacing*((1-lineend)^1/strip) |
| 30449 |
local rest=(1-lineend)^0 |
| 30450 |
local fontdata=Carg(1) |
| 30451 |
local semicolon=spacing*P(";") |
| 30452 |
local plus=spacing*P("plus")*number |
| 30453 |
local minus=spacing*P("minus")*number |
| 30454 |
local function addkernpair(data,one,two,value) |
| 30455 |
local chr=data.characters[one] |
| 30456 |
if chr then |
| 30457 |
local kerns=chr.kerns |
| 30458 |
if kerns then |
| 30459 |
kerns[two]=tonumber(value) |
| 30460 |
else |
| 30461 |
chr.kerns={ [two]=tonumber(value) } |
| 30462 |
end |
| 30463 |
end |
| 30464 |
end |
| 30465 |
local p_kernpair=(fontdata*P("KPX")*name*name*number)/addkernpair |
| 30466 |
local chr=false |
| 30467 |
local ind=0 |
| 30468 |
local function start(data,version) |
| 30469 |
data.metadata.afmversion=version |
| 30470 |
ind=0 |
| 30471 |
chr={} |
| 30472 |
end |
| 30473 |
local function stop() |
| 30474 |
ind=0 |
| 30475 |
chr=false |
| 30476 |
end |
| 30477 |
local function setindex(i) |
| 30478 |
if i<0 then |
| 30479 |
ind=ind+1 |
| 30480 |
else |
| 30481 |
ind=i |
| 30482 |
end |
| 30483 |
chr={ |
| 30484 |
index=ind |
| 30485 |
} |
| 30486 |
end |
| 30487 |
local function setwidth(width) |
| 30488 |
chr.width=width |
| 30489 |
end |
| 30490 |
local function setname(data,name) |
| 30491 |
data.characters[name]=chr |
| 30492 |
end |
| 30493 |
local function setboundingbox(boundingbox) |
| 30494 |
chr.boundingbox=boundingbox |
| 30495 |
end |
| 30496 |
local function setligature(plus,becomes) |
| 30497 |
local ligatures=chr.ligatures |
| 30498 |
if ligatures then |
| 30499 |
ligatures[plus]=becomes |
| 30500 |
else |
| 30501 |
chr.ligatures={ [plus]=becomes } |
| 30502 |
end |
| 30503 |
end |
| 30504 |
local p_charmetric=(( |
| 30505 |
P("C")*number/setindex+P("WX")*number/setwidth+P("N")*fontdata*name/setname+P("B")*Ct((number)^4)/setboundingbox+P("L")*(name)^2/setligature |
| 30506 |
)*semicolon )^1 |
| 30507 |
local p_charmetrics=P("StartCharMetrics")*number*(p_charmetric+(1-P("EndCharMetrics")))^0*P("EndCharMetrics") |
| 30508 |
local p_kernpairs=P("StartKernPairs")*number*(p_kernpair+(1-P("EndKernPairs" )))^0*P("EndKernPairs" ) |
| 30509 |
local function set_1(data,key,a) data.metadata[lower(key)]=a end |
| 30510 |
local function set_2(data,key,a,b) data.metadata[lower(key)]={ a,b } end |
| 30511 |
local function set_3(data,key,a,b,c) data.metadata[lower(key)]={ a,b,c } end |
| 30512 |
local p_parameters=P(false)+fontdata*((P("FontName")+P("FullName")+P("FamilyName"))/lower)*words/function(data,key,value) |
| 30513 |
data.metadata[key]=value |
| 30514 |
end+fontdata*((P("Weight")+P("Version"))/lower)*name/function(data,key,value) |
| 30515 |
data.metadata[key]=value |
| 30516 |
end+fontdata*P("IsFixedPitch")*name/function(data,pitch) |
| 30517 |
data.metadata.monospaced=toboolean(pitch,true) |
| 30518 |
end+fontdata*P("FontBBox")*Ct(number^4)/function(data,boundingbox) |
| 30519 |
data.metadata.boundingbox=boundingbox |
| 30520 |
end+fontdata*((P("CharWidth")+P("CapHeight")+P("XHeight")+P("Descender")+P("Ascender")+P("ItalicAngle"))/lower)*number/function(data,key,value) |
| 30521 |
data.metadata[key]=value |
| 30522 |
end+P("Comment")*spacing*(P(false)+(fontdata*C("DESIGNSIZE")*number*rest)/set_1 |
| 30523 |
+(fontdata*C("TFM designsize")*number*rest)/set_1+(fontdata*C("DesignSize")*number*rest)/set_1+(fontdata*C("CODINGSCHEME")*words*rest)/set_1 |
| 30524 |
+(fontdata*C("CHECKSUM")*number*words*rest)/set_1 |
| 30525 |
+(fontdata*C("SPACE")*number*plus*minus*rest)/set_3 |
| 30526 |
+(fontdata*C("QUAD")*number*rest)/set_1 |
| 30527 |
+(fontdata*C("EXTRASPACE")*number*rest)/set_1 |
| 30528 |
+(fontdata*C("NUM")*number*number*number*rest)/set_3 |
| 30529 |
+(fontdata*C("DENOM")*number*number*rest)/set_2 |
| 30530 |
+(fontdata*C("SUP")*number*number*number*rest)/set_3 |
| 30531 |
+(fontdata*C("SUB")*number*number*rest)/set_2 |
| 30532 |
+(fontdata*C("SUPDROP")*number*rest)/set_1 |
| 30533 |
+(fontdata*C("SUBDROP")*number*rest)/set_1 |
| 30534 |
+(fontdata*C("DELIM")*number*number*rest)/set_2 |
| 30535 |
+(fontdata*C("AXISHEIGHT")*number*rest)/set_1 |
| 30536 |
) |
| 30537 |
local fullparser=(P("StartFontMetrics")*fontdata*name/start )*(p_charmetrics+p_kernpairs+p_parameters+(1-P("EndFontMetrics")) )^0*(P("EndFontMetrics")/stop ) |
| 30538 |
local infoparser=(P("StartFontMetrics")*fontdata*name/start )*(p_parameters+(1-P("EndFontMetrics")) )^0*(P("EndFontMetrics")/stop ) |
| 30539 |
local function read(filename,parser) |
| 30540 |
local afmblob=io.loaddata(filename) |
| 30541 |
if afmblob then |
| 30542 |
local data={ |
| 30543 |
resources={ |
| 30544 |
filename=resolvers.unresolve(filename), |
| 30545 |
version=afm.version, |
| 30546 |
creator="context mkiv", |
| 30547 |
}, |
| 30548 |
properties={ |
| 30549 |
hasitalics=false, |
| 30550 |
}, |
| 30551 |
goodies={}, |
| 30552 |
metadata={ |
| 30553 |
filename=file.removesuffix(file.basename(filename)) |
| 30554 |
}, |
| 30555 |
characters={ |
| 30556 |
}, |
| 30557 |
descriptions={ |
| 30558 |
}, |
| 30559 |
} |
| 30560 |
if trace_loading then |
| 30561 |
report_afm("parsing afm file %a",filename) |
| 30562 |
end |
| 30563 |
lpegmatch(parser,afmblob,1,data) |
| 30564 |
return data |
| 30565 |
else |
| 30566 |
if trace_loading then |
| 30567 |
report_afm("no valid afm file %a",filename) |
| 30568 |
end |
| 30569 |
return nil |
| 30570 |
end |
| 30571 |
end |
| 30572 |
function readers.loadfont(afmname,pfbname) |
| 30573 |
local data=read(resolvers.findfile(afmname),fullparser) |
| 30574 |
if data then |
| 30575 |
if not pfbname or pfbname=="" then |
| 30576 |
pfbname=resolvers.findfile(file.replacesuffix(file.nameonly(afmname),"pfb")) |
| 30577 |
end |
| 30578 |
if pfbname and pfbname~="" then |
| 30579 |
data.resources.filename=resolvers.unresolve(pfbname) |
| 30580 |
get_indexes(data,pfbname) |
| 30581 |
return data |
| 30582 |
else |
| 30583 |
report_afm("no pfb file for %a",afmname) |
| 30584 |
end |
| 30585 |
end |
| 30586 |
end |
| 30587 |
function readers.loadshapes(filename) |
| 30588 |
local fullname=resolvers.findfile(filename) or "" |
| 30589 |
if fullname=="" then |
| 30590 |
return { |
| 30591 |
filename="not found: "..filename, |
| 30592 |
glyphs={} |
| 30593 |
} |
| 30594 |
else |
| 30595 |
return { |
| 30596 |
filename=fullname, |
| 30597 |
format="opentype", |
| 30598 |
glyphs=get_shapes(fullname) or {}, |
| 30599 |
units=1000, |
| 30600 |
} |
| 30601 |
end |
| 30602 |
end |
| 30603 |
function readers.getinfo(filename) |
| 30604 |
local data=read(resolvers.findfile(filename),infoparser) |
| 30605 |
if data then |
| 30606 |
return data.metadata |
| 30607 |
end |
| 30608 |
end |
| 30609 |
|
| 30610 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-onr”] --- |
| 30611 |
|
| 30612 |
|
| 30613 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-one” b7fb0389462a49bc1f41bebd2da85401] --- |
| 30614 |
|
| 30615 |
if not modules then modules={} end modules ['font-one']={ |
| 30616 |
version=1.001, |
| 30617 |
optimize=true, |
| 30618 |
comment="companion to font-ini.mkiv", |
| 30619 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 30620 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 30621 |
license="see context related readme files" |
| 30622 |
} |
| 30623 |
local fonts,logs,trackers,containers,resolvers=fonts,logs,trackers,containers,resolvers |
| 30624 |
local next,type,tonumber,rawget=next,type,tonumber,rawget |
| 30625 |
local match,gsub=string.match,string.gsub |
| 30626 |
local abs=math.abs |
| 30627 |
local P,S,R,Cmt,C,Ct,Cs,Carg=lpeg.P,lpeg.S,lpeg.R,lpeg.Cmt,lpeg.C,lpeg.Ct,lpeg.Cs,lpeg.Carg |
| 30628 |
local lpegmatch,patterns=lpeg.match,lpeg.patterns |
| 30629 |
local sortedhash=table.sortedhash |
| 30630 |
local trace_features=false trackers.register("afm.features",function(v) trace_features=v end) |
| 30631 |
local trace_indexing=false trackers.register("afm.indexing",function(v) trace_indexing=v end) |
| 30632 |
local trace_loading=false trackers.register("afm.loading",function(v) trace_loading=v end) |
| 30633 |
local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) |
| 30634 |
local report_afm=logs.reporter("fonts","afm loading") |
| 30635 |
local setmetatableindex=table.setmetatableindex |
| 30636 |
local derivetable=table.derive |
| 30637 |
local findbinfile=resolvers.findbinfile |
| 30638 |
local privateoffset=fonts.constructors and fonts.constructors.privateoffset or 0xF0000 |
| 30639 |
local definers=fonts.definers |
| 30640 |
local readers=fonts.readers |
| 30641 |
local constructors=fonts.constructors |
| 30642 |
local afm=constructors.handlers.afm |
| 30643 |
local pfb=constructors.handlers.pfb |
| 30644 |
local otf=fonts.handlers.otf |
| 30645 |
local otfreaders=otf.readers |
| 30646 |
local otfenhancers=otf.enhancers |
| 30647 |
local afmfeatures=constructors.features.afm |
| 30648 |
local registerafmfeature=afmfeatures.register |
| 30649 |
local afmenhancers=constructors.enhancers.afm |
| 30650 |
local registerafmenhancer=afmenhancers.register |
| 30651 |
afm.version=1.513 |
| 30652 |
afm.cache=containers.define("fonts","one",afm.version,true) |
| 30653 |
afm.autoprefixed=true |
| 30654 |
afm.helpdata={} |
| 30655 |
afm.syncspace=true |
| 30656 |
local overloads=fonts.mappings.overloads |
| 30657 |
local applyruntimefixes=fonts.treatments and fonts.treatments.applyfixes |
| 30658 |
function afm.load(filename) |
| 30659 |
filename=resolvers.findfile(filename,'afm') or "" |
| 30660 |
if filename~="" and not fonts.names.ignoredfile(filename) then |
| 30661 |
local name=file.removesuffix(file.basename(filename)) |
| 30662 |
local data=containers.read(afm.cache,name) |
| 30663 |
local attr=lfs.attributes(filename) |
| 30664 |
local size=attr and attr.size or 0 |
| 30665 |
local time=attr and attr.modification or 0 |
| 30666 |
local pfbfile=file.replacesuffix(name,"pfb") |
| 30667 |
local pfbname=resolvers.findfile(pfbfile,"pfb") or "" |
| 30668 |
if pfbname=="" then |
| 30669 |
pfbname=resolvers.findfile(file.basename(pfbfile),"pfb") or "" |
| 30670 |
end |
| 30671 |
local pfbsize=0 |
| 30672 |
local pfbtime=0 |
| 30673 |
if pfbname~="" then |
| 30674 |
local attr=lfs.attributes(pfbname) |
| 30675 |
pfbsize=attr.size or 0 |
| 30676 |
pfbtime=attr.modification or 0 |
| 30677 |
end |
| 30678 |
if not data or data.size~=size or data.time~=time or data.pfbsize~=pfbsize or data.pfbtime~=pfbtime then |
| 30679 |
report_afm("reading %a",filename) |
| 30680 |
data=afm.readers.loadfont(filename,pfbname) |
| 30681 |
if data then |
| 30682 |
afmenhancers.apply(data,filename) |
| 30683 |
fonts.mappings.addtounicode(data,filename) |
| 30684 |
otfreaders.stripredundant(data) |
| 30685 |
otfreaders.pack(data) |
| 30686 |
data.size=size |
| 30687 |
data.time=time |
| 30688 |
data.pfbsize=pfbsize |
| 30689 |
data.pfbtime=pfbtime |
| 30690 |
report_afm("saving %a in cache",name) |
| 30691 |
data=containers.write(afm.cache,name,data) |
| 30692 |
data=containers.read(afm.cache,name) |
| 30693 |
end |
| 30694 |
end |
| 30695 |
if data then |
| 30696 |
otfreaders.unpack(data) |
| 30697 |
otfreaders.expand(data) |
| 30698 |
otfreaders.addunicodetable(data) |
| 30699 |
otfenhancers.apply(data,filename,data) |
| 30700 |
if applyruntimefixes then |
| 30701 |
applyruntimefixes(filename,data) |
| 30702 |
end |
| 30703 |
end |
| 30704 |
return data |
| 30705 |
end |
| 30706 |
end |
| 30707 |
local uparser=fonts.mappings.makenameparser() |
| 30708 |
local function enhance_unify_names(data,filename) |
| 30709 |
local unicodevector=fonts.encodings.agl.unicodes |
| 30710 |
local unicodes={} |
| 30711 |
local names={} |
| 30712 |
local private=data.private or privateoffset |
| 30713 |
local descriptions=data.descriptions |
| 30714 |
for name,blob in sortedhash(data.characters) do |
| 30715 |
local code=unicodevector[name] |
| 30716 |
if not code then |
| 30717 |
code=lpegmatch(uparser,name) |
| 30718 |
if type(code)~="number" then |
| 30719 |
code=private |
| 30720 |
private=private+1 |
| 30721 |
report_afm("assigning private slot %U for unknown glyph name %a",code,name) |
| 30722 |
end |
| 30723 |
end |
| 30724 |
local index=blob.index |
| 30725 |
unicodes[name]=code |
| 30726 |
names[name]=index |
| 30727 |
blob.name=name |
| 30728 |
descriptions[code]={ |
| 30729 |
boundingbox=blob.boundingbox, |
| 30730 |
width=blob.width, |
| 30731 |
kerns=blob.kerns, |
| 30732 |
index=index, |
| 30733 |
name=name, |
| 30734 |
} |
| 30735 |
end |
| 30736 |
for unicode,description in next,descriptions do |
| 30737 |
local kerns=description.kerns |
| 30738 |
if kerns then |
| 30739 |
local krn={} |
| 30740 |
for name,kern in next,kerns do |
| 30741 |
local unicode=unicodes[name] |
| 30742 |
if unicode then |
| 30743 |
krn[unicode]=kern |
| 30744 |
else |
| 30745 |
end |
| 30746 |
end |
| 30747 |
description.kerns=krn |
| 30748 |
end |
| 30749 |
end |
| 30750 |
data.characters=nil |
| 30751 |
data.private=private |
| 30752 |
local resources=data.resources |
| 30753 |
local filename=resources.filename or file.removesuffix(file.basename(filename)) |
| 30754 |
resources.filename=resolvers.unresolve(filename) |
| 30755 |
resources.unicodes=unicodes |
| 30756 |
resources.marks={} |
| 30757 |
end |
| 30758 |
local everywhere={ ["*"]={ ["*"]=true } } |
| 30759 |
local noflags={ false,false,false,false } |
| 30760 |
local function enhance_normalize_features(data) |
| 30761 |
local ligatures=setmetatableindex("table") |
| 30762 |
local kerns=setmetatableindex("table") |
| 30763 |
local extrakerns=setmetatableindex("table") |
| 30764 |
for u,c in next,data.descriptions do |
| 30765 |
local l=c.ligatures |
| 30766 |
local k=c.kerns |
| 30767 |
local e=c.extrakerns |
| 30768 |
if l then |
| 30769 |
ligatures[u]=l |
| 30770 |
for u,v in next,l do |
| 30771 |
l[u]={ ligature=v } |
| 30772 |
end |
| 30773 |
c.ligatures=nil |
| 30774 |
end |
| 30775 |
if k then |
| 30776 |
kerns[u]=k |
| 30777 |
for u,v in next,k do |
| 30778 |
k[u]=v |
| 30779 |
end |
| 30780 |
c.kerns=nil |
| 30781 |
end |
| 30782 |
if e then |
| 30783 |
extrakerns[u]=e |
| 30784 |
for u,v in next,e do |
| 30785 |
e[u]=v |
| 30786 |
end |
| 30787 |
c.extrakerns=nil |
| 30788 |
end |
| 30789 |
end |
| 30790 |
local features={ |
| 30791 |
gpos={}, |
| 30792 |
gsub={}, |
| 30793 |
} |
| 30794 |
local sequences={ |
| 30795 |
} |
| 30796 |
if next(ligatures) then |
| 30797 |
features.gsub.liga=everywhere |
| 30798 |
data.properties.hasligatures=true |
| 30799 |
sequences[#sequences+1]={ |
| 30800 |
features={ |
| 30801 |
liga=everywhere, |
| 30802 |
}, |
| 30803 |
flags=noflags, |
| 30804 |
name="s_s_0", |
| 30805 |
nofsteps=1, |
| 30806 |
order={ "liga" }, |
| 30807 |
type="gsub_ligature", |
| 30808 |
steps={ |
| 30809 |
{ |
| 30810 |
coverage=ligatures, |
| 30811 |
}, |
| 30812 |
}, |
| 30813 |
} |
| 30814 |
end |
| 30815 |
if next(kerns) then |
| 30816 |
features.gpos.kern=everywhere |
| 30817 |
data.properties.haskerns=true |
| 30818 |
sequences[#sequences+1]={ |
| 30819 |
features={ |
| 30820 |
kern=everywhere, |
| 30821 |
}, |
| 30822 |
flags=noflags, |
| 30823 |
name="p_s_0", |
| 30824 |
nofsteps=1, |
| 30825 |
order={ "kern" }, |
| 30826 |
type="gpos_pair", |
| 30827 |
steps={ |
| 30828 |
{ |
| 30829 |
format="kern", |
| 30830 |
coverage=kerns, |
| 30831 |
}, |
| 30832 |
}, |
| 30833 |
} |
| 30834 |
end |
| 30835 |
if next(extrakerns) then |
| 30836 |
features.gpos.extrakerns=everywhere |
| 30837 |
data.properties.haskerns=true |
| 30838 |
sequences[#sequences+1]={ |
| 30839 |
features={ |
| 30840 |
extrakerns=everywhere, |
| 30841 |
}, |
| 30842 |
flags=noflags, |
| 30843 |
name="p_s_1", |
| 30844 |
nofsteps=1, |
| 30845 |
order={ "extrakerns" }, |
| 30846 |
type="gpos_pair", |
| 30847 |
steps={ |
| 30848 |
{ |
| 30849 |
format="kern", |
| 30850 |
coverage=extrakerns, |
| 30851 |
}, |
| 30852 |
}, |
| 30853 |
} |
| 30854 |
end |
| 30855 |
data.resources.features=features |
| 30856 |
data.resources.sequences=sequences |
| 30857 |
end |
| 30858 |
local function enhance_fix_names(data) |
| 30859 |
for k,v in next,data.descriptions do |
| 30860 |
local n=v.name |
| 30861 |
local r=overloads[n] |
| 30862 |
if r then |
| 30863 |
local name=r.name |
| 30864 |
if trace_indexing then |
| 30865 |
report_afm("renaming characters %a to %a",n,name) |
| 30866 |
end |
| 30867 |
v.name=name |
| 30868 |
v.unicode=r.unicode |
| 30869 |
end |
| 30870 |
end |
| 30871 |
end |
| 30872 |
local addthem=function(rawdata,ligatures) |
| 30873 |
if ligatures then |
| 30874 |
local descriptions=rawdata.descriptions |
| 30875 |
local resources=rawdata.resources |
| 30876 |
local unicodes=resources.unicodes |
| 30877 |
for ligname,ligdata in next,ligatures do |
| 30878 |
local one=descriptions[unicodes[ligname]] |
| 30879 |
if one then |
| 30880 |
for _,pair in next,ligdata do |
| 30881 |
local two=unicodes[pair[1]] |
| 30882 |
local three=unicodes[pair[2]] |
| 30883 |
if two and three then |
| 30884 |
local ol=one.ligatures |
| 30885 |
if ol then |
| 30886 |
if not ol[two] then |
| 30887 |
ol[two]=three |
| 30888 |
end |
| 30889 |
else |
| 30890 |
one.ligatures={ [two]=three } |
| 30891 |
end |
| 30892 |
end |
| 30893 |
end |
| 30894 |
end |
| 30895 |
end |
| 30896 |
end |
| 30897 |
end |
| 30898 |
local function enhance_add_ligatures(rawdata) |
| 30899 |
addthem(rawdata,afm.helpdata.ligatures) |
| 30900 |
end |
| 30901 |
local function enhance_add_extra_kerns(rawdata) |
| 30902 |
local descriptions=rawdata.descriptions |
| 30903 |
local resources=rawdata.resources |
| 30904 |
local unicodes=resources.unicodes |
| 30905 |
local function do_it_left(what) |
| 30906 |
if what then |
| 30907 |
for unicode,description in next,descriptions do |
| 30908 |
local kerns=description.kerns |
| 30909 |
if kerns then |
| 30910 |
local extrakerns |
| 30911 |
for complex,simple in next,what do |
| 30912 |
complex=unicodes[complex] |
| 30913 |
simple=unicodes[simple] |
| 30914 |
if complex and simple then |
| 30915 |
local ks=kerns[simple] |
| 30916 |
if ks and not kerns[complex] then |
| 30917 |
if extrakerns then |
| 30918 |
extrakerns[complex]=ks |
| 30919 |
else |
| 30920 |
extrakerns={ [complex]=ks } |
| 30921 |
end |
| 30922 |
end |
| 30923 |
end |
| 30924 |
end |
| 30925 |
if extrakerns then |
| 30926 |
description.extrakerns=extrakerns |
| 30927 |
end |
| 30928 |
end |
| 30929 |
end |
| 30930 |
end |
| 30931 |
end |
| 30932 |
local function do_it_copy(what) |
| 30933 |
if what then |
| 30934 |
for complex,simple in next,what do |
| 30935 |
complex=unicodes[complex] |
| 30936 |
simple=unicodes[simple] |
| 30937 |
if complex and simple then |
| 30938 |
local complexdescription=descriptions[complex] |
| 30939 |
if complexdescription then |
| 30940 |
local simpledescription=descriptions[complex] |
| 30941 |
if simpledescription then |
| 30942 |
local extrakerns |
| 30943 |
local kerns=simpledescription.kerns |
| 30944 |
if kerns then |
| 30945 |
for unicode,kern in next,kerns do |
| 30946 |
if extrakerns then |
| 30947 |
extrakerns[unicode]=kern |
| 30948 |
else |
| 30949 |
extrakerns={ [unicode]=kern } |
| 30950 |
end |
| 30951 |
end |
| 30952 |
end |
| 30953 |
local extrakerns=simpledescription.extrakerns |
| 30954 |
if extrakerns then |
| 30955 |
for unicode,kern in next,extrakerns do |
| 30956 |
if extrakerns then |
| 30957 |
extrakerns[unicode]=kern |
| 30958 |
else |
| 30959 |
extrakerns={ [unicode]=kern } |
| 30960 |
end |
| 30961 |
end |
| 30962 |
end |
| 30963 |
if extrakerns then |
| 30964 |
complexdescription.extrakerns=extrakerns |
| 30965 |
end |
| 30966 |
end |
| 30967 |
end |
| 30968 |
end |
| 30969 |
end |
| 30970 |
end |
| 30971 |
end |
| 30972 |
do_it_left(afm.helpdata.leftkerned) |
| 30973 |
do_it_left(afm.helpdata.bothkerned) |
| 30974 |
do_it_copy(afm.helpdata.bothkerned) |
| 30975 |
do_it_copy(afm.helpdata.rightkerned) |
| 30976 |
end |
| 30977 |
local function adddimensions(data) |
| 30978 |
if data then |
| 30979 |
for unicode,description in next,data.descriptions do |
| 30980 |
local bb=description.boundingbox |
| 30981 |
if bb then |
| 30982 |
local ht=bb[4] |
| 30983 |
local dp=-bb[2] |
| 30984 |
if ht==0 or ht<0 then |
| 30985 |
else |
| 30986 |
description.height=ht |
| 30987 |
end |
| 30988 |
if dp==0 or dp<0 then |
| 30989 |
else |
| 30990 |
description.depth=dp |
| 30991 |
end |
| 30992 |
end |
| 30993 |
end |
| 30994 |
end |
| 30995 |
end |
| 30996 |
local function copytotfm(data) |
| 30997 |
if data and data.descriptions then |
| 30998 |
local metadata=data.metadata |
| 30999 |
local resources=data.resources |
| 31000 |
local properties=derivetable(data.properties) |
| 31001 |
local descriptions=derivetable(data.descriptions) |
| 31002 |
local goodies=derivetable(data.goodies) |
| 31003 |
local characters={} |
| 31004 |
local parameters={} |
| 31005 |
local unicodes=resources.unicodes |
| 31006 |
for unicode,description in next,data.descriptions do |
| 31007 |
characters[unicode]={} |
| 31008 |
end |
| 31009 |
local filename=constructors.checkedfilename(resources) |
| 31010 |
local fontname=metadata.fontname or metadata.fullname |
| 31011 |
local fullname=metadata.fullname or metadata.fontname |
| 31012 |
local endash=0x2013 |
| 31013 |
local emdash=0x2014 |
| 31014 |
local space=0x0020 |
| 31015 |
local spacer="space" |
| 31016 |
local spaceunits=500 |
| 31017 |
local monospaced=metadata.monospaced |
| 31018 |
local charwidth=metadata.charwidth |
| 31019 |
local italicangle=metadata.italicangle |
| 31020 |
local charxheight=metadata.xheight and metadata.xheight>0 and metadata.xheight |
| 31021 |
properties.monospaced=monospaced |
| 31022 |
parameters.italicangle=italicangle |
| 31023 |
parameters.charwidth=charwidth |
| 31024 |
parameters.charxheight=charxheight |
| 31025 |
local d_endash=descriptions[endash] |
| 31026 |
local d_emdash=descriptions[emdash] |
| 31027 |
local d_space=descriptions[space] |
| 31028 |
if not d_space or d_space==0 then |
| 31029 |
d_space=d_endash |
| 31030 |
end |
| 31031 |
if d_space then |
| 31032 |
spaceunits,spacer=d_space.width or 0,"space" |
| 31033 |
end |
| 31034 |
if properties.monospaced then |
| 31035 |
if spaceunits==0 and d_emdash then |
| 31036 |
spaceunits,spacer=d_emdash.width or 0,"emdash" |
| 31037 |
end |
| 31038 |
else |
| 31039 |
if spaceunits==0 and d_endash then |
| 31040 |
spaceunits,spacer=d_emdash.width or 0,"endash" |
| 31041 |
end |
| 31042 |
end |
| 31043 |
if spaceunits==0 and charwidth then |
| 31044 |
spaceunits,spacer=charwidth or 0,"charwidth" |
| 31045 |
end |
| 31046 |
if spaceunits==0 then |
| 31047 |
spaceunits=tonumber(spaceunits) or 500 |
| 31048 |
end |
| 31049 |
if spaceunits==0 then |
| 31050 |
spaceunits=500 |
| 31051 |
end |
| 31052 |
parameters.slant=0 |
| 31053 |
parameters.space=spaceunits |
| 31054 |
parameters.space_stretch=500 |
| 31055 |
parameters.space_shrink=333 |
| 31056 |
parameters.x_height=400 |
| 31057 |
parameters.quad=1000 |
| 31058 |
if italicangle and italicangle~=0 then |
| 31059 |
parameters.italicangle=italicangle |
| 31060 |
parameters.italicfactor=math.cos(math.rad(90+italicangle)) |
| 31061 |
parameters.slant=- math.tan(italicangle*math.pi/180) |
| 31062 |
end |
| 31063 |
if monospaced then |
| 31064 |
parameters.space_stretch=0 |
| 31065 |
parameters.space_shrink=0 |
| 31066 |
elseif afm.syncspace then |
| 31067 |
parameters.space_stretch=spaceunits/2 |
| 31068 |
parameters.space_shrink=spaceunits/3 |
| 31069 |
end |
| 31070 |
parameters.extra_space=parameters.space_shrink |
| 31071 |
if charxheight then |
| 31072 |
parameters.x_height=charxheight |
| 31073 |
else |
| 31074 |
local x=0x0078 |
| 31075 |
if x then |
| 31076 |
local x=descriptions[x] |
| 31077 |
if x then |
| 31078 |
parameters.x_height=x.height |
| 31079 |
end |
| 31080 |
end |
| 31081 |
end |
| 31082 |
if metadata.sup then |
| 31083 |
local dummy={ 0,0,0 } |
| 31084 |
parameters[ 1]=metadata.designsize or 0 |
| 31085 |
parameters[ 2]=metadata.checksum or 0 |
| 31086 |
parameters[ 3], |
| 31087 |
parameters[ 4], |
| 31088 |
parameters[ 5]=unpack(metadata.space or dummy) |
| 31089 |
parameters[ 6]=metadata.quad or 0 |
| 31090 |
parameters[ 7]=metadata.extraspace or 0 |
| 31091 |
parameters[ 8], |
| 31092 |
parameters[ 9], |
| 31093 |
parameters[10]=unpack(metadata.num or dummy) |
| 31094 |
parameters[11], |
| 31095 |
parameters[12]=unpack(metadata.denom or dummy) |
| 31096 |
parameters[13], |
| 31097 |
parameters[14], |
| 31098 |
parameters[15]=unpack(metadata.sup or dummy) |
| 31099 |
parameters[16], |
| 31100 |
parameters[17]=unpack(metadata.sub or dummy) |
| 31101 |
parameters[18]=metadata.supdrop or 0 |
| 31102 |
parameters[19]=metadata.subdrop or 0 |
| 31103 |
parameters[20], |
| 31104 |
parameters[21]=unpack(metadata.delim or dummy) |
| 31105 |
parameters[22]=metadata.axisheight or 0 |
| 31106 |
end |
| 31107 |
parameters.designsize=(metadata.designsize or 10)*65536 |
| 31108 |
parameters.ascender=abs(metadata.ascender or 0) |
| 31109 |
parameters.descender=abs(metadata.descender or 0) |
| 31110 |
parameters.units=1000 |
| 31111 |
properties.spacer=spacer |
| 31112 |
properties.format=fonts.formats[filename] or "type1" |
| 31113 |
properties.filename=filename |
| 31114 |
properties.fontname=fontname |
| 31115 |
properties.fullname=fullname |
| 31116 |
properties.psname=fullname |
| 31117 |
properties.name=filename or fullname or fontname |
| 31118 |
properties.private=properties.private or data.private or privateoffset |
| 31119 |
if not CONTEXTLMTXMODE or CONTEXTLMTXMODE==0 then |
| 31120 |
properties.encodingbytes=2 |
| 31121 |
end |
| 31122 |
if next(characters) then |
| 31123 |
return { |
| 31124 |
characters=characters, |
| 31125 |
descriptions=descriptions, |
| 31126 |
parameters=parameters, |
| 31127 |
resources=resources, |
| 31128 |
properties=properties, |
| 31129 |
goodies=goodies, |
| 31130 |
} |
| 31131 |
end |
| 31132 |
end |
| 31133 |
return nil |
| 31134 |
end |
| 31135 |
function afm.setfeatures(tfmdata,features) |
| 31136 |
local okay=constructors.initializefeatures("afm",tfmdata,features,trace_features,report_afm) |
| 31137 |
if okay then |
| 31138 |
return constructors.collectprocessors("afm",tfmdata,features,trace_features,report_afm) |
| 31139 |
else |
| 31140 |
return {} |
| 31141 |
end |
| 31142 |
end |
| 31143 |
local function addtables(data) |
| 31144 |
local resources=data.resources |
| 31145 |
local lookuptags=resources.lookuptags |
| 31146 |
local unicodes=resources.unicodes |
| 31147 |
if not lookuptags then |
| 31148 |
lookuptags={} |
| 31149 |
resources.lookuptags=lookuptags |
| 31150 |
end |
| 31151 |
setmetatableindex(lookuptags,function(t,k) |
| 31152 |
local v=type(k)=="number" and ("lookup "..k) or k |
| 31153 |
t[k]=v |
| 31154 |
return v |
| 31155 |
end) |
| 31156 |
if not unicodes then |
| 31157 |
unicodes={} |
| 31158 |
resources.unicodes=unicodes |
| 31159 |
setmetatableindex(unicodes,function(t,k) |
| 31160 |
setmetatableindex(unicodes,nil) |
| 31161 |
for u,d in next,data.descriptions do |
| 31162 |
local n=d.name |
| 31163 |
if n then |
| 31164 |
t[n]=u |
| 31165 |
end |
| 31166 |
end |
| 31167 |
return rawget(t,k) |
| 31168 |
end) |
| 31169 |
end |
| 31170 |
constructors.addcoreunicodes(unicodes) |
| 31171 |
end |
| 31172 |
local function afmtotfm(specification) |
| 31173 |
local afmname=specification.filename or specification.name |
| 31174 |
if specification.forced=="afm" or specification.format=="afm" then |
| 31175 |
if trace_loading then |
| 31176 |
report_afm("forcing afm format for %a",afmname) |
| 31177 |
end |
| 31178 |
else |
| 31179 |
local tfmname=findbinfile(afmname,"ofm") or "" |
| 31180 |
if tfmname~="" then |
| 31181 |
if trace_loading then |
| 31182 |
report_afm("fallback from afm to tfm for %a",afmname) |
| 31183 |
end |
| 31184 |
return |
| 31185 |
end |
| 31186 |
end |
| 31187 |
if afmname~="" then |
| 31188 |
local features=constructors.checkedfeatures("afm",specification.features.normal) |
| 31189 |
specification.features.normal=features |
| 31190 |
constructors.hashinstance(specification,true) |
| 31191 |
specification=definers.resolve(specification) |
| 31192 |
local cache_id=specification.hash |
| 31193 |
local tfmdata=containers.read(constructors.cache,cache_id) |
| 31194 |
if not tfmdata then |
| 31195 |
local rawdata=afm.load(afmname) |
| 31196 |
if rawdata and next(rawdata) then |
| 31197 |
addtables(rawdata) |
| 31198 |
adddimensions(rawdata) |
| 31199 |
tfmdata=copytotfm(rawdata) |
| 31200 |
if tfmdata and next(tfmdata) then |
| 31201 |
local shared=tfmdata.shared |
| 31202 |
if not shared then |
| 31203 |
shared={} |
| 31204 |
tfmdata.shared=shared |
| 31205 |
end |
| 31206 |
shared.rawdata=rawdata |
| 31207 |
shared.dynamics={} |
| 31208 |
tfmdata.changed={} |
| 31209 |
shared.features=features |
| 31210 |
shared.processes=afm.setfeatures(tfmdata,features) |
| 31211 |
end |
| 31212 |
elseif trace_loading then |
| 31213 |
report_afm("no (valid) afm file found with name %a",afmname) |
| 31214 |
end |
| 31215 |
tfmdata=containers.write(constructors.cache,cache_id,tfmdata) |
| 31216 |
end |
| 31217 |
return tfmdata |
| 31218 |
end |
| 31219 |
end |
| 31220 |
local function read_from_afm(specification) |
| 31221 |
local tfmdata=afmtotfm(specification) |
| 31222 |
if tfmdata then |
| 31223 |
tfmdata.properties.name=specification.name |
| 31224 |
tfmdata.properties.id=specification.id |
| 31225 |
tfmdata=constructors.scale(tfmdata,specification) |
| 31226 |
local allfeatures=tfmdata.shared.features or specification.features.normal |
| 31227 |
constructors.applymanipulators("afm",tfmdata,allfeatures,trace_features,report_afm) |
| 31228 |
fonts.loggers.register(tfmdata,'afm',specification) |
| 31229 |
end |
| 31230 |
return tfmdata |
| 31231 |
end |
| 31232 |
registerafmfeature { |
| 31233 |
name="mode", |
| 31234 |
description="mode", |
| 31235 |
initializers={ |
| 31236 |
base=otf.modeinitializer, |
| 31237 |
node=otf.modeinitializer, |
| 31238 |
} |
| 31239 |
} |
| 31240 |
registerafmfeature { |
| 31241 |
name="features", |
| 31242 |
description="features", |
| 31243 |
default=true, |
| 31244 |
initializers={ |
| 31245 |
node=otf.nodemodeinitializer, |
| 31246 |
base=otf.basemodeinitializer, |
| 31247 |
}, |
| 31248 |
processors={ |
| 31249 |
node=otf.featuresprocessor, |
| 31250 |
} |
| 31251 |
} |
| 31252 |
fonts.formats.afm="type1" |
| 31253 |
fonts.formats.pfb="type1" |
| 31254 |
local function check_afm(specification,fullname) |
| 31255 |
local foundname=findbinfile(fullname,'afm') or "" |
| 31256 |
if foundname=="" then |
| 31257 |
foundname=fonts.names.getfilename(fullname,"afm") or "" |
| 31258 |
end |
| 31259 |
if fullname and foundname=="" and afm.autoprefixed then |
| 31260 |
local encoding,shortname=match(fullname,"^(.-)%-(.*)$") |
| 31261 |
if encoding and shortname and fonts.encodings.known[encoding] then |
| 31262 |
shortname=findbinfile(shortname,'afm') or "" |
| 31263 |
if shortname~="" then |
| 31264 |
foundname=shortname |
| 31265 |
if trace_defining then |
| 31266 |
report_afm("stripping encoding prefix from filename %a",afmname) |
| 31267 |
end |
| 31268 |
end |
| 31269 |
end |
| 31270 |
end |
| 31271 |
if foundname~="" then |
| 31272 |
specification.filename=foundname |
| 31273 |
specification.format="afm" |
| 31274 |
return read_from_afm(specification) |
| 31275 |
end |
| 31276 |
end |
| 31277 |
function readers.afm(specification,method) |
| 31278 |
local fullname=specification.filename or "" |
| 31279 |
local tfmdata=nil |
| 31280 |
if fullname=="" then |
| 31281 |
local forced=specification.forced or "" |
| 31282 |
if forced~="" then |
| 31283 |
tfmdata=check_afm(specification,specification.name.."."..forced) |
| 31284 |
end |
| 31285 |
if not tfmdata then |
| 31286 |
local check_tfm=readers.check_tfm |
| 31287 |
method=(check_tfm and (method or definers.method or "afm or tfm")) or "afm" |
| 31288 |
if method=="tfm" then |
| 31289 |
tfmdata=check_tfm(specification,specification.name) |
| 31290 |
elseif method=="afm" then |
| 31291 |
tfmdata=check_afm(specification,specification.name) |
| 31292 |
elseif method=="tfm or afm" then |
| 31293 |
tfmdata=check_tfm(specification,specification.name) or check_afm(specification,specification.name) |
| 31294 |
else |
| 31295 |
tfmdata=check_afm(specification,specification.name) or check_tfm(specification,specification.name) |
| 31296 |
end |
| 31297 |
end |
| 31298 |
else |
| 31299 |
tfmdata=check_afm(specification,fullname) |
| 31300 |
end |
| 31301 |
return tfmdata |
| 31302 |
end |
| 31303 |
function readers.pfb(specification,method) |
| 31304 |
local original=specification.specification |
| 31305 |
if trace_defining then |
| 31306 |
report_afm("using afm reader for %a",original) |
| 31307 |
end |
| 31308 |
specification.forced="afm" |
| 31309 |
local function swap(name) |
| 31310 |
local value=specification[swap] |
| 31311 |
if value then |
| 31312 |
specification[swap]=gsub("%.pfb",".afm",1) |
| 31313 |
end |
| 31314 |
end |
| 31315 |
swap("filename") |
| 31316 |
swap("fullname") |
| 31317 |
swap("forcedname") |
| 31318 |
swap("specification") |
| 31319 |
return readers.afm(specification,method) |
| 31320 |
end |
| 31321 |
registerafmenhancer("unify names",enhance_unify_names) |
| 31322 |
registerafmenhancer("add ligatures",enhance_add_ligatures) |
| 31323 |
registerafmenhancer("add extra kerns",enhance_add_extra_kerns) |
| 31324 |
registerafmenhancer("normalize features",enhance_normalize_features) |
| 31325 |
registerafmenhancer("check extra features",otfenhancers.enhance) |
| 31326 |
registerafmenhancer("fix names",enhance_fix_names) |
| 31327 |
|
| 31328 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-one”] --- |
| 31329 |
|
| 31330 |
|
| 31331 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-afk” b7bef80aa4c18357cbfa0ae4df4d4046] --- |
| 31332 |
|
| 31333 |
if not modules then modules={} end modules ['font-afk']={ |
| 31334 |
version=1.001, |
| 31335 |
comment="companion to font-lib.mkiv", |
| 31336 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 31337 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 31338 |
license="see context related readme files", |
| 31339 |
dataonly=true, |
| 31340 |
} |
| 31341 |
local allocate=utilities.storage.allocate |
| 31342 |
fonts.handlers.afm.helpdata={ |
| 31343 |
ligatures=allocate { |
| 31344 |
['f']={ |
| 31345 |
{ 'f','ff' }, |
| 31346 |
{ 'i','fi' }, |
| 31347 |
{ 'l','fl' }, |
| 31348 |
}, |
| 31349 |
['ff']={ |
| 31350 |
{ 'i','ffi' } |
| 31351 |
}, |
| 31352 |
['fi']={ |
| 31353 |
{ 'i','fii' } |
| 31354 |
}, |
| 31355 |
['fl']={ |
| 31356 |
{ 'i','fli' } |
| 31357 |
}, |
| 31358 |
['s']={ |
| 31359 |
{ 't','st' } |
| 31360 |
}, |
| 31361 |
['i']={ |
| 31362 |
{ 'j','ij' } |
| 31363 |
}, |
| 31364 |
}, |
| 31365 |
texligatures=allocate { |
| 31366 |
['quoteleft']={ |
| 31367 |
{ 'quoteleft','quotedblleft' } |
| 31368 |
}, |
| 31369 |
['quoteright']={ |
| 31370 |
{ 'quoteright','quotedblright' } |
| 31371 |
}, |
| 31372 |
['hyphen']={ |
| 31373 |
{ 'hyphen','endash' } |
| 31374 |
}, |
| 31375 |
['endash']={ |
| 31376 |
{ 'hyphen','emdash' } |
| 31377 |
} |
| 31378 |
}, |
| 31379 |
leftkerned=allocate { |
| 31380 |
AEligature="A",aeligature="a", |
| 31381 |
OEligature="O",oeligature="o", |
| 31382 |
IJligature="I",ijligature="i", |
| 31383 |
AE="A",ae="a", |
| 31384 |
OE="O",oe="o", |
| 31385 |
IJ="I",ij="i", |
| 31386 |
Ssharp="S",ssharp="s", |
| 31387 |
}, |
| 31388 |
rightkerned=allocate { |
| 31389 |
AEligature="E",aeligature="e", |
| 31390 |
OEligature="E",oeligature="e", |
| 31391 |
IJligature="J",ijligature="j", |
| 31392 |
AE="E",ae="e", |
| 31393 |
OE="E",oe="e", |
| 31394 |
IJ="J",ij="j", |
| 31395 |
Ssharp="S",ssharp="s", |
| 31396 |
}, |
| 31397 |
bothkerned=allocate { |
| 31398 |
Acircumflex="A",acircumflex="a", |
| 31399 |
Ccircumflex="C",ccircumflex="c", |
| 31400 |
Ecircumflex="E",ecircumflex="e", |
| 31401 |
Gcircumflex="G",gcircumflex="g", |
| 31402 |
Hcircumflex="H",hcircumflex="h", |
| 31403 |
Icircumflex="I",icircumflex="i", |
| 31404 |
Jcircumflex="J",jcircumflex="j", |
| 31405 |
Ocircumflex="O",ocircumflex="o", |
| 31406 |
Scircumflex="S",scircumflex="s", |
| 31407 |
Ucircumflex="U",ucircumflex="u", |
| 31408 |
Wcircumflex="W",wcircumflex="w", |
| 31409 |
Ycircumflex="Y",ycircumflex="y", |
| 31410 |
Agrave="A",agrave="a", |
| 31411 |
Egrave="E",egrave="e", |
| 31412 |
Igrave="I",igrave="i", |
| 31413 |
Ograve="O",ograve="o", |
| 31414 |
Ugrave="U",ugrave="u", |
| 31415 |
Ygrave="Y",ygrave="y", |
| 31416 |
Atilde="A",atilde="a", |
| 31417 |
Itilde="I",itilde="i", |
| 31418 |
Otilde="O",otilde="o", |
| 31419 |
Utilde="U",utilde="u", |
| 31420 |
Ntilde="N",ntilde="n", |
| 31421 |
Adiaeresis="A",adiaeresis="a",Adieresis="A",adieresis="a", |
| 31422 |
Ediaeresis="E",ediaeresis="e",Edieresis="E",edieresis="e", |
| 31423 |
Idiaeresis="I",idiaeresis="i",Idieresis="I",idieresis="i", |
| 31424 |
Odiaeresis="O",odiaeresis="o",Odieresis="O",odieresis="o", |
| 31425 |
Udiaeresis="U",udiaeresis="u",Udieresis="U",udieresis="u", |
| 31426 |
Ydiaeresis="Y",ydiaeresis="y",Ydieresis="Y",ydieresis="y", |
| 31427 |
Aacute="A",aacute="a", |
| 31428 |
Cacute="C",cacute="c", |
| 31429 |
Eacute="E",eacute="e", |
| 31430 |
Iacute="I",iacute="i", |
| 31431 |
Lacute="L",lacute="l", |
| 31432 |
Nacute="N",nacute="n", |
| 31433 |
Oacute="O",oacute="o", |
| 31434 |
Racute="R",racute="r", |
| 31435 |
Sacute="S",sacute="s", |
| 31436 |
Uacute="U",uacute="u", |
| 31437 |
Yacute="Y",yacute="y", |
| 31438 |
Zacute="Z",zacute="z", |
| 31439 |
Dstroke="D",dstroke="d", |
| 31440 |
Hstroke="H",hstroke="h", |
| 31441 |
Tstroke="T",tstroke="t", |
| 31442 |
Cdotaccent="C",cdotaccent="c", |
| 31443 |
Edotaccent="E",edotaccent="e", |
| 31444 |
Gdotaccent="G",gdotaccent="g", |
| 31445 |
Idotaccent="I",idotaccent="i", |
| 31446 |
Zdotaccent="Z",zdotaccent="z", |
| 31447 |
Amacron="A",amacron="a", |
| 31448 |
Emacron="E",emacron="e", |
| 31449 |
Imacron="I",imacron="i", |
| 31450 |
Omacron="O",omacron="o", |
| 31451 |
Umacron="U",umacron="u", |
| 31452 |
Ccedilla="C",ccedilla="c", |
| 31453 |
Kcedilla="K",kcedilla="k", |
| 31454 |
Lcedilla="L",lcedilla="l", |
| 31455 |
Ncedilla="N",ncedilla="n", |
| 31456 |
Rcedilla="R",rcedilla="r", |
| 31457 |
Scedilla="S",scedilla="s", |
| 31458 |
Tcedilla="T",tcedilla="t", |
| 31459 |
Ohungarumlaut="O",ohungarumlaut="o", |
| 31460 |
Uhungarumlaut="U",uhungarumlaut="u", |
| 31461 |
Aogonek="A",aogonek="a", |
| 31462 |
Eogonek="E",eogonek="e", |
| 31463 |
Iogonek="I",iogonek="i", |
| 31464 |
Uogonek="U",uogonek="u", |
| 31465 |
Aring="A",aring="a", |
| 31466 |
Uring="U",uring="u", |
| 31467 |
Abreve="A",abreve="a", |
| 31468 |
Ebreve="E",ebreve="e", |
| 31469 |
Gbreve="G",gbreve="g", |
| 31470 |
Ibreve="I",ibreve="i", |
| 31471 |
Obreve="O",obreve="o", |
| 31472 |
Ubreve="U",ubreve="u", |
| 31473 |
Ccaron="C",ccaron="c", |
| 31474 |
Dcaron="D",dcaron="d", |
| 31475 |
Ecaron="E",ecaron="e", |
| 31476 |
Lcaron="L",lcaron="l", |
| 31477 |
Ncaron="N",ncaron="n", |
| 31478 |
Rcaron="R",rcaron="r", |
| 31479 |
Scaron="S",scaron="s", |
| 31480 |
Tcaron="T",tcaron="t", |
| 31481 |
Zcaron="Z",zcaron="z", |
| 31482 |
dotlessI="I",dotlessi="i", |
| 31483 |
dotlessJ="J",dotlessj="j", |
| 31484 |
AEligature="AE",aeligature="ae",AE="AE",ae="ae", |
| 31485 |
OEligature="OE",oeligature="oe",OE="OE",oe="oe", |
| 31486 |
IJligature="IJ",ijligature="ij",IJ="IJ",ij="ij", |
| 31487 |
Lstroke="L",lstroke="l",Lslash="L",lslash="l", |
| 31488 |
Ostroke="O",ostroke="o",Oslash="O",oslash="o", |
| 31489 |
Ssharp="SS",ssharp="ss", |
| 31490 |
Aumlaut="A",aumlaut="a", |
| 31491 |
Eumlaut="E",eumlaut="e", |
| 31492 |
Iumlaut="I",iumlaut="i", |
| 31493 |
Oumlaut="O",oumlaut="o", |
| 31494 |
Uumlaut="U",uumlaut="u", |
| 31495 |
} |
| 31496 |
} |
| 31497 |
|
| 31498 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-afk”] --- |
| 31499 |
|
| 31500 |
|
| 31501 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-tfm” f0eb5e2a8068b17ad401bb7efdba1630] --- |
| 31502 |
|
| 31503 |
if not modules then modules={} end modules ['luatex-fonts-tfm']={ |
| 31504 |
version=1.001, |
| 31505 |
comment="companion to font-ini.mkiv", |
| 31506 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 31507 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 31508 |
license="see context related readme files" |
| 31509 |
} |
| 31510 |
local next,type=next,type |
| 31511 |
local match,format=string.match,string.format |
| 31512 |
local concat,sortedhash=table.concat,table.sortedhash |
| 31513 |
local idiv=number.idiv |
| 31514 |
local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) |
| 31515 |
local trace_features=false trackers.register("tfm.features",function(v) trace_features=v end) |
| 31516 |
local report_defining=logs.reporter("fonts","defining") |
| 31517 |
local report_tfm=logs.reporter("fonts","tfm loading") |
| 31518 |
local findbinfile=resolvers.findbinfile |
| 31519 |
local setmetatableindex=table.setmetatableindex |
| 31520 |
local fonts=fonts |
| 31521 |
local handlers=fonts.handlers |
| 31522 |
local helpers=fonts.helpers |
| 31523 |
local readers=fonts.readers |
| 31524 |
local constructors=fonts.constructors |
| 31525 |
local encodings=fonts.encodings |
| 31526 |
local tfm=constructors.handlers.tfm |
| 31527 |
tfm.version=1.000 |
| 31528 |
tfm.maxnestingdepth=5 |
| 31529 |
tfm.maxnestingsize=65536*1024 |
| 31530 |
local otf=fonts.handlers.otf |
| 31531 |
local otfenhancers=otf.enhancers |
| 31532 |
local tfmfeatures=constructors.features.tfm |
| 31533 |
local registertfmfeature=tfmfeatures.register |
| 31534 |
local tfmenhancers=constructors.enhancers.tfm |
| 31535 |
local registertfmenhancer=tfmenhancers.register |
| 31536 |
local charcommand=helpers.commands.char |
| 31537 |
constructors.resolvevirtualtoo=false |
| 31538 |
fonts.formats.tfm="type1" |
| 31539 |
fonts.formats.ofm="type1" |
| 31540 |
function tfm.setfeatures(tfmdata,features) |
| 31541 |
local okay=constructors.initializefeatures("tfm",tfmdata,features,trace_features,report_tfm) |
| 31542 |
if okay then |
| 31543 |
return constructors.collectprocessors("tfm",tfmdata,features,trace_features,report_tfm) |
| 31544 |
else |
| 31545 |
return {} |
| 31546 |
end |
| 31547 |
end |
| 31548 |
local depth={} |
| 31549 |
local loadtfm=font.read_tfm |
| 31550 |
local loadvf=font.read_vf |
| 31551 |
local function read_from_tfm(specification) |
| 31552 |
local filename=specification.filename |
| 31553 |
local size=specification.size |
| 31554 |
depth[filename]=(depth[filename] or 0)+1 |
| 31555 |
if trace_defining then |
| 31556 |
report_defining("loading tfm file %a at size %s",filename,size) |
| 31557 |
end |
| 31558 |
local tfmdata=loadtfm(filename,size) |
| 31559 |
if tfmdata then |
| 31560 |
local features=specification.features and specification.features.normal or {} |
| 31561 |
local features=constructors.checkedfeatures("tfm",features) |
| 31562 |
specification.features.normal=features |
| 31563 |
local newtfmdata=(depth[filename]==1) and tfm.reencode(tfmdata,specification) |
| 31564 |
if newtfmdata then |
| 31565 |
tfmdata=newtfmdata |
| 31566 |
end |
| 31567 |
local resources=tfmdata.resources or {} |
| 31568 |
local properties=tfmdata.properties or {} |
| 31569 |
local parameters=tfmdata.parameters or {} |
| 31570 |
local shared=tfmdata.shared or {} |
| 31571 |
shared.features=features |
| 31572 |
shared.resources=resources |
| 31573 |
properties.name=tfmdata.name |
| 31574 |
properties.fontname=tfmdata.fontname |
| 31575 |
properties.psname=tfmdata.psname |
| 31576 |
properties.fullname=tfmdata.fullname |
| 31577 |
properties.filename=specification.filename |
| 31578 |
properties.format=tfmdata.format or fonts.formats.tfm |
| 31579 |
properties.usedbitmap=tfmdata.usedbitmap |
| 31580 |
tfmdata.properties=properties |
| 31581 |
tfmdata.resources=resources |
| 31582 |
tfmdata.parameters=parameters |
| 31583 |
tfmdata.shared=shared |
| 31584 |
shared.rawdata={ resources=resources } |
| 31585 |
shared.features=features |
| 31586 |
if newtfmdata then |
| 31587 |
if not resources.marks then |
| 31588 |
resources.marks={} |
| 31589 |
end |
| 31590 |
if not resources.sequences then |
| 31591 |
resources.sequences={} |
| 31592 |
end |
| 31593 |
if not resources.features then |
| 31594 |
resources.features={ |
| 31595 |
gsub={}, |
| 31596 |
gpos={}, |
| 31597 |
} |
| 31598 |
end |
| 31599 |
if not tfmdata.changed then |
| 31600 |
tfmdata.changed={} |
| 31601 |
end |
| 31602 |
if not tfmdata.descriptions then |
| 31603 |
tfmdata.descriptions=tfmdata.characters |
| 31604 |
end |
| 31605 |
otf.readers.addunicodetable(tfmdata) |
| 31606 |
tfmenhancers.apply(tfmdata,filename) |
| 31607 |
constructors.applymanipulators("tfm",tfmdata,features,trace_features,report_tfm) |
| 31608 |
otf.readers.unifymissing(tfmdata) |
| 31609 |
fonts.mappings.addtounicode(tfmdata,filename) |
| 31610 |
tfmdata.tounicode=1 |
| 31611 |
local tounicode=fonts.mappings.tounicode |
| 31612 |
for unicode,v in next,tfmdata.characters do |
| 31613 |
local u=v.unicode |
| 31614 |
if u then |
| 31615 |
v.tounicode=tounicode(u) |
| 31616 |
end |
| 31617 |
end |
| 31618 |
if tfmdata.usedbitmap then |
| 31619 |
tfm.addtounicode(tfmdata) |
| 31620 |
end |
| 31621 |
end |
| 31622 |
shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil |
| 31623 |
if size<0 then |
| 31624 |
size=idiv(65536*-size,100) |
| 31625 |
end |
| 31626 |
parameters.factor=1 |
| 31627 |
parameters.units=1000 |
| 31628 |
parameters.size=size |
| 31629 |
parameters.slant=parameters.slant or parameters[1] or 0 |
| 31630 |
parameters.space=parameters.space or parameters[2] or 0 |
| 31631 |
parameters.space_stretch=parameters.space_stretch or parameters[3] or 0 |
| 31632 |
parameters.space_shrink=parameters.space_shrink or parameters[4] or 0 |
| 31633 |
parameters.x_height=parameters.x_height or parameters[5] or 0 |
| 31634 |
parameters.quad=parameters.quad or parameters[6] or 0 |
| 31635 |
parameters.extra_space=parameters.extra_space or parameters[7] or 0 |
| 31636 |
constructors.enhanceparameters(parameters) |
| 31637 |
properties.private=properties.private or tfmdata.private or privateoffset |
| 31638 |
if newtfmdata then |
| 31639 |
elseif constructors.resolvevirtualtoo then |
| 31640 |
fonts.loggers.register(tfmdata,file.suffix(filename),specification) |
| 31641 |
local vfname=findbinfile(specification.name,'ovf') |
| 31642 |
if vfname and vfname~="" then |
| 31643 |
local vfdata=loadvf(vfname,size) |
| 31644 |
if vfdata then |
| 31645 |
local chars=tfmdata.characters |
| 31646 |
for k,v in next,vfdata.characters do |
| 31647 |
chars[k].commands=v.commands |
| 31648 |
end |
| 31649 |
properties.virtualized=true |
| 31650 |
tfmdata.fonts=vfdata.fonts |
| 31651 |
tfmdata.type="virtual" |
| 31652 |
local fontlist=vfdata.fonts |
| 31653 |
local name=file.nameonly(filename) |
| 31654 |
for i=1,#fontlist do |
| 31655 |
local n=fontlist[i].name |
| 31656 |
local s=fontlist[i].size |
| 31657 |
local d=depth[filename] |
| 31658 |
s=constructors.scaled(s,vfdata.designsize) |
| 31659 |
if d>tfm.maxnestingdepth then |
| 31660 |
report_defining("too deeply nested virtual font %a with size %a, max nesting depth %s",n,s,tfm.maxnestingdepth) |
| 31661 |
fontlist[i]={ id=0 } |
| 31662 |
elseif (d>1) and (s>tfm.maxnestingsize) then |
| 31663 |
report_defining("virtual font %a exceeds size %s",n,s) |
| 31664 |
fontlist[i]={ id=0 } |
| 31665 |
else |
| 31666 |
local t,id=constructors.readanddefine(n,s) |
| 31667 |
fontlist[i]={ id=id } |
| 31668 |
end |
| 31669 |
end |
| 31670 |
end |
| 31671 |
end |
| 31672 |
end |
| 31673 |
properties.haskerns=true |
| 31674 |
properties.hasligatures=true |
| 31675 |
properties.hasitalics=true |
| 31676 |
resources.unicodes={} |
| 31677 |
resources.lookuptags={} |
| 31678 |
depth[filename]=depth[filename]-1 |
| 31679 |
return tfmdata |
| 31680 |
else |
| 31681 |
depth[filename]=depth[filename]-1 |
| 31682 |
end |
| 31683 |
end |
| 31684 |
local function check_tfm(specification,fullname) |
| 31685 |
local foundname=findbinfile(fullname,'tfm') or "" |
| 31686 |
if foundname=="" then |
| 31687 |
foundname=findbinfile(fullname,'ofm') or "" |
| 31688 |
end |
| 31689 |
if foundname=="" then |
| 31690 |
foundname=fonts.names.getfilename(fullname,"tfm") or "" |
| 31691 |
end |
| 31692 |
if foundname~="" then |
| 31693 |
specification.filename=foundname |
| 31694 |
specification.format="ofm" |
| 31695 |
return read_from_tfm(specification) |
| 31696 |
elseif trace_defining then |
| 31697 |
report_defining("loading tfm with name %a fails",specification.name) |
| 31698 |
end |
| 31699 |
end |
| 31700 |
readers.check_tfm=check_tfm |
| 31701 |
function readers.tfm(specification) |
| 31702 |
local fullname=specification.filename or "" |
| 31703 |
if fullname=="" then |
| 31704 |
local forced=specification.forced or "" |
| 31705 |
if forced~="" then |
| 31706 |
fullname=specification.name.."."..forced |
| 31707 |
else |
| 31708 |
fullname=specification.name |
| 31709 |
end |
| 31710 |
end |
| 31711 |
return check_tfm(specification,fullname) |
| 31712 |
end |
| 31713 |
readers.ofm=readers.tfm |
| 31714 |
do |
| 31715 |
local outfiles={} |
| 31716 |
local tfmcache=table.setmetatableindex(function(t,tfmdata) |
| 31717 |
local id=font.define(tfmdata) |
| 31718 |
t[tfmdata]=id |
| 31719 |
return id |
| 31720 |
end) |
| 31721 |
local encdone=table.setmetatableindex("table") |
| 31722 |
function tfm.reencode(tfmdata,specification) |
| 31723 |
local features=specification.features |
| 31724 |
if not features then |
| 31725 |
return |
| 31726 |
end |
| 31727 |
local features=features.normal |
| 31728 |
if not features then |
| 31729 |
return |
| 31730 |
end |
| 31731 |
local tfmfile=file.basename(tfmdata.name) |
| 31732 |
local encfile=features.reencode |
| 31733 |
local pfbfile=features.pfbfile |
| 31734 |
local bitmap=features.bitmap |
| 31735 |
if not encfile then |
| 31736 |
return |
| 31737 |
end |
| 31738 |
local pfbfile=outfiles[tfmfile] |
| 31739 |
if pfbfile==nil then |
| 31740 |
if bitmap then |
| 31741 |
pfbfile=false |
| 31742 |
elseif type(pfbfile)~="string" then |
| 31743 |
pfbfile=tfmfile |
| 31744 |
end |
| 31745 |
if type(pfbfile)=="string" then |
| 31746 |
pfbfile=file.addsuffix(pfbfile,"pfb") |
| 31747 |
report_tfm("using type1 shapes from %a for %a",pfbfile,tfmfile) |
| 31748 |
else |
| 31749 |
report_tfm("using bitmap shapes for %a",tfmfile) |
| 31750 |
pfbfile=false |
| 31751 |
end |
| 31752 |
outfiles[tfmfile]=pfbfile |
| 31753 |
end |
| 31754 |
local encoding=false |
| 31755 |
local vector=false |
| 31756 |
if type(pfbfile)=="string" then |
| 31757 |
local pfb=constructors.handlers.pfb |
| 31758 |
if pfb and pfb.loadvector then |
| 31759 |
local v,e=pfb.loadvector(pfbfile) |
| 31760 |
if v then |
| 31761 |
vector=v |
| 31762 |
end |
| 31763 |
if e then |
| 31764 |
encoding=e |
| 31765 |
end |
| 31766 |
end |
| 31767 |
end |
| 31768 |
if type(encfile)=="string" and encfile~="auto" then |
| 31769 |
encoding=fonts.encodings.load(file.addsuffix(encfile,"enc")) |
| 31770 |
if encoding then |
| 31771 |
encoding=encoding.vector |
| 31772 |
end |
| 31773 |
end |
| 31774 |
if not encoding then |
| 31775 |
report_tfm("bad encoding for %a, quitting",tfmfile) |
| 31776 |
return |
| 31777 |
end |
| 31778 |
local unicoding=fonts.encodings.agl and fonts.encodings.agl.unicodes |
| 31779 |
local virtualid=tfmcache[tfmdata] |
| 31780 |
local tfmdata=table.copy(tfmdata) |
| 31781 |
local characters={} |
| 31782 |
local originals=tfmdata.characters |
| 31783 |
local indices={} |
| 31784 |
local parentfont={ "font",1 } |
| 31785 |
local private=tfmdata.privateoffset or constructors.privateoffset |
| 31786 |
local reported=encdone[tfmfile][encfile] |
| 31787 |
local backmap=vector and table.swapped(vector) |
| 31788 |
local done={} |
| 31789 |
for index,name in sortedhash(encoding) do |
| 31790 |
local unicode=unicoding[name] |
| 31791 |
local original=originals[index] |
| 31792 |
if original then |
| 31793 |
if unicode then |
| 31794 |
original.unicode=unicode |
| 31795 |
else |
| 31796 |
unicode=private |
| 31797 |
private=private+1 |
| 31798 |
if not reported then |
| 31799 |
report_tfm("glyph %a in font %a with encoding %a gets unicode %U",name,tfmfile,encfile,unicode) |
| 31800 |
end |
| 31801 |
end |
| 31802 |
characters[unicode]=original |
| 31803 |
indices[index]=unicode |
| 31804 |
original.name=name |
| 31805 |
if backmap then |
| 31806 |
original.index=backmap[name] |
| 31807 |
else |
| 31808 |
original.commands={ parentfont,charcommand[index] } |
| 31809 |
original.oindex=index |
| 31810 |
end |
| 31811 |
done[name]=true |
| 31812 |
elseif not done[name] then |
| 31813 |
report_tfm("bad index %a in font %a with name %a",index,tfmfile,name) |
| 31814 |
end |
| 31815 |
end |
| 31816 |
encdone[tfmfile][encfile]=true |
| 31817 |
for k,v in next,characters do |
| 31818 |
local kerns=v.kerns |
| 31819 |
if kerns then |
| 31820 |
local t={} |
| 31821 |
for k,v in next,kerns do |
| 31822 |
local i=indices[k] |
| 31823 |
if i then |
| 31824 |
t[i]=v |
| 31825 |
end |
| 31826 |
end |
| 31827 |
v.kerns=next(t) and t or nil |
| 31828 |
end |
| 31829 |
local ligatures=v.ligatures |
| 31830 |
if ligatures then |
| 31831 |
local t={} |
| 31832 |
for k,v in next,ligatures do |
| 31833 |
local i=indices[k] |
| 31834 |
if i then |
| 31835 |
t[i]=v |
| 31836 |
v.char=indices[v.char] |
| 31837 |
end |
| 31838 |
end |
| 31839 |
v.ligatures=next(t) and t or nil |
| 31840 |
end |
| 31841 |
end |
| 31842 |
tfmdata.fonts={ { id=virtualid } } |
| 31843 |
tfmdata.characters=characters |
| 31844 |
tfmdata.fullname=tfmdata.fullname or tfmdata.name |
| 31845 |
tfmdata.psname=file.nameonly(pfbfile or tfmdata.name) |
| 31846 |
tfmdata.filename=pfbfile |
| 31847 |
tfmdata.encodingbytes=2 |
| 31848 |
tfmdata.format="type1" |
| 31849 |
tfmdata.tounicode=1 |
| 31850 |
tfmdata.embedding="subset" |
| 31851 |
tfmdata.usedbitmap=bitmap and virtualid |
| 31852 |
tfmdata.private=private |
| 31853 |
return tfmdata |
| 31854 |
end |
| 31855 |
end |
| 31856 |
do |
| 31857 |
local template=[[ |
| 31858 |
/CIDInit /ProcSet findresource begin |
| 31859 |
12 dict begin |
| 31860 |
begincmap |
| 31861 |
/CIDSystemInfo << /Registry (TeX) /Ordering (bitmap-%s) /Supplement 0 >> def |
| 31862 |
/CMapName /TeX-bitmap-%s def |
| 31863 |
/CMapType 2 def |
| 31864 |
1 begincodespacerange |
| 31865 |
<00> <FF> |
| 31866 |
endcodespacerange |
| 31867 |
%s beginbfchar |
| 31868 |
%s |
| 31869 |
endbfchar |
| 31870 |
endcmap |
| 31871 |
CMapName currentdict /CMap defineresource pop end |
| 31872 |
end |
| 31873 |
end |
| 31874 |
]] |
| 31875 |
local flushstreamobject=lpdf and lpdf.flushstreamobject |
| 31876 |
local setfontattributes=lpdf and lpdf.setfontattributes |
| 31877 |
if not flushstreamobject then |
| 31878 |
flushstreamobject=function(data) |
| 31879 |
return pdf.obj { immediate=true,type="stream",string=data } |
| 31880 |
end |
| 31881 |
end |
| 31882 |
if not setfontattributes then |
| 31883 |
setfontattributes=function(id,data) |
| 31884 |
return pdf.setfontattributes(id,data) |
| 31885 |
end |
| 31886 |
end |
| 31887 |
function tfm.addtounicode(tfmdata) |
| 31888 |
local id=tfmdata.usedbitmap |
| 31889 |
local map={} |
| 31890 |
local char={} |
| 31891 |
for k,v in next,tfmdata.characters do |
| 31892 |
local index=v.oindex |
| 31893 |
local tounicode=v.tounicode |
| 31894 |
if index and tounicode then |
| 31895 |
map[index]=tounicode |
| 31896 |
end |
| 31897 |
end |
| 31898 |
for k,v in sortedhash(map) do |
| 31899 |
char[#char+1]=format("<%02X> <%s>",k,v) |
| 31900 |
end |
| 31901 |
char=concat(char,"\n") |
| 31902 |
local stream=format(template,id,id,#char,char) |
| 31903 |
local reference=flushstreamobject(stream,nil,true) |
| 31904 |
setfontattributes(id,format("/ToUnicode %i 0 R",reference)) |
| 31905 |
end |
| 31906 |
end |
| 31907 |
do |
| 31908 |
local everywhere={ ["*"]={ ["*"]=true } } |
| 31909 |
local noflags={ false,false,false,false } |
| 31910 |
local function enhance_normalize_features(data) |
| 31911 |
local ligatures=setmetatableindex("table") |
| 31912 |
local kerns=setmetatableindex("table") |
| 31913 |
local characters=data.characters |
| 31914 |
for u,c in next,characters do |
| 31915 |
local l=c.ligatures |
| 31916 |
local k=c.kerns |
| 31917 |
if l then |
| 31918 |
ligatures[u]=l |
| 31919 |
for u,v in next,l do |
| 31920 |
l[u]={ ligature=v.char } |
| 31921 |
end |
| 31922 |
c.ligatures=nil |
| 31923 |
end |
| 31924 |
if k then |
| 31925 |
kerns[u]=k |
| 31926 |
for u,v in next,k do |
| 31927 |
k[u]=v |
| 31928 |
end |
| 31929 |
c.kerns=nil |
| 31930 |
end |
| 31931 |
end |
| 31932 |
for u,l in next,ligatures do |
| 31933 |
for k,v in next,l do |
| 31934 |
local vl=v.ligature |
| 31935 |
local dl=ligatures[vl] |
| 31936 |
if dl then |
| 31937 |
for kk,vv in next,dl do |
| 31938 |
v[kk]=vv |
| 31939 |
end |
| 31940 |
end |
| 31941 |
end |
| 31942 |
end |
| 31943 |
local features={ |
| 31944 |
gpos={}, |
| 31945 |
gsub={}, |
| 31946 |
} |
| 31947 |
local sequences={ |
| 31948 |
} |
| 31949 |
if next(ligatures) then |
| 31950 |
features.gsub.liga=everywhere |
| 31951 |
data.properties.hasligatures=true |
| 31952 |
sequences[#sequences+1]={ |
| 31953 |
features={ |
| 31954 |
liga=everywhere, |
| 31955 |
}, |
| 31956 |
flags=noflags, |
| 31957 |
name="s_s_0", |
| 31958 |
nofsteps=1, |
| 31959 |
order={ "liga" }, |
| 31960 |
type="gsub_ligature", |
| 31961 |
steps={ |
| 31962 |
{ |
| 31963 |
coverage=ligatures, |
| 31964 |
}, |
| 31965 |
}, |
| 31966 |
} |
| 31967 |
end |
| 31968 |
if next(kerns) then |
| 31969 |
features.gpos.kern=everywhere |
| 31970 |
data.properties.haskerns=true |
| 31971 |
sequences[#sequences+1]={ |
| 31972 |
features={ |
| 31973 |
kern=everywhere, |
| 31974 |
}, |
| 31975 |
flags=noflags, |
| 31976 |
name="p_s_0", |
| 31977 |
nofsteps=1, |
| 31978 |
order={ "kern" }, |
| 31979 |
type="gpos_pair", |
| 31980 |
steps={ |
| 31981 |
{ |
| 31982 |
format="kern", |
| 31983 |
coverage=kerns, |
| 31984 |
}, |
| 31985 |
}, |
| 31986 |
} |
| 31987 |
end |
| 31988 |
data.resources.features=features |
| 31989 |
data.resources.sequences=sequences |
| 31990 |
data.shared.resources=data.shared.resources or resources |
| 31991 |
end |
| 31992 |
registertfmenhancer("normalize features",enhance_normalize_features) |
| 31993 |
registertfmenhancer("check extra features",otfenhancers.enhance) |
| 31994 |
end |
| 31995 |
registertfmfeature { |
| 31996 |
name="mode", |
| 31997 |
description="mode", |
| 31998 |
initializers={ |
| 31999 |
base=otf.modeinitializer, |
| 32000 |
node=otf.modeinitializer, |
| 32001 |
} |
| 32002 |
} |
| 32003 |
registertfmfeature { |
| 32004 |
name="features", |
| 32005 |
description="features", |
| 32006 |
default=true, |
| 32007 |
initializers={ |
| 32008 |
base=otf.basemodeinitializer, |
| 32009 |
node=otf.nodemodeinitializer, |
| 32010 |
}, |
| 32011 |
processors={ |
| 32012 |
node=otf.featuresprocessor, |
| 32013 |
} |
| 32014 |
} |
| 32015 |
|
| 32016 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-tfm”] --- |
| 32017 |
|
| 32018 |
|
| 32019 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-lua” 1fbfdf7b689b2bdfd0e3bb9bf74ce136] --- |
| 32020 |
|
| 32021 |
if not modules then modules={} end modules ['font-lua']={ |
| 32022 |
version=1.001, |
| 32023 |
comment="companion to font-ini.mkiv", |
| 32024 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 32025 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 32026 |
license="see context related readme files" |
| 32027 |
} |
| 32028 |
local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) |
| 32029 |
local report_lua=logs.reporter("fonts","lua loading") |
| 32030 |
local fonts=fonts |
| 32031 |
local readers=fonts.readers |
| 32032 |
fonts.formats.lua="lua" |
| 32033 |
local function check_lua(specification,fullname) |
| 32034 |
local fullname=resolvers.findfile(fullname) or "" |
| 32035 |
if fullname~="" then |
| 32036 |
local loader=loadfile(fullname) |
| 32037 |
loader=loader and loader() |
| 32038 |
return loader and loader(specification) |
| 32039 |
end |
| 32040 |
end |
| 32041 |
readers.check_lua=check_lua |
| 32042 |
function readers.lua(specification) |
| 32043 |
local original=specification.specification |
| 32044 |
if trace_defining then |
| 32045 |
report_lua("using lua reader for %a",original) |
| 32046 |
end |
| 32047 |
local fullname=specification.filename or "" |
| 32048 |
if fullname=="" then |
| 32049 |
local forced=specification.forced or "" |
| 32050 |
if forced~="" then |
| 32051 |
fullname=specification.name.."."..forced |
| 32052 |
else |
| 32053 |
fullname=specification.name |
| 32054 |
end |
| 32055 |
end |
| 32056 |
return check_lua(specification,fullname) |
| 32057 |
end |
| 32058 |
|
| 32059 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-lua”] --- |
| 32060 |
|
| 32061 |
|
| 32062 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-def” cec0e49aee881c4cbd36d541f0162c6f] --- |
| 32063 |
|
| 32064 |
if not modules then modules={} end modules ['font-def']={ |
| 32065 |
version=1.001, |
| 32066 |
comment="companion to font-ini.mkiv", |
| 32067 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 32068 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 32069 |
license="see context related readme files" |
| 32070 |
} |
| 32071 |
local lower,gsub=string.lower,string.gsub |
| 32072 |
local tostring,next=tostring,next |
| 32073 |
local lpegmatch=lpeg.match |
| 32074 |
local suffixonly,removesuffix,basename=file.suffix,file.removesuffix,file.basename |
| 32075 |
local formatters=string.formatters |
| 32076 |
local sortedhash,sortedkeys=table.sortedhash,table.sortedkeys |
| 32077 |
local allocate=utilities.storage.allocate |
| 32078 |
local trace_defining=false trackers .register("fonts.defining",function(v) trace_defining=v end) |
| 32079 |
local directive_embedall=false directives.register("fonts.embedall",function(v) directive_embedall=v end) |
| 32080 |
trackers.register("fonts.loading","fonts.defining","otf.loading","afm.loading","tfm.loading") |
| 32081 |
local report_defining=logs.reporter("fonts","defining") |
| 32082 |
local fonts=fonts |
| 32083 |
local fontdata=fonts.hashes.identifiers |
| 32084 |
local readers=fonts.readers |
| 32085 |
local definers=fonts.definers |
| 32086 |
local specifiers=fonts.specifiers |
| 32087 |
local constructors=fonts.constructors |
| 32088 |
local fontgoodies=fonts.goodies |
| 32089 |
readers.sequence=allocate { 'otf','ttf','afm','tfm','lua' } |
| 32090 |
local variants=allocate() |
| 32091 |
specifiers.variants=variants |
| 32092 |
definers.methods=definers.methods or {} |
| 32093 |
local internalized=allocate() |
| 32094 |
local loadedfonts=constructors.loadedfonts |
| 32095 |
local designsizes=constructors.designsizes |
| 32096 |
local resolvefile=fontgoodies and fontgoodies.filenames and fontgoodies.filenames.resolve or function(s) return s end |
| 32097 |
local function makespecification(specification,lookup,name,sub,method,detail,size) |
| 32098 |
size=size or 655360 |
| 32099 |
if not lookup or lookup=="" then |
| 32100 |
lookup=definers.defaultlookup |
| 32101 |
end |
| 32102 |
if trace_defining then |
| 32103 |
report_defining("specification %a, lookup %a, name %a, sub %a, method %a, detail %a", |
| 32104 |
specification,lookup,name,sub,method,detail) |
| 32105 |
end |
| 32106 |
local t={ |
| 32107 |
lookup=lookup, |
| 32108 |
specification=specification, |
| 32109 |
size=size, |
| 32110 |
name=name, |
| 32111 |
sub=sub, |
| 32112 |
method=method, |
| 32113 |
detail=detail, |
| 32114 |
resolved="", |
| 32115 |
forced="", |
| 32116 |
features={}, |
| 32117 |
} |
| 32118 |
return t |
| 32119 |
end |
| 32120 |
definers.makespecification=makespecification |
| 32121 |
if context then |
| 32122 |
local splitter,splitspecifiers=nil,"" |
| 32123 |
local P,C,S,Cc,Cs=lpeg.P,lpeg.C,lpeg.S,lpeg.Cc,lpeg.Cs |
| 32124 |
local left=P("(") |
| 32125 |
local right=P(")") |
| 32126 |
local colon=P(":") |
| 32127 |
local space=P(" ") |
| 32128 |
local lbrace=P("{") |
| 32129 |
local rbrace=P("}") |
| 32130 |
definers.defaultlookup="file" |
| 32131 |
local prefixpattern=P(false) |
| 32132 |
local function addspecifier(symbol) |
| 32133 |
splitspecifiers=splitspecifiers..symbol |
| 32134 |
local method=S(splitspecifiers) |
| 32135 |
local lookup=C(prefixpattern)*colon |
| 32136 |
local sub=left*C(P(1-left-right-method)^1)*right |
| 32137 |
local specification=C(method)*C(P(1)^1) |
| 32138 |
local name=Cs((lbrace/"")*(1-rbrace)^1*(rbrace/"")+(1-sub-specification)^1) |
| 32139 |
splitter=P((lookup+Cc(""))*name*(sub+Cc(""))*(specification+Cc(""))) |
| 32140 |
end |
| 32141 |
local function addlookup(str) |
| 32142 |
prefixpattern=prefixpattern+P(str) |
| 32143 |
end |
| 32144 |
definers.addlookup=addlookup |
| 32145 |
addlookup("file") |
| 32146 |
addlookup("name") |
| 32147 |
addlookup("spec") |
| 32148 |
local function getspecification(str) |
| 32149 |
return lpegmatch(splitter,str or "") |
| 32150 |
end |
| 32151 |
definers.getspecification=getspecification |
| 32152 |
function definers.registersplit(symbol,action,verbosename) |
| 32153 |
addspecifier(symbol) |
| 32154 |
variants[symbol]=action |
| 32155 |
if verbosename then |
| 32156 |
variants[verbosename]=action |
| 32157 |
end |
| 32158 |
end |
| 32159 |
function definers.analyze(specification,size) |
| 32160 |
local lookup,name,sub,method,detail=getspecification(specification or "") |
| 32161 |
return makespecification(specification,lookup,name,sub,method,detail,size) |
| 32162 |
end |
| 32163 |
end |
| 32164 |
definers.resolvers=definers.resolvers or {} |
| 32165 |
local resolvers=definers.resolvers |
| 32166 |
function resolvers.file(specification) |
| 32167 |
local name=resolvefile(specification.name) |
| 32168 |
local suffix=lower(suffixonly(name)) |
| 32169 |
if fonts.formats[suffix] then |
| 32170 |
specification.forced=suffix |
| 32171 |
specification.forcedname=name |
| 32172 |
specification.name=removesuffix(name) |
| 32173 |
else |
| 32174 |
specification.name=name |
| 32175 |
end |
| 32176 |
end |
| 32177 |
function resolvers.name(specification) |
| 32178 |
local resolve=fonts.names.resolve |
| 32179 |
if resolve then |
| 32180 |
local resolved,sub,subindex,instance=resolve(specification.name,specification.sub,specification) |
| 32181 |
if resolved then |
| 32182 |
specification.resolved=resolved |
| 32183 |
specification.sub=sub |
| 32184 |
specification.subindex=subindex |
| 32185 |
if instance then |
| 32186 |
specification.instance=instance |
| 32187 |
local features=specification.features |
| 32188 |
if not features then |
| 32189 |
features={} |
| 32190 |
specification.features=features |
| 32191 |
end |
| 32192 |
local normal=features.normal |
| 32193 |
if not normal then |
| 32194 |
normal={} |
| 32195 |
features.normal=normal |
| 32196 |
end |
| 32197 |
normal.instance=instance |
| 32198 |
end |
| 32199 |
local suffix=lower(suffixonly(resolved)) |
| 32200 |
if fonts.formats[suffix] then |
| 32201 |
specification.forced=suffix |
| 32202 |
specification.forcedname=resolved |
| 32203 |
specification.name=removesuffix(resolved) |
| 32204 |
else |
| 32205 |
specification.name=resolved |
| 32206 |
end |
| 32207 |
end |
| 32208 |
else |
| 32209 |
resolvers.file(specification) |
| 32210 |
end |
| 32211 |
end |
| 32212 |
function resolvers.spec(specification) |
| 32213 |
local resolvespec=fonts.names.resolvespec |
| 32214 |
if resolvespec then |
| 32215 |
local resolved,sub,subindex=resolvespec(specification.name,specification.sub,specification) |
| 32216 |
if resolved then |
| 32217 |
specification.resolved=resolved |
| 32218 |
specification.sub=sub |
| 32219 |
specification.subindex=subindex |
| 32220 |
specification.forced=lower(suffixonly(resolved)) |
| 32221 |
specification.forcedname=resolved |
| 32222 |
specification.name=removesuffix(resolved) |
| 32223 |
end |
| 32224 |
else |
| 32225 |
resolvers.name(specification) |
| 32226 |
end |
| 32227 |
end |
| 32228 |
function definers.resolve(specification) |
| 32229 |
if not specification.resolved or specification.resolved=="" then |
| 32230 |
local r=resolvers[specification.lookup] |
| 32231 |
if r then |
| 32232 |
r(specification) |
| 32233 |
end |
| 32234 |
end |
| 32235 |
if specification.forced=="" then |
| 32236 |
specification.forced=nil |
| 32237 |
specification.forcedname=nil |
| 32238 |
end |
| 32239 |
specification.hash=lower(specification.name..' @ '..constructors.hashfeatures(specification)) |
| 32240 |
if specification.sub and specification.sub~="" then |
| 32241 |
specification.hash=specification.sub..' @ '..specification.hash |
| 32242 |
end |
| 32243 |
return specification |
| 32244 |
end |
| 32245 |
function definers.applypostprocessors(tfmdata) |
| 32246 |
local postprocessors=tfmdata.postprocessors |
| 32247 |
if postprocessors then |
| 32248 |
local properties=tfmdata.properties |
| 32249 |
for i=1,#postprocessors do |
| 32250 |
local extrahash=postprocessors[i](tfmdata) |
| 32251 |
if type(extrahash)=="string" and extrahash~="" then |
| 32252 |
extrahash=gsub(lower(extrahash),"[^a-z]","-") |
| 32253 |
properties.fullname=formatters["%s-%s"](properties.fullname,extrahash) |
| 32254 |
end |
| 32255 |
end |
| 32256 |
end |
| 32257 |
return tfmdata |
| 32258 |
end |
| 32259 |
local function checkembedding(tfmdata) |
| 32260 |
local properties=tfmdata.properties |
| 32261 |
local embedding |
| 32262 |
if directive_embedall then |
| 32263 |
embedding="full" |
| 32264 |
elseif properties and properties.filename and constructors.dontembed[properties.filename] then |
| 32265 |
embedding="no" |
| 32266 |
else |
| 32267 |
embedding="subset" |
| 32268 |
end |
| 32269 |
if properties then |
| 32270 |
properties.embedding=embedding |
| 32271 |
else |
| 32272 |
tfmdata.properties={ embedding=embedding } |
| 32273 |
end |
| 32274 |
tfmdata.embedding=embedding |
| 32275 |
end |
| 32276 |
local function checkfeatures(tfmdata) |
| 32277 |
local resources=tfmdata.resources |
| 32278 |
local shared=tfmdata.shared |
| 32279 |
if resources and shared then |
| 32280 |
local features=resources.features |
| 32281 |
local usedfeatures=shared.features |
| 32282 |
if features and usedfeatures then |
| 32283 |
local usedlanguage=usedfeatures.language or "dflt" |
| 32284 |
local usedscript=usedfeatures.script or "dflt" |
| 32285 |
local function check(what) |
| 32286 |
if what then |
| 32287 |
local foundlanguages={} |
| 32288 |
for feature,scripts in next,what do |
| 32289 |
if usedscript=="auto" or scripts["*"] then |
| 32290 |
elseif not scripts[usedscript] then |
| 32291 |
else |
| 32292 |
for script,languages in next,scripts do |
| 32293 |
if languages["*"] then |
| 32294 |
elseif context and not languages[usedlanguage] then |
| 32295 |
report_defining("font %!font:name!, feature %a, script %a, no language %a", |
| 32296 |
tfmdata,feature,script,usedlanguage) |
| 32297 |
end |
| 32298 |
end |
| 32299 |
end |
| 32300 |
for script,languages in next,scripts do |
| 32301 |
for language in next,languages do |
| 32302 |
foundlanguages[language]=true |
| 32303 |
end |
| 32304 |
end |
| 32305 |
end |
| 32306 |
if false then |
| 32307 |
foundlanguages["*"]=nil |
| 32308 |
foundlanguages=sortedkeys(foundlanguages) |
| 32309 |
for feature,scripts in sortedhash(what) do |
| 32310 |
for script,languages in next,scripts do |
| 32311 |
if not languages["*"] then |
| 32312 |
for i=1,#foundlanguages do |
| 32313 |
local language=foundlanguages[i] |
| 32314 |
if context and not languages[language] then |
| 32315 |
report_defining("font %!font:name!, feature %a, script %a, no language %a", |
| 32316 |
tfmdata,feature,script,language) |
| 32317 |
end |
| 32318 |
end |
| 32319 |
end |
| 32320 |
end |
| 32321 |
end |
| 32322 |
end |
| 32323 |
end |
| 32324 |
end |
| 32325 |
check(features.gsub) |
| 32326 |
check(features.gpos) |
| 32327 |
end |
| 32328 |
end |
| 32329 |
end |
| 32330 |
function definers.loadfont(specification) |
| 32331 |
local hash=constructors.hashinstance(specification) |
| 32332 |
local tfmdata=loadedfonts[hash] |
| 32333 |
if not tfmdata then |
| 32334 |
local forced=specification.forced or "" |
| 32335 |
if forced~="" then |
| 32336 |
local reader=readers[lower(forced)] |
| 32337 |
tfmdata=reader and reader(specification) |
| 32338 |
if not tfmdata then |
| 32339 |
report_defining("forced type %a of %a not found",forced,specification.name) |
| 32340 |
end |
| 32341 |
else |
| 32342 |
local sequence=readers.sequence |
| 32343 |
for s=1,#sequence do |
| 32344 |
local reader=sequence[s] |
| 32345 |
if readers[reader] then |
| 32346 |
if trace_defining then |
| 32347 |
report_defining("trying (reader sequence driven) type %a for %a with file %a",reader,specification.name,specification.filename) |
| 32348 |
end |
| 32349 |
tfmdata=readers[reader](specification) |
| 32350 |
if tfmdata then |
| 32351 |
break |
| 32352 |
else |
| 32353 |
specification.filename=nil |
| 32354 |
end |
| 32355 |
end |
| 32356 |
end |
| 32357 |
end |
| 32358 |
if tfmdata then |
| 32359 |
tfmdata=definers.applypostprocessors(tfmdata) |
| 32360 |
checkembedding(tfmdata) |
| 32361 |
loadedfonts[hash]=tfmdata |
| 32362 |
designsizes[specification.hash]=tfmdata.parameters.designsize |
| 32363 |
checkfeatures(tfmdata) |
| 32364 |
end |
| 32365 |
end |
| 32366 |
if not tfmdata then |
| 32367 |
report_defining("font with asked name %a is not found using lookup %a",specification.name,specification.lookup) |
| 32368 |
end |
| 32369 |
return tfmdata |
| 32370 |
end |
| 32371 |
function constructors.readanddefine(name,size) |
| 32372 |
local specification=definers.analyze(name,size) |
| 32373 |
local method=specification.method |
| 32374 |
if method and variants[method] then |
| 32375 |
specification=variants[method](specification) |
| 32376 |
end |
| 32377 |
specification=definers.resolve(specification) |
| 32378 |
local hash=constructors.hashinstance(specification) |
| 32379 |
local id=definers.registered(hash) |
| 32380 |
if not id then |
| 32381 |
local tfmdata=definers.loadfont(specification) |
| 32382 |
if tfmdata then |
| 32383 |
tfmdata.properties.hash=hash |
| 32384 |
id=font.define(tfmdata) |
| 32385 |
definers.register(tfmdata,id) |
| 32386 |
else |
| 32387 |
id=0 |
| 32388 |
end |
| 32389 |
end |
| 32390 |
return fontdata[id],id |
| 32391 |
end |
| 32392 |
function definers.registered(hash) |
| 32393 |
local id=internalized[hash] |
| 32394 |
return id,id and fontdata[id] |
| 32395 |
end |
| 32396 |
function definers.register(tfmdata,id) |
| 32397 |
if tfmdata and id then |
| 32398 |
local hash=tfmdata.properties.hash |
| 32399 |
if not hash then |
| 32400 |
report_defining("registering font, id %a, name %a, invalid hash",id,tfmdata.properties.filename or "?") |
| 32401 |
elseif not internalized[hash] then |
| 32402 |
internalized[hash]=id |
| 32403 |
if trace_defining then |
| 32404 |
report_defining("registering font, id %s, hash %a",id,hash) |
| 32405 |
end |
| 32406 |
fontdata[id]=tfmdata |
| 32407 |
end |
| 32408 |
end |
| 32409 |
end |
| 32410 |
function definers.read(specification,size,id) |
| 32411 |
statistics.starttiming(fonts) |
| 32412 |
if type(specification)=="string" then |
| 32413 |
specification=definers.analyze(specification,size) |
| 32414 |
end |
| 32415 |
local method=specification.method |
| 32416 |
if method and variants[method] then |
| 32417 |
specification=variants[method](specification) |
| 32418 |
end |
| 32419 |
specification=definers.resolve(specification) |
| 32420 |
local hash=constructors.hashinstance(specification) |
| 32421 |
local tfmdata=definers.registered(hash) |
| 32422 |
if tfmdata then |
| 32423 |
if trace_defining then |
| 32424 |
report_defining("already hashed: %s",hash) |
| 32425 |
end |
| 32426 |
else |
| 32427 |
tfmdata=definers.loadfont(specification) |
| 32428 |
if tfmdata then |
| 32429 |
tfmdata.original=specification.specification |
| 32430 |
if trace_defining then |
| 32431 |
report_defining("loaded and hashed: %s",hash) |
| 32432 |
end |
| 32433 |
tfmdata.properties.hash=hash |
| 32434 |
if id then |
| 32435 |
definers.register(tfmdata,id) |
| 32436 |
end |
| 32437 |
else |
| 32438 |
if trace_defining then |
| 32439 |
report_defining("not loaded and hashed: %s",hash) |
| 32440 |
end |
| 32441 |
end |
| 32442 |
end |
| 32443 |
if not tfmdata then |
| 32444 |
report_defining("unknown font %a, loading aborted",specification.name) |
| 32445 |
elseif trace_defining and type(tfmdata)=="table" then |
| 32446 |
local properties=tfmdata.properties or {} |
| 32447 |
local parameters=tfmdata.parameters or {} |
| 32448 |
report_defining("using %a font with id %a, name %a, size %a, bytes %a, encoding %a, fullname %a, filename %a", |
| 32449 |
properties.format or "unknown",id or "-",properties.name,parameters.size,properties.encodingbytes, |
| 32450 |
properties.encodingname,properties.fullname,basename(properties.filename)) |
| 32451 |
end |
| 32452 |
statistics.stoptiming(fonts) |
| 32453 |
return tfmdata |
| 32454 |
end |
| 32455 |
function font.getfont(id) |
| 32456 |
return fontdata[id] |
| 32457 |
end |
| 32458 |
if not context then |
| 32459 |
callbacks.register('define_font',definers.read,"definition of fonts (tfmdata preparation)") |
| 32460 |
end |
| 32461 |
|
| 32462 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-def”] --- |
| 32463 |
|
| 32464 |
|
| 32465 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-shp” a174ac26390bd0828805747500df0077] --- |
| 32466 |
|
| 32467 |
if not modules then modules={} end modules ['font-shp']={ |
| 32468 |
version=1.001, |
| 32469 |
comment="companion to font-ini.mkiv", |
| 32470 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 32471 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 32472 |
license="see context related readme files" |
| 32473 |
} |
| 32474 |
local tonumber,next=tonumber,next |
| 32475 |
local concat=table.concat |
| 32476 |
local formatters,lower=string.formatters,string.lower |
| 32477 |
local otf=fonts.handlers.otf |
| 32478 |
local afm=fonts.handlers.afm |
| 32479 |
local pfb=fonts.handlers.pfb |
| 32480 |
local hashes=fonts.hashes |
| 32481 |
local identifiers=hashes.identifiers |
| 32482 |
local version=otf.version or 0.015 |
| 32483 |
local shapescache=containers.define("fonts","shapes",version,true) |
| 32484 |
local streamscache=containers.define("fonts","streams",version,true) |
| 32485 |
local compact_streams=false |
| 32486 |
directives.register("fonts.streams.compact",function(v) compact_streams=v end) |
| 32487 |
local function packoutlines(data,makesequence) |
| 32488 |
local subfonts=data.subfonts |
| 32489 |
if subfonts then |
| 32490 |
for i=1,#subfonts do |
| 32491 |
packoutlines(subfonts[i],makesequence) |
| 32492 |
end |
| 32493 |
return |
| 32494 |
end |
| 32495 |
local common=data.segments |
| 32496 |
if common then |
| 32497 |
return |
| 32498 |
end |
| 32499 |
local glyphs=data.glyphs |
| 32500 |
if not glyphs then |
| 32501 |
return |
| 32502 |
end |
| 32503 |
if makesequence then |
| 32504 |
for index=0,#glyphs do |
| 32505 |
local glyph=glyphs[index] |
| 32506 |
if glyph then |
| 32507 |
local segments=glyph.segments |
| 32508 |
if segments then |
| 32509 |
local sequence={} |
| 32510 |
local nofsequence=0 |
| 32511 |
for i=1,#segments do |
| 32512 |
local segment=segments[i] |
| 32513 |
local nofsegment=#segment |
| 32514 |
nofsequence=nofsequence+1 |
| 32515 |
sequence[nofsequence]=segment[nofsegment] |
| 32516 |
for i=1,nofsegment-1 do |
| 32517 |
nofsequence=nofsequence+1 |
| 32518 |
sequence[nofsequence]=segment[i] |
| 32519 |
end |
| 32520 |
end |
| 32521 |
glyph.sequence=sequence |
| 32522 |
glyph.segments=nil |
| 32523 |
end |
| 32524 |
end |
| 32525 |
end |
| 32526 |
else |
| 32527 |
local hash={} |
| 32528 |
local common={} |
| 32529 |
local reverse={} |
| 32530 |
local last=0 |
| 32531 |
for index=0,#glyphs do |
| 32532 |
local glyph=glyphs[index] |
| 32533 |
if glyph then |
| 32534 |
local segments=glyph.segments |
| 32535 |
if segments then |
| 32536 |
for i=1,#segments do |
| 32537 |
local h=concat(segments[i]," ") |
| 32538 |
hash[h]=(hash[h] or 0)+1 |
| 32539 |
end |
| 32540 |
end |
| 32541 |
end |
| 32542 |
end |
| 32543 |
for index=0,#glyphs do |
| 32544 |
local glyph=glyphs[index] |
| 32545 |
if glyph then |
| 32546 |
local segments=glyph.segments |
| 32547 |
if segments then |
| 32548 |
for i=1,#segments do |
| 32549 |
local segment=segments[i] |
| 32550 |
local h=concat(segment," ") |
| 32551 |
if hash[h]>1 then |
| 32552 |
local idx=reverse[h] |
| 32553 |
if not idx then |
| 32554 |
last=last+1 |
| 32555 |
reverse[h]=last |
| 32556 |
common[last]=segment |
| 32557 |
idx=last |
| 32558 |
end |
| 32559 |
segments[i]=idx |
| 32560 |
end |
| 32561 |
end |
| 32562 |
end |
| 32563 |
end |
| 32564 |
end |
| 32565 |
if last>0 then |
| 32566 |
data.segments=common |
| 32567 |
end |
| 32568 |
end |
| 32569 |
end |
| 32570 |
local function unpackoutlines(data) |
| 32571 |
local subfonts=data.subfonts |
| 32572 |
if subfonts then |
| 32573 |
for i=1,#subfonts do |
| 32574 |
unpackoutlines(subfonts[i]) |
| 32575 |
end |
| 32576 |
return |
| 32577 |
end |
| 32578 |
local common=data.segments |
| 32579 |
if not common then |
| 32580 |
return |
| 32581 |
end |
| 32582 |
local glyphs=data.glyphs |
| 32583 |
if not glyphs then |
| 32584 |
return |
| 32585 |
end |
| 32586 |
for index=0,#glyphs do |
| 32587 |
local glyph=glyphs[index] |
| 32588 |
if glyph then |
| 32589 |
local segments=glyph.segments |
| 32590 |
if segments then |
| 32591 |
for i=1,#segments do |
| 32592 |
local c=common[segments[i]] |
| 32593 |
if c then |
| 32594 |
segments[i]=c |
| 32595 |
end |
| 32596 |
end |
| 32597 |
end |
| 32598 |
end |
| 32599 |
end |
| 32600 |
data.segments=nil |
| 32601 |
end |
| 32602 |
local readers=otf.readers |
| 32603 |
local cleanname=otf.readers.helpers.cleanname |
| 32604 |
local function makehash(filename,sub,instance) |
| 32605 |
local name=cleanname(file.basename(filename)) |
| 32606 |
if instance then |
| 32607 |
return formatters["%s-%s-%s"](name,sub or 0,cleanname(instance)) |
| 32608 |
else |
| 32609 |
return formatters["%s-%s"] (name,sub or 0) |
| 32610 |
end |
| 32611 |
end |
| 32612 |
local function loadoutlines(cache,filename,sub,instance) |
| 32613 |
local base=file.basename(filename) |
| 32614 |
local name=file.removesuffix(base) |
| 32615 |
local kind=file.suffix(filename) |
| 32616 |
local attr=lfs.attributes(filename) |
| 32617 |
local size=attr and attr.size or 0 |
| 32618 |
local time=attr and attr.modification or 0 |
| 32619 |
local sub=tonumber(sub) |
| 32620 |
if size>0 and (kind=="otf" or kind=="ttf" or kind=="tcc") then |
| 32621 |
local hash=makehash(filename,sub,instance) |
| 32622 |
data=containers.read(cache,hash) |
| 32623 |
if not data or data.time~=time or data.size~=size then |
| 32624 |
data=otf.readers.loadshapes(filename,sub,instance) |
| 32625 |
if data then |
| 32626 |
data.size=size |
| 32627 |
data.format=data.format or (kind=="otf" and "opentype") or "truetype" |
| 32628 |
data.time=time |
| 32629 |
packoutlines(data) |
| 32630 |
containers.write(cache,hash,data) |
| 32631 |
data=containers.read(cache,hash) |
| 32632 |
end |
| 32633 |
end |
| 32634 |
unpackoutlines(data) |
| 32635 |
elseif size>0 and (kind=="pfb") then |
| 32636 |
local hash=containers.cleanname(base) |
| 32637 |
data=containers.read(cache,hash) |
| 32638 |
if not data or data.time~=time or data.size~=size then |
| 32639 |
data=afm.readers.loadshapes(filename) |
| 32640 |
if data then |
| 32641 |
data.size=size |
| 32642 |
data.format="type1" |
| 32643 |
data.time=time |
| 32644 |
packoutlines(data) |
| 32645 |
containers.write(cache,hash,data) |
| 32646 |
data=containers.read(cache,hash) |
| 32647 |
end |
| 32648 |
end |
| 32649 |
unpackoutlines(data) |
| 32650 |
else |
| 32651 |
data={ |
| 32652 |
filename=filename, |
| 32653 |
size=0, |
| 32654 |
time=time, |
| 32655 |
format="unknown", |
| 32656 |
units=1000, |
| 32657 |
glyphs={} |
| 32658 |
} |
| 32659 |
end |
| 32660 |
return data |
| 32661 |
end |
| 32662 |
local function cachethem(cache,hash,data) |
| 32663 |
containers.write(cache,hash,data,compact_streams) |
| 32664 |
return containers.read(cache,hash) |
| 32665 |
end |
| 32666 |
local function loadstreams(cache,filename,sub,instance) |
| 32667 |
local base=file.basename(filename) |
| 32668 |
local name=file.removesuffix(base) |
| 32669 |
local kind=lower(file.suffix(filename)) |
| 32670 |
local attr=lfs.attributes(filename) |
| 32671 |
local size=attr and attr.size or 0 |
| 32672 |
local time=attr and attr.modification or 0 |
| 32673 |
local sub=tonumber(sub) |
| 32674 |
if size>0 and (kind=="otf" or kind=="ttf" or kind=="ttc") then |
| 32675 |
local hash=makehash(filename,sub,instance) |
| 32676 |
data=containers.read(cache,hash) |
| 32677 |
if not data or data.time~=time or data.size~=size then |
| 32678 |
data=otf.readers.loadshapes(filename,sub,instance,true) |
| 32679 |
if data then |
| 32680 |
local glyphs=data.glyphs |
| 32681 |
local streams={} |
| 32682 |
if glyphs then |
| 32683 |
for i=0,#glyphs do |
| 32684 |
local glyph=glyphs[i] |
| 32685 |
if glyph then |
| 32686 |
streams[i]=glyph.stream or "" |
| 32687 |
else |
| 32688 |
streams[i]="" |
| 32689 |
end |
| 32690 |
end |
| 32691 |
end |
| 32692 |
data.streams=streams |
| 32693 |
data.glyphs=nil |
| 32694 |
data.size=size |
| 32695 |
data.format=data.format or (kind=="otf" and "opentype") or "truetype" |
| 32696 |
data.time=time |
| 32697 |
data=cachethem(cache,hash,data) |
| 32698 |
end |
| 32699 |
end |
| 32700 |
elseif size>0 and (kind=="pfb") then |
| 32701 |
local hash=makehash(filename,sub,instance) |
| 32702 |
data=containers.read(cache,hash) |
| 32703 |
if not data or data.time~=time or data.size~=size then |
| 32704 |
local names,encoding,streams,metadata=pfb.loadvector(filename,false,true) |
| 32705 |
if streams then |
| 32706 |
local fontbbox=metadata.fontbbox or { 0,0,0,0 } |
| 32707 |
for i=0,#streams do |
| 32708 |
local s=streams[i] |
| 32709 |
streams[i]=s.stream or "\14" |
| 32710 |
end |
| 32711 |
data={ |
| 32712 |
filename=filename, |
| 32713 |
size=size, |
| 32714 |
time=time, |
| 32715 |
format="type1", |
| 32716 |
streams=streams, |
| 32717 |
fontheader={ |
| 32718 |
fontversion=metadata.version, |
| 32719 |
units=1000, |
| 32720 |
xmin=fontbbox[1], |
| 32721 |
ymin=fontbbox[2], |
| 32722 |
xmax=fontbbox[3], |
| 32723 |
ymax=fontbbox[4], |
| 32724 |
}, |
| 32725 |
horizontalheader={ |
| 32726 |
ascender=0, |
| 32727 |
descender=0, |
| 32728 |
}, |
| 32729 |
maximumprofile={ |
| 32730 |
nofglyphs=#streams+1, |
| 32731 |
}, |
| 32732 |
names={ |
| 32733 |
copyright=metadata.copyright, |
| 32734 |
family=metadata.familyname, |
| 32735 |
fullname=metadata.fullname, |
| 32736 |
fontname=metadata.fontname, |
| 32737 |
subfamily=metadata.subfamilyname, |
| 32738 |
trademark=metadata.trademark, |
| 32739 |
notice=metadata.notice, |
| 32740 |
version=metadata.version, |
| 32741 |
}, |
| 32742 |
cffinfo={ |
| 32743 |
familyname=metadata.familyname, |
| 32744 |
fullname=metadata.fullname, |
| 32745 |
italicangle=metadata.italicangle, |
| 32746 |
monospaced=metadata.isfixedpitch and true or false, |
| 32747 |
underlineposition=metadata.underlineposition, |
| 32748 |
underlinethickness=metadata.underlinethickness, |
| 32749 |
weight=metadata.weight, |
| 32750 |
}, |
| 32751 |
} |
| 32752 |
data=cachethem(cache,hash,data) |
| 32753 |
end |
| 32754 |
end |
| 32755 |
else |
| 32756 |
data={ |
| 32757 |
filename=filename, |
| 32758 |
size=0, |
| 32759 |
time=time, |
| 32760 |
format="unknown", |
| 32761 |
streams={} |
| 32762 |
} |
| 32763 |
end |
| 32764 |
return data |
| 32765 |
end |
| 32766 |
local loadedshapes={} |
| 32767 |
local loadedstreams={} |
| 32768 |
local function loadoutlinedata(fontdata,streams) |
| 32769 |
local properties=fontdata.properties |
| 32770 |
local filename=properties.filename |
| 32771 |
local subindex=fontdata.subindex |
| 32772 |
local instance=properties.instance |
| 32773 |
local hash=makehash(filename,subindex,instance) |
| 32774 |
local loaded=loadedshapes[hash] |
| 32775 |
if not loaded then |
| 32776 |
loaded=loadoutlines(shapescache,filename,subindex,instance) |
| 32777 |
loadedshapes[hash]=loaded |
| 32778 |
end |
| 32779 |
return loaded |
| 32780 |
end |
| 32781 |
hashes.shapes=table.setmetatableindex(function(t,k) |
| 32782 |
local f=identifiers[k] |
| 32783 |
if f then |
| 32784 |
return loadoutlinedata(f) |
| 32785 |
end |
| 32786 |
end) |
| 32787 |
local function getstreamhash(fontid) |
| 32788 |
local fontdata=identifiers[fontid] |
| 32789 |
if fontdata then |
| 32790 |
local properties=fontdata.properties |
| 32791 |
local fonthash=makehash(properties.filename,properties.subfont,properties.instance) |
| 32792 |
return fonthash,fontdata |
| 32793 |
end |
| 32794 |
end |
| 32795 |
local function loadstreamdata(fontdata) |
| 32796 |
local properties=fontdata.properties |
| 32797 |
local shared=fontdata.shared |
| 32798 |
local rawdata=shared and shared.rawdata |
| 32799 |
local metadata=rawdata and rawdata.metadata |
| 32800 |
local filename=properties.filename |
| 32801 |
local subindex=metadata and metadata.subfontindex |
| 32802 |
local instance=properties.instance |
| 32803 |
local hash=makehash(filename,subindex,instance) |
| 32804 |
local loaded=loadedstreams[hash] |
| 32805 |
if not loaded then |
| 32806 |
loaded=loadstreams(streamscache,filename,subindex,instance) |
| 32807 |
loadedstreams[hash]=loaded |
| 32808 |
end |
| 32809 |
return loaded |
| 32810 |
end |
| 32811 |
hashes.streams=table.setmetatableindex(function(t,k) |
| 32812 |
local f=identifiers[k] |
| 32813 |
if f then |
| 32814 |
return loadstreamdata(f) |
| 32815 |
end |
| 32816 |
end) |
| 32817 |
otf.loadoutlinedata=loadoutlinedata |
| 32818 |
otf.loadstreamdata=loadstreamdata |
| 32819 |
otf.loadshapes=loadshapes |
| 32820 |
otf.getstreamhash=getstreamhash |
| 32821 |
local streams=fonts.hashes.streams |
| 32822 |
callback.register("glyph_stream_provider",function(id,index,mode) |
| 32823 |
if id>0 then |
| 32824 |
local streams=streams[id].streams |
| 32825 |
if streams then |
| 32826 |
return streams[index] or "" |
| 32827 |
end |
| 32828 |
end |
| 32829 |
return "" |
| 32830 |
end) |
| 32831 |
|
| 32832 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-shp”] --- |
| 32833 |
|
| 32834 |
|
| 32835 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-def” f435e0875f203f343157baeff876ec9c] --- |
| 32836 |
|
| 32837 |
if not modules then modules={} end modules ['luatex-fonts-def']={ |
| 32838 |
version=1.001, |
| 32839 |
comment="companion to luatex-*.tex", |
| 32840 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 32841 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 32842 |
license="see context related readme files" |
| 32843 |
} |
| 32844 |
if context then |
| 32845 |
os.exit() |
| 32846 |
end |
| 32847 |
local fonts=fonts |
| 32848 |
fonts.constructors.namemode="specification" |
| 32849 |
function fonts.definers.getspecification(str) |
| 32850 |
return "",str,"",":",str |
| 32851 |
end |
| 32852 |
local list={} |
| 32853 |
local function issome () list.lookup='name' end |
| 32854 |
local function isfile () list.lookup='file' end |
| 32855 |
local function isname () list.lookup='name' end |
| 32856 |
local function thename(s) list.name=s end |
| 32857 |
local function issub (v) list.sub=v end |
| 32858 |
local function iscrap (s) list.crap=string.lower(s) end |
| 32859 |
local function iskey (k,v) list[k]=v end |
| 32860 |
local function istrue (s) list[s]=true end |
| 32861 |
local function isfalse(s) list[s]=false end |
| 32862 |
local P,S,R,C,Cs=lpeg.P,lpeg.S,lpeg.R,lpeg.C,lpeg.Cs |
| 32863 |
local spaces=P(" ")^0 |
| 32864 |
local namespec=Cs((P("{")/"")*(1-S("}"))^0*(P("}")/"")+(1-S("/:("))^0) |
| 32865 |
local crapspec=spaces*P("/")*(((1-P(":"))^0)/iscrap)*spaces |
| 32866 |
local filename_1=P("file:")/isfile*(namespec/thename) |
| 32867 |
local filename_2=P("[")*P(true)/isfile*(((1-P("]"))^0)/thename)*P("]") |
| 32868 |
local fontname_1=P("name:")/isname*(namespec/thename) |
| 32869 |
local fontname_2=P(true)/issome*(namespec/thename) |
| 32870 |
local sometext=R("az","AZ","09")^1 |
| 32871 |
local somekey=R("az","AZ","09")^1 |
| 32872 |
local somevalue=(P("{")/"")*(1-P("}"))^0*(P("}")/"")+(1-S(";"))^1 |
| 32873 |
local truevalue=P("+")*spaces*(sometext/istrue) |
| 32874 |
local falsevalue=P("-")*spaces*(sometext/isfalse) |
| 32875 |
local keyvalue=(C(somekey)*spaces*P("=")*spaces*C(somevalue))/iskey |
| 32876 |
local somevalue=sometext/istrue |
| 32877 |
local subvalue=P("(")*(C(P(1-S("()"))^1)/issub)*P(")") |
| 32878 |
local option=spaces*(keyvalue+falsevalue+truevalue+somevalue)*spaces |
| 32879 |
local options=P(":")*spaces*(P(";")^0*option)^0 |
| 32880 |
local pattern=(filename_1+filename_2+fontname_1+fontname_2)*subvalue^0*crapspec^0*options^0 |
| 32881 |
function fonts.definers.analyze(str,size) |
| 32882 |
local specification=fonts.definers.makespecification(str,nil,nil,nil,":",nil,size) |
| 32883 |
list={} |
| 32884 |
lpeg.match(pattern,str) |
| 32885 |
list.crap=nil |
| 32886 |
if list.name then |
| 32887 |
specification.name=list.name |
| 32888 |
list.name=nil |
| 32889 |
end |
| 32890 |
if list.lookup then |
| 32891 |
specification.lookup=list.lookup |
| 32892 |
list.lookup=nil |
| 32893 |
end |
| 32894 |
if list.sub then |
| 32895 |
specification.sub=list.sub |
| 32896 |
list.sub=nil |
| 32897 |
end |
| 32898 |
specification.features.normal=fonts.handlers.otf.features.normalize(list) |
| 32899 |
list=nil |
| 32900 |
return specification |
| 32901 |
end |
| 32902 |
function fonts.definers.applypostprocessors(tfmdata) |
| 32903 |
local postprocessors=tfmdata.postprocessors |
| 32904 |
if postprocessors then |
| 32905 |
for i=1,#postprocessors do |
| 32906 |
local extrahash=postprocessors[i](tfmdata) |
| 32907 |
if type(extrahash)=="string" and extrahash~="" then |
| 32908 |
extrahash=string.gsub(lower(extrahash),"[^a-z]","-") |
| 32909 |
tfmdata.properties.fullname=format("%s-%s",tfmdata.properties.fullname,extrahash) |
| 32910 |
end |
| 32911 |
end |
| 32912 |
end |
| 32913 |
return tfmdata |
| 32914 |
end |
| 32915 |
|
| 32916 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-def”] --- |
| 32917 |
|
| 32918 |
|
| 32919 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-ext” 32013cbc5d5d336be8b1d1e5879d86c4] --- |
| 32920 |
|
| 32921 |
if not modules then modules={} end modules ['luatex-fonts-ext']={ |
| 32922 |
version=1.001, |
| 32923 |
comment="companion to luatex-*.tex", |
| 32924 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 32925 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 32926 |
license="see context related readme files" |
| 32927 |
} |
| 32928 |
if context then |
| 32929 |
os.exit() |
| 32930 |
end |
| 32931 |
local byte=string.byte |
| 32932 |
local fonts=fonts |
| 32933 |
local handlers=fonts.handlers |
| 32934 |
local otf=handlers.otf |
| 32935 |
local afm=handlers.afm |
| 32936 |
local registerotffeature=otf.features.register |
| 32937 |
local registerafmfeature=afm.features.register |
| 32938 |
function fonts.loggers.onetimemessage() end |
| 32939 |
fonts.protrusions=fonts.protrusions or {} |
| 32940 |
fonts.protrusions.setups=fonts.protrusions.setups or {} |
| 32941 |
local setups=fonts.protrusions.setups |
| 32942 |
setups['default']={ |
| 32943 |
factor=1, |
| 32944 |
left=1, |
| 32945 |
right=1, |
| 32946 |
[0x002C]={ 0,1 }, |
| 32947 |
[0x002E]={ 0,1 }, |
| 32948 |
[0x003A]={ 0,1 }, |
| 32949 |
[0x003B]={ 0,1 }, |
| 32950 |
[0x002D]={ 0,1 }, |
| 32951 |
[0x2013]={ 0,0.50 }, |
| 32952 |
[0x2014]={ 0,0.33 }, |
| 32953 |
[0x3001]={ 0,1 }, |
| 32954 |
[0x3002]={ 0,1 }, |
| 32955 |
[0x060C]={ 0,1 }, |
| 32956 |
[0x061B]={ 0,1 }, |
| 32957 |
[0x06D4]={ 0,1 }, |
| 32958 |
} |
| 32959 |
local function initializeprotrusion(tfmdata,value) |
| 32960 |
if value then |
| 32961 |
local setup=setups[value] |
| 32962 |
if setup then |
| 32963 |
local factor,left,right=setup.factor or 1,setup.left or 1,setup.right or 1 |
| 32964 |
local emwidth=tfmdata.parameters.quad |
| 32965 |
tfmdata.parameters.protrusion={ |
| 32966 |
auto=true, |
| 32967 |
} |
| 32968 |
for i,chr in next,tfmdata.characters do |
| 32969 |
local v,pl,pr=setup[i],nil,nil |
| 32970 |
if v then |
| 32971 |
pl,pr=v[1],v[2] |
| 32972 |
end |
| 32973 |
if pl and pl~=0 then chr.left_protruding=left*pl*factor end |
| 32974 |
if pr and pr~=0 then chr.right_protruding=right*pr*factor end |
| 32975 |
end |
| 32976 |
end |
| 32977 |
end |
| 32978 |
end |
| 32979 |
local specification={ |
| 32980 |
name="protrusion", |
| 32981 |
description="shift characters into the left and or right margin", |
| 32982 |
initializers={ |
| 32983 |
base=initializeprotrusion, |
| 32984 |
node=initializeprotrusion, |
| 32985 |
} |
| 32986 |
} |
| 32987 |
registerotffeature(specification) |
| 32988 |
registerafmfeature(specification) |
| 32989 |
fonts.expansions=fonts.expansions or {} |
| 32990 |
fonts.expansions.setups=fonts.expansions.setups or {} |
| 32991 |
local setups=fonts.expansions.setups |
| 32992 |
setups['default']={ |
| 32993 |
stretch=2, |
| 32994 |
shrink=2, |
| 32995 |
step=.5, |
| 32996 |
factor=1, |
| 32997 |
[byte('A')]=0.5,[byte('B')]=0.7,[byte('C')]=0.7,[byte('D')]=0.5,[byte('E')]=0.7, |
| 32998 |
[byte('F')]=0.7,[byte('G')]=0.5,[byte('H')]=0.7,[byte('K')]=0.7,[byte('M')]=0.7, |
| 32999 |
[byte('N')]=0.7,[byte('O')]=0.5,[byte('P')]=0.7,[byte('Q')]=0.5,[byte('R')]=0.7, |
| 33000 |
[byte('S')]=0.7,[byte('U')]=0.7,[byte('W')]=0.7,[byte('Z')]=0.7, |
| 33001 |
[byte('a')]=0.7,[byte('b')]=0.7,[byte('c')]=0.7,[byte('d')]=0.7,[byte('e')]=0.7, |
| 33002 |
[byte('g')]=0.7,[byte('h')]=0.7,[byte('k')]=0.7,[byte('m')]=0.7,[byte('n')]=0.7, |
| 33003 |
[byte('o')]=0.7,[byte('p')]=0.7,[byte('q')]=0.7,[byte('s')]=0.7,[byte('u')]=0.7, |
| 33004 |
[byte('w')]=0.7,[byte('z')]=0.7, |
| 33005 |
[byte('2')]=0.7,[byte('3')]=0.7,[byte('6')]=0.7,[byte('8')]=0.7,[byte('9')]=0.7, |
| 33006 |
} |
| 33007 |
local function initializeexpansion(tfmdata,value) |
| 33008 |
if value then |
| 33009 |
local setup=setups[value] |
| 33010 |
if setup then |
| 33011 |
local factor=setup.factor or 1 |
| 33012 |
tfmdata.parameters.expansion={ |
| 33013 |
stretch=10*(setup.stretch or 0), |
| 33014 |
shrink=10*(setup.shrink or 0), |
| 33015 |
step=10*(setup.step or 0), |
| 33016 |
auto=true, |
| 33017 |
} |
| 33018 |
for i,chr in next,tfmdata.characters do |
| 33019 |
local v=setup[i] |
| 33020 |
if v and v~=0 then |
| 33021 |
chr.expansion_factor=v*factor |
| 33022 |
else |
| 33023 |
chr.expansion_factor=factor |
| 33024 |
end |
| 33025 |
end |
| 33026 |
end |
| 33027 |
end |
| 33028 |
end |
| 33029 |
local specification={ |
| 33030 |
name="expansion", |
| 33031 |
description="apply hz optimization", |
| 33032 |
initializers={ |
| 33033 |
base=initializeexpansion, |
| 33034 |
node=initializeexpansion, |
| 33035 |
} |
| 33036 |
} |
| 33037 |
registerotffeature(specification) |
| 33038 |
registerafmfeature(specification) |
| 33039 |
if not otf.features.normalize then |
| 33040 |
otf.features.normalize=function(t) |
| 33041 |
if t.rand then |
| 33042 |
t.rand="random" |
| 33043 |
end |
| 33044 |
return t |
| 33045 |
end |
| 33046 |
end |
| 33047 |
function fonts.helpers.nametoslot(name) |
| 33048 |
local t=type(name) |
| 33049 |
if t=="string" then |
| 33050 |
local tfmdata=fonts.hashes.identifiers[currentfont()] |
| 33051 |
local shared=tfmdata and tfmdata.shared |
| 33052 |
local fntdata=shared and shared.rawdata |
| 33053 |
return fntdata and fntdata.resources.unicodes[name] |
| 33054 |
elseif t=="number" then |
| 33055 |
return n |
| 33056 |
end |
| 33057 |
end |
| 33058 |
fonts.encodings=fonts.encodings or {} |
| 33059 |
local reencodings={} |
| 33060 |
fonts.encodings.reencodings=reencodings |
| 33061 |
local function specialreencode(tfmdata,value) |
| 33062 |
local encoding=value and reencodings[value] |
| 33063 |
if encoding then |
| 33064 |
local temp={} |
| 33065 |
local char=tfmdata.characters |
| 33066 |
for k,v in next,encoding do |
| 33067 |
temp[k]=char[v] |
| 33068 |
end |
| 33069 |
for k,v in next,temp do |
| 33070 |
char[k]=temp[k] |
| 33071 |
end |
| 33072 |
return string.format("reencoded:%s",value) |
| 33073 |
end |
| 33074 |
end |
| 33075 |
local function initialize(tfmdata,value) |
| 33076 |
tfmdata.postprocessors=tfmdata.postprocessors or {} |
| 33077 |
table.insert(tfmdata.postprocessors, |
| 33078 |
function(tfmdata) |
| 33079 |
return specialreencode(tfmdata,value) |
| 33080 |
end |
| 33081 |
) |
| 33082 |
end |
| 33083 |
registerotffeature { |
| 33084 |
name="reencode", |
| 33085 |
description="reencode characters", |
| 33086 |
manipulators={ |
| 33087 |
base=initialize, |
| 33088 |
node=initialize, |
| 33089 |
} |
| 33090 |
} |
| 33091 |
local function initialize(tfmdata,key,value) |
| 33092 |
if value then |
| 33093 |
tfmdata.mathparameters=nil |
| 33094 |
end |
| 33095 |
end |
| 33096 |
registerotffeature { |
| 33097 |
name="ignoremathconstants", |
| 33098 |
description="ignore math constants table", |
| 33099 |
initializers={ |
| 33100 |
base=initialize, |
| 33101 |
node=initialize, |
| 33102 |
} |
| 33103 |
} |
| 33104 |
|
| 33105 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-ext”] --- |
| 33106 |
|
| 33107 |
|
| 33108 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-imp-tex” 9882d382700e714cace08b7f09820958] --- |
| 33109 |
|
| 33110 |
if not modules then modules={} end modules ['font-imp-tex']={ |
| 33111 |
version=1.001, |
| 33112 |
comment="companion to font-ini.mkiv", |
| 33113 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 33114 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 33115 |
license="see context related readme files" |
| 33116 |
} |
| 33117 |
local next=next |
| 33118 |
local fonts=fonts |
| 33119 |
local otf=fonts.handlers.otf |
| 33120 |
local registerotffeature=otf.features.register |
| 33121 |
local addotffeature=otf.addfeature |
| 33122 |
local tlig={ |
| 33123 |
type="ligature", |
| 33124 |
order={ "tlig" }, |
| 33125 |
prepend=true, |
| 33126 |
data={ |
| 33127 |
[0x2013]={ 0x002D,0x002D }, |
| 33128 |
[0x2014]={ 0x002D,0x002D,0x002D }, |
| 33129 |
}, |
| 33130 |
} |
| 33131 |
local tquo={ |
| 33132 |
type="ligature", |
| 33133 |
order={ "tquo" }, |
| 33134 |
prepend=true, |
| 33135 |
data={ |
| 33136 |
[0x201C]={ 0x0060,0x0060 }, |
| 33137 |
[0x201D]={ 0x0027,0x0027 }, |
| 33138 |
[0x201E]={ 0x002C,0x002C }, |
| 33139 |
}, |
| 33140 |
} |
| 33141 |
local trep={ |
| 33142 |
type="substitution", |
| 33143 |
order={ "trep" }, |
| 33144 |
prepend=true, |
| 33145 |
data={ |
| 33146 |
[0x0027]=0x2019, |
| 33147 |
}, |
| 33148 |
} |
| 33149 |
addotffeature("trep",trep) |
| 33150 |
addotffeature("tlig",tlig) |
| 33151 |
addotffeature("tquo",tquo) |
| 33152 |
registerotffeature { name="tlig",description="tex ligatures" } |
| 33153 |
registerotffeature { name="tquo",description="tex quotes" } |
| 33154 |
registerotffeature { name="trep",description="tex replacements" } |
| 33155 |
local anum_arabic={ |
| 33156 |
[0x0030]=0x0660, |
| 33157 |
[0x0031]=0x0661, |
| 33158 |
[0x0032]=0x0662, |
| 33159 |
[0x0033]=0x0663, |
| 33160 |
[0x0034]=0x0664, |
| 33161 |
[0x0035]=0x0665, |
| 33162 |
[0x0036]=0x0666, |
| 33163 |
[0x0037]=0x0667, |
| 33164 |
[0x0038]=0x0668, |
| 33165 |
[0x0039]=0x0669, |
| 33166 |
} |
| 33167 |
local anum_persian={ |
| 33168 |
[0x0030]=0x06F0, |
| 33169 |
[0x0031]=0x06F1, |
| 33170 |
[0x0032]=0x06F2, |
| 33171 |
[0x0033]=0x06F3, |
| 33172 |
[0x0034]=0x06F4, |
| 33173 |
[0x0035]=0x06F5, |
| 33174 |
[0x0036]=0x06F6, |
| 33175 |
[0x0037]=0x06F7, |
| 33176 |
[0x0038]=0x06F8, |
| 33177 |
[0x0039]=0x06F9, |
| 33178 |
} |
| 33179 |
local function valid(data) |
| 33180 |
local features=data.resources.features |
| 33181 |
if features then |
| 33182 |
for k,v in next,features do |
| 33183 |
for k,v in next,v do |
| 33184 |
if v.arab then |
| 33185 |
return true |
| 33186 |
end |
| 33187 |
end |
| 33188 |
end |
| 33189 |
end |
| 33190 |
end |
| 33191 |
local specification={ |
| 33192 |
{ |
| 33193 |
type="substitution", |
| 33194 |
features={ arab={ urd=true,dflt=true } }, |
| 33195 |
order={ "anum" }, |
| 33196 |
data=anum_arabic, |
| 33197 |
valid=valid, |
| 33198 |
}, |
| 33199 |
{ |
| 33200 |
type="substitution", |
| 33201 |
features={ arab={ urd=true } }, |
| 33202 |
order={ "anum" }, |
| 33203 |
data=anum_persian, |
| 33204 |
valid=valid, |
| 33205 |
}, |
| 33206 |
} |
| 33207 |
addotffeature("anum",specification) |
| 33208 |
registerotffeature { |
| 33209 |
name="anum", |
| 33210 |
description="arabic digits", |
| 33211 |
} |
| 33212 |
|
| 33213 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-imp-tex”] --- |
| 33214 |
|
| 33215 |
|
| 33216 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-imp-ligatures” 250f6f4488ee770c23177afb2ff75676] --- |
| 33217 |
|
| 33218 |
if not modules then modules={} end modules ['font-imp-ligatures']={ |
| 33219 |
version=1.001, |
| 33220 |
comment="companion to font-ini.mkiv", |
| 33221 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 33222 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 33223 |
license="see context related readme files" |
| 33224 |
} |
| 33225 |
local lpegmatch=lpeg.match |
| 33226 |
local utfsplit=utf.split |
| 33227 |
local settings_to_array=utilities.parsers.settings_to_array |
| 33228 |
local fonts=fonts |
| 33229 |
local otf=fonts.handlers.otf |
| 33230 |
local registerotffeature=otf.features.register |
| 33231 |
local addotffeature=otf.addfeature |
| 33232 |
local lookups={} |
| 33233 |
local protect={} |
| 33234 |
local revert={} |
| 33235 |
local zwjchar=0x200C |
| 33236 |
local zwj={ zwjchar } |
| 33237 |
addotffeature { |
| 33238 |
name="blockligatures", |
| 33239 |
type="chainsubstitution", |
| 33240 |
nocheck=true, |
| 33241 |
prepend=true, |
| 33242 |
future=true, |
| 33243 |
lookups={ |
| 33244 |
{ |
| 33245 |
type="multiple", |
| 33246 |
data=lookups, |
| 33247 |
}, |
| 33248 |
}, |
| 33249 |
data={ |
| 33250 |
rules=protect, |
| 33251 |
} |
| 33252 |
} |
| 33253 |
addotffeature { |
| 33254 |
name="blockligatures", |
| 33255 |
type="chainsubstitution", |
| 33256 |
nocheck=true, |
| 33257 |
append=true, |
| 33258 |
overload=false, |
| 33259 |
lookups={ |
| 33260 |
{ |
| 33261 |
type="ligature", |
| 33262 |
data=lookups, |
| 33263 |
}, |
| 33264 |
}, |
| 33265 |
data={ |
| 33266 |
rules=revert, |
| 33267 |
} |
| 33268 |
} |
| 33269 |
registerotffeature { |
| 33270 |
name='blockligatures', |
| 33271 |
description='block certain ligatures', |
| 33272 |
} |
| 33273 |
local splitter=lpeg.splitat(":") |
| 33274 |
local function blockligatures(str) |
| 33275 |
local t=settings_to_array(str) |
| 33276 |
for i=1,#t do |
| 33277 |
local ti=t[i] |
| 33278 |
local before,current,after=lpegmatch(splitter,ti) |
| 33279 |
if current and after then |
| 33280 |
if before then |
| 33281 |
before=utfsplit(before) |
| 33282 |
for i=1,#before do |
| 33283 |
before[i]={ before[i] } |
| 33284 |
end |
| 33285 |
end |
| 33286 |
if current then |
| 33287 |
current=utfsplit(current) |
| 33288 |
end |
| 33289 |
if after then |
| 33290 |
after=utfsplit(after) |
| 33291 |
for i=1,#after do |
| 33292 |
after[i]={ after[i] } |
| 33293 |
end |
| 33294 |
end |
| 33295 |
else |
| 33296 |
before=nil |
| 33297 |
current=utfsplit(ti) |
| 33298 |
after=nil |
| 33299 |
end |
| 33300 |
if #current>1 then |
| 33301 |
local one=current[1] |
| 33302 |
local two=current[2] |
| 33303 |
lookups[one]={ one,zwjchar } |
| 33304 |
local one={ one } |
| 33305 |
local two={ two } |
| 33306 |
local new=#protect+1 |
| 33307 |
protect[new]={ |
| 33308 |
before=before, |
| 33309 |
current={ one,two }, |
| 33310 |
after=after, |
| 33311 |
lookups={ 1,false }, |
| 33312 |
} |
| 33313 |
revert[new]={ |
| 33314 |
current={ one,zwj }, |
| 33315 |
after={ two }, |
| 33316 |
lookups={ 1,false }, |
| 33317 |
} |
| 33318 |
end |
| 33319 |
end |
| 33320 |
end |
| 33321 |
otf.helpers.blockligatures=blockligatures |
| 33322 |
if context then |
| 33323 |
interfaces.implement { |
| 33324 |
name="blockligatures", |
| 33325 |
arguments="string", |
| 33326 |
actions=blockligatures, |
| 33327 |
} |
| 33328 |
end |
| 33329 |
|
| 33330 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-imp-ligatures”] --- |
| 33331 |
|
| 33332 |
|
| 33333 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-imp-italics” 3cc555a1fe00dc45449f1e4a47a5c990] --- |
| 33334 |
|
| 33335 |
if not modules then modules={} end modules ['font-imp-italics']={ |
| 33336 |
version=1.001, |
| 33337 |
comment="companion to font-ini.mkiv and hand-ini.mkiv", |
| 33338 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 33339 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 33340 |
license="see context related readme files" |
| 33341 |
} |
| 33342 |
local next,tonumber=next,tonumber |
| 33343 |
local fonts=fonts |
| 33344 |
local handlers=fonts.handlers |
| 33345 |
local registerotffeature=handlers.otf.features.register |
| 33346 |
local registerafmfeature=handlers.afm.features.register |
| 33347 |
local function initialize(tfmdata,value) |
| 33348 |
if value then |
| 33349 |
local parameters=tfmdata.parameters |
| 33350 |
local italicangle=parameters.italicangle |
| 33351 |
if italicangle and italicangle~=0 then |
| 33352 |
local properties=tfmdata.properties |
| 33353 |
local factor=tonumber(value) or 1 |
| 33354 |
properties.hasitalics=true |
| 33355 |
properties.autoitalicamount=factor*(parameters.uwidth or 40)/2 |
| 33356 |
end |
| 33357 |
end |
| 33358 |
end |
| 33359 |
local specification={ |
| 33360 |
name="itlc", |
| 33361 |
description="italic correction", |
| 33362 |
initializers={ |
| 33363 |
base=initialize, |
| 33364 |
node=initialize, |
| 33365 |
} |
| 33366 |
} |
| 33367 |
registerotffeature(specification) |
| 33368 |
registerafmfeature(specification) |
| 33369 |
if context then |
| 33370 |
local function initialize(tfmdata,value) |
| 33371 |
tfmdata.properties.textitalics=toboolean(value) |
| 33372 |
end |
| 33373 |
local specification={ |
| 33374 |
name="textitalics", |
| 33375 |
description="use alternative text italic correction", |
| 33376 |
initializers={ |
| 33377 |
base=initialize, |
| 33378 |
node=initialize, |
| 33379 |
} |
| 33380 |
} |
| 33381 |
registerotffeature(specification) |
| 33382 |
registerafmfeature(specification) |
| 33383 |
local letter=characters.is_letter |
| 33384 |
local always=true |
| 33385 |
local function collapseitalics(tfmdata,key,value) |
| 33386 |
local threshold=value==true and 100 or tonumber(value) |
| 33387 |
if threshold and threshold>0 then |
| 33388 |
if threshold>100 then |
| 33389 |
threshold=100 |
| 33390 |
end |
| 33391 |
for unicode,data in next,tfmdata.characters do |
| 33392 |
if always or letter[unicode] or letter[data.unicode] then |
| 33393 |
local italic=data.italic |
| 33394 |
if italic and italic~=0 then |
| 33395 |
local width=data.width |
| 33396 |
if width and width~=0 then |
| 33397 |
local delta=threshold*italic/100 |
| 33398 |
data.width=width+delta |
| 33399 |
data.italic=italic-delta |
| 33400 |
end |
| 33401 |
end |
| 33402 |
end |
| 33403 |
end |
| 33404 |
end |
| 33405 |
end |
| 33406 |
local dimensions_specification={ |
| 33407 |
name="collapseitalics", |
| 33408 |
description="collapse italics", |
| 33409 |
manipulators={ |
| 33410 |
base=collapseitalics, |
| 33411 |
node=collapseitalics, |
| 33412 |
} |
| 33413 |
} |
| 33414 |
registerotffeature(dimensions_specification) |
| 33415 |
registerafmfeature(dimensions_specification) |
| 33416 |
end |
| 33417 |
|
| 33418 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-imp-italics”] --- |
| 33419 |
|
| 33420 |
|
| 33421 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “font-imp-effects” d05997c1826355548ec9aec1346f9f23] --- |
| 33422 |
|
| 33423 |
if not modules then modules={} end modules ['font-imp-effects']={ |
| 33424 |
version=1.001, |
| 33425 |
comment="companion to font-ini.mkiv", |
| 33426 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 33427 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 33428 |
license="see context related readme files" |
| 33429 |
} |
| 33430 |
local next,type,tonumber=next,type,tonumber |
| 33431 |
local is_boolean=string.is_boolean |
| 33432 |
local fonts=fonts |
| 33433 |
local handlers=fonts.handlers |
| 33434 |
local registerotffeature=handlers.otf.features.register |
| 33435 |
local registerafmfeature=handlers.afm.features.register |
| 33436 |
local settings_to_hash=utilities.parsers.settings_to_hash_colon_too |
| 33437 |
local helpers=fonts.helpers |
| 33438 |
local prependcommands=helpers.prependcommands |
| 33439 |
local charcommand=helpers.commands.char |
| 33440 |
local leftcommand=helpers.commands.left |
| 33441 |
local rightcommand=helpers.commands.right |
| 33442 |
local upcommand=helpers.commands.up |
| 33443 |
local downcommand=helpers.commands.down |
| 33444 |
local dummycommand=helpers.commands.dummy |
| 33445 |
local report_effect=logs.reporter("fonts","effect") |
| 33446 |
local report_slant=logs.reporter("fonts","slant") |
| 33447 |
local report_extend=logs.reporter("fonts","extend") |
| 33448 |
local report_squeeze=logs.reporter("fonts","squeeze") |
| 33449 |
local trace=false |
| 33450 |
trackers.register("fonts.effect",function(v) trace=v end) |
| 33451 |
trackers.register("fonts.slant",function(v) trace=v end) |
| 33452 |
trackers.register("fonts.extend",function(v) trace=v end) |
| 33453 |
trackers.register("fonts.squeeze",function(v) trace=v end) |
| 33454 |
local function initializeslant(tfmdata,value) |
| 33455 |
value=tonumber(value) |
| 33456 |
if not value then |
| 33457 |
value=0 |
| 33458 |
elseif value>1 then |
| 33459 |
value=1 |
| 33460 |
elseif value<-1 then |
| 33461 |
value=-1 |
| 33462 |
end |
| 33463 |
if trace then |
| 33464 |
report_slant("applying %0.3f",value) |
| 33465 |
end |
| 33466 |
tfmdata.parameters.slantfactor=value |
| 33467 |
end |
| 33468 |
local specification={ |
| 33469 |
name="slant", |
| 33470 |
description="slant glyphs", |
| 33471 |
initializers={ |
| 33472 |
base=initializeslant, |
| 33473 |
node=initializeslant, |
| 33474 |
} |
| 33475 |
} |
| 33476 |
registerotffeature(specification) |
| 33477 |
registerafmfeature(specification) |
| 33478 |
local function initializeextend(tfmdata,value) |
| 33479 |
value=tonumber(value) |
| 33480 |
if not value then |
| 33481 |
value=0 |
| 33482 |
elseif value>10 then |
| 33483 |
value=10 |
| 33484 |
elseif value<-10 then |
| 33485 |
value=-10 |
| 33486 |
end |
| 33487 |
if trace then |
| 33488 |
report_extend("applying %0.3f",value) |
| 33489 |
end |
| 33490 |
tfmdata.parameters.extendfactor=value |
| 33491 |
end |
| 33492 |
local specification={ |
| 33493 |
name="extend", |
| 33494 |
description="scale glyphs horizontally", |
| 33495 |
initializers={ |
| 33496 |
base=initializeextend, |
| 33497 |
node=initializeextend, |
| 33498 |
} |
| 33499 |
} |
| 33500 |
registerotffeature(specification) |
| 33501 |
registerafmfeature(specification) |
| 33502 |
local function initializesqueeze(tfmdata,value) |
| 33503 |
value=tonumber(value) |
| 33504 |
if not value then |
| 33505 |
value=0 |
| 33506 |
elseif value>10 then |
| 33507 |
value=10 |
| 33508 |
elseif value<-10 then |
| 33509 |
value=-10 |
| 33510 |
end |
| 33511 |
if trace then |
| 33512 |
report_squeeze("applying %0.3f",value) |
| 33513 |
end |
| 33514 |
tfmdata.parameters.squeezefactor=value |
| 33515 |
end |
| 33516 |
local specification={ |
| 33517 |
name="squeeze", |
| 33518 |
description="scale glyphs vertically", |
| 33519 |
initializers={ |
| 33520 |
base=initializesqueeze, |
| 33521 |
node=initializesqueeze, |
| 33522 |
} |
| 33523 |
} |
| 33524 |
registerotffeature(specification) |
| 33525 |
registerafmfeature(specification) |
| 33526 |
local effects={ |
| 33527 |
inner=0, |
| 33528 |
normal=0, |
| 33529 |
outer=1, |
| 33530 |
outline=1, |
| 33531 |
both=2, |
| 33532 |
hidden=3, |
| 33533 |
} |
| 33534 |
local function initializeeffect(tfmdata,value) |
| 33535 |
local spec |
| 33536 |
if type(value)=="number" then |
| 33537 |
spec={ width=value } |
| 33538 |
else |
| 33539 |
spec=settings_to_hash(value) |
| 33540 |
end |
| 33541 |
local effect=spec.effect or "both" |
| 33542 |
local width=tonumber(spec.width) or 0 |
| 33543 |
local mode=effects[effect] |
| 33544 |
if not mode then |
| 33545 |
report_effect("invalid effect %a",effect) |
| 33546 |
elseif width==0 and mode==0 then |
| 33547 |
report_effect("invalid width %a for effect %a",width,effect) |
| 33548 |
else |
| 33549 |
local parameters=tfmdata.parameters |
| 33550 |
local properties=tfmdata.properties |
| 33551 |
parameters.mode=mode |
| 33552 |
parameters.width=width*1000 |
| 33553 |
if is_boolean(spec.auto)==true then |
| 33554 |
local squeeze=1-width/20 |
| 33555 |
local average=(1-squeeze)*width*100 |
| 33556 |
spec.squeeze=squeeze |
| 33557 |
spec.extend=1+width/2 |
| 33558 |
spec.wdelta=average |
| 33559 |
spec.hdelta=average/2 |
| 33560 |
spec.ddelta=average/2 |
| 33561 |
spec.vshift=average/2 |
| 33562 |
end |
| 33563 |
local factor=tonumber(spec.factor) or 0 |
| 33564 |
local hfactor=tonumber(spec.hfactor) or factor |
| 33565 |
local vfactor=tonumber(spec.vfactor) or factor |
| 33566 |
local delta=tonumber(spec.delta) or 1 |
| 33567 |
local wdelta=tonumber(spec.wdelta) or delta |
| 33568 |
local hdelta=tonumber(spec.hdelta) or delta |
| 33569 |
local ddelta=tonumber(spec.ddelta) or hdelta |
| 33570 |
local vshift=tonumber(spec.vshift) or 0 |
| 33571 |
local slant=spec.slant |
| 33572 |
local extend=spec.extend |
| 33573 |
local squeeze=spec.squeeze |
| 33574 |
if slant then |
| 33575 |
initializeslant(tfmdata,slant) |
| 33576 |
end |
| 33577 |
if extend then |
| 33578 |
initializeextend(tfmdata,extend) |
| 33579 |
end |
| 33580 |
if squeeze then |
| 33581 |
initializesqueeze(tfmdata,squeeze) |
| 33582 |
end |
| 33583 |
properties.effect={ |
| 33584 |
effect=effect, |
| 33585 |
width=width, |
| 33586 |
factor=factor, |
| 33587 |
hfactor=hfactor, |
| 33588 |
vfactor=vfactor, |
| 33589 |
wdelta=wdelta, |
| 33590 |
hdelta=hdelta, |
| 33591 |
ddelta=ddelta, |
| 33592 |
vshift=vshift, |
| 33593 |
slant=tfmdata.parameters.slantfactor, |
| 33594 |
extend=tfmdata.parameters.extendfactor, |
| 33595 |
squeeze=tfmdata.parameters.squeezefactor, |
| 33596 |
} |
| 33597 |
end |
| 33598 |
end |
| 33599 |
local rules={ |
| 33600 |
"RadicalRuleThickness", |
| 33601 |
"OverbarRuleThickness", |
| 33602 |
"FractionRuleThickness", |
| 33603 |
"UnderbarRuleThickness", |
| 33604 |
} |
| 33605 |
local function setmathparameters(tfmdata,characters,mathparameters,dx,dy,squeeze,multiplier) |
| 33606 |
if dy~=0 then |
| 33607 |
for i=1,#rules do |
| 33608 |
local name=rules[i] |
| 33609 |
local value=mathparameters[name] |
| 33610 |
if value then |
| 33611 |
mathparameters[name]=(squeeze or 1)*(value+dy) |
| 33612 |
end |
| 33613 |
end |
| 33614 |
end |
| 33615 |
end |
| 33616 |
local function setmathcharacters(tfmdata,characters,mathparameters,dx,dy,squeeze,wdelta,hdelta,ddelta) |
| 33617 |
local function wdpatch(char) |
| 33618 |
if wsnap~=0 then |
| 33619 |
char.width=char.width+wdelta/2 |
| 33620 |
end |
| 33621 |
end |
| 33622 |
local function htpatch(char) |
| 33623 |
if hsnap~=0 then |
| 33624 |
local height=char.height |
| 33625 |
if height then |
| 33626 |
char.height=char.height+2*dy |
| 33627 |
end |
| 33628 |
end |
| 33629 |
end |
| 33630 |
local character=characters[0x221A] |
| 33631 |
if character and character.next then |
| 33632 |
local char=character |
| 33633 |
local next=character.next |
| 33634 |
wdpatch(char) |
| 33635 |
htpatch(char) |
| 33636 |
while next do |
| 33637 |
char=characters[next] |
| 33638 |
wdpatch(char) |
| 33639 |
htpatch(char) |
| 33640 |
next=char.next |
| 33641 |
end |
| 33642 |
if char then |
| 33643 |
local v=char.vert_variants |
| 33644 |
if v then |
| 33645 |
local top=v[#v] |
| 33646 |
if top then |
| 33647 |
local char=characters[top.glyph] |
| 33648 |
htpatch(char) |
| 33649 |
end |
| 33650 |
end |
| 33651 |
end |
| 33652 |
end |
| 33653 |
end |
| 33654 |
local function manipulateeffect(tfmdata) |
| 33655 |
local effect=tfmdata.properties.effect |
| 33656 |
if effect then |
| 33657 |
local characters=tfmdata.characters |
| 33658 |
local parameters=tfmdata.parameters |
| 33659 |
local mathparameters=tfmdata.mathparameters |
| 33660 |
local multiplier=effect.width*100 |
| 33661 |
local factor=parameters.factor |
| 33662 |
local hfactor=parameters.hfactor |
| 33663 |
local vfactor=parameters.vfactor |
| 33664 |
local wdelta=effect.wdelta*hfactor*multiplier |
| 33665 |
local hdelta=effect.hdelta*vfactor*multiplier |
| 33666 |
local ddelta=effect.ddelta*vfactor*multiplier |
| 33667 |
local vshift=effect.vshift*vfactor*multiplier |
| 33668 |
local squeeze=effect.squeeze |
| 33669 |
local hshift=wdelta/2 |
| 33670 |
local dx=multiplier*vfactor |
| 33671 |
local dy=vshift |
| 33672 |
local factor=(1+effect.factor)*factor |
| 33673 |
local hfactor=(1+effect.hfactor)*hfactor |
| 33674 |
local vfactor=(1+effect.vfactor)*vfactor |
| 33675 |
vshift=vshift~=0 and upcommand[vshift] or false |
| 33676 |
hshift=rightcommand[hshift] |
| 33677 |
for unicode,character in next,characters do |
| 33678 |
local oldwidth=character.width |
| 33679 |
local oldheight=character.height |
| 33680 |
local olddepth=character.depth |
| 33681 |
if oldwidth and oldwidth>0 then |
| 33682 |
character.width=oldwidth+wdelta |
| 33683 |
local commands=character.commands |
| 33684 |
if vshift then |
| 33685 |
if commands then |
| 33686 |
prependcommands (commands, |
| 33687 |
hshift, |
| 33688 |
vshift |
| 33689 |
) |
| 33690 |
else |
| 33691 |
character.commands={ |
| 33692 |
hshift, |
| 33693 |
vshift, |
| 33694 |
charcommand[unicode] |
| 33695 |
} |
| 33696 |
end |
| 33697 |
else |
| 33698 |
if commands then |
| 33699 |
prependcommands (commands, |
| 33700 |
hshift |
| 33701 |
) |
| 33702 |
else |
| 33703 |
character.commands={ |
| 33704 |
hshift, |
| 33705 |
charcommand[unicode] |
| 33706 |
} |
| 33707 |
end |
| 33708 |
end |
| 33709 |
end |
| 33710 |
if oldheight and oldheight>0 then |
| 33711 |
character.height=oldheight+hdelta |
| 33712 |
end |
| 33713 |
if olddepth and olddepth>0 then |
| 33714 |
character.depth=olddepth+ddelta |
| 33715 |
end |
| 33716 |
end |
| 33717 |
if mathparameters then |
| 33718 |
setmathparameters(tfmdata,characters,mathparameters,dx,dy,squeeze,multiplier) |
| 33719 |
setmathcharacters(tfmdata,characters,mathparameters,dx,dy,squeeze,wdelta,hdelta,ddelta) |
| 33720 |
end |
| 33721 |
parameters.factor=factor |
| 33722 |
parameters.hfactor=hfactor |
| 33723 |
parameters.vfactor=vfactor |
| 33724 |
if trace then |
| 33725 |
report_effect("applying") |
| 33726 |
report_effect(" effect : %s",effect.effect) |
| 33727 |
report_effect(" width : %s => %s",effect.width,multiplier) |
| 33728 |
report_effect(" factor : %s => %s",effect.factor,factor ) |
| 33729 |
report_effect(" hfactor : %s => %s",effect.hfactor,hfactor) |
| 33730 |
report_effect(" vfactor : %s => %s",effect.vfactor,vfactor) |
| 33731 |
report_effect(" wdelta : %s => %s",effect.wdelta,wdelta) |
| 33732 |
report_effect(" hdelta : %s => %s",effect.hdelta,hdelta) |
| 33733 |
report_effect(" ddelta : %s => %s",effect.ddelta,ddelta) |
| 33734 |
end |
| 33735 |
end |
| 33736 |
end |
| 33737 |
local specification={ |
| 33738 |
name="effect", |
| 33739 |
description="apply effects to glyphs", |
| 33740 |
initializers={ |
| 33741 |
base=initializeeffect, |
| 33742 |
node=initializeeffect, |
| 33743 |
}, |
| 33744 |
manipulators={ |
| 33745 |
base=manipulateeffect, |
| 33746 |
node=manipulateeffect, |
| 33747 |
}, |
| 33748 |
} |
| 33749 |
registerotffeature(specification) |
| 33750 |
registerafmfeature(specification) |
| 33751 |
local function initializeoutline(tfmdata,value) |
| 33752 |
value=tonumber(value) |
| 33753 |
if not value then |
| 33754 |
value=0 |
| 33755 |
else |
| 33756 |
value=tonumber(value) or 0 |
| 33757 |
end |
| 33758 |
local parameters=tfmdata.parameters |
| 33759 |
local properties=tfmdata.properties |
| 33760 |
parameters.mode=effects.outline |
| 33761 |
parameters.width=value*1000 |
| 33762 |
properties.effect={ |
| 33763 |
effect=effect, |
| 33764 |
width=width, |
| 33765 |
} |
| 33766 |
end |
| 33767 |
local specification={ |
| 33768 |
name="outline", |
| 33769 |
description="outline glyphs", |
| 33770 |
initializers={ |
| 33771 |
base=initializeoutline, |
| 33772 |
node=initializeoutline, |
| 33773 |
} |
| 33774 |
} |
| 33775 |
registerotffeature(specification) |
| 33776 |
registerafmfeature(specification) |
| 33777 |
|
| 33778 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “font-imp-effects”] --- |
| 33779 |
|
| 33780 |
|
| 33781 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-lig” fbd251eea3810a43a8d5542319361d68] --- |
| 33782 |
|
| 33783 |
|
| 33784 |
fonts.handlers.otf.addfeature { |
| 33785 |
["dataset"]={ |
| 33786 |
{ |
| 33787 |
["data"]={ |
| 33788 |
["À"]={ "A","̀" }, |
| 33789 |
["Á"]={ "A","́" }, |
| 33790 |
["Â"]={ "A","̂" }, |
| 33791 |
["Ã"]={ "A","̃" }, |
| 33792 |
["Ä"]={ "A","̈" }, |
| 33793 |
["Å"]={ "A","̊" }, |
| 33794 |
["Ç"]={ "C","̧" }, |
| 33795 |
["È"]={ "E","̀" }, |
| 33796 |
["É"]={ "E","́" }, |
| 33797 |
["Ê"]={ "E","̂" }, |
| 33798 |
["Ë"]={ "E","̈" }, |
| 33799 |
["Ì"]={ "I","̀" }, |
| 33800 |
["Í"]={ "I","́" }, |
| 33801 |
["Î"]={ "I","̂" }, |
| 33802 |
["Ï"]={ "I","̈" }, |
| 33803 |
["Ñ"]={ "N","̃" }, |
| 33804 |
["Ò"]={ "O","̀" }, |
| 33805 |
["Ó"]={ "O","́" }, |
| 33806 |
["Ô"]={ "O","̂" }, |
| 33807 |
["Õ"]={ "O","̃" }, |
| 33808 |
["Ö"]={ "O","̈" }, |
| 33809 |
["Ù"]={ "U","̀" }, |
| 33810 |
["Ú"]={ "U","́" }, |
| 33811 |
["Û"]={ "U","̂" }, |
| 33812 |
["Ü"]={ "U","̈" }, |
| 33813 |
["Ý"]={ "Y","́" }, |
| 33814 |
["à"]={ "a","̀" }, |
| 33815 |
["á"]={ "a","́" }, |
| 33816 |
["â"]={ "a","̂" }, |
| 33817 |
["ã"]={ "a","̃" }, |
| 33818 |
["ä"]={ "a","̈" }, |
| 33819 |
["å"]={ "a","̊" }, |
| 33820 |
["ç"]={ "c","̧" }, |
| 33821 |
["è"]={ "e","̀" }, |
| 33822 |
["é"]={ "e","́" }, |
| 33823 |
["ê"]={ "e","̂" }, |
| 33824 |
["ë"]={ "e","̈" }, |
| 33825 |
["ì"]={ "i","̀" }, |
| 33826 |
["í"]={ "i","́" }, |
| 33827 |
["î"]={ "i","̂" }, |
| 33828 |
["ï"]={ "i","̈" }, |
| 33829 |
["ñ"]={ "n","̃" }, |
| 33830 |
["ò"]={ "o","̀" }, |
| 33831 |
["ó"]={ "o","́" }, |
| 33832 |
["ô"]={ "o","̂" }, |
| 33833 |
["õ"]={ "o","̃" }, |
| 33834 |
["ö"]={ "o","̈" }, |
| 33835 |
["ù"]={ "u","̀" }, |
| 33836 |
["ú"]={ "u","́" }, |
| 33837 |
["û"]={ "u","̂" }, |
| 33838 |
["ü"]={ "u","̈" }, |
| 33839 |
["ý"]={ "y","́" }, |
| 33840 |
["ÿ"]={ "y","̈" }, |
| 33841 |
["Ā"]={ "A","̄" }, |
| 33842 |
["ā"]={ "a","̄" }, |
| 33843 |
["Ă"]={ "A","̆" }, |
| 33844 |
["ă"]={ "a","̆" }, |
| 33845 |
["Ą"]={ "A","̨" }, |
| 33846 |
["ą"]={ "a","̨" }, |
| 33847 |
["Ć"]={ "C","́" }, |
| 33848 |
["ć"]={ "c","́" }, |
| 33849 |
["Ĉ"]={ "C","̂" }, |
| 33850 |
["ĉ"]={ "c","̂" }, |
| 33851 |
["Ċ"]={ "C","̇" }, |
| 33852 |
["ċ"]={ "c","̇" }, |
| 33853 |
["Č"]={ "C","̌" }, |
| 33854 |
["č"]={ "c","̌" }, |
| 33855 |
["Ď"]={ "D","̌" }, |
| 33856 |
["ď"]={ "d","̌" }, |
| 33857 |
["Ē"]={ "E","̄" }, |
| 33858 |
["ē"]={ "e","̄" }, |
| 33859 |
["Ĕ"]={ "E","̆" }, |
| 33860 |
["ĕ"]={ "e","̆" }, |
| 33861 |
["Ė"]={ "E","̇" }, |
| 33862 |
["ė"]={ "e","̇" }, |
| 33863 |
["Ę"]={ "E","̨" }, |
| 33864 |
["ę"]={ "e","̨" }, |
| 33865 |
["Ě"]={ "E","̌" }, |
| 33866 |
["ě"]={ "e","̌" }, |
| 33867 |
["Ĝ"]={ "G","̂" }, |
| 33868 |
["ĝ"]={ "g","̂" }, |
| 33869 |
["Ğ"]={ "G","̆" }, |
| 33870 |
["ğ"]={ "g","̆" }, |
| 33871 |
["Ġ"]={ "G","̇" }, |
| 33872 |
["ġ"]={ "g","̇" }, |
| 33873 |
["Ģ"]={ "G","̧" }, |
| 33874 |
["ģ"]={ "g","̧" }, |
| 33875 |
["Ĥ"]={ "H","̂" }, |
| 33876 |
["ĥ"]={ "h","̂" }, |
| 33877 |
["Ĩ"]={ "I","̃" }, |
| 33878 |
["ĩ"]={ "i","̃" }, |
| 33879 |
["Ī"]={ "I","̄" }, |
| 33880 |
["ī"]={ "i","̄" }, |
| 33881 |
["Ĭ"]={ "I","̆" }, |
| 33882 |
["ĭ"]={ "i","̆" }, |
| 33883 |
["Į"]={ "I","̨" }, |
| 33884 |
["į"]={ "i","̨" }, |
| 33885 |
["İ"]={ "I","̇" }, |
| 33886 |
["Ĵ"]={ "J","̂" }, |
| 33887 |
["ĵ"]={ "j","̂" }, |
| 33888 |
["Ķ"]={ "K","̧" }, |
| 33889 |
["ķ"]={ "k","̧" }, |
| 33890 |
["Ĺ"]={ "L","́" }, |
| 33891 |
["ĺ"]={ "l","́" }, |
| 33892 |
["Ļ"]={ "L","̧" }, |
| 33893 |
["ļ"]={ "l","̧" }, |
| 33894 |
["Ľ"]={ "L","̌" }, |
| 33895 |
["ľ"]={ "l","̌" }, |
| 33896 |
["Ń"]={ "N","́" }, |
| 33897 |
["ń"]={ "n","́" }, |
| 33898 |
["Ņ"]={ "N","̧" }, |
| 33899 |
["ņ"]={ "n","̧" }, |
| 33900 |
["Ň"]={ "N","̌" }, |
| 33901 |
["ň"]={ "n","̌" }, |
| 33902 |
["Ō"]={ "O","̄" }, |
| 33903 |
["ō"]={ "o","̄" }, |
| 33904 |
["Ŏ"]={ "O","̆" }, |
| 33905 |
["ŏ"]={ "o","̆" }, |
| 33906 |
["Ő"]={ "O","̋" }, |
| 33907 |
["ő"]={ "o","̋" }, |
| 33908 |
["Ŕ"]={ "R","́" }, |
| 33909 |
["ŕ"]={ "r","́" }, |
| 33910 |
["Ŗ"]={ "R","̧" }, |
| 33911 |
["ŗ"]={ "r","̧" }, |
| 33912 |
["Ř"]={ "R","̌" }, |
| 33913 |
["ř"]={ "r","̌" }, |
| 33914 |
["Ś"]={ "S","́" }, |
| 33915 |
["ś"]={ "s","́" }, |
| 33916 |
["Ŝ"]={ "S","̂" }, |
| 33917 |
["ŝ"]={ "s","̂" }, |
| 33918 |
["Ş"]={ "S","̧" }, |
| 33919 |
["ş"]={ "s","̧" }, |
| 33920 |
["Š"]={ "S","̌" }, |
| 33921 |
["š"]={ "s","̌" }, |
| 33922 |
["Ţ"]={ "T","̧" }, |
| 33923 |
["ţ"]={ "t","̧" }, |
| 33924 |
["Ť"]={ "T","̌" }, |
| 33925 |
["ť"]={ "t","̌" }, |
| 33926 |
["Ũ"]={ "U","̃" }, |
| 33927 |
["ũ"]={ "u","̃" }, |
| 33928 |
["Ū"]={ "U","̄" }, |
| 33929 |
["ū"]={ "u","̄" }, |
| 33930 |
["Ŭ"]={ "U","̆" }, |
| 33931 |
["ŭ"]={ "u","̆" }, |
| 33932 |
["Ů"]={ "U","̊" }, |
| 33933 |
["ů"]={ "u","̊" }, |
| 33934 |
["Ű"]={ "U","̋" }, |
| 33935 |
["ű"]={ "u","̋" }, |
| 33936 |
["Ų"]={ "U","̨" }, |
| 33937 |
["ų"]={ "u","̨" }, |
| 33938 |
["Ŵ"]={ "W","̂" }, |
| 33939 |
["ŵ"]={ "w","̂" }, |
| 33940 |
["Ŷ"]={ "Y","̂" }, |
| 33941 |
["ŷ"]={ "y","̂" }, |
| 33942 |
["Ÿ"]={ "Y","̈" }, |
| 33943 |
["Ź"]={ "Z","́" }, |
| 33944 |
["ź"]={ "z","́" }, |
| 33945 |
["Ż"]={ "Z","̇" }, |
| 33946 |
["ż"]={ "z","̇" }, |
| 33947 |
["Ž"]={ "Z","̌" }, |
| 33948 |
["ž"]={ "z","̌" }, |
| 33949 |
["Ơ"]={ "O","̛" }, |
| 33950 |
["ơ"]={ "o","̛" }, |
| 33951 |
["Ư"]={ "U","̛" }, |
| 33952 |
["ư"]={ "u","̛" }, |
| 33953 |
["Ǎ"]={ "A","̌" }, |
| 33954 |
["ǎ"]={ "a","̌" }, |
| 33955 |
["Ǐ"]={ "I","̌" }, |
| 33956 |
["ǐ"]={ "i","̌" }, |
| 33957 |
["Ǒ"]={ "O","̌" }, |
| 33958 |
["ǒ"]={ "o","̌" }, |
| 33959 |
["Ǔ"]={ "U","̌" }, |
| 33960 |
["ǔ"]={ "u","̌" }, |
| 33961 |
["Ǖ"]={ "Ü","̄" }, |
| 33962 |
["ǖ"]={ "ü","̄" }, |
| 33963 |
["Ǘ"]={ "Ü","́" }, |
| 33964 |
["ǘ"]={ "ü","́" }, |
| 33965 |
["Ǚ"]={ "Ü","̌" }, |
| 33966 |
["ǚ"]={ "ü","̌" }, |
| 33967 |
["Ǜ"]={ "Ü","̀" }, |
| 33968 |
["ǜ"]={ "ü","̀" }, |
| 33969 |
["Ǟ"]={ "Ä","̄" }, |
| 33970 |
["ǟ"]={ "ä","̄" }, |
| 33971 |
["Ǡ"]={ "Ȧ","̄" }, |
| 33972 |
["ǡ"]={ "ȧ","̄" }, |
| 33973 |
["Ǣ"]={ "Æ","̄" }, |
| 33974 |
["ǣ"]={ "æ","̄" }, |
| 33975 |
["Ǧ"]={ "G","̌" }, |
| 33976 |
["ǧ"]={ "g","̌" }, |
| 33977 |
["Ǩ"]={ "K","̌" }, |
| 33978 |
["ǩ"]={ "k","̌" }, |
| 33979 |
["Ǫ"]={ "O","̨" }, |
| 33980 |
["ǫ"]={ "o","̨" }, |
| 33981 |
["Ǭ"]={ "Ǫ","̄" }, |
| 33982 |
["ǭ"]={ "ǫ","̄" }, |
| 33983 |
["Ǯ"]={ "Ʒ","̌" }, |
| 33984 |
["ǯ"]={ "ʒ","̌" }, |
| 33985 |
["ǰ"]={ "j","̌" }, |
| 33986 |
["Ǵ"]={ "G","́" }, |
| 33987 |
["ǵ"]={ "g","́" }, |
| 33988 |
["Ǹ"]={ "N","̀" }, |
| 33989 |
["ǹ"]={ "n","̀" }, |
| 33990 |
["Ǻ"]={ "Å","́" }, |
| 33991 |
["ǻ"]={ "å","́" }, |
| 33992 |
["Ǽ"]={ "Æ","́" }, |
| 33993 |
["ǽ"]={ "æ","́" }, |
| 33994 |
["Ǿ"]={ "Ø","́" }, |
| 33995 |
["ǿ"]={ "ø","́" }, |
| 33996 |
["Ȁ"]={ "A","̏" }, |
| 33997 |
["ȁ"]={ "a","̏" }, |
| 33998 |
["Ȃ"]={ "A","̑" }, |
| 33999 |
["ȃ"]={ "a","̑" }, |
| 34000 |
["Ȅ"]={ "E","̏" }, |
| 34001 |
["ȅ"]={ "e","̏" }, |
| 34002 |
["Ȇ"]={ "E","̑" }, |
| 34003 |
["ȇ"]={ "e","̑" }, |
| 34004 |
["Ȉ"]={ "I","̏" }, |
| 34005 |
["ȉ"]={ "i","̏" }, |
| 34006 |
["Ȋ"]={ "I","̑" }, |
| 34007 |
["ȋ"]={ "i","̑" }, |
| 34008 |
["Ȍ"]={ "O","̏" }, |
| 34009 |
["ȍ"]={ "o","̏" }, |
| 34010 |
["Ȏ"]={ "O","̑" }, |
| 34011 |
["ȏ"]={ "o","̑" }, |
| 34012 |
["Ȑ"]={ "R","̏" }, |
| 34013 |
["ȑ"]={ "r","̏" }, |
| 34014 |
["Ȓ"]={ "R","̑" }, |
| 34015 |
["ȓ"]={ "r","̑" }, |
| 34016 |
["Ȕ"]={ "U","̏" }, |
| 34017 |
["ȕ"]={ "u","̏" }, |
| 34018 |
["Ȗ"]={ "U","̑" }, |
| 34019 |
["ȗ"]={ "u","̑" }, |
| 34020 |
["Ș"]={ "S","̦" }, |
| 34021 |
["ș"]={ "s","̦" }, |
| 34022 |
["Ț"]={ "T","̦" }, |
| 34023 |
["ț"]={ "t","̦" }, |
| 34024 |
["Ȟ"]={ "H","̌" }, |
| 34025 |
["ȟ"]={ "h","̌" }, |
| 34026 |
["Ȧ"]={ "A","̇" }, |
| 34027 |
["ȧ"]={ "a","̇" }, |
| 34028 |
["Ȩ"]={ "E","̧" }, |
| 34029 |
["ȩ"]={ "e","̧" }, |
| 34030 |
["Ȫ"]={ "Ö","̄" }, |
| 34031 |
["ȫ"]={ "ö","̄" }, |
| 34032 |
["Ȭ"]={ "Õ","̄" }, |
| 34033 |
["ȭ"]={ "õ","̄" }, |
| 34034 |
["Ȯ"]={ "O","̇" }, |
| 34035 |
["ȯ"]={ "o","̇" }, |
| 34036 |
["Ȱ"]={ "Ȯ","̄" }, |
| 34037 |
["ȱ"]={ "ȯ","̄" }, |
| 34038 |
["Ȳ"]={ "Y","̄" }, |
| 34039 |
["ȳ"]={ "y","̄" }, |
| 34040 |
["̈́"]={ "̈","́" }, |
| 34041 |
["΅"]={ "¨","́" }, |
| 34042 |
["Ά"]={ "Α","́" }, |
| 34043 |
["Έ"]={ "Ε","́" }, |
| 34044 |
["Ή"]={ "Η","́" }, |
| 34045 |
["Ί"]={ "Ι","́" }, |
| 34046 |
["Ό"]={ "Ο","́" }, |
| 34047 |
["Ύ"]={ "Υ","́" }, |
| 34048 |
["Ώ"]={ "Ω","́" }, |
| 34049 |
["ΐ"]={ "ϊ","́" }, |
| 34050 |
["Ϊ"]={ "Ι","̈" }, |
| 34051 |
["Ϋ"]={ "Υ","̈" }, |
| 34052 |
["ά"]={ "α","́" }, |
| 34053 |
["έ"]={ "ε","́" }, |
| 34054 |
["ή"]={ "η","́" }, |
| 34055 |
["ί"]={ "ι","́" }, |
| 34056 |
["ΰ"]={ "ϋ","́" }, |
| 34057 |
["ϊ"]={ "ι","̈" }, |
| 34058 |
["ϋ"]={ "υ","̈" }, |
| 34059 |
["ό"]={ "ο","́" }, |
| 34060 |
["ύ"]={ "υ","́" }, |
| 34061 |
["ώ"]={ "ω","́" }, |
| 34062 |
["ϓ"]={ "ϒ","́" }, |
| 34063 |
["ϔ"]={ "ϒ","̈" }, |
| 34064 |
["Ѐ"]={ "Е","̀" }, |
| 34065 |
["Ё"]={ "Е","̈" }, |
| 34066 |
["Ѓ"]={ "Г","́" }, |
| 34067 |
["Ї"]={ "І","̈" }, |
| 34068 |
["Ќ"]={ "К","́" }, |
| 34069 |
["Ѝ"]={ "И","̀" }, |
| 34070 |
["Ў"]={ "У","̆" }, |
| 34071 |
["Й"]={ "И","̆" }, |
| 34072 |
["й"]={ "и","̆" }, |
| 34073 |
["ѐ"]={ "е","̀" }, |
| 34074 |
["ё"]={ "е","̈" }, |
| 34075 |
["ѓ"]={ "г","́" }, |
| 34076 |
["ї"]={ "і","̈" }, |
| 34077 |
["ќ"]={ "к","́" }, |
| 34078 |
["ѝ"]={ "и","̀" }, |
| 34079 |
["ў"]={ "у","̆" }, |
| 34080 |
["Ѷ"]={ "Ѵ","̏" }, |
| 34081 |
["ѷ"]={ "ѵ","̏" }, |
| 34082 |
["Ӂ"]={ "Ж","̆" }, |
| 34083 |
["ӂ"]={ "ж","̆" }, |
| 34084 |
["Ӑ"]={ "А","̆" }, |
| 34085 |
["ӑ"]={ "а","̆" }, |
| 34086 |
["Ӓ"]={ "А","̈" }, |
| 34087 |
["ӓ"]={ "а","̈" }, |
| 34088 |
["Ӗ"]={ "Е","̆" }, |
| 34089 |
["ӗ"]={ "е","̆" }, |
| 34090 |
["Ӛ"]={ "Ә","̈" }, |
| 34091 |
["ӛ"]={ "ә","̈" }, |
| 34092 |
["Ӝ"]={ "Ж","̈" }, |
| 34093 |
["ӝ"]={ "ж","̈" }, |
| 34094 |
["Ӟ"]={ "З","̈" }, |
| 34095 |
["ӟ"]={ "з","̈" }, |
| 34096 |
["Ӣ"]={ "И","̄" }, |
| 34097 |
["ӣ"]={ "и","̄" }, |
| 34098 |
["Ӥ"]={ "И","̈" }, |
| 34099 |
["ӥ"]={ "и","̈" }, |
| 34100 |
["Ӧ"]={ "О","̈" }, |
| 34101 |
["ӧ"]={ "о","̈" }, |
| 34102 |
["Ӫ"]={ "Ө","̈" }, |
| 34103 |
["ӫ"]={ "ө","̈" }, |
| 34104 |
["Ӭ"]={ "Э","̈" }, |
| 34105 |
["ӭ"]={ "э","̈" }, |
| 34106 |
["Ӯ"]={ "У","̄" }, |
| 34107 |
["ӯ"]={ "у","̄" }, |
| 34108 |
["Ӱ"]={ "У","̈" }, |
| 34109 |
["ӱ"]={ "у","̈" }, |
| 34110 |
["Ӳ"]={ "У","̋" }, |
| 34111 |
["ӳ"]={ "у","̋" }, |
| 34112 |
["Ӵ"]={ "Ч","̈" }, |
| 34113 |
["ӵ"]={ "ч","̈" }, |
| 34114 |
["Ӹ"]={ "Ы","̈" }, |
| 34115 |
["ӹ"]={ "ы","̈" }, |
| 34116 |
["آ"]={ "ا","ٓ" }, |
| 34117 |
["أ"]={ "ا","ٔ" }, |
| 34118 |
["ؤ"]={ "و","ٔ" }, |
| 34119 |
["إ"]={ "ا","ٕ" }, |
| 34120 |
["ئ"]={ "ي","ٔ" }, |
| 34121 |
["ۀ"]={ "ە","ٔ" }, |
| 34122 |
["ۂ"]={ "ہ","ٔ" }, |
| 34123 |
["ۓ"]={ "ے","ٔ" }, |
| 34124 |
["ऩ"]={ "न","़" }, |
| 34125 |
["ऱ"]={ "र","़" }, |
| 34126 |
["ऴ"]={ "ळ","़" }, |
| 34127 |
["क़"]={ "क","़" }, |
| 34128 |
["ख़"]={ "ख","़" }, |
| 34129 |
["ग़"]={ "ग","़" }, |
| 34130 |
["ज़"]={ "ज","़" }, |
| 34131 |
["ड़"]={ "ड","़" }, |
| 34132 |
["ढ़"]={ "ढ","़" }, |
| 34133 |
["फ़"]={ "फ","़" }, |
| 34134 |
["य़"]={ "य","़" }, |
| 34135 |
["ো"]={ "ে","া" }, |
| 34136 |
["ৌ"]={ "ে","ৗ" }, |
| 34137 |
["ড়"]={ "ড","়" }, |
| 34138 |
["ঢ়"]={ "ঢ","়" }, |
| 34139 |
["য়"]={ "য","়" }, |
| 34140 |
["ਲ਼"]={ "ਲ","਼" }, |
| 34141 |
["ਸ਼"]={ "ਸ","਼" }, |
| 34142 |
["ਖ਼"]={ "ਖ","਼" }, |
| 34143 |
["ਗ਼"]={ "ਗ","਼" }, |
| 34144 |
["ਜ਼"]={ "ਜ","਼" }, |
| 34145 |
["ਫ਼"]={ "ਫ","਼" }, |
| 34146 |
["ୈ"]={ "େ","ୖ" }, |
| 34147 |
["ୋ"]={ "େ","ା" }, |
| 34148 |
["ୌ"]={ "େ","ୗ" }, |
| 34149 |
["ଡ଼"]={ "ଡ","଼" }, |
| 34150 |
["ଢ଼"]={ "ଢ","଼" }, |
| 34151 |
["ஔ"]={ "ஒ","ௗ" }, |
| 34152 |
["ொ"]={ "ெ","ா" }, |
| 34153 |
["ோ"]={ "ே","ா" }, |
| 34154 |
["ௌ"]={ "ெ","ௗ" }, |
| 34155 |
["ై"]={ "ె","ౖ" }, |
| 34156 |
["ೀ"]={ "ಿ","ೕ" }, |
| 34157 |
["ೇ"]={ "ೆ","ೕ" }, |
| 34158 |
["ೈ"]={ "ೆ","ೖ" }, |
| 34159 |
["ೊ"]={ "ೆ","ೂ" }, |
| 34160 |
["ೋ"]={ "ೊ","ೕ" }, |
| 34161 |
["ൊ"]={ "െ","ാ" }, |
| 34162 |
["ോ"]={ "േ","ാ" }, |
| 34163 |
["ൌ"]={ "െ","ൗ" }, |
| 34164 |
["ේ"]={ "ෙ","්" }, |
| 34165 |
["ො"]={ "ෙ","ා" }, |
| 34166 |
["ෝ"]={ "ො","්" }, |
| 34167 |
["ෞ"]={ "ෙ","ෟ" }, |
| 34168 |
["གྷ"]={ "ག","ྷ" }, |
| 34169 |
["ཌྷ"]={ "ཌ","ྷ" }, |
| 34170 |
["དྷ"]={ "ད","ྷ" }, |
| 34171 |
["བྷ"]={ "བ","ྷ" }, |
| 34172 |
["ཛྷ"]={ "ཛ","ྷ" }, |
| 34173 |
["ཀྵ"]={ "ཀ","ྵ" }, |
| 34174 |
["ཱི"]={ "ཱ","ི" }, |
| 34175 |
["ཱུ"]={ "ཱ","ུ" }, |
| 34176 |
["ྲྀ"]={ "ྲ","ྀ" }, |
| 34177 |
["ླྀ"]={ "ླ","ྀ" }, |
| 34178 |
["ཱྀ"]={ "ཱ","ྀ" }, |
| 34179 |
["ྒྷ"]={ "ྒ","ྷ" }, |
| 34180 |
["ྜྷ"]={ "ྜ","ྷ" }, |
| 34181 |
["ྡྷ"]={ "ྡ","ྷ" }, |
| 34182 |
["ྦྷ"]={ "ྦ","ྷ" }, |
| 34183 |
["ྫྷ"]={ "ྫ","ྷ" }, |
| 34184 |
["ྐྵ"]={ "ྐ","ྵ" }, |
| 34185 |
["ဦ"]={ "ဥ","ီ" }, |
| 34186 |
["ᬆ"]={ "ᬅ","ᬵ" }, |
| 34187 |
["ᬈ"]={ "ᬇ","ᬵ" }, |
| 34188 |
["ᬊ"]={ "ᬉ","ᬵ" }, |
| 34189 |
["ᬌ"]={ "ᬋ","ᬵ" }, |
| 34190 |
["ᬎ"]={ "ᬍ","ᬵ" }, |
| 34191 |
["ᬒ"]={ "ᬑ","ᬵ" }, |
| 34192 |
["ᬻ"]={ "ᬺ","ᬵ" }, |
| 34193 |
["ᬽ"]={ "ᬼ","ᬵ" }, |
| 34194 |
["ᭀ"]={ "ᬾ","ᬵ" }, |
| 34195 |
["ᭁ"]={ "ᬿ","ᬵ" }, |
| 34196 |
["ᭃ"]={ "ᭂ","ᬵ" }, |
| 34197 |
["Ḁ"]={ "A","̥" }, |
| 34198 |
["ḁ"]={ "a","̥" }, |
| 34199 |
["Ḃ"]={ "B","̇" }, |
| 34200 |
["ḃ"]={ "b","̇" }, |
| 34201 |
["Ḅ"]={ "B","̣" }, |
| 34202 |
["ḅ"]={ "b","̣" }, |
| 34203 |
["Ḇ"]={ "B","̱" }, |
| 34204 |
["ḇ"]={ "b","̱" }, |
| 34205 |
["Ḉ"]={ "Ç","́" }, |
| 34206 |
["ḉ"]={ "ç","́" }, |
| 34207 |
["Ḋ"]={ "D","̇" }, |
| 34208 |
["ḋ"]={ "d","̇" }, |
| 34209 |
["Ḍ"]={ "D","̣" }, |
| 34210 |
["ḍ"]={ "d","̣" }, |
| 34211 |
["Ḏ"]={ "D","̱" }, |
| 34212 |
["ḏ"]={ "d","̱" }, |
| 34213 |
["Ḑ"]={ "D","̧" }, |
| 34214 |
["ḑ"]={ "d","̧" }, |
| 34215 |
["Ḓ"]={ "D","̭" }, |
| 34216 |
["ḓ"]={ "d","̭" }, |
| 34217 |
["Ḕ"]={ "Ē","̀" }, |
| 34218 |
["ḕ"]={ "ē","̀" }, |
| 34219 |
["Ḗ"]={ "Ē","́" }, |
| 34220 |
["ḗ"]={ "ē","́" }, |
| 34221 |
["Ḙ"]={ "E","̭" }, |
| 34222 |
["ḙ"]={ "e","̭" }, |
| 34223 |
["Ḛ"]={ "E","̰" }, |
| 34224 |
["ḛ"]={ "e","̰" }, |
| 34225 |
["Ḝ"]={ "Ȩ","̆" }, |
| 34226 |
["ḝ"]={ "ȩ","̆" }, |
| 34227 |
["Ḟ"]={ "F","̇" }, |
| 34228 |
["ḟ"]={ "f","̇" }, |
| 34229 |
["Ḡ"]={ "G","̄" }, |
| 34230 |
["ḡ"]={ "g","̄" }, |
| 34231 |
["Ḣ"]={ "H","̇" }, |
| 34232 |
["ḣ"]={ "h","̇" }, |
| 34233 |
["Ḥ"]={ "H","̣" }, |
| 34234 |
["ḥ"]={ "h","̣" }, |
| 34235 |
["Ḧ"]={ "H","̈" }, |
| 34236 |
["ḧ"]={ "h","̈" }, |
| 34237 |
["Ḩ"]={ "H","̧" }, |
| 34238 |
["ḩ"]={ "h","̧" }, |
| 34239 |
["Ḫ"]={ "H","̮" }, |
| 34240 |
["ḫ"]={ "h","̮" }, |
| 34241 |
["Ḭ"]={ "I","̰" }, |
| 34242 |
["ḭ"]={ "i","̰" }, |
| 34243 |
["Ḯ"]={ "Ï","́" }, |
| 34244 |
["ḯ"]={ "ï","́" }, |
| 34245 |
["Ḱ"]={ "K","́" }, |
| 34246 |
["ḱ"]={ "k","́" }, |
| 34247 |
["Ḳ"]={ "K","̣" }, |
| 34248 |
["ḳ"]={ "k","̣" }, |
| 34249 |
["Ḵ"]={ "K","̱" }, |
| 34250 |
["ḵ"]={ "k","̱" }, |
| 34251 |
["Ḷ"]={ "L","̣" }, |
| 34252 |
["ḷ"]={ "l","̣" }, |
| 34253 |
["Ḹ"]={ "Ḷ","̄" }, |
| 34254 |
["ḹ"]={ "ḷ","̄" }, |
| 34255 |
["Ḻ"]={ "L","̱" }, |
| 34256 |
["ḻ"]={ "l","̱" }, |
| 34257 |
["Ḽ"]={ "L","̭" }, |
| 34258 |
["ḽ"]={ "l","̭" }, |
| 34259 |
["Ḿ"]={ "M","́" }, |
| 34260 |
["ḿ"]={ "m","́" }, |
| 34261 |
["Ṁ"]={ "M","̇" }, |
| 34262 |
["ṁ"]={ "m","̇" }, |
| 34263 |
["Ṃ"]={ "M","̣" }, |
| 34264 |
["ṃ"]={ "m","̣" }, |
| 34265 |
["Ṅ"]={ "N","̇" }, |
| 34266 |
["ṅ"]={ "n","̇" }, |
| 34267 |
["Ṇ"]={ "N","̣" }, |
| 34268 |
["ṇ"]={ "n","̣" }, |
| 34269 |
["Ṉ"]={ "N","̱" }, |
| 34270 |
["ṉ"]={ "n","̱" }, |
| 34271 |
["Ṋ"]={ "N","̭" }, |
| 34272 |
["ṋ"]={ "n","̭" }, |
| 34273 |
["Ṍ"]={ "Õ","́" }, |
| 34274 |
["ṍ"]={ "õ","́" }, |
| 34275 |
["Ṏ"]={ "Õ","̈" }, |
| 34276 |
["ṏ"]={ "õ","̈" }, |
| 34277 |
["Ṑ"]={ "Ō","̀" }, |
| 34278 |
["ṑ"]={ "ō","̀" }, |
| 34279 |
["Ṓ"]={ "Ō","́" }, |
| 34280 |
["ṓ"]={ "ō","́" }, |
| 34281 |
["Ṕ"]={ "P","́" }, |
| 34282 |
["ṕ"]={ "p","́" }, |
| 34283 |
["Ṗ"]={ "P","̇" }, |
| 34284 |
["ṗ"]={ "p","̇" }, |
| 34285 |
["Ṙ"]={ "R","̇" }, |
| 34286 |
["ṙ"]={ "r","̇" }, |
| 34287 |
["Ṛ"]={ "R","̣" }, |
| 34288 |
["ṛ"]={ "r","̣" }, |
| 34289 |
["Ṝ"]={ "Ṛ","̄" }, |
| 34290 |
["ṝ"]={ "ṛ","̄" }, |
| 34291 |
["Ṟ"]={ "R","̱" }, |
| 34292 |
["ṟ"]={ "r","̱" }, |
| 34293 |
["Ṡ"]={ "S","̇" }, |
| 34294 |
["ṡ"]={ "s","̇" }, |
| 34295 |
["Ṣ"]={ "S","̣" }, |
| 34296 |
["ṣ"]={ "s","̣" }, |
| 34297 |
["Ṥ"]={ "Ś","̇" }, |
| 34298 |
["ṥ"]={ "ś","̇" }, |
| 34299 |
["Ṧ"]={ "Š","̇" }, |
| 34300 |
["ṧ"]={ "š","̇" }, |
| 34301 |
["Ṩ"]={ "Ṣ","̇" }, |
| 34302 |
["ṩ"]={ "ṣ","̇" }, |
| 34303 |
["Ṫ"]={ "T","̇" }, |
| 34304 |
["ṫ"]={ "t","̇" }, |
| 34305 |
["Ṭ"]={ "T","̣" }, |
| 34306 |
["ṭ"]={ "t","̣" }, |
| 34307 |
["Ṯ"]={ "T","̱" }, |
| 34308 |
["ṯ"]={ "t","̱" }, |
| 34309 |
["Ṱ"]={ "T","̭" }, |
| 34310 |
["ṱ"]={ "t","̭" }, |
| 34311 |
["Ṳ"]={ "U","̤" }, |
| 34312 |
["ṳ"]={ "u","̤" }, |
| 34313 |
["Ṵ"]={ "U","̰" }, |
| 34314 |
["ṵ"]={ "u","̰" }, |
| 34315 |
["Ṷ"]={ "U","̭" }, |
| 34316 |
["ṷ"]={ "u","̭" }, |
| 34317 |
["Ṹ"]={ "Ũ","́" }, |
| 34318 |
["ṹ"]={ "ũ","́" }, |
| 34319 |
["Ṻ"]={ "Ū","̈" }, |
| 34320 |
["ṻ"]={ "ū","̈" }, |
| 34321 |
["Ṽ"]={ "V","̃" }, |
| 34322 |
["ṽ"]={ "v","̃" }, |
| 34323 |
["Ṿ"]={ "V","̣" }, |
| 34324 |
["ṿ"]={ "v","̣" }, |
| 34325 |
["Ẁ"]={ "W","̀" }, |
| 34326 |
["ẁ"]={ "w","̀" }, |
| 34327 |
["Ẃ"]={ "W","́" }, |
| 34328 |
["ẃ"]={ "w","́" }, |
| 34329 |
["Ẅ"]={ "W","̈" }, |
| 34330 |
["ẅ"]={ "w","̈" }, |
| 34331 |
["Ẇ"]={ "W","̇" }, |
| 34332 |
["ẇ"]={ "w","̇" }, |
| 34333 |
["Ẉ"]={ "W","̣" }, |
| 34334 |
["ẉ"]={ "w","̣" }, |
| 34335 |
["Ẋ"]={ "X","̇" }, |
| 34336 |
["ẋ"]={ "x","̇" }, |
| 34337 |
["Ẍ"]={ "X","̈" }, |
| 34338 |
["ẍ"]={ "x","̈" }, |
| 34339 |
["Ẏ"]={ "Y","̇" }, |
| 34340 |
["ẏ"]={ "y","̇" }, |
| 34341 |
["Ẑ"]={ "Z","̂" }, |
| 34342 |
["ẑ"]={ "z","̂" }, |
| 34343 |
["Ẓ"]={ "Z","̣" }, |
| 34344 |
["ẓ"]={ "z","̣" }, |
| 34345 |
["Ẕ"]={ "Z","̱" }, |
| 34346 |
["ẕ"]={ "z","̱" }, |
| 34347 |
["ẖ"]={ "h","̱" }, |
| 34348 |
["ẗ"]={ "t","̈" }, |
| 34349 |
["ẘ"]={ "w","̊" }, |
| 34350 |
["ẙ"]={ "y","̊" }, |
| 34351 |
["ẛ"]={ "ſ","̇" }, |
| 34352 |
["Ạ"]={ "A","̣" }, |
| 34353 |
["ạ"]={ "a","̣" }, |
| 34354 |
["Ả"]={ "A","̉" }, |
| 34355 |
["ả"]={ "a","̉" }, |
| 34356 |
["Ấ"]={ "Â","́" }, |
| 34357 |
["ấ"]={ "â","́" }, |
| 34358 |
["Ầ"]={ "Â","̀" }, |
| 34359 |
["ầ"]={ "â","̀" }, |
| 34360 |
["Ẩ"]={ "Â","̉" }, |
| 34361 |
["ẩ"]={ "â","̉" }, |
| 34362 |
["Ẫ"]={ "Â","̃" }, |
| 34363 |
["ẫ"]={ "â","̃" }, |
| 34364 |
["Ậ"]={ "Ạ","̂" }, |
| 34365 |
["ậ"]={ "ạ","̂" }, |
| 34366 |
["Ắ"]={ "Ă","́" }, |
| 34367 |
["ắ"]={ "ă","́" }, |
| 34368 |
["Ằ"]={ "Ă","̀" }, |
| 34369 |
["ằ"]={ "ă","̀" }, |
| 34370 |
["Ẳ"]={ "Ă","̉" }, |
| 34371 |
["ẳ"]={ "ă","̉" }, |
| 34372 |
["Ẵ"]={ "Ă","̃" }, |
| 34373 |
["ẵ"]={ "ă","̃" }, |
| 34374 |
["Ặ"]={ "Ạ","̆" }, |
| 34375 |
["ặ"]={ "ạ","̆" }, |
| 34376 |
["Ẹ"]={ "E","̣" }, |
| 34377 |
["ẹ"]={ "e","̣" }, |
| 34378 |
["Ẻ"]={ "E","̉" }, |
| 34379 |
["ẻ"]={ "e","̉" }, |
| 34380 |
["Ẽ"]={ "E","̃" }, |
| 34381 |
["ẽ"]={ "e","̃" }, |
| 34382 |
["Ế"]={ "Ê","́" }, |
| 34383 |
["ế"]={ "ê","́" }, |
| 34384 |
["Ề"]={ "Ê","̀" }, |
| 34385 |
["ề"]={ "ê","̀" }, |
| 34386 |
["Ể"]={ "Ê","̉" }, |
| 34387 |
["ể"]={ "ê","̉" }, |
| 34388 |
["Ễ"]={ "Ê","̃" }, |
| 34389 |
["ễ"]={ "ê","̃" }, |
| 34390 |
["Ệ"]={ "Ẹ","̂" }, |
| 34391 |
["ệ"]={ "ẹ","̂" }, |
| 34392 |
["Ỉ"]={ "I","̉" }, |
| 34393 |
["ỉ"]={ "i","̉" }, |
| 34394 |
["Ị"]={ "I","̣" }, |
| 34395 |
["ị"]={ "i","̣" }, |
| 34396 |
["Ọ"]={ "O","̣" }, |
| 34397 |
["ọ"]={ "o","̣" }, |
| 34398 |
["Ỏ"]={ "O","̉" }, |
| 34399 |
["ỏ"]={ "o","̉" }, |
| 34400 |
["Ố"]={ "Ô","́" }, |
| 34401 |
["ố"]={ "ô","́" }, |
| 34402 |
["Ồ"]={ "Ô","̀" }, |
| 34403 |
["ồ"]={ "ô","̀" }, |
| 34404 |
["Ổ"]={ "Ô","̉" }, |
| 34405 |
["ổ"]={ "ô","̉" }, |
| 34406 |
["Ỗ"]={ "Ô","̃" }, |
| 34407 |
["ỗ"]={ "ô","̃" }, |
| 34408 |
["Ộ"]={ "Ọ","̂" }, |
| 34409 |
["ộ"]={ "ọ","̂" }, |
| 34410 |
["Ớ"]={ "Ơ","́" }, |
| 34411 |
["ớ"]={ "ơ","́" }, |
| 34412 |
["Ờ"]={ "Ơ","̀" }, |
| 34413 |
["ờ"]={ "ơ","̀" }, |
| 34414 |
["Ở"]={ "Ơ","̉" }, |
| 34415 |
["ở"]={ "ơ","̉" }, |
| 34416 |
["Ỡ"]={ "Ơ","̃" }, |
| 34417 |
["ỡ"]={ "ơ","̃" }, |
| 34418 |
["Ợ"]={ "Ơ","̣" }, |
| 34419 |
["ợ"]={ "ơ","̣" }, |
| 34420 |
["Ụ"]={ "U","̣" }, |
| 34421 |
["ụ"]={ "u","̣" }, |
| 34422 |
["Ủ"]={ "U","̉" }, |
| 34423 |
["ủ"]={ "u","̉" }, |
| 34424 |
["Ứ"]={ "Ư","́" }, |
| 34425 |
["ứ"]={ "ư","́" }, |
| 34426 |
["Ừ"]={ "Ư","̀" }, |
| 34427 |
["ừ"]={ "ư","̀" }, |
| 34428 |
["Ử"]={ "Ư","̉" }, |
| 34429 |
["ử"]={ "ư","̉" }, |
| 34430 |
["Ữ"]={ "Ư","̃" }, |
| 34431 |
["ữ"]={ "ư","̃" }, |
| 34432 |
["Ự"]={ "Ư","̣" }, |
| 34433 |
["ự"]={ "ư","̣" }, |
| 34434 |
["Ỳ"]={ "Y","̀" }, |
| 34435 |
["ỳ"]={ "y","̀" }, |
| 34436 |
["Ỵ"]={ "Y","̣" }, |
| 34437 |
["ỵ"]={ "y","̣" }, |
| 34438 |
["Ỷ"]={ "Y","̉" }, |
| 34439 |
["ỷ"]={ "y","̉" }, |
| 34440 |
["Ỹ"]={ "Y","̃" }, |
| 34441 |
["ỹ"]={ "y","̃" }, |
| 34442 |
["ἀ"]={ "α","̓" }, |
| 34443 |
["ἁ"]={ "α","̔" }, |
| 34444 |
["ἂ"]={ "ἀ","̀" }, |
| 34445 |
["ἃ"]={ "ἁ","̀" }, |
| 34446 |
["ἄ"]={ "ἀ","́" }, |
| 34447 |
["ἅ"]={ "ἁ","́" }, |
| 34448 |
["ἆ"]={ "ἀ","͂" }, |
| 34449 |
["ἇ"]={ "ἁ","͂" }, |
| 34450 |
["Ἀ"]={ "Α","̓" }, |
| 34451 |
["Ἁ"]={ "Α","̔" }, |
| 34452 |
["Ἂ"]={ "Ἀ","̀" }, |
| 34453 |
["Ἃ"]={ "Ἁ","̀" }, |
| 34454 |
["Ἄ"]={ "Ἀ","́" }, |
| 34455 |
["Ἅ"]={ "Ἁ","́" }, |
| 34456 |
["Ἆ"]={ "Ἀ","͂" }, |
| 34457 |
["Ἇ"]={ "Ἁ","͂" }, |
| 34458 |
["ἐ"]={ "ε","̓" }, |
| 34459 |
["ἑ"]={ "ε","̔" }, |
| 34460 |
["ἒ"]={ "ἐ","̀" }, |
| 34461 |
["ἓ"]={ "ἑ","̀" }, |
| 34462 |
["ἔ"]={ "ἐ","́" }, |
| 34463 |
["ἕ"]={ "ἑ","́" }, |
| 34464 |
["Ἐ"]={ "Ε","̓" }, |
| 34465 |
["Ἑ"]={ "Ε","̔" }, |
| 34466 |
["Ἒ"]={ "Ἐ","̀" }, |
| 34467 |
["Ἓ"]={ "Ἑ","̀" }, |
| 34468 |
["Ἔ"]={ "Ἐ","́" }, |
| 34469 |
["Ἕ"]={ "Ἑ","́" }, |
| 34470 |
["ἠ"]={ "η","̓" }, |
| 34471 |
["ἡ"]={ "η","̔" }, |
| 34472 |
["ἢ"]={ "ἠ","̀" }, |
| 34473 |
["ἣ"]={ "ἡ","̀" }, |
| 34474 |
["ἤ"]={ "ἠ","́" }, |
| 34475 |
["ἥ"]={ "ἡ","́" }, |
| 34476 |
["ἦ"]={ "ἠ","͂" }, |
| 34477 |
["ἧ"]={ "ἡ","͂" }, |
| 34478 |
["Ἠ"]={ "Η","̓" }, |
| 34479 |
["Ἡ"]={ "Η","̔" }, |
| 34480 |
["Ἢ"]={ "Ἠ","̀" }, |
| 34481 |
["Ἣ"]={ "Ἡ","̀" }, |
| 34482 |
["Ἤ"]={ "Ἠ","́" }, |
| 34483 |
["Ἥ"]={ "Ἡ","́" }, |
| 34484 |
["Ἦ"]={ "Ἠ","͂" }, |
| 34485 |
["Ἧ"]={ "Ἡ","͂" }, |
| 34486 |
["ἰ"]={ "ι","̓" }, |
| 34487 |
["ἱ"]={ "ι","̔" }, |
| 34488 |
["ἲ"]={ "ἰ","̀" }, |
| 34489 |
["ἳ"]={ "ἱ","̀" }, |
| 34490 |
["ἴ"]={ "ἰ","́" }, |
| 34491 |
["ἵ"]={ "ἱ","́" }, |
| 34492 |
["ἶ"]={ "ἰ","͂" }, |
| 34493 |
["ἷ"]={ "ἱ","͂" }, |
| 34494 |
["Ἰ"]={ "Ι","̓" }, |
| 34495 |
["Ἱ"]={ "Ι","̔" }, |
| 34496 |
["Ἲ"]={ "Ἰ","̀" }, |
| 34497 |
["Ἳ"]={ "Ἱ","̀" }, |
| 34498 |
["Ἴ"]={ "Ἰ","́" }, |
| 34499 |
["Ἵ"]={ "Ἱ","́" }, |
| 34500 |
["Ἶ"]={ "Ἰ","͂" }, |
| 34501 |
["Ἷ"]={ "Ἱ","͂" }, |
| 34502 |
["ὀ"]={ "ο","̓" }, |
| 34503 |
["ὁ"]={ "ο","̔" }, |
| 34504 |
["ὂ"]={ "ὀ","̀" }, |
| 34505 |
["ὃ"]={ "ὁ","̀" }, |
| 34506 |
["ὄ"]={ "ὀ","́" }, |
| 34507 |
["ὅ"]={ "ὁ","́" }, |
| 34508 |
["Ὀ"]={ "Ο","̓" }, |
| 34509 |
["Ὁ"]={ "Ο","̔" }, |
| 34510 |
["Ὂ"]={ "Ὀ","̀" }, |
| 34511 |
["Ὃ"]={ "Ὁ","̀" }, |
| 34512 |
["Ὄ"]={ "Ὀ","́" }, |
| 34513 |
["Ὅ"]={ "Ὁ","́" }, |
| 34514 |
["ὐ"]={ "υ","̓" }, |
| 34515 |
["ὑ"]={ "υ","̔" }, |
| 34516 |
["ὒ"]={ "ὐ","̀" }, |
| 34517 |
["ὓ"]={ "ὑ","̀" }, |
| 34518 |
["ὔ"]={ "ὐ","́" }, |
| 34519 |
["ὕ"]={ "ὑ","́" }, |
| 34520 |
["ὖ"]={ "ὐ","͂" }, |
| 34521 |
["ὗ"]={ "ὑ","͂" }, |
| 34522 |
["Ὑ"]={ "Υ","̔" }, |
| 34523 |
["Ὓ"]={ "Ὑ","̀" }, |
| 34524 |
["Ὕ"]={ "Ὑ","́" }, |
| 34525 |
["Ὗ"]={ "Ὑ","͂" }, |
| 34526 |
["ὠ"]={ "ω","̓" }, |
| 34527 |
["ὡ"]={ "ω","̔" }, |
| 34528 |
["ὢ"]={ "ὠ","̀" }, |
| 34529 |
["ὣ"]={ "ὡ","̀" }, |
| 34530 |
["ὤ"]={ "ὠ","́" }, |
| 34531 |
["ὥ"]={ "ὡ","́" }, |
| 34532 |
["ὦ"]={ "ὠ","͂" }, |
| 34533 |
["ὧ"]={ "ὡ","͂" }, |
| 34534 |
["Ὠ"]={ "Ω","̓" }, |
| 34535 |
["Ὡ"]={ "Ω","̔" }, |
| 34536 |
["Ὢ"]={ "Ὠ","̀" }, |
| 34537 |
["Ὣ"]={ "Ὡ","̀" }, |
| 34538 |
["Ὤ"]={ "Ὠ","́" }, |
| 34539 |
["Ὥ"]={ "Ὡ","́" }, |
| 34540 |
["Ὦ"]={ "Ὠ","͂" }, |
| 34541 |
["Ὧ"]={ "Ὡ","͂" }, |
| 34542 |
["ὰ"]={ "α","̀" }, |
| 34543 |
["ὲ"]={ "ε","̀" }, |
| 34544 |
["ὴ"]={ "η","̀" }, |
| 34545 |
["ὶ"]={ "ι","̀" }, |
| 34546 |
["ὸ"]={ "ο","̀" }, |
| 34547 |
["ὺ"]={ "υ","̀" }, |
| 34548 |
["ὼ"]={ "ω","̀" }, |
| 34549 |
["ᾀ"]={ "ἀ","ͅ" }, |
| 34550 |
["ᾁ"]={ "ἁ","ͅ" }, |
| 34551 |
["ᾂ"]={ "ἂ","ͅ" }, |
| 34552 |
["ᾃ"]={ "ἃ","ͅ" }, |
| 34553 |
["ᾄ"]={ "ἄ","ͅ" }, |
| 34554 |
["ᾅ"]={ "ἅ","ͅ" }, |
| 34555 |
["ᾆ"]={ "ἆ","ͅ" }, |
| 34556 |
["ᾇ"]={ "ἇ","ͅ" }, |
| 34557 |
["ᾈ"]={ "Ἀ","ͅ" }, |
| 34558 |
["ᾉ"]={ "Ἁ","ͅ" }, |
| 34559 |
["ᾊ"]={ "Ἂ","ͅ" }, |
| 34560 |
["ᾋ"]={ "Ἃ","ͅ" }, |
| 34561 |
["ᾌ"]={ "Ἄ","ͅ" }, |
| 34562 |
["ᾍ"]={ "Ἅ","ͅ" }, |
| 34563 |
["ᾎ"]={ "Ἆ","ͅ" }, |
| 34564 |
["ᾏ"]={ "Ἇ","ͅ" }, |
| 34565 |
["ᾐ"]={ "ἠ","ͅ" }, |
| 34566 |
["ᾑ"]={ "ἡ","ͅ" }, |
| 34567 |
["ᾒ"]={ "ἢ","ͅ" }, |
| 34568 |
["ᾓ"]={ "ἣ","ͅ" }, |
| 34569 |
["ᾔ"]={ "ἤ","ͅ" }, |
| 34570 |
["ᾕ"]={ "ἥ","ͅ" }, |
| 34571 |
["ᾖ"]={ "ἦ","ͅ" }, |
| 34572 |
["ᾗ"]={ "ἧ","ͅ" }, |
| 34573 |
["ᾘ"]={ "Ἠ","ͅ" }, |
| 34574 |
["ᾙ"]={ "Ἡ","ͅ" }, |
| 34575 |
["ᾚ"]={ "Ἢ","ͅ" }, |
| 34576 |
["ᾛ"]={ "Ἣ","ͅ" }, |
| 34577 |
["ᾜ"]={ "Ἤ","ͅ" }, |
| 34578 |
["ᾝ"]={ "Ἥ","ͅ" }, |
| 34579 |
["ᾞ"]={ "Ἦ","ͅ" }, |
| 34580 |
["ᾟ"]={ "Ἧ","ͅ" }, |
| 34581 |
["ᾠ"]={ "ὠ","ͅ" }, |
| 34582 |
["ᾡ"]={ "ὡ","ͅ" }, |
| 34583 |
["ᾢ"]={ "ὢ","ͅ" }, |
| 34584 |
["ᾣ"]={ "ὣ","ͅ" }, |
| 34585 |
["ᾤ"]={ "ὤ","ͅ" }, |
| 34586 |
["ᾥ"]={ "ὥ","ͅ" }, |
| 34587 |
["ᾦ"]={ "ὦ","ͅ" }, |
| 34588 |
["ᾧ"]={ "ὧ","ͅ" }, |
| 34589 |
["ᾨ"]={ "Ὠ","ͅ" }, |
| 34590 |
["ᾩ"]={ "Ὡ","ͅ" }, |
| 34591 |
["ᾪ"]={ "Ὢ","ͅ" }, |
| 34592 |
["ᾫ"]={ "Ὣ","ͅ" }, |
| 34593 |
["ᾬ"]={ "Ὤ","ͅ" }, |
| 34594 |
["ᾭ"]={ "Ὥ","ͅ" }, |
| 34595 |
["ᾮ"]={ "Ὦ","ͅ" }, |
| 34596 |
["ᾯ"]={ "Ὧ","ͅ" }, |
| 34597 |
["ᾰ"]={ "α","̆" }, |
| 34598 |
["ᾱ"]={ "α","̄" }, |
| 34599 |
["ᾲ"]={ "ὰ","ͅ" }, |
| 34600 |
["ᾳ"]={ "α","ͅ" }, |
| 34601 |
["ᾴ"]={ "ά","ͅ" }, |
| 34602 |
["ᾶ"]={ "α","͂" }, |
| 34603 |
["ᾷ"]={ "ᾶ","ͅ" }, |
| 34604 |
["Ᾰ"]={ "Α","̆" }, |
| 34605 |
["Ᾱ"]={ "Α","̄" }, |
| 34606 |
["Ὰ"]={ "Α","̀" }, |
| 34607 |
["ᾼ"]={ "Α","ͅ" }, |
| 34608 |
["῁"]={ "¨","͂" }, |
| 34609 |
["ῂ"]={ "ὴ","ͅ" }, |
| 34610 |
["ῃ"]={ "η","ͅ" }, |
| 34611 |
["ῄ"]={ "ή","ͅ" }, |
| 34612 |
["ῆ"]={ "η","͂" }, |
| 34613 |
["ῇ"]={ "ῆ","ͅ" }, |
| 34614 |
["Ὲ"]={ "Ε","̀" }, |
| 34615 |
["Ὴ"]={ "Η","̀" }, |
| 34616 |
["ῌ"]={ "Η","ͅ" }, |
| 34617 |
["῍"]={ "᾿","̀" }, |
| 34618 |
["῎"]={ "᾿","́" }, |
| 34619 |
["῏"]={ "᾿","͂" }, |
| 34620 |
["ῐ"]={ "ι","̆" }, |
| 34621 |
["ῑ"]={ "ι","̄" }, |
| 34622 |
["ῒ"]={ "ϊ","̀" }, |
| 34623 |
["ῖ"]={ "ι","͂" }, |
| 34624 |
["ῗ"]={ "ϊ","͂" }, |
| 34625 |
["Ῐ"]={ "Ι","̆" }, |
| 34626 |
["Ῑ"]={ "Ι","̄" }, |
| 34627 |
["Ὶ"]={ "Ι","̀" }, |
| 34628 |
["῝"]={ "῾","̀" }, |
| 34629 |
["῞"]={ "῾","́" }, |
| 34630 |
["῟"]={ "῾","͂" }, |
| 34631 |
["ῠ"]={ "υ","̆" }, |
| 34632 |
["ῡ"]={ "υ","̄" }, |
| 34633 |
["ῢ"]={ "ϋ","̀" }, |
| 34634 |
["ῤ"]={ "ρ","̓" }, |
| 34635 |
["ῥ"]={ "ρ","̔" }, |
| 34636 |
["ῦ"]={ "υ","͂" }, |
| 34637 |
["ῧ"]={ "ϋ","͂" }, |
| 34638 |
["Ῠ"]={ "Υ","̆" }, |
| 34639 |
["Ῡ"]={ "Υ","̄" }, |
| 34640 |
["Ὺ"]={ "Υ","̀" }, |
| 34641 |
["Ῥ"]={ "Ρ","̔" }, |
| 34642 |
["῭"]={ "¨","̀" }, |
| 34643 |
["ῲ"]={ "ὼ","ͅ" }, |
| 34644 |
["ῳ"]={ "ω","ͅ" }, |
| 34645 |
["ῴ"]={ "ώ","ͅ" }, |
| 34646 |
["ῶ"]={ "ω","͂" }, |
| 34647 |
["ῷ"]={ "ῶ","ͅ" }, |
| 34648 |
["Ὸ"]={ "Ο","̀" }, |
| 34649 |
["Ὼ"]={ "Ω","̀" }, |
| 34650 |
["ῼ"]={ "Ω","ͅ" }, |
| 34651 |
["↚"]={ "←","̸" }, |
| 34652 |
["↛"]={ "→","̸" }, |
| 34653 |
["↮"]={ "↔","̸" }, |
| 34654 |
["⇍"]={ "⇐","̸" }, |
| 34655 |
["⇎"]={ "⇔","̸" }, |
| 34656 |
["⇏"]={ "⇒","̸" }, |
| 34657 |
["∄"]={ "∃","̸" }, |
| 34658 |
["∉"]={ "∈","̸" }, |
| 34659 |
["∌"]={ "∋","̸" }, |
| 34660 |
["∤"]={ "∣","̸" }, |
| 34661 |
["∦"]={ "∥","̸" }, |
| 34662 |
["≁"]={ "∼","̸" }, |
| 34663 |
["≄"]={ "≃","̸" }, |
| 34664 |
["≇"]={ "≅","̸" }, |
| 34665 |
["≉"]={ "≈","̸" }, |
| 34666 |
["≠"]={ "=","̸" }, |
| 34667 |
["≢"]={ "≡","̸" }, |
| 34668 |
["≭"]={ "≍","̸" }, |
| 34669 |
["≮"]={ "<","̸" }, |
| 34670 |
["≯"]={ ">","̸" }, |
| 34671 |
["≰"]={ "≤","̸" }, |
| 34672 |
["≱"]={ "≥","̸" }, |
| 34673 |
["≴"]={ "≲","̸" }, |
| 34674 |
["≵"]={ "≳","̸" }, |
| 34675 |
["≸"]={ "≶","̸" }, |
| 34676 |
["≹"]={ "≷","̸" }, |
| 34677 |
["⊀"]={ "≺","̸" }, |
| 34678 |
["⊁"]={ "≻","̸" }, |
| 34679 |
["⊄"]={ "⊂","̸" }, |
| 34680 |
["⊅"]={ "⊃","̸" }, |
| 34681 |
["⊈"]={ "⊆","̸" }, |
| 34682 |
["⊉"]={ "⊇","̸" }, |
| 34683 |
["⊬"]={ "⊢","̸" }, |
| 34684 |
["⊭"]={ "⊨","̸" }, |
| 34685 |
["⊮"]={ "⊩","̸" }, |
| 34686 |
["⊯"]={ "⊫","̸" }, |
| 34687 |
["⋠"]={ "≼","̸" }, |
| 34688 |
["⋡"]={ "≽","̸" }, |
| 34689 |
["⋢"]={ "⊑","̸" }, |
| 34690 |
["⋣"]={ "⊒","̸" }, |
| 34691 |
["⋪"]={ "⊲","̸" }, |
| 34692 |
["⋫"]={ "⊳","̸" }, |
| 34693 |
["⋬"]={ "⊴","̸" }, |
| 34694 |
["⋭"]={ "⊵","̸" }, |
| 34695 |
["⫝̸"]={ "⫝","̸" }, |
| 34696 |
["が"]={ "か","゙" }, |
| 34697 |
["ぎ"]={ "き","゙" }, |
| 34698 |
["ぐ"]={ "く","゙" }, |
| 34699 |
["げ"]={ "け","゙" }, |
| 34700 |
["ご"]={ "こ","゙" }, |
| 34701 |
["ざ"]={ "さ","゙" }, |
| 34702 |
["じ"]={ "し","゙" }, |
| 34703 |
["ず"]={ "す","゙" }, |
| 34704 |
["ぜ"]={ "せ","゙" }, |
| 34705 |
["ぞ"]={ "そ","゙" }, |
| 34706 |
["だ"]={ "た","゙" }, |
| 34707 |
["ぢ"]={ "ち","゙" }, |
| 34708 |
["づ"]={ "つ","゙" }, |
| 34709 |
["で"]={ "て","゙" }, |
| 34710 |
["ど"]={ "と","゙" }, |
| 34711 |
["ば"]={ "は","゙" }, |
| 34712 |
["ぱ"]={ "は","゚" }, |
| 34713 |
["び"]={ "ひ","゙" }, |
| 34714 |
["ぴ"]={ "ひ","゚" }, |
| 34715 |
["ぶ"]={ "ふ","゙" }, |
| 34716 |
["ぷ"]={ "ふ","゚" }, |
| 34717 |
["べ"]={ "へ","゙" }, |
| 34718 |
["ぺ"]={ "へ","゚" }, |
| 34719 |
["ぼ"]={ "ほ","゙" }, |
| 34720 |
["ぽ"]={ "ほ","゚" }, |
| 34721 |
["ゔ"]={ "う","゙" }, |
| 34722 |
["ゞ"]={ "ゝ","゙" }, |
| 34723 |
["ガ"]={ "カ","゙" }, |
| 34724 |
["ギ"]={ "キ","゙" }, |
| 34725 |
["グ"]={ "ク","゙" }, |
| 34726 |
["ゲ"]={ "ケ","゙" }, |
| 34727 |
["ゴ"]={ "コ","゙" }, |
| 34728 |
["ザ"]={ "サ","゙" }, |
| 34729 |
["ジ"]={ "シ","゙" }, |
| 34730 |
["ズ"]={ "ス","゙" }, |
| 34731 |
["ゼ"]={ "セ","゙" }, |
| 34732 |
["ゾ"]={ "ソ","゙" }, |
| 34733 |
["ダ"]={ "タ","゙" }, |
| 34734 |
["ヂ"]={ "チ","゙" }, |
| 34735 |
["ヅ"]={ "ツ","゙" }, |
| 34736 |
["デ"]={ "テ","゙" }, |
| 34737 |
["ド"]={ "ト","゙" }, |
| 34738 |
["バ"]={ "ハ","゙" }, |
| 34739 |
["パ"]={ "ハ","゚" }, |
| 34740 |
["ビ"]={ "ヒ","゙" }, |
| 34741 |
["ピ"]={ "ヒ","゚" }, |
| 34742 |
["ブ"]={ "フ","゙" }, |
| 34743 |
["プ"]={ "フ","゚" }, |
| 34744 |
["ベ"]={ "ヘ","゙" }, |
| 34745 |
["ペ"]={ "ヘ","゚" }, |
| 34746 |
["ボ"]={ "ホ","゙" }, |
| 34747 |
["ポ"]={ "ホ","゚" }, |
| 34748 |
["ヴ"]={ "ウ","゙" }, |
| 34749 |
["ヷ"]={ "ワ","゙" }, |
| 34750 |
["ヸ"]={ "ヰ","゙" }, |
| 34751 |
["ヹ"]={ "ヱ","゙" }, |
| 34752 |
["ヺ"]={ "ヲ","゙" }, |
| 34753 |
["ヾ"]={ "ヽ","゙" }, |
| 34754 |
["יִ"]={ "י","ִ" }, |
| 34755 |
["ײַ"]={ "ײ","ַ" }, |
| 34756 |
["שׁ"]={ "ש","ׁ" }, |
| 34757 |
["שׂ"]={ "ש","ׂ" }, |
| 34758 |
["שּׁ"]={ "שּ","ׁ" }, |
| 34759 |
["שּׂ"]={ "שּ","ׂ" }, |
| 34760 |
["אַ"]={ "א","ַ" }, |
| 34761 |
["אָ"]={ "א","ָ" }, |
| 34762 |
["אּ"]={ "א","ּ" }, |
| 34763 |
["בּ"]={ "ב","ּ" }, |
| 34764 |
["גּ"]={ "ג","ּ" }, |
| 34765 |
["דּ"]={ "ד","ּ" }, |
| 34766 |
["הּ"]={ "ה","ּ" }, |
| 34767 |
["וּ"]={ "ו","ּ" }, |
| 34768 |
["זּ"]={ "ז","ּ" }, |
| 34769 |
["טּ"]={ "ט","ּ" }, |
| 34770 |
["יּ"]={ "י","ּ" }, |
| 34771 |
["ךּ"]={ "ך","ּ" }, |
| 34772 |
["כּ"]={ "כ","ּ" }, |
| 34773 |
["לּ"]={ "ל","ּ" }, |
| 34774 |
["מּ"]={ "מ","ּ" }, |
| 34775 |
["נּ"]={ "נ","ּ" }, |
| 34776 |
["סּ"]={ "ס","ּ" }, |
| 34777 |
["ףּ"]={ "ף","ּ" }, |
| 34778 |
["פּ"]={ "פ","ּ" }, |
| 34779 |
["צּ"]={ "צ","ּ" }, |
| 34780 |
["קּ"]={ "ק","ּ" }, |
| 34781 |
["רּ"]={ "ר","ּ" }, |
| 34782 |
["שּ"]={ "ש","ּ" }, |
| 34783 |
["תּ"]={ "ת","ּ" }, |
| 34784 |
["וֹ"]={ "ו","ֹ" }, |
| 34785 |
["בֿ"]={ "ב","ֿ" }, |
| 34786 |
["כֿ"]={ "כ","ֿ" }, |
| 34787 |
["פֿ"]={ "פ","ֿ" }, |
| 34788 |
["𑂚"]={ "𑂙","𑂺" }, |
| 34789 |
["𑂜"]={ "𑂛","𑂺" }, |
| 34790 |
["𑂫"]={ "𑂥","𑂺" }, |
| 34791 |
["𑄮"]={ "𑄱","𑄧" }, |
| 34792 |
["𑄯"]={ "𑄲","𑄧" }, |
| 34793 |
["𑍋"]={ "𑍇","𑌾" }, |
| 34794 |
["𑍌"]={ "𑍇","𑍗" }, |
| 34795 |
["𑒻"]={ "𑒹","𑒺" }, |
| 34796 |
["𑒼"]={ "𑒹","𑒰" }, |
| 34797 |
["𑒾"]={ "𑒹","𑒽" }, |
| 34798 |
["𑖺"]={ "𑖸","𑖯" }, |
| 34799 |
["𑖻"]={ "𑖹","𑖯" }, |
| 34800 |
["𝅗𝅥"]={ "𝅗","𝅥" }, |
| 34801 |
["𝅘𝅥"]={ "𝅘","𝅥" }, |
| 34802 |
["𝅘𝅥𝅮"]={ "𝅘𝅥","𝅮" }, |
| 34803 |
["𝅘𝅥𝅯"]={ "𝅘𝅥","𝅯" }, |
| 34804 |
["𝅘𝅥𝅰"]={ "𝅘𝅥","𝅰" }, |
| 34805 |
["𝅘𝅥𝅱"]={ "𝅘𝅥","𝅱" }, |
| 34806 |
["𝅘𝅥𝅲"]={ "𝅘𝅥","𝅲" }, |
| 34807 |
["𝆹𝅥"]={ "𝆹","𝅥" }, |
| 34808 |
["𝆺𝅥"]={ "𝆺","𝅥" }, |
| 34809 |
["𝆹𝅥𝅮"]={ "𝆹𝅥","𝅮" }, |
| 34810 |
["𝆺𝅥𝅮"]={ "𝆺𝅥","𝅮" }, |
| 34811 |
["𝆹𝅥𝅯"]={ "𝆹𝅥","𝅯" }, |
| 34812 |
["𝆺𝅥𝅯"]={ "𝆺𝅥","𝅯" }, |
| 34813 |
}, |
| 34814 |
}, |
| 34815 |
{ |
| 34816 |
["data"]={ |
| 34817 |
["À"]={ "A","̀" }, |
| 34818 |
["Á"]={ "A","́" }, |
| 34819 |
["Â"]={ "A","̂" }, |
| 34820 |
["Ã"]={ "A","̃" }, |
| 34821 |
["Ä"]={ "A","̈" }, |
| 34822 |
["Å"]={ "A","̊" }, |
| 34823 |
["Ç"]={ "C","̧" }, |
| 34824 |
["È"]={ "E","̀" }, |
| 34825 |
["É"]={ "E","́" }, |
| 34826 |
["Ê"]={ "E","̂" }, |
| 34827 |
["Ë"]={ "E","̈" }, |
| 34828 |
["Ì"]={ "I","̀" }, |
| 34829 |
["Í"]={ "I","́" }, |
| 34830 |
["Î"]={ "I","̂" }, |
| 34831 |
["Ï"]={ "I","̈" }, |
| 34832 |
["Ñ"]={ "N","̃" }, |
| 34833 |
["Ò"]={ "O","̀" }, |
| 34834 |
["Ó"]={ "O","́" }, |
| 34835 |
["Ô"]={ "O","̂" }, |
| 34836 |
["Õ"]={ "O","̃" }, |
| 34837 |
["Ö"]={ "O","̈" }, |
| 34838 |
["Ù"]={ "U","̀" }, |
| 34839 |
["Ú"]={ "U","́" }, |
| 34840 |
["Û"]={ "U","̂" }, |
| 34841 |
["Ü"]={ "U","̈" }, |
| 34842 |
["Ý"]={ "Y","́" }, |
| 34843 |
["à"]={ "a","̀" }, |
| 34844 |
["á"]={ "a","́" }, |
| 34845 |
["â"]={ "a","̂" }, |
| 34846 |
["ã"]={ "a","̃" }, |
| 34847 |
["ä"]={ "a","̈" }, |
| 34848 |
["å"]={ "a","̊" }, |
| 34849 |
["ç"]={ "c","̧" }, |
| 34850 |
["è"]={ "e","̀" }, |
| 34851 |
["é"]={ "e","́" }, |
| 34852 |
["ê"]={ "e","̂" }, |
| 34853 |
["ë"]={ "e","̈" }, |
| 34854 |
["ì"]={ "i","̀" }, |
| 34855 |
["í"]={ "i","́" }, |
| 34856 |
["î"]={ "i","̂" }, |
| 34857 |
["ï"]={ "i","̈" }, |
| 34858 |
["ñ"]={ "n","̃" }, |
| 34859 |
["ò"]={ "o","̀" }, |
| 34860 |
["ó"]={ "o","́" }, |
| 34861 |
["ô"]={ "o","̂" }, |
| 34862 |
["õ"]={ "o","̃" }, |
| 34863 |
["ö"]={ "o","̈" }, |
| 34864 |
["ù"]={ "u","̀" }, |
| 34865 |
["ú"]={ "u","́" }, |
| 34866 |
["û"]={ "u","̂" }, |
| 34867 |
["ü"]={ "u","̈" }, |
| 34868 |
["ý"]={ "y","́" }, |
| 34869 |
["ÿ"]={ "y","̈" }, |
| 34870 |
["Ā"]={ "A","̄" }, |
| 34871 |
["ā"]={ "a","̄" }, |
| 34872 |
["Ă"]={ "A","̆" }, |
| 34873 |
["ă"]={ "a","̆" }, |
| 34874 |
["Ą"]={ "A","̨" }, |
| 34875 |
["ą"]={ "a","̨" }, |
| 34876 |
["Ć"]={ "C","́" }, |
| 34877 |
["ć"]={ "c","́" }, |
| 34878 |
["Ĉ"]={ "C","̂" }, |
| 34879 |
["ĉ"]={ "c","̂" }, |
| 34880 |
["Ċ"]={ "C","̇" }, |
| 34881 |
["ċ"]={ "c","̇" }, |
| 34882 |
["Č"]={ "C","̌" }, |
| 34883 |
["č"]={ "c","̌" }, |
| 34884 |
["Ď"]={ "D","̌" }, |
| 34885 |
["ď"]={ "d","̌" }, |
| 34886 |
["Ē"]={ "E","̄" }, |
| 34887 |
["ē"]={ "e","̄" }, |
| 34888 |
["Ĕ"]={ "E","̆" }, |
| 34889 |
["ĕ"]={ "e","̆" }, |
| 34890 |
["Ė"]={ "E","̇" }, |
| 34891 |
["ė"]={ "e","̇" }, |
| 34892 |
["Ę"]={ "E","̨" }, |
| 34893 |
["ę"]={ "e","̨" }, |
| 34894 |
["Ě"]={ "E","̌" }, |
| 34895 |
["ě"]={ "e","̌" }, |
| 34896 |
["Ĝ"]={ "G","̂" }, |
| 34897 |
["ĝ"]={ "g","̂" }, |
| 34898 |
["Ğ"]={ "G","̆" }, |
| 34899 |
["ğ"]={ "g","̆" }, |
| 34900 |
["Ġ"]={ "G","̇" }, |
| 34901 |
["ġ"]={ "g","̇" }, |
| 34902 |
["Ģ"]={ "G","̧" }, |
| 34903 |
["ģ"]={ "g","̧" }, |
| 34904 |
["Ĥ"]={ "H","̂" }, |
| 34905 |
["ĥ"]={ "h","̂" }, |
| 34906 |
["Ĩ"]={ "I","̃" }, |
| 34907 |
["ĩ"]={ "i","̃" }, |
| 34908 |
["Ī"]={ "I","̄" }, |
| 34909 |
["ī"]={ "i","̄" }, |
| 34910 |
["Ĭ"]={ "I","̆" }, |
| 34911 |
["ĭ"]={ "i","̆" }, |
| 34912 |
["Į"]={ "I","̨" }, |
| 34913 |
["į"]={ "i","̨" }, |
| 34914 |
["İ"]={ "I","̇" }, |
| 34915 |
["Ĵ"]={ "J","̂" }, |
| 34916 |
["ĵ"]={ "j","̂" }, |
| 34917 |
["Ķ"]={ "K","̧" }, |
| 34918 |
["ķ"]={ "k","̧" }, |
| 34919 |
["Ĺ"]={ "L","́" }, |
| 34920 |
["ĺ"]={ "l","́" }, |
| 34921 |
["Ļ"]={ "L","̧" }, |
| 34922 |
["ļ"]={ "l","̧" }, |
| 34923 |
["Ľ"]={ "L","̌" }, |
| 34924 |
["ľ"]={ "l","̌" }, |
| 34925 |
["Ń"]={ "N","́" }, |
| 34926 |
["ń"]={ "n","́" }, |
| 34927 |
["Ņ"]={ "N","̧" }, |
| 34928 |
["ņ"]={ "n","̧" }, |
| 34929 |
["Ň"]={ "N","̌" }, |
| 34930 |
["ň"]={ "n","̌" }, |
| 34931 |
["Ō"]={ "O","̄" }, |
| 34932 |
["ō"]={ "o","̄" }, |
| 34933 |
["Ŏ"]={ "O","̆" }, |
| 34934 |
["ŏ"]={ "o","̆" }, |
| 34935 |
["Ő"]={ "O","̋" }, |
| 34936 |
["ő"]={ "o","̋" }, |
| 34937 |
["Ŕ"]={ "R","́" }, |
| 34938 |
["ŕ"]={ "r","́" }, |
| 34939 |
["Ŗ"]={ "R","̧" }, |
| 34940 |
["ŗ"]={ "r","̧" }, |
| 34941 |
["Ř"]={ "R","̌" }, |
| 34942 |
["ř"]={ "r","̌" }, |
| 34943 |
["Ś"]={ "S","́" }, |
| 34944 |
["ś"]={ "s","́" }, |
| 34945 |
["Ŝ"]={ "S","̂" }, |
| 34946 |
["ŝ"]={ "s","̂" }, |
| 34947 |
["Ş"]={ "S","̧" }, |
| 34948 |
["ş"]={ "s","̧" }, |
| 34949 |
["Š"]={ "S","̌" }, |
| 34950 |
["š"]={ "s","̌" }, |
| 34951 |
["Ţ"]={ "T","̧" }, |
| 34952 |
["ţ"]={ "t","̧" }, |
| 34953 |
["Ť"]={ "T","̌" }, |
| 34954 |
["ť"]={ "t","̌" }, |
| 34955 |
["Ũ"]={ "U","̃" }, |
| 34956 |
["ũ"]={ "u","̃" }, |
| 34957 |
["Ū"]={ "U","̄" }, |
| 34958 |
["ū"]={ "u","̄" }, |
| 34959 |
["Ŭ"]={ "U","̆" }, |
| 34960 |
["ŭ"]={ "u","̆" }, |
| 34961 |
["Ů"]={ "U","̊" }, |
| 34962 |
["ů"]={ "u","̊" }, |
| 34963 |
["Ű"]={ "U","̋" }, |
| 34964 |
["ű"]={ "u","̋" }, |
| 34965 |
["Ų"]={ "U","̨" }, |
| 34966 |
["ų"]={ "u","̨" }, |
| 34967 |
["Ŵ"]={ "W","̂" }, |
| 34968 |
["ŵ"]={ "w","̂" }, |
| 34969 |
["Ŷ"]={ "Y","̂" }, |
| 34970 |
["ŷ"]={ "y","̂" }, |
| 34971 |
["Ÿ"]={ "Y","̈" }, |
| 34972 |
["Ź"]={ "Z","́" }, |
| 34973 |
["ź"]={ "z","́" }, |
| 34974 |
["Ż"]={ "Z","̇" }, |
| 34975 |
["ż"]={ "z","̇" }, |
| 34976 |
["Ž"]={ "Z","̌" }, |
| 34977 |
["ž"]={ "z","̌" }, |
| 34978 |
["Ơ"]={ "O","̛" }, |
| 34979 |
["ơ"]={ "o","̛" }, |
| 34980 |
["Ư"]={ "U","̛" }, |
| 34981 |
["ư"]={ "u","̛" }, |
| 34982 |
["Ǎ"]={ "A","̌" }, |
| 34983 |
["ǎ"]={ "a","̌" }, |
| 34984 |
["Ǐ"]={ "I","̌" }, |
| 34985 |
["ǐ"]={ "i","̌" }, |
| 34986 |
["Ǒ"]={ "O","̌" }, |
| 34987 |
["ǒ"]={ "o","̌" }, |
| 34988 |
["Ǔ"]={ "U","̌" }, |
| 34989 |
["ǔ"]={ "u","̌" }, |
| 34990 |
["Ǖ"]={ "Ü","̄" }, |
| 34991 |
["ǖ"]={ "ü","̄" }, |
| 34992 |
["Ǘ"]={ "Ü","́" }, |
| 34993 |
["ǘ"]={ "ü","́" }, |
| 34994 |
["Ǚ"]={ "Ü","̌" }, |
| 34995 |
["ǚ"]={ "ü","̌" }, |
| 34996 |
["Ǜ"]={ "Ü","̀" }, |
| 34997 |
["ǜ"]={ "ü","̀" }, |
| 34998 |
["Ǟ"]={ "Ä","̄" }, |
| 34999 |
["ǟ"]={ "ä","̄" }, |
| 35000 |
["Ǡ"]={ "Ȧ","̄" }, |
| 35001 |
["ǡ"]={ "ȧ","̄" }, |
| 35002 |
["Ǣ"]={ "Æ","̄" }, |
| 35003 |
["ǣ"]={ "æ","̄" }, |
| 35004 |
["Ǧ"]={ "G","̌" }, |
| 35005 |
["ǧ"]={ "g","̌" }, |
| 35006 |
["Ǩ"]={ "K","̌" }, |
| 35007 |
["ǩ"]={ "k","̌" }, |
| 35008 |
["Ǫ"]={ "O","̨" }, |
| 35009 |
["ǫ"]={ "o","̨" }, |
| 35010 |
["Ǭ"]={ "Ǫ","̄" }, |
| 35011 |
["ǭ"]={ "ǫ","̄" }, |
| 35012 |
["Ǯ"]={ "Ʒ","̌" }, |
| 35013 |
["ǯ"]={ "ʒ","̌" }, |
| 35014 |
["ǰ"]={ "j","̌" }, |
| 35015 |
["Ǵ"]={ "G","́" }, |
| 35016 |
["ǵ"]={ "g","́" }, |
| 35017 |
["Ǹ"]={ "N","̀" }, |
| 35018 |
["ǹ"]={ "n","̀" }, |
| 35019 |
["Ǻ"]={ "Å","́" }, |
| 35020 |
["ǻ"]={ "å","́" }, |
| 35021 |
["Ǽ"]={ "Æ","́" }, |
| 35022 |
["ǽ"]={ "æ","́" }, |
| 35023 |
["Ǿ"]={ "Ø","́" }, |
| 35024 |
["ǿ"]={ "ø","́" }, |
| 35025 |
["Ȁ"]={ "A","̏" }, |
| 35026 |
["ȁ"]={ "a","̏" }, |
| 35027 |
["Ȃ"]={ "A","̑" }, |
| 35028 |
["ȃ"]={ "a","̑" }, |
| 35029 |
["Ȅ"]={ "E","̏" }, |
| 35030 |
["ȅ"]={ "e","̏" }, |
| 35031 |
["Ȇ"]={ "E","̑" }, |
| 35032 |
["ȇ"]={ "e","̑" }, |
| 35033 |
["Ȉ"]={ "I","̏" }, |
| 35034 |
["ȉ"]={ "i","̏" }, |
| 35035 |
["Ȋ"]={ "I","̑" }, |
| 35036 |
["ȋ"]={ "i","̑" }, |
| 35037 |
["Ȍ"]={ "O","̏" }, |
| 35038 |
["ȍ"]={ "o","̏" }, |
| 35039 |
["Ȏ"]={ "O","̑" }, |
| 35040 |
["ȏ"]={ "o","̑" }, |
| 35041 |
["Ȑ"]={ "R","̏" }, |
| 35042 |
["ȑ"]={ "r","̏" }, |
| 35043 |
["Ȓ"]={ "R","̑" }, |
| 35044 |
["ȓ"]={ "r","̑" }, |
| 35045 |
["Ȕ"]={ "U","̏" }, |
| 35046 |
["ȕ"]={ "u","̏" }, |
| 35047 |
["Ȗ"]={ "U","̑" }, |
| 35048 |
["ȗ"]={ "u","̑" }, |
| 35049 |
["Ș"]={ "S","̦" }, |
| 35050 |
["ș"]={ "s","̦" }, |
| 35051 |
["Ț"]={ "T","̦" }, |
| 35052 |
["ț"]={ "t","̦" }, |
| 35053 |
["Ȟ"]={ "H","̌" }, |
| 35054 |
["ȟ"]={ "h","̌" }, |
| 35055 |
["Ȧ"]={ "A","̇" }, |
| 35056 |
["ȧ"]={ "a","̇" }, |
| 35057 |
["Ȩ"]={ "E","̧" }, |
| 35058 |
["ȩ"]={ "e","̧" }, |
| 35059 |
["Ȫ"]={ "Ö","̄" }, |
| 35060 |
["ȫ"]={ "ö","̄" }, |
| 35061 |
["Ȭ"]={ "Õ","̄" }, |
| 35062 |
["ȭ"]={ "õ","̄" }, |
| 35063 |
["Ȯ"]={ "O","̇" }, |
| 35064 |
["ȯ"]={ "o","̇" }, |
| 35065 |
["Ȱ"]={ "Ȯ","̄" }, |
| 35066 |
["ȱ"]={ "ȯ","̄" }, |
| 35067 |
["Ȳ"]={ "Y","̄" }, |
| 35068 |
["ȳ"]={ "y","̄" }, |
| 35069 |
["̈́"]={ "̈","́" }, |
| 35070 |
["΅"]={ "¨","́" }, |
| 35071 |
["Ά"]={ "Α","́" }, |
| 35072 |
["Έ"]={ "Ε","́" }, |
| 35073 |
["Ή"]={ "Η","́" }, |
| 35074 |
["Ί"]={ "Ι","́" }, |
| 35075 |
["Ό"]={ "Ο","́" }, |
| 35076 |
["Ύ"]={ "Υ","́" }, |
| 35077 |
["Ώ"]={ "Ω","́" }, |
| 35078 |
["ΐ"]={ "ϊ","́" }, |
| 35079 |
["Ϊ"]={ "Ι","̈" }, |
| 35080 |
["Ϋ"]={ "Υ","̈" }, |
| 35081 |
["ά"]={ "α","́" }, |
| 35082 |
["έ"]={ "ε","́" }, |
| 35083 |
["ή"]={ "η","́" }, |
| 35084 |
["ί"]={ "ι","́" }, |
| 35085 |
["ΰ"]={ "ϋ","́" }, |
| 35086 |
["ϊ"]={ "ι","̈" }, |
| 35087 |
["ϋ"]={ "υ","̈" }, |
| 35088 |
["ό"]={ "ο","́" }, |
| 35089 |
["ύ"]={ "υ","́" }, |
| 35090 |
["ώ"]={ "ω","́" }, |
| 35091 |
["ϓ"]={ "ϒ","́" }, |
| 35092 |
["ϔ"]={ "ϒ","̈" }, |
| 35093 |
["Ѐ"]={ "Е","̀" }, |
| 35094 |
["Ё"]={ "Е","̈" }, |
| 35095 |
["Ѓ"]={ "Г","́" }, |
| 35096 |
["Ї"]={ "І","̈" }, |
| 35097 |
["Ќ"]={ "К","́" }, |
| 35098 |
["Ѝ"]={ "И","̀" }, |
| 35099 |
["Ў"]={ "У","̆" }, |
| 35100 |
["Й"]={ "И","̆" }, |
| 35101 |
["й"]={ "и","̆" }, |
| 35102 |
["ѐ"]={ "е","̀" }, |
| 35103 |
["ё"]={ "е","̈" }, |
| 35104 |
["ѓ"]={ "г","́" }, |
| 35105 |
["ї"]={ "і","̈" }, |
| 35106 |
["ќ"]={ "к","́" }, |
| 35107 |
["ѝ"]={ "и","̀" }, |
| 35108 |
["ў"]={ "у","̆" }, |
| 35109 |
["Ѷ"]={ "Ѵ","̏" }, |
| 35110 |
["ѷ"]={ "ѵ","̏" }, |
| 35111 |
["Ӂ"]={ "Ж","̆" }, |
| 35112 |
["ӂ"]={ "ж","̆" }, |
| 35113 |
["Ӑ"]={ "А","̆" }, |
| 35114 |
["ӑ"]={ "а","̆" }, |
| 35115 |
["Ӓ"]={ "А","̈" }, |
| 35116 |
["ӓ"]={ "а","̈" }, |
| 35117 |
["Ӗ"]={ "Е","̆" }, |
| 35118 |
["ӗ"]={ "е","̆" }, |
| 35119 |
["Ӛ"]={ "Ә","̈" }, |
| 35120 |
["ӛ"]={ "ә","̈" }, |
| 35121 |
["Ӝ"]={ "Ж","̈" }, |
| 35122 |
["ӝ"]={ "ж","̈" }, |
| 35123 |
["Ӟ"]={ "З","̈" }, |
| 35124 |
["ӟ"]={ "з","̈" }, |
| 35125 |
["Ӣ"]={ "И","̄" }, |
| 35126 |
["ӣ"]={ "и","̄" }, |
| 35127 |
["Ӥ"]={ "И","̈" }, |
| 35128 |
["ӥ"]={ "и","̈" }, |
| 35129 |
["Ӧ"]={ "О","̈" }, |
| 35130 |
["ӧ"]={ "о","̈" }, |
| 35131 |
["Ӫ"]={ "Ө","̈" }, |
| 35132 |
["ӫ"]={ "ө","̈" }, |
| 35133 |
["Ӭ"]={ "Э","̈" }, |
| 35134 |
["ӭ"]={ "э","̈" }, |
| 35135 |
["Ӯ"]={ "У","̄" }, |
| 35136 |
["ӯ"]={ "у","̄" }, |
| 35137 |
["Ӱ"]={ "У","̈" }, |
| 35138 |
["ӱ"]={ "у","̈" }, |
| 35139 |
["Ӳ"]={ "У","̋" }, |
| 35140 |
["ӳ"]={ "у","̋" }, |
| 35141 |
["Ӵ"]={ "Ч","̈" }, |
| 35142 |
["ӵ"]={ "ч","̈" }, |
| 35143 |
["Ӹ"]={ "Ы","̈" }, |
| 35144 |
["ӹ"]={ "ы","̈" }, |
| 35145 |
["آ"]={ "ا","ٓ" }, |
| 35146 |
["أ"]={ "ا","ٔ" }, |
| 35147 |
["ؤ"]={ "و","ٔ" }, |
| 35148 |
["إ"]={ "ا","ٕ" }, |
| 35149 |
["ئ"]={ "ي","ٔ" }, |
| 35150 |
["ۀ"]={ "ە","ٔ" }, |
| 35151 |
["ۂ"]={ "ہ","ٔ" }, |
| 35152 |
["ۓ"]={ "ے","ٔ" }, |
| 35153 |
["ऩ"]={ "न","़" }, |
| 35154 |
["ऱ"]={ "र","़" }, |
| 35155 |
["ऴ"]={ "ळ","़" }, |
| 35156 |
["क़"]={ "क","़" }, |
| 35157 |
["ख़"]={ "ख","़" }, |
| 35158 |
["ग़"]={ "ग","़" }, |
| 35159 |
["ज़"]={ "ज","़" }, |
| 35160 |
["ड़"]={ "ड","़" }, |
| 35161 |
["ढ़"]={ "ढ","़" }, |
| 35162 |
["फ़"]={ "फ","़" }, |
| 35163 |
["य़"]={ "य","़" }, |
| 35164 |
["ো"]={ "ে","া" }, |
| 35165 |
["ৌ"]={ "ে","ৗ" }, |
| 35166 |
["ড়"]={ "ড","়" }, |
| 35167 |
["ঢ়"]={ "ঢ","়" }, |
| 35168 |
["য়"]={ "য","়" }, |
| 35169 |
["ਲ਼"]={ "ਲ","਼" }, |
| 35170 |
["ਸ਼"]={ "ਸ","਼" }, |
| 35171 |
["ਖ਼"]={ "ਖ","਼" }, |
| 35172 |
["ਗ਼"]={ "ਗ","਼" }, |
| 35173 |
["ਜ਼"]={ "ਜ","਼" }, |
| 35174 |
["ਫ਼"]={ "ਫ","਼" }, |
| 35175 |
["ୈ"]={ "େ","ୖ" }, |
| 35176 |
["ୋ"]={ "େ","ା" }, |
| 35177 |
["ୌ"]={ "େ","ୗ" }, |
| 35178 |
["ଡ଼"]={ "ଡ","଼" }, |
| 35179 |
["ଢ଼"]={ "ଢ","଼" }, |
| 35180 |
["ஔ"]={ "ஒ","ௗ" }, |
| 35181 |
["ொ"]={ "ெ","ா" }, |
| 35182 |
["ோ"]={ "ே","ா" }, |
| 35183 |
["ௌ"]={ "ெ","ௗ" }, |
| 35184 |
["ై"]={ "ె","ౖ" }, |
| 35185 |
["ೀ"]={ "ಿ","ೕ" }, |
| 35186 |
["ೇ"]={ "ೆ","ೕ" }, |
| 35187 |
["ೈ"]={ "ೆ","ೖ" }, |
| 35188 |
["ೊ"]={ "ೆ","ೂ" }, |
| 35189 |
["ೋ"]={ "ೊ","ೕ" }, |
| 35190 |
["ൊ"]={ "െ","ാ" }, |
| 35191 |
["ോ"]={ "േ","ാ" }, |
| 35192 |
["ൌ"]={ "െ","ൗ" }, |
| 35193 |
["ේ"]={ "ෙ","්" }, |
| 35194 |
["ො"]={ "ෙ","ා" }, |
| 35195 |
["ෝ"]={ "ො","්" }, |
| 35196 |
["ෞ"]={ "ෙ","ෟ" }, |
| 35197 |
["གྷ"]={ "ག","ྷ" }, |
| 35198 |
["ཌྷ"]={ "ཌ","ྷ" }, |
| 35199 |
["དྷ"]={ "ད","ྷ" }, |
| 35200 |
["བྷ"]={ "བ","ྷ" }, |
| 35201 |
["ཛྷ"]={ "ཛ","ྷ" }, |
| 35202 |
["ཀྵ"]={ "ཀ","ྵ" }, |
| 35203 |
["ཱི"]={ "ཱ","ི" }, |
| 35204 |
["ཱུ"]={ "ཱ","ུ" }, |
| 35205 |
["ྲྀ"]={ "ྲ","ྀ" }, |
| 35206 |
["ླྀ"]={ "ླ","ྀ" }, |
| 35207 |
["ཱྀ"]={ "ཱ","ྀ" }, |
| 35208 |
["ྒྷ"]={ "ྒ","ྷ" }, |
| 35209 |
["ྜྷ"]={ "ྜ","ྷ" }, |
| 35210 |
["ྡྷ"]={ "ྡ","ྷ" }, |
| 35211 |
["ྦྷ"]={ "ྦ","ྷ" }, |
| 35212 |
["ྫྷ"]={ "ྫ","ྷ" }, |
| 35213 |
["ྐྵ"]={ "ྐ","ྵ" }, |
| 35214 |
["ဦ"]={ "ဥ","ီ" }, |
| 35215 |
["ᬆ"]={ "ᬅ","ᬵ" }, |
| 35216 |
["ᬈ"]={ "ᬇ","ᬵ" }, |
| 35217 |
["ᬊ"]={ "ᬉ","ᬵ" }, |
| 35218 |
["ᬌ"]={ "ᬋ","ᬵ" }, |
| 35219 |
["ᬎ"]={ "ᬍ","ᬵ" }, |
| 35220 |
["ᬒ"]={ "ᬑ","ᬵ" }, |
| 35221 |
["ᬻ"]={ "ᬺ","ᬵ" }, |
| 35222 |
["ᬽ"]={ "ᬼ","ᬵ" }, |
| 35223 |
["ᭀ"]={ "ᬾ","ᬵ" }, |
| 35224 |
["ᭁ"]={ "ᬿ","ᬵ" }, |
| 35225 |
["ᭃ"]={ "ᭂ","ᬵ" }, |
| 35226 |
["Ḁ"]={ "A","̥" }, |
| 35227 |
["ḁ"]={ "a","̥" }, |
| 35228 |
["Ḃ"]={ "B","̇" }, |
| 35229 |
["ḃ"]={ "b","̇" }, |
| 35230 |
["Ḅ"]={ "B","̣" }, |
| 35231 |
["ḅ"]={ "b","̣" }, |
| 35232 |
["Ḇ"]={ "B","̱" }, |
| 35233 |
["ḇ"]={ "b","̱" }, |
| 35234 |
["Ḉ"]={ "Ç","́" }, |
| 35235 |
["ḉ"]={ "ç","́" }, |
| 35236 |
["Ḋ"]={ "D","̇" }, |
| 35237 |
["ḋ"]={ "d","̇" }, |
| 35238 |
["Ḍ"]={ "D","̣" }, |
| 35239 |
["ḍ"]={ "d","̣" }, |
| 35240 |
["Ḏ"]={ "D","̱" }, |
| 35241 |
["ḏ"]={ "d","̱" }, |
| 35242 |
["Ḑ"]={ "D","̧" }, |
| 35243 |
["ḑ"]={ "d","̧" }, |
| 35244 |
["Ḓ"]={ "D","̭" }, |
| 35245 |
["ḓ"]={ "d","̭" }, |
| 35246 |
["Ḕ"]={ "Ē","̀" }, |
| 35247 |
["ḕ"]={ "ē","̀" }, |
| 35248 |
["Ḗ"]={ "Ē","́" }, |
| 35249 |
["ḗ"]={ "ē","́" }, |
| 35250 |
["Ḙ"]={ "E","̭" }, |
| 35251 |
["ḙ"]={ "e","̭" }, |
| 35252 |
["Ḛ"]={ "E","̰" }, |
| 35253 |
["ḛ"]={ "e","̰" }, |
| 35254 |
["Ḝ"]={ "Ȩ","̆" }, |
| 35255 |
["ḝ"]={ "ȩ","̆" }, |
| 35256 |
["Ḟ"]={ "F","̇" }, |
| 35257 |
["ḟ"]={ "f","̇" }, |
| 35258 |
["Ḡ"]={ "G","̄" }, |
| 35259 |
["ḡ"]={ "g","̄" }, |
| 35260 |
["Ḣ"]={ "H","̇" }, |
| 35261 |
["ḣ"]={ "h","̇" }, |
| 35262 |
["Ḥ"]={ "H","̣" }, |
| 35263 |
["ḥ"]={ "h","̣" }, |
| 35264 |
["Ḧ"]={ "H","̈" }, |
| 35265 |
["ḧ"]={ "h","̈" }, |
| 35266 |
["Ḩ"]={ "H","̧" }, |
| 35267 |
["ḩ"]={ "h","̧" }, |
| 35268 |
["Ḫ"]={ "H","̮" }, |
| 35269 |
["ḫ"]={ "h","̮" }, |
| 35270 |
["Ḭ"]={ "I","̰" }, |
| 35271 |
["ḭ"]={ "i","̰" }, |
| 35272 |
["Ḯ"]={ "Ï","́" }, |
| 35273 |
["ḯ"]={ "ï","́" }, |
| 35274 |
["Ḱ"]={ "K","́" }, |
| 35275 |
["ḱ"]={ "k","́" }, |
| 35276 |
["Ḳ"]={ "K","̣" }, |
| 35277 |
["ḳ"]={ "k","̣" }, |
| 35278 |
["Ḵ"]={ "K","̱" }, |
| 35279 |
["ḵ"]={ "k","̱" }, |
| 35280 |
["Ḷ"]={ "L","̣" }, |
| 35281 |
["ḷ"]={ "l","̣" }, |
| 35282 |
["Ḹ"]={ "Ḷ","̄" }, |
| 35283 |
["ḹ"]={ "ḷ","̄" }, |
| 35284 |
["Ḻ"]={ "L","̱" }, |
| 35285 |
["ḻ"]={ "l","̱" }, |
| 35286 |
["Ḽ"]={ "L","̭" }, |
| 35287 |
["ḽ"]={ "l","̭" }, |
| 35288 |
["Ḿ"]={ "M","́" }, |
| 35289 |
["ḿ"]={ "m","́" }, |
| 35290 |
["Ṁ"]={ "M","̇" }, |
| 35291 |
["ṁ"]={ "m","̇" }, |
| 35292 |
["Ṃ"]={ "M","̣" }, |
| 35293 |
["ṃ"]={ "m","̣" }, |
| 35294 |
["Ṅ"]={ "N","̇" }, |
| 35295 |
["ṅ"]={ "n","̇" }, |
| 35296 |
["Ṇ"]={ "N","̣" }, |
| 35297 |
["ṇ"]={ "n","̣" }, |
| 35298 |
["Ṉ"]={ "N","̱" }, |
| 35299 |
["ṉ"]={ "n","̱" }, |
| 35300 |
["Ṋ"]={ "N","̭" }, |
| 35301 |
["ṋ"]={ "n","̭" }, |
| 35302 |
["Ṍ"]={ "Õ","́" }, |
| 35303 |
["ṍ"]={ "õ","́" }, |
| 35304 |
["Ṏ"]={ "Õ","̈" }, |
| 35305 |
["ṏ"]={ "õ","̈" }, |
| 35306 |
["Ṑ"]={ "Ō","̀" }, |
| 35307 |
["ṑ"]={ "ō","̀" }, |
| 35308 |
["Ṓ"]={ "Ō","́" }, |
| 35309 |
["ṓ"]={ "ō","́" }, |
| 35310 |
["Ṕ"]={ "P","́" }, |
| 35311 |
["ṕ"]={ "p","́" }, |
| 35312 |
["Ṗ"]={ "P","̇" }, |
| 35313 |
["ṗ"]={ "p","̇" }, |
| 35314 |
["Ṙ"]={ "R","̇" }, |
| 35315 |
["ṙ"]={ "r","̇" }, |
| 35316 |
["Ṛ"]={ "R","̣" }, |
| 35317 |
["ṛ"]={ "r","̣" }, |
| 35318 |
["Ṝ"]={ "Ṛ","̄" }, |
| 35319 |
["ṝ"]={ "ṛ","̄" }, |
| 35320 |
["Ṟ"]={ "R","̱" }, |
| 35321 |
["ṟ"]={ "r","̱" }, |
| 35322 |
["Ṡ"]={ "S","̇" }, |
| 35323 |
["ṡ"]={ "s","̇" }, |
| 35324 |
["Ṣ"]={ "S","̣" }, |
| 35325 |
["ṣ"]={ "s","̣" }, |
| 35326 |
["Ṥ"]={ "Ś","̇" }, |
| 35327 |
["ṥ"]={ "ś","̇" }, |
| 35328 |
["Ṧ"]={ "Š","̇" }, |
| 35329 |
["ṧ"]={ "š","̇" }, |
| 35330 |
["Ṩ"]={ "Ṣ","̇" }, |
| 35331 |
["ṩ"]={ "ṣ","̇" }, |
| 35332 |
["Ṫ"]={ "T","̇" }, |
| 35333 |
["ṫ"]={ "t","̇" }, |
| 35334 |
["Ṭ"]={ "T","̣" }, |
| 35335 |
["ṭ"]={ "t","̣" }, |
| 35336 |
["Ṯ"]={ "T","̱" }, |
| 35337 |
["ṯ"]={ "t","̱" }, |
| 35338 |
["Ṱ"]={ "T","̭" }, |
| 35339 |
["ṱ"]={ "t","̭" }, |
| 35340 |
["Ṳ"]={ "U","̤" }, |
| 35341 |
["ṳ"]={ "u","̤" }, |
| 35342 |
["Ṵ"]={ "U","̰" }, |
| 35343 |
["ṵ"]={ "u","̰" }, |
| 35344 |
["Ṷ"]={ "U","̭" }, |
| 35345 |
["ṷ"]={ "u","̭" }, |
| 35346 |
["Ṹ"]={ "Ũ","́" }, |
| 35347 |
["ṹ"]={ "ũ","́" }, |
| 35348 |
["Ṻ"]={ "Ū","̈" }, |
| 35349 |
["ṻ"]={ "ū","̈" }, |
| 35350 |
["Ṽ"]={ "V","̃" }, |
| 35351 |
["ṽ"]={ "v","̃" }, |
| 35352 |
["Ṿ"]={ "V","̣" }, |
| 35353 |
["ṿ"]={ "v","̣" }, |
| 35354 |
["Ẁ"]={ "W","̀" }, |
| 35355 |
["ẁ"]={ "w","̀" }, |
| 35356 |
["Ẃ"]={ "W","́" }, |
| 35357 |
["ẃ"]={ "w","́" }, |
| 35358 |
["Ẅ"]={ "W","̈" }, |
| 35359 |
["ẅ"]={ "w","̈" }, |
| 35360 |
["Ẇ"]={ "W","̇" }, |
| 35361 |
["ẇ"]={ "w","̇" }, |
| 35362 |
["Ẉ"]={ "W","̣" }, |
| 35363 |
["ẉ"]={ "w","̣" }, |
| 35364 |
["Ẋ"]={ "X","̇" }, |
| 35365 |
["ẋ"]={ "x","̇" }, |
| 35366 |
["Ẍ"]={ "X","̈" }, |
| 35367 |
["ẍ"]={ "x","̈" }, |
| 35368 |
["Ẏ"]={ "Y","̇" }, |
| 35369 |
["ẏ"]={ "y","̇" }, |
| 35370 |
["Ẑ"]={ "Z","̂" }, |
| 35371 |
["ẑ"]={ "z","̂" }, |
| 35372 |
["Ẓ"]={ "Z","̣" }, |
| 35373 |
["ẓ"]={ "z","̣" }, |
| 35374 |
["Ẕ"]={ "Z","̱" }, |
| 35375 |
["ẕ"]={ "z","̱" }, |
| 35376 |
["ẖ"]={ "h","̱" }, |
| 35377 |
["ẗ"]={ "t","̈" }, |
| 35378 |
["ẘ"]={ "w","̊" }, |
| 35379 |
["ẙ"]={ "y","̊" }, |
| 35380 |
["ẛ"]={ "ſ","̇" }, |
| 35381 |
["Ạ"]={ "A","̣" }, |
| 35382 |
["ạ"]={ "a","̣" }, |
| 35383 |
["Ả"]={ "A","̉" }, |
| 35384 |
["ả"]={ "a","̉" }, |
| 35385 |
["Ấ"]={ "Â","́" }, |
| 35386 |
["ấ"]={ "â","́" }, |
| 35387 |
["Ầ"]={ "Â","̀" }, |
| 35388 |
["ầ"]={ "â","̀" }, |
| 35389 |
["Ẩ"]={ "Â","̉" }, |
| 35390 |
["ẩ"]={ "â","̉" }, |
| 35391 |
["Ẫ"]={ "Â","̃" }, |
| 35392 |
["ẫ"]={ "â","̃" }, |
| 35393 |
["Ậ"]={ "Ạ","̂" }, |
| 35394 |
["ậ"]={ "ạ","̂" }, |
| 35395 |
["Ắ"]={ "Ă","́" }, |
| 35396 |
["ắ"]={ "ă","́" }, |
| 35397 |
["Ằ"]={ "Ă","̀" }, |
| 35398 |
["ằ"]={ "ă","̀" }, |
| 35399 |
["Ẳ"]={ "Ă","̉" }, |
| 35400 |
["ẳ"]={ "ă","̉" }, |
| 35401 |
["Ẵ"]={ "Ă","̃" }, |
| 35402 |
["ẵ"]={ "ă","̃" }, |
| 35403 |
["Ặ"]={ "Ạ","̆" }, |
| 35404 |
["ặ"]={ "ạ","̆" }, |
| 35405 |
["Ẹ"]={ "E","̣" }, |
| 35406 |
["ẹ"]={ "e","̣" }, |
| 35407 |
["Ẻ"]={ "E","̉" }, |
| 35408 |
["ẻ"]={ "e","̉" }, |
| 35409 |
["Ẽ"]={ "E","̃" }, |
| 35410 |
["ẽ"]={ "e","̃" }, |
| 35411 |
["Ế"]={ "Ê","́" }, |
| 35412 |
["ế"]={ "ê","́" }, |
| 35413 |
["Ề"]={ "Ê","̀" }, |
| 35414 |
["ề"]={ "ê","̀" }, |
| 35415 |
["Ể"]={ "Ê","̉" }, |
| 35416 |
["ể"]={ "ê","̉" }, |
| 35417 |
["Ễ"]={ "Ê","̃" }, |
| 35418 |
["ễ"]={ "ê","̃" }, |
| 35419 |
["Ệ"]={ "Ẹ","̂" }, |
| 35420 |
["ệ"]={ "ẹ","̂" }, |
| 35421 |
["Ỉ"]={ "I","̉" }, |
| 35422 |
["ỉ"]={ "i","̉" }, |
| 35423 |
["Ị"]={ "I","̣" }, |
| 35424 |
["ị"]={ "i","̣" }, |
| 35425 |
["Ọ"]={ "O","̣" }, |
| 35426 |
["ọ"]={ "o","̣" }, |
| 35427 |
["Ỏ"]={ "O","̉" }, |
| 35428 |
["ỏ"]={ "o","̉" }, |
| 35429 |
["Ố"]={ "Ô","́" }, |
| 35430 |
["ố"]={ "ô","́" }, |
| 35431 |
["Ồ"]={ "Ô","̀" }, |
| 35432 |
["ồ"]={ "ô","̀" }, |
| 35433 |
["Ổ"]={ "Ô","̉" }, |
| 35434 |
["ổ"]={ "ô","̉" }, |
| 35435 |
["Ỗ"]={ "Ô","̃" }, |
| 35436 |
["ỗ"]={ "ô","̃" }, |
| 35437 |
["Ộ"]={ "Ọ","̂" }, |
| 35438 |
["ộ"]={ "ọ","̂" }, |
| 35439 |
["Ớ"]={ "Ơ","́" }, |
| 35440 |
["ớ"]={ "ơ","́" }, |
| 35441 |
["Ờ"]={ "Ơ","̀" }, |
| 35442 |
["ờ"]={ "ơ","̀" }, |
| 35443 |
["Ở"]={ "Ơ","̉" }, |
| 35444 |
["ở"]={ "ơ","̉" }, |
| 35445 |
["Ỡ"]={ "Ơ","̃" }, |
| 35446 |
["ỡ"]={ "ơ","̃" }, |
| 35447 |
["Ợ"]={ "Ơ","̣" }, |
| 35448 |
["ợ"]={ "ơ","̣" }, |
| 35449 |
["Ụ"]={ "U","̣" }, |
| 35450 |
["ụ"]={ "u","̣" }, |
| 35451 |
["Ủ"]={ "U","̉" }, |
| 35452 |
["ủ"]={ "u","̉" }, |
| 35453 |
["Ứ"]={ "Ư","́" }, |
| 35454 |
["ứ"]={ "ư","́" }, |
| 35455 |
["Ừ"]={ "Ư","̀" }, |
| 35456 |
["ừ"]={ "ư","̀" }, |
| 35457 |
["Ử"]={ "Ư","̉" }, |
| 35458 |
["ử"]={ "ư","̉" }, |
| 35459 |
["Ữ"]={ "Ư","̃" }, |
| 35460 |
["ữ"]={ "ư","̃" }, |
| 35461 |
["Ự"]={ "Ư","̣" }, |
| 35462 |
["ự"]={ "ư","̣" }, |
| 35463 |
["Ỳ"]={ "Y","̀" }, |
| 35464 |
["ỳ"]={ "y","̀" }, |
| 35465 |
["Ỵ"]={ "Y","̣" }, |
| 35466 |
["ỵ"]={ "y","̣" }, |
| 35467 |
["Ỷ"]={ "Y","̉" }, |
| 35468 |
["ỷ"]={ "y","̉" }, |
| 35469 |
["Ỹ"]={ "Y","̃" }, |
| 35470 |
["ỹ"]={ "y","̃" }, |
| 35471 |
["ἀ"]={ "α","̓" }, |
| 35472 |
["ἁ"]={ "α","̔" }, |
| 35473 |
["ἂ"]={ "ἀ","̀" }, |
| 35474 |
["ἃ"]={ "ἁ","̀" }, |
| 35475 |
["ἄ"]={ "ἀ","́" }, |
| 35476 |
["ἅ"]={ "ἁ","́" }, |
| 35477 |
["ἆ"]={ "ἀ","͂" }, |
| 35478 |
["ἇ"]={ "ἁ","͂" }, |
| 35479 |
["Ἀ"]={ "Α","̓" }, |
| 35480 |
["Ἁ"]={ "Α","̔" }, |
| 35481 |
["Ἂ"]={ "Ἀ","̀" }, |
| 35482 |
["Ἃ"]={ "Ἁ","̀" }, |
| 35483 |
["Ἄ"]={ "Ἀ","́" }, |
| 35484 |
["Ἅ"]={ "Ἁ","́" }, |
| 35485 |
["Ἆ"]={ "Ἀ","͂" }, |
| 35486 |
["Ἇ"]={ "Ἁ","͂" }, |
| 35487 |
["ἐ"]={ "ε","̓" }, |
| 35488 |
["ἑ"]={ "ε","̔" }, |
| 35489 |
["ἒ"]={ "ἐ","̀" }, |
| 35490 |
["ἓ"]={ "ἑ","̀" }, |
| 35491 |
["ἔ"]={ "ἐ","́" }, |
| 35492 |
["ἕ"]={ "ἑ","́" }, |
| 35493 |
["Ἐ"]={ "Ε","̓" }, |
| 35494 |
["Ἑ"]={ "Ε","̔" }, |
| 35495 |
["Ἒ"]={ "Ἐ","̀" }, |
| 35496 |
["Ἓ"]={ "Ἑ","̀" }, |
| 35497 |
["Ἔ"]={ "Ἐ","́" }, |
| 35498 |
["Ἕ"]={ "Ἑ","́" }, |
| 35499 |
["ἠ"]={ "η","̓" }, |
| 35500 |
["ἡ"]={ "η","̔" }, |
| 35501 |
["ἢ"]={ "ἠ","̀" }, |
| 35502 |
["ἣ"]={ "ἡ","̀" }, |
| 35503 |
["ἤ"]={ "ἠ","́" }, |
| 35504 |
["ἥ"]={ "ἡ","́" }, |
| 35505 |
["ἦ"]={ "ἠ","͂" }, |
| 35506 |
["ἧ"]={ "ἡ","͂" }, |
| 35507 |
["Ἠ"]={ "Η","̓" }, |
| 35508 |
["Ἡ"]={ "Η","̔" }, |
| 35509 |
["Ἢ"]={ "Ἠ","̀" }, |
| 35510 |
["Ἣ"]={ "Ἡ","̀" }, |
| 35511 |
["Ἤ"]={ "Ἠ","́" }, |
| 35512 |
["Ἥ"]={ "Ἡ","́" }, |
| 35513 |
["Ἦ"]={ "Ἠ","͂" }, |
| 35514 |
["Ἧ"]={ "Ἡ","͂" }, |
| 35515 |
["ἰ"]={ "ι","̓" }, |
| 35516 |
["ἱ"]={ "ι","̔" }, |
| 35517 |
["ἲ"]={ "ἰ","̀" }, |
| 35518 |
["ἳ"]={ "ἱ","̀" }, |
| 35519 |
["ἴ"]={ "ἰ","́" }, |
| 35520 |
["ἵ"]={ "ἱ","́" }, |
| 35521 |
["ἶ"]={ "ἰ","͂" }, |
| 35522 |
["ἷ"]={ "ἱ","͂" }, |
| 35523 |
["Ἰ"]={ "Ι","̓" }, |
| 35524 |
["Ἱ"]={ "Ι","̔" }, |
| 35525 |
["Ἲ"]={ "Ἰ","̀" }, |
| 35526 |
["Ἳ"]={ "Ἱ","̀" }, |
| 35527 |
["Ἴ"]={ "Ἰ","́" }, |
| 35528 |
["Ἵ"]={ "Ἱ","́" }, |
| 35529 |
["Ἶ"]={ "Ἰ","͂" }, |
| 35530 |
["Ἷ"]={ "Ἱ","͂" }, |
| 35531 |
["ὀ"]={ "ο","̓" }, |
| 35532 |
["ὁ"]={ "ο","̔" }, |
| 35533 |
["ὂ"]={ "ὀ","̀" }, |
| 35534 |
["ὃ"]={ "ὁ","̀" }, |
| 35535 |
["ὄ"]={ "ὀ","́" }, |
| 35536 |
["ὅ"]={ "ὁ","́" }, |
| 35537 |
["Ὀ"]={ "Ο","̓" }, |
| 35538 |
["Ὁ"]={ "Ο","̔" }, |
| 35539 |
["Ὂ"]={ "Ὀ","̀" }, |
| 35540 |
["Ὃ"]={ "Ὁ","̀" }, |
| 35541 |
["Ὄ"]={ "Ὀ","́" }, |
| 35542 |
["Ὅ"]={ "Ὁ","́" }, |
| 35543 |
["ὐ"]={ "υ","̓" }, |
| 35544 |
["ὑ"]={ "υ","̔" }, |
| 35545 |
["ὒ"]={ "ὐ","̀" }, |
| 35546 |
["ὓ"]={ "ὑ","̀" }, |
| 35547 |
["ὔ"]={ "ὐ","́" }, |
| 35548 |
["ὕ"]={ "ὑ","́" }, |
| 35549 |
["ὖ"]={ "ὐ","͂" }, |
| 35550 |
["ὗ"]={ "ὑ","͂" }, |
| 35551 |
["Ὑ"]={ "Υ","̔" }, |
| 35552 |
["Ὓ"]={ "Ὑ","̀" }, |
| 35553 |
["Ὕ"]={ "Ὑ","́" }, |
| 35554 |
["Ὗ"]={ "Ὑ","͂" }, |
| 35555 |
["ὠ"]={ "ω","̓" }, |
| 35556 |
["ὡ"]={ "ω","̔" }, |
| 35557 |
["ὢ"]={ "ὠ","̀" }, |
| 35558 |
["ὣ"]={ "ὡ","̀" }, |
| 35559 |
["ὤ"]={ "ὠ","́" }, |
| 35560 |
["ὥ"]={ "ὡ","́" }, |
| 35561 |
["ὦ"]={ "ὠ","͂" }, |
| 35562 |
["ὧ"]={ "ὡ","͂" }, |
| 35563 |
["Ὠ"]={ "Ω","̓" }, |
| 35564 |
["Ὡ"]={ "Ω","̔" }, |
| 35565 |
["Ὢ"]={ "Ὠ","̀" }, |
| 35566 |
["Ὣ"]={ "Ὡ","̀" }, |
| 35567 |
["Ὤ"]={ "Ὠ","́" }, |
| 35568 |
["Ὥ"]={ "Ὡ","́" }, |
| 35569 |
["Ὦ"]={ "Ὠ","͂" }, |
| 35570 |
["Ὧ"]={ "Ὡ","͂" }, |
| 35571 |
["ὰ"]={ "α","̀" }, |
| 35572 |
["ὲ"]={ "ε","̀" }, |
| 35573 |
["ὴ"]={ "η","̀" }, |
| 35574 |
["ὶ"]={ "ι","̀" }, |
| 35575 |
["ὸ"]={ "ο","̀" }, |
| 35576 |
["ὺ"]={ "υ","̀" }, |
| 35577 |
["ὼ"]={ "ω","̀" }, |
| 35578 |
["ᾀ"]={ "ἀ","ͅ" }, |
| 35579 |
["ᾁ"]={ "ἁ","ͅ" }, |
| 35580 |
["ᾂ"]={ "ἂ","ͅ" }, |
| 35581 |
["ᾃ"]={ "ἃ","ͅ" }, |
| 35582 |
["ᾄ"]={ "ἄ","ͅ" }, |
| 35583 |
["ᾅ"]={ "ἅ","ͅ" }, |
| 35584 |
["ᾆ"]={ "ἆ","ͅ" }, |
| 35585 |
["ᾇ"]={ "ἇ","ͅ" }, |
| 35586 |
["ᾈ"]={ "Ἀ","ͅ" }, |
| 35587 |
["ᾉ"]={ "Ἁ","ͅ" }, |
| 35588 |
["ᾊ"]={ "Ἂ","ͅ" }, |
| 35589 |
["ᾋ"]={ "Ἃ","ͅ" }, |
| 35590 |
["ᾌ"]={ "Ἄ","ͅ" }, |
| 35591 |
["ᾍ"]={ "Ἅ","ͅ" }, |
| 35592 |
["ᾎ"]={ "Ἆ","ͅ" }, |
| 35593 |
["ᾏ"]={ "Ἇ","ͅ" }, |
| 35594 |
["ᾐ"]={ "ἠ","ͅ" }, |
| 35595 |
["ᾑ"]={ "ἡ","ͅ" }, |
| 35596 |
["ᾒ"]={ "ἢ","ͅ" }, |
| 35597 |
["ᾓ"]={ "ἣ","ͅ" }, |
| 35598 |
["ᾔ"]={ "ἤ","ͅ" }, |
| 35599 |
["ᾕ"]={ "ἥ","ͅ" }, |
| 35600 |
["ᾖ"]={ "ἦ","ͅ" }, |
| 35601 |
["ᾗ"]={ "ἧ","ͅ" }, |
| 35602 |
["ᾘ"]={ "Ἠ","ͅ" }, |
| 35603 |
["ᾙ"]={ "Ἡ","ͅ" }, |
| 35604 |
["ᾚ"]={ "Ἢ","ͅ" }, |
| 35605 |
["ᾛ"]={ "Ἣ","ͅ" }, |
| 35606 |
["ᾜ"]={ "Ἤ","ͅ" }, |
| 35607 |
["ᾝ"]={ "Ἥ","ͅ" }, |
| 35608 |
["ᾞ"]={ "Ἦ","ͅ" }, |
| 35609 |
["ᾟ"]={ "Ἧ","ͅ" }, |
| 35610 |
["ᾠ"]={ "ὠ","ͅ" }, |
| 35611 |
["ᾡ"]={ "ὡ","ͅ" }, |
| 35612 |
["ᾢ"]={ "ὢ","ͅ" }, |
| 35613 |
["ᾣ"]={ "ὣ","ͅ" }, |
| 35614 |
["ᾤ"]={ "ὤ","ͅ" }, |
| 35615 |
["ᾥ"]={ "ὥ","ͅ" }, |
| 35616 |
["ᾦ"]={ "ὦ","ͅ" }, |
| 35617 |
["ᾧ"]={ "ὧ","ͅ" }, |
| 35618 |
["ᾨ"]={ "Ὠ","ͅ" }, |
| 35619 |
["ᾩ"]={ "Ὡ","ͅ" }, |
| 35620 |
["ᾪ"]={ "Ὢ","ͅ" }, |
| 35621 |
["ᾫ"]={ "Ὣ","ͅ" }, |
| 35622 |
["ᾬ"]={ "Ὤ","ͅ" }, |
| 35623 |
["ᾭ"]={ "Ὥ","ͅ" }, |
| 35624 |
["ᾮ"]={ "Ὦ","ͅ" }, |
| 35625 |
["ᾯ"]={ "Ὧ","ͅ" }, |
| 35626 |
["ᾰ"]={ "α","̆" }, |
| 35627 |
["ᾱ"]={ "α","̄" }, |
| 35628 |
["ᾲ"]={ "ὰ","ͅ" }, |
| 35629 |
["ᾳ"]={ "α","ͅ" }, |
| 35630 |
["ᾴ"]={ "ά","ͅ" }, |
| 35631 |
["ᾶ"]={ "α","͂" }, |
| 35632 |
["ᾷ"]={ "ᾶ","ͅ" }, |
| 35633 |
["Ᾰ"]={ "Α","̆" }, |
| 35634 |
["Ᾱ"]={ "Α","̄" }, |
| 35635 |
["Ὰ"]={ "Α","̀" }, |
| 35636 |
["ᾼ"]={ "Α","ͅ" }, |
| 35637 |
["῁"]={ "¨","͂" }, |
| 35638 |
["ῂ"]={ "ὴ","ͅ" }, |
| 35639 |
["ῃ"]={ "η","ͅ" }, |
| 35640 |
["ῄ"]={ "ή","ͅ" }, |
| 35641 |
["ῆ"]={ "η","͂" }, |
| 35642 |
["ῇ"]={ "ῆ","ͅ" }, |
| 35643 |
["Ὲ"]={ "Ε","̀" }, |
| 35644 |
["Ὴ"]={ "Η","̀" }, |
| 35645 |
["ῌ"]={ "Η","ͅ" }, |
| 35646 |
["῍"]={ "᾿","̀" }, |
| 35647 |
["῎"]={ "᾿","́" }, |
| 35648 |
["῏"]={ "᾿","͂" }, |
| 35649 |
["ῐ"]={ "ι","̆" }, |
| 35650 |
["ῑ"]={ "ι","̄" }, |
| 35651 |
["ῒ"]={ "ϊ","̀" }, |
| 35652 |
["ῖ"]={ "ι","͂" }, |
| 35653 |
["ῗ"]={ "ϊ","͂" }, |
| 35654 |
["Ῐ"]={ "Ι","̆" }, |
| 35655 |
["Ῑ"]={ "Ι","̄" }, |
| 35656 |
["Ὶ"]={ "Ι","̀" }, |
| 35657 |
["῝"]={ "῾","̀" }, |
| 35658 |
["῞"]={ "῾","́" }, |
| 35659 |
["῟"]={ "῾","͂" }, |
| 35660 |
["ῠ"]={ "υ","̆" }, |
| 35661 |
["ῡ"]={ "υ","̄" }, |
| 35662 |
["ῢ"]={ "ϋ","̀" }, |
| 35663 |
["ῤ"]={ "ρ","̓" }, |
| 35664 |
["ῥ"]={ "ρ","̔" }, |
| 35665 |
["ῦ"]={ "υ","͂" }, |
| 35666 |
["ῧ"]={ "ϋ","͂" }, |
| 35667 |
["Ῠ"]={ "Υ","̆" }, |
| 35668 |
["Ῡ"]={ "Υ","̄" }, |
| 35669 |
["Ὺ"]={ "Υ","̀" }, |
| 35670 |
["Ῥ"]={ "Ρ","̔" }, |
| 35671 |
["῭"]={ "¨","̀" }, |
| 35672 |
["ῲ"]={ "ὼ","ͅ" }, |
| 35673 |
["ῳ"]={ "ω","ͅ" }, |
| 35674 |
["ῴ"]={ "ώ","ͅ" }, |
| 35675 |
["ῶ"]={ "ω","͂" }, |
| 35676 |
["ῷ"]={ "ῶ","ͅ" }, |
| 35677 |
["Ὸ"]={ "Ο","̀" }, |
| 35678 |
["Ὼ"]={ "Ω","̀" }, |
| 35679 |
["ῼ"]={ "Ω","ͅ" }, |
| 35680 |
["↚"]={ "←","̸" }, |
| 35681 |
["↛"]={ "→","̸" }, |
| 35682 |
["↮"]={ "↔","̸" }, |
| 35683 |
["⇍"]={ "⇐","̸" }, |
| 35684 |
["⇎"]={ "⇔","̸" }, |
| 35685 |
["⇏"]={ "⇒","̸" }, |
| 35686 |
["∄"]={ "∃","̸" }, |
| 35687 |
["∉"]={ "∈","̸" }, |
| 35688 |
["∌"]={ "∋","̸" }, |
| 35689 |
["∤"]={ "∣","̸" }, |
| 35690 |
["∦"]={ "∥","̸" }, |
| 35691 |
["≁"]={ "∼","̸" }, |
| 35692 |
["≄"]={ "≃","̸" }, |
| 35693 |
["≇"]={ "≅","̸" }, |
| 35694 |
["≉"]={ "≈","̸" }, |
| 35695 |
["≠"]={ "=","̸" }, |
| 35696 |
["≢"]={ "≡","̸" }, |
| 35697 |
["≭"]={ "≍","̸" }, |
| 35698 |
["≮"]={ "<","̸" }, |
| 35699 |
["≯"]={ ">","̸" }, |
| 35700 |
["≰"]={ "≤","̸" }, |
| 35701 |
["≱"]={ "≥","̸" }, |
| 35702 |
["≴"]={ "≲","̸" }, |
| 35703 |
["≵"]={ "≳","̸" }, |
| 35704 |
["≸"]={ "≶","̸" }, |
| 35705 |
["≹"]={ "≷","̸" }, |
| 35706 |
["⊀"]={ "≺","̸" }, |
| 35707 |
["⊁"]={ "≻","̸" }, |
| 35708 |
["⊄"]={ "⊂","̸" }, |
| 35709 |
["⊅"]={ "⊃","̸" }, |
| 35710 |
["⊈"]={ "⊆","̸" }, |
| 35711 |
["⊉"]={ "⊇","̸" }, |
| 35712 |
["⊬"]={ "⊢","̸" }, |
| 35713 |
["⊭"]={ "⊨","̸" }, |
| 35714 |
["⊮"]={ "⊩","̸" }, |
| 35715 |
["⊯"]={ "⊫","̸" }, |
| 35716 |
["⋠"]={ "≼","̸" }, |
| 35717 |
["⋡"]={ "≽","̸" }, |
| 35718 |
["⋢"]={ "⊑","̸" }, |
| 35719 |
["⋣"]={ "⊒","̸" }, |
| 35720 |
["⋪"]={ "⊲","̸" }, |
| 35721 |
["⋫"]={ "⊳","̸" }, |
| 35722 |
["⋬"]={ "⊴","̸" }, |
| 35723 |
["⋭"]={ "⊵","̸" }, |
| 35724 |
["⫝̸"]={ "⫝","̸" }, |
| 35725 |
["が"]={ "か","゙" }, |
| 35726 |
["ぎ"]={ "き","゙" }, |
| 35727 |
["ぐ"]={ "く","゙" }, |
| 35728 |
["げ"]={ "け","゙" }, |
| 35729 |
["ご"]={ "こ","゙" }, |
| 35730 |
["ざ"]={ "さ","゙" }, |
| 35731 |
["じ"]={ "し","゙" }, |
| 35732 |
["ず"]={ "す","゙" }, |
| 35733 |
["ぜ"]={ "せ","゙" }, |
| 35734 |
["ぞ"]={ "そ","゙" }, |
| 35735 |
["だ"]={ "た","゙" }, |
| 35736 |
["ぢ"]={ "ち","゙" }, |
| 35737 |
["づ"]={ "つ","゙" }, |
| 35738 |
["で"]={ "て","゙" }, |
| 35739 |
["ど"]={ "と","゙" }, |
| 35740 |
["ば"]={ "は","゙" }, |
| 35741 |
["ぱ"]={ "は","゚" }, |
| 35742 |
["び"]={ "ひ","゙" }, |
| 35743 |
["ぴ"]={ "ひ","゚" }, |
| 35744 |
["ぶ"]={ "ふ","゙" }, |
| 35745 |
["ぷ"]={ "ふ","゚" }, |
| 35746 |
["べ"]={ "へ","゙" }, |
| 35747 |
["ぺ"]={ "へ","゚" }, |
| 35748 |
["ぼ"]={ "ほ","゙" }, |
| 35749 |
["ぽ"]={ "ほ","゚" }, |
| 35750 |
["ゔ"]={ "う","゙" }, |
| 35751 |
["ゞ"]={ "ゝ","゙" }, |
| 35752 |
["ガ"]={ "カ","゙" }, |
| 35753 |
["ギ"]={ "キ","゙" }, |
| 35754 |
["グ"]={ "ク","゙" }, |
| 35755 |
["ゲ"]={ "ケ","゙" }, |
| 35756 |
["ゴ"]={ "コ","゙" }, |
| 35757 |
["ザ"]={ "サ","゙" }, |
| 35758 |
["ジ"]={ "シ","゙" }, |
| 35759 |
["ズ"]={ "ス","゙" }, |
| 35760 |
["ゼ"]={ "セ","゙" }, |
| 35761 |
["ゾ"]={ "ソ","゙" }, |
| 35762 |
["ダ"]={ "タ","゙" }, |
| 35763 |
["ヂ"]={ "チ","゙" }, |
| 35764 |
["ヅ"]={ "ツ","゙" }, |
| 35765 |
["デ"]={ "テ","゙" }, |
| 35766 |
["ド"]={ "ト","゙" }, |
| 35767 |
["バ"]={ "ハ","゙" }, |
| 35768 |
["パ"]={ "ハ","゚" }, |
| 35769 |
["ビ"]={ "ヒ","゙" }, |
| 35770 |
["ピ"]={ "ヒ","゚" }, |
| 35771 |
["ブ"]={ "フ","゙" }, |
| 35772 |
["プ"]={ "フ","゚" }, |
| 35773 |
["ベ"]={ "ヘ","゙" }, |
| 35774 |
["ペ"]={ "ヘ","゚" }, |
| 35775 |
["ボ"]={ "ホ","゙" }, |
| 35776 |
["ポ"]={ "ホ","゚" }, |
| 35777 |
["ヴ"]={ "ウ","゙" }, |
| 35778 |
["ヷ"]={ "ワ","゙" }, |
| 35779 |
["ヸ"]={ "ヰ","゙" }, |
| 35780 |
["ヹ"]={ "ヱ","゙" }, |
| 35781 |
["ヺ"]={ "ヲ","゙" }, |
| 35782 |
["ヾ"]={ "ヽ","゙" }, |
| 35783 |
["יִ"]={ "י","ִ" }, |
| 35784 |
["ײַ"]={ "ײ","ַ" }, |
| 35785 |
["שׁ"]={ "ש","ׁ" }, |
| 35786 |
["שׂ"]={ "ש","ׂ" }, |
| 35787 |
["שּׁ"]={ "שּ","ׁ" }, |
| 35788 |
["שּׂ"]={ "שּ","ׂ" }, |
| 35789 |
["אַ"]={ "א","ַ" }, |
| 35790 |
["אָ"]={ "א","ָ" }, |
| 35791 |
["אּ"]={ "א","ּ" }, |
| 35792 |
["בּ"]={ "ב","ּ" }, |
| 35793 |
["גּ"]={ "ג","ּ" }, |
| 35794 |
["דּ"]={ "ד","ּ" }, |
| 35795 |
["הּ"]={ "ה","ּ" }, |
| 35796 |
["וּ"]={ "ו","ּ" }, |
| 35797 |
["זּ"]={ "ז","ּ" }, |
| 35798 |
["טּ"]={ "ט","ּ" }, |
| 35799 |
["יּ"]={ "י","ּ" }, |
| 35800 |
["ךּ"]={ "ך","ּ" }, |
| 35801 |
["כּ"]={ "כ","ּ" }, |
| 35802 |
["לּ"]={ "ל","ּ" }, |
| 35803 |
["מּ"]={ "מ","ּ" }, |
| 35804 |
["נּ"]={ "נ","ּ" }, |
| 35805 |
["סּ"]={ "ס","ּ" }, |
| 35806 |
["ףּ"]={ "ף","ּ" }, |
| 35807 |
["פּ"]={ "פ","ּ" }, |
| 35808 |
["צּ"]={ "צ","ּ" }, |
| 35809 |
["קּ"]={ "ק","ּ" }, |
| 35810 |
["רּ"]={ "ר","ּ" }, |
| 35811 |
["שּ"]={ "ש","ּ" }, |
| 35812 |
["תּ"]={ "ת","ּ" }, |
| 35813 |
["וֹ"]={ "ו","ֹ" }, |
| 35814 |
["בֿ"]={ "ב","ֿ" }, |
| 35815 |
["כֿ"]={ "כ","ֿ" }, |
| 35816 |
["פֿ"]={ "פ","ֿ" }, |
| 35817 |
["𑂚"]={ "𑂙","𑂺" }, |
| 35818 |
["𑂜"]={ "𑂛","𑂺" }, |
| 35819 |
["𑂫"]={ "𑂥","𑂺" }, |
| 35820 |
["𑄮"]={ "𑄱","𑄧" }, |
| 35821 |
["𑄯"]={ "𑄲","𑄧" }, |
| 35822 |
["𑍋"]={ "𑍇","𑌾" }, |
| 35823 |
["𑍌"]={ "𑍇","𑍗" }, |
| 35824 |
["𑒻"]={ "𑒹","𑒺" }, |
| 35825 |
["𑒼"]={ "𑒹","𑒰" }, |
| 35826 |
["𑒾"]={ "𑒹","𑒽" }, |
| 35827 |
["𑖺"]={ "𑖸","𑖯" }, |
| 35828 |
["𑖻"]={ "𑖹","𑖯" }, |
| 35829 |
["𝅗𝅥"]={ "𝅗","𝅥" }, |
| 35830 |
["𝅘𝅥"]={ "𝅘","𝅥" }, |
| 35831 |
["𝅘𝅥𝅮"]={ "𝅘𝅥","𝅮" }, |
| 35832 |
["𝅘𝅥𝅯"]={ "𝅘𝅥","𝅯" }, |
| 35833 |
["𝅘𝅥𝅰"]={ "𝅘𝅥","𝅰" }, |
| 35834 |
["𝅘𝅥𝅱"]={ "𝅘𝅥","𝅱" }, |
| 35835 |
["𝅘𝅥𝅲"]={ "𝅘𝅥","𝅲" }, |
| 35836 |
["𝆹𝅥"]={ "𝆹","𝅥" }, |
| 35837 |
["𝆺𝅥"]={ "𝆺","𝅥" }, |
| 35838 |
["𝆹𝅥𝅮"]={ "𝆹𝅥","𝅮" }, |
| 35839 |
["𝆺𝅥𝅮"]={ "𝆺𝅥","𝅮" }, |
| 35840 |
["𝆹𝅥𝅯"]={ "𝆹𝅥","𝅯" }, |
| 35841 |
["𝆺𝅥𝅯"]={ "𝆺𝅥","𝅯" }, |
| 35842 |
}, |
| 35843 |
}, |
| 35844 |
}, |
| 35845 |
["name"]="collapse", |
| 35846 |
["prepend"]=true, |
| 35847 |
["type"]="ligature", |
| 35848 |
} |
| 35849 |
|
| 35850 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-lig”] --- |
| 35851 |
|
| 35852 |
|
| 35853 |
do --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-gbn” 34e4543a02f6fbc8c2ade896cb6dc7df] --- |
| 35854 |
|
| 35855 |
if not modules then modules={} end modules ['luatex-fonts-gbn']={ |
| 35856 |
version=1.001, |
| 35857 |
comment="companion to luatex-*.tex", |
| 35858 |
author="Hans Hagen, PRAGMA-ADE, Hasselt NL", |
| 35859 |
copyright="PRAGMA ADE / ConTeXt Development Team", |
| 35860 |
license="see context related readme files" |
| 35861 |
} |
| 35862 |
if context then |
| 35863 |
os.exit() |
| 35864 |
end |
| 35865 |
local next=next |
| 35866 |
local fonts=fonts |
| 35867 |
local nodes=nodes |
| 35868 |
local nuts=nodes.nuts |
| 35869 |
local traverseid=nuts.traverseid |
| 35870 |
local flushnode=nuts.flushnode |
| 35871 |
local glyph_code=nodes.nodecodes.glyph |
| 35872 |
local disc_code=nodes.nodecodes.disc |
| 35873 |
local tonode=nuts.tonode |
| 35874 |
local tonut=nuts.tonut |
| 35875 |
local getfont=nuts.getfont |
| 35876 |
local getchar=nuts.getchar |
| 35877 |
local getid=nuts.getid |
| 35878 |
local getboth=nuts.getboth |
| 35879 |
local getprev=nuts.getprev |
| 35880 |
local getnext=nuts.getnext |
| 35881 |
local getdisc=nuts.getdisc |
| 35882 |
local setchar=nuts.setchar |
| 35883 |
local setlink=nuts.setlink |
| 35884 |
local setprev=nuts.setprev |
| 35885 |
local n_ligaturing=node.ligaturing |
| 35886 |
local n_kerning=node.kerning |
| 35887 |
local d_ligaturing=nuts.ligaturing |
| 35888 |
local d_kerning=nuts.kerning |
| 35889 |
local basemodepass=true |
| 35890 |
local function l_warning() logs.report("fonts","don't call 'node.ligaturing' directly") l_warning=nil end |
| 35891 |
local function k_warning() logs.report("fonts","don't call 'node.kerning' directly") k_warning=nil end |
| 35892 |
function node.ligaturing(...) |
| 35893 |
if basemodepass and l_warning then |
| 35894 |
l_warning() |
| 35895 |
end |
| 35896 |
return n_ligaturing(...) |
| 35897 |
end |
| 35898 |
function node.kerning(...) |
| 35899 |
if basemodepass and k_warning then |
| 35900 |
k_warning() |
| 35901 |
end |
| 35902 |
return n_kerning(...) |
| 35903 |
end |
| 35904 |
function nuts.ligaturing(...) |
| 35905 |
if basemodepass and l_warning then |
| 35906 |
l_warning() |
| 35907 |
end |
| 35908 |
return d_ligaturing(...) |
| 35909 |
end |
| 35910 |
function nuts.kerning(...) |
| 35911 |
if basemodepass and k_warning then |
| 35912 |
k_warning() |
| 35913 |
end |
| 35914 |
return d_kerning(...) |
| 35915 |
end |
| 35916 |
function nodes.handlers.setbasemodepass(v) |
| 35917 |
basemodepass=v |
| 35918 |
end |
| 35919 |
local function nodepass(head,groupcode,size,packtype,direction) |
| 35920 |
local fontdata=fonts.hashes.identifiers |
| 35921 |
if fontdata then |
| 35922 |
local usedfonts={} |
| 35923 |
local basefonts={} |
| 35924 |
local prevfont=nil |
| 35925 |
local basefont=nil |
| 35926 |
local variants=nil |
| 35927 |
local redundant=nil |
| 35928 |
local nofused=0 |
| 35929 |
for n in traverseid(glyph_code,head) do |
| 35930 |
local font=getfont(n) |
| 35931 |
if font~=prevfont then |
| 35932 |
if basefont then |
| 35933 |
basefont[2]=getprev(n) |
| 35934 |
end |
| 35935 |
prevfont=font |
| 35936 |
local used=usedfonts[font] |
| 35937 |
if not used then |
| 35938 |
local tfmdata=fontdata[font] |
| 35939 |
if tfmdata then |
| 35940 |
local shared=tfmdata.shared |
| 35941 |
if shared then |
| 35942 |
local processors=shared.processes |
| 35943 |
if processors and #processors>0 then |
| 35944 |
usedfonts[font]=processors |
| 35945 |
nofused=nofused+1 |
| 35946 |
elseif basemodepass then |
| 35947 |
basefont={ n,nil } |
| 35948 |
basefonts[#basefonts+1]=basefont |
| 35949 |
end |
| 35950 |
end |
| 35951 |
local resources=tfmdata.resources |
| 35952 |
variants=resources and resources.variants |
| 35953 |
variants=variants and next(variants) and variants or false |
| 35954 |
end |
| 35955 |
else |
| 35956 |
local tfmdata=fontdata[prevfont] |
| 35957 |
if tfmdata then |
| 35958 |
local resources=tfmdata.resources |
| 35959 |
variants=resources and resources.variants |
| 35960 |
variants=variants and next(variants) and variants or false |
| 35961 |
end |
| 35962 |
end |
| 35963 |
end |
| 35964 |
if variants then |
| 35965 |
local char=getchar(n) |
| 35966 |
if (char>=0xFE00 and char<=0xFE0F) or (char>=0xE0100 and char<=0xE01EF) then |
| 35967 |
local hash=variants[char] |
| 35968 |
if hash then |
| 35969 |
local p=getprev(n) |
| 35970 |
if p and getid(p)==glyph_code then |
| 35971 |
local variant=hash[getchar(p)] |
| 35972 |
if variant then |
| 35973 |
setchar(p,variant) |
| 35974 |
end |
| 35975 |
end |
| 35976 |
end |
| 35977 |
if not redundant then |
| 35978 |
redundant={ n } |
| 35979 |
else |
| 35980 |
redundant[#redundant+1]=n |
| 35981 |
end |
| 35982 |
end |
| 35983 |
end |
| 35984 |
end |
| 35985 |
local nofbasefonts=#basefonts |
| 35986 |
if redundant then |
| 35987 |
for i=1,#redundant do |
| 35988 |
local r=redundant[i] |
| 35989 |
local p,n=getboth(r) |
| 35990 |
if r==head then |
| 35991 |
head=n |
| 35992 |
setprev(n) |
| 35993 |
else |
| 35994 |
setlink(p,n) |
| 35995 |
end |
| 35996 |
if nofbasefonts>0 then |
| 35997 |
for i=1,nofbasefonts do |
| 35998 |
local bi=basefonts[i] |
| 35999 |
if r==bi[1] then |
| 36000 |
bi[1]=n |
| 36001 |
end |
| 36002 |
if r==bi[2] then |
| 36003 |
bi[2]=n |
| 36004 |
end |
| 36005 |
end |
| 36006 |
end |
| 36007 |
flushnode(r) |
| 36008 |
end |
| 36009 |
end |
| 36010 |
for d in traverseid(disc_code,head) do |
| 36011 |
local _,_,r=getdisc(d) |
| 36012 |
if r then |
| 36013 |
for n in traverseid(glyph_code,r) do |
| 36014 |
local font=getfont(n) |
| 36015 |
if font~=prevfont then |
| 36016 |
prevfont=font |
| 36017 |
local used=usedfonts[font] |
| 36018 |
if not used then |
| 36019 |
local tfmdata=fontdata[font] |
| 36020 |
if tfmdata then |
| 36021 |
local shared=tfmdata.shared |
| 36022 |
if shared then |
| 36023 |
local processors=shared.processes |
| 36024 |
if processors and #processors>0 then |
| 36025 |
usedfonts[font]=processors |
| 36026 |
nofused=nofused+1 |
| 36027 |
end |
| 36028 |
end |
| 36029 |
end |
| 36030 |
end |
| 36031 |
end |
| 36032 |
end |
| 36033 |
end |
| 36034 |
end |
| 36035 |
if next(usedfonts) then |
| 36036 |
for font,processors in next,usedfonts do |
| 36037 |
for i=1,#processors do |
| 36038 |
head=processors[i](head,font,0,direction,nofused) or head |
| 36039 |
end |
| 36040 |
end |
| 36041 |
end |
| 36042 |
if basemodepass and nofbasefonts>0 then |
| 36043 |
for i=1,nofbasefonts do |
| 36044 |
local range=basefonts[i] |
| 36045 |
local start=range[1] |
| 36046 |
local stop=range[2] |
| 36047 |
if start then |
| 36048 |
local front=head==start |
| 36049 |
local prev,next |
| 36050 |
if stop then |
| 36051 |
next=getnext(stop) |
| 36052 |
start,stop=d_ligaturing(start,stop) |
| 36053 |
start,stop=d_kerning(start,stop) |
| 36054 |
else |
| 36055 |
prev=getprev(start) |
| 36056 |
start=d_ligaturing(start) |
| 36057 |
start=d_kerning(start) |
| 36058 |
end |
| 36059 |
if prev then |
| 36060 |
setlink(prev,start) |
| 36061 |
end |
| 36062 |
if next then |
| 36063 |
setlink(stop,next) |
| 36064 |
end |
| 36065 |
if front and head~=start then |
| 36066 |
head=start |
| 36067 |
end |
| 36068 |
end |
| 36069 |
end |
| 36070 |
end |
| 36071 |
end |
| 36072 |
return head |
| 36073 |
end |
| 36074 |
local function basepass(head) |
| 36075 |
if basemodepass then |
| 36076 |
head=d_ligaturing(head) |
| 36077 |
head=d_kerning(head) |
| 36078 |
end |
| 36079 |
return head |
| 36080 |
end |
| 36081 |
local protectpass=node.direct.protectglyphs or node.direct.protect_glyphs |
| 36082 |
local injectpass=nodes.injections.handler |
| 36083 |
function nodes.handlers.nodepass(head,...) |
| 36084 |
if head then |
| 36085 |
return tonode(nodepass(tonut(head),...)) |
| 36086 |
end |
| 36087 |
end |
| 36088 |
function nodes.handlers.basepass(head) |
| 36089 |
if head then |
| 36090 |
return tonode(basepass(tonut(head))) |
| 36091 |
end |
| 36092 |
end |
| 36093 |
function nodes.handlers.injectpass(head) |
| 36094 |
if head then |
| 36095 |
return tonode(injectpass(tonut(head))) |
| 36096 |
end |
| 36097 |
end |
| 36098 |
function nodes.handlers.protectpass(head) |
| 36099 |
if head then |
| 36100 |
protectpass(tonut(head)) |
| 36101 |
return head |
| 36102 |
end |
| 36103 |
end |
| 36104 |
function nodes.simple_font_handler(head,groupcode,size,packtype,direction) |
| 36105 |
if head then |
| 36106 |
head=tonut(head) |
| 36107 |
head=nodepass(head,groupcode,size,packtype,direction) |
| 36108 |
head=injectpass(head) |
| 36109 |
if not basemodepass then |
| 36110 |
head=basepass(head) |
| 36111 |
end |
| 36112 |
protectpass(head) |
| 36113 |
head=tonode(head) |
| 36114 |
end |
| 36115 |
return head |
| 36116 |
end |
| 36117 |
|
| 36118 |
end --- [luaotfload, fontloader-2023-12-28.lua scope for “fonts-gbn”] --- |
| 36119 |
|
| 36120 |
|
| 36121 |
--- vim:ft=lua:sw=2:ts=8:et:tw=79 |