diff options
author | Luigi Scarso <luigi.scarso@gmail.com> | 2020-02-15 12:45:08 +0000 |
---|---|---|
committer | Luigi Scarso <luigi.scarso@gmail.com> | 2020-02-15 12:45:08 +0000 |
commit | 1eb99bf05849e3108129d32eaacaa40c9e266c4b (patch) | |
tree | 23d14dd9414feedf2c78eb5029a5c7ed60c2bca2 /Build/source/texk/web2c/luatexdir/font/luafont.c | |
parent | c919a62f6a535e0c586534c9ac6d8f671d91c02c (diff) |
sync with luatex rev. 7287
git-svn-id: svn://tug.org/texlive/trunk@53789 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/font/luafont.c')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/font/luafont.c | 213 |
1 files changed, 204 insertions, 9 deletions
diff --git a/Build/source/texk/web2c/luatexdir/font/luafont.c b/Build/source/texk/web2c/luatexdir/font/luafont.c index 14efbf8a794..dd0c6856495 100644 --- a/Build/source/texk/web2c/luatexdir/font/luafont.c +++ b/Build/source/texk/web2c/luatexdir/font/luafont.c @@ -169,6 +169,207 @@ static void dump_math_kerns(lua_State * L, charinfo * co, int l, int id) } } +#define set_packet_number(fw) { \ + fw = *(vfp++); \ + fw = fw * 256 + *(vfp++); \ + fw = fw * 256 + *(vfp++); \ + fw = fw * 256 + *(vfp++); \ +} + +#define set_packet_scaled(fw) { \ + fw = *(vfp++); \ + if (fw > 127) { \ + fw = fw - 256; \ + } \ + fw = fw * 256 + *(vfp++); \ + fw = fw * 256 + *(vfp++); \ + fw = fw * 256 + *(vfp++); \ +} + +static void font_commands_to_lua(lua_State * L, internal_font_number f, charinfo * co) +{ + eight_bits *vfp = get_charinfo_packets(co); + if (vfp != NULL) { + int cmd; + int i = 1; + lua_push_string_by_name(L,commands); + lua_newtable(L); + while ((cmd = *(vfp++)) != packet_end_code) { + switch (cmd) { + case packet_font_code: + { + halfword f ; + set_packet_number(f); + lua_createtable(L, 2, 0); + lua_push_string_by_name(L,font); + lua_rawseti(L, -2, 1); + lua_pushinteger(L, f); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + } + break; + case packet_push_code: + { + lua_createtable(L, 1, 0); + lua_push_string_by_name(L,push); + lua_rawseti(L, -2, 1); + lua_rawseti(L, -2, i++); + } + break; + case packet_pop_code: + { + lua_createtable(L, 1, 0); + lua_push_string_by_name(L,pop); + lua_rawseti(L, -2, 1); + lua_rawseti(L, -2, i++); + } + break; + case packet_char_code: + { + halfword c ; + set_packet_number(c); + lua_createtable(L, 2, 0); + lua_push_string_by_name(L,char); + lua_rawseti(L, -2, 1); + lua_pushinteger(L, c); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + } + break; + case packet_rule_code: + { + halfword h, w ; + set_packet_scaled(h); + set_packet_scaled(w); + lua_createtable(L, 3, 0); + lua_push_string_by_name(L,rule); + lua_rawseti(L, -2, 1); + lua_pushinteger(L, h); + lua_rawseti(L, -2, 2); + lua_pushinteger(L, w); + lua_rawseti(L, -2, 3); + lua_rawseti(L, -2, i++); + } + break; + case packet_right_code: + { + halfword r ; + set_packet_scaled(r); + lua_createtable(L, 1, 0); + lua_push_string_by_name(L,right); + lua_rawseti(L, -2, 1); + lua_pushinteger(L, r); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + } + break; + case packet_down_code: + { + halfword d ; + set_packet_scaled(d); + lua_createtable(L, 1, 0); + lua_push_string_by_name(L,down); + lua_rawseti(L, -2, 1); + lua_pushinteger(L, d); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + } + break; + case packet_pdf_code: + { + halfword m, l; + set_packet_number(m); + set_packet_number(l); + lua_createtable(L, 3, 0); + lua_push_string_by_name(L,pdf); + lua_rawseti(L, -2, 1); + lua_pushinteger(L, m); + lua_rawseti(L, -2, 2); + lua_pushstring(L,"<pdf data>"); + lua_rawseti(L, -2, 3); + lua_rawseti(L, -2, i++); + vfp += l; + } + break; + case packet_pdf_mode: + { + halfword m; + set_packet_number(m); + lua_createtable(L, 2, 0); + lua_push_string_by_name(L,mode); + lua_rawseti(L, -2, 1); + lua_pushinteger(L, m); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + } + break; + case packet_special_code: + { + halfword l; + set_packet_number(l); + lua_createtable(L, 2, 0); + lua_push_string_by_name(L,special); + lua_rawseti(L, -2, 1); + lua_pushstring(L,"<special data>"); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + vfp += l; + } + break; + case packet_lua_code: + { + halfword n; + set_packet_number(n); + lua_createtable(L, 2, 0); + lua_push_string_by_name(L,lua); + lua_rawseti(L, -2, 1); + lua_pushstring(L,"<lua data>"); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + } + break; + case packet_image_code: + { + halfword n; + set_packet_number(n); + lua_createtable(L, 2, 0); + lua_push_string_by_name(L,image); + lua_rawseti(L, -2, 1); + lua_pushstring(L,"<image data>"); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + } + break; + case packet_node_code: + { + halfword n; + set_packet_number(n); + lua_createtable(L, 2, 0); + lua_push_string_by_name(L,node); + lua_rawseti(L, -2, 1); + lua_pushstring(L,"<node data>"); + lua_rawseti(L, -2, 2); + lua_rawseti(L, -2, i++); + } + break; + case packet_nop_code: + { + lua_createtable(L, 1, 0); + lua_push_string_by_name(L,nop); + lua_rawseti(L, -2, 1); + lua_rawseti(L, -2, i++); + } + break; + case packet_scale_code: + break; + default: + break; + } + } + lua_rawset(L, -3); + } +} + static void font_char_to_lua(lua_State * L, internal_font_number f, charinfo * co) { liginfo *l; @@ -343,6 +544,7 @@ static void font_char_to_lua(lua_State * L, internal_font_number f, charinfo * c else lua_pop(L, 2); } + font_commands_to_lua(L,f,co); } static void write_lua_parameters(lua_State * L, int f) @@ -432,11 +634,11 @@ static void write_lua_math_parameters(lua_State * L, int f) lua_rawset(L, -3); } -int font_to_lua(lua_State * L, int f) +int font_to_lua(lua_State * L, int f, int usecache) { int k; charinfo *co; - if (font_cache_id(f) > 0) { + if (usecache && font_cache_id(f) > 0) { /*tex Fetch the table from the registry if it was saved there by |font_from_lua|. */ lua_rawgeti(L, LUA_REGISTRYINDEX, font_cache_id(f)); return 1; @@ -523,13 +725,6 @@ int font_to_lua(lua_State * L, int f) } } lua_rawset(L, -3); - if (font_cache_id(f) == 0) { - /*tex Renew the cache. */ - int r; - lua_pushvalue(L, -1); - r = luaL_ref(L, LUA_REGISTRYINDEX); - set_font_cache_id(f, r); - } return 1; } |