diff options
author | Luigi Scarso <luigi.scarso@gmail.com> | 2018-01-09 23:43:20 +0000 |
---|---|---|
committer | Luigi Scarso <luigi.scarso@gmail.com> | 2018-01-09 23:43:20 +0000 |
commit | aa5d0e8bf3515c424ba0594a2d4e06ae31da7796 (patch) | |
tree | e56fd10d89732547ddb207c1998a1ded4360382e /Build/source/texk/web2c/luatexdir/font | |
parent | d33684eeca435784c95c62c7981dd02f7818b263 (diff) |
Imported Luatex 1.06.3 (Lua 5.2.4)
git-svn-id: svn://tug.org/texlive/trunk@46269 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/font')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/font/luafont.w | 270 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/font/texfont.h | 10 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/font/texfont.w | 27 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/font/vfpacket.w | 24 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/font/writefont.w | 35 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/font/writetype2.w | 34 |
6 files changed, 309 insertions, 91 deletions
diff --git a/Build/source/texk/web2c/luatexdir/font/luafont.w b/Build/source/texk/web2c/luatexdir/font/luafont.w index 4e874d9becb..7065f96d904 100644 --- a/Build/source/texk/web2c/luatexdir/font/luafont.w +++ b/Build/source/texk/web2c/luatexdir/font/luafont.w @@ -461,9 +461,6 @@ int font_to_lua(lua_State * L, int f) if (font_step(f) != 0) { dump_intfield(L,step,font_step(f)); } - if (font_auto_expand(f) != 0) { - dump_booleanfield(L,auto_expand,font_auto_expand(f)); - } if (pdf_font_attr(f) != 0) { char *s = makecstring(pdf_font_attr(f)); dump_stringfield(L,attributes,s); @@ -623,6 +620,7 @@ static int n_some_field(lua_State * L, int name_index) static int count_char_packet_bytes(lua_State * L) { register int i; + register int ts; register int l = 0; int ff = 0; for (i = 1; i <= (int) lua_rawlen(L, -1); i++) { @@ -642,39 +640,57 @@ static int count_char_packet_bytes(lua_State * L) ff = 1; } else if (lua_key_eq(s, slot)) { l += 10; - ff = 1; } else if (lua_key_eq(s, comment) || lua_key_eq(s, nop)) { ; } else if (lua_key_eq(s, push) || lua_key_eq(s, pop)) { l++; } else if (lua_key_eq(s, rule)) { l += 9; - } else if (lua_key_eq(s, right) || lua_key_eq(s, node) - || lua_key_eq(s, down) || lua_key_eq(s, image)) { + } else if (lua_key_eq(s, right) || lua_key_eq(s, node) || lua_key_eq(s, down) || lua_key_eq(s, image)) { l += 5; } else if (lua_key_eq(s, scale)) { l += sizeof(float) + 1; + } else if (lua_key_eq(s, pdf)) { + size_t len; + l += 5; + ts = lua_rawlen(L, -2); + lua_rawgeti(L, -2, 2); + if (ts == 3) { + if (lua_type(L,-1) == LUA_TSTRING) { + /* no need to do something */ + } else if (lua_type(L,-1) == LUA_TNUMBER) { + /* no need to do something */ + } else { + normal_error("vf command","invalid packet pdf literal category"); + } + lua_rawgeti(L, -3, 3); + } + if (lua_type(L,-1) == LUA_TSTRING) { + (void) lua_tolstring(L, -1, &len); + if (len > 0) { + l = (int) (l + 5 + (int) len); + } + } else { + normal_error("vf command","invalid packet pdf literal"); + } + lua_pop(L, ts == 3 ? 2 : 1); } else if (lua_key_eq(s, special) || lua_key_eq(s, lua)) { size_t len; lua_rawgeti(L, -2, 2); if (lua_type(L,-1) == LUA_TSTRING) { (void) lua_tolstring(L, -1, &len); - lua_pop(L, 1); if (len > 0) { l = (int) (l + 5 + (int) len); } } else { - lua_pop(L, 1); normal_error("vf command","invalid packet special"); - /* fprintf(stdout, "invalid packet special!\n"); */ } + lua_pop(L, 1); } else { normal_error("vf command","unknown packet command"); - /* fprintf(stdout, "unknown packet command %s!\n", s); */ } } else { normal_error("vf command","no packet command"); - /* fprintf(stdout, "no packet command!\n"); */ } lua_pop(L, 1); /* command name */ } @@ -700,6 +716,8 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern const char *s; eight_bits *cpackets, *cp; int ff = 0; + int sf = 0; + int ts = 0; int max_f = 0; int pc = count_char_packet_bytes(L); if (pc <= 0) @@ -725,19 +743,20 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern do_store_four(ff); } } else if (lua_key_eq(s, slot)) { + /* we could be sparse but no real reason */ cmd = packet_nop_code; lua_rawgeti(L, -2, 2); - n = (int) luaL_checkinteger(L, -1); - if (n ==0) { - ff = f; + n = (int) lua_roundnumber(L, -1); + if (n == 0) { + sf = f; } else { - ff = (n > max_f ? l_fonts[1] : l_fonts[n]); + sf = (n > max_f ? l_fonts[1] : l_fonts[n]); } lua_rawgeti(L, -3, 3); - n = (int) luaL_checkinteger(L, -1); + n = (int) lua_roundnumber(L, -1); lua_pop(L, 2); append_packet(packet_font_code); - do_store_four(ff); + do_store_four(sf); append_packet(packet_char_code); do_store_four(n); } else if (lua_key_eq(s, comment) || lua_key_eq(s, nop)) { @@ -754,6 +773,8 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern cmd = packet_right_code; } else if (lua_key_eq(s, down)) { cmd = packet_down_code; + } else if (lua_key_eq(s, pdf)) { + cmd = packet_pdf_code; } else if (lua_key_eq(s, special)) { cmd = packet_special_code; } else if (lua_key_eq(s, image)) { @@ -771,7 +792,7 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern case packet_font_code: append_packet(cmd); lua_rawgeti(L, -2, 2); - n = (int) luaL_checkinteger(L, -1); + n = (int) lua_roundnumber(L, -1); if (n == 0) { ff = n; } else { @@ -790,7 +811,7 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern case packet_char_code: append_packet(cmd); lua_rawgeti(L, -2, 2); - n = (int) luaL_checkinteger(L, -1); + n = (int) lua_roundnumber(L, -1); do_store_four(n); lua_pop(L, 1); break; @@ -798,20 +819,62 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern case packet_down_code: append_packet(cmd); lua_rawgeti(L, -2, 2); - n = (int) luaL_checkinteger(L, -1); + n = (int) lua_roundnumber(L, -1); do_store_four(sp_to_dvi(n, atsize)); lua_pop(L, 1); break; case packet_rule_code: append_packet(cmd); lua_rawgeti(L, -2, 2); - n = (int) luaL_checkinteger(L, -1); + n = (int) lua_roundnumber(L, -1); do_store_four(sp_to_dvi(n, atsize)); lua_rawgeti(L, -3, 3); - n = (int) luaL_checkinteger(L, -1); + n = (int) lua_roundnumber(L, -1); do_store_four(sp_to_dvi(n, atsize)); lua_pop(L, 2); break; + case packet_pdf_code: + append_packet(cmd); + ts = (int) lua_rawlen(L, -2); + lua_rawgeti(L, -2, 2); + if (ts == 3) { + if (lua_type(L, -1) == LUA_TSTRING) { + s = lua_tostring(L, -1); + if (lua_key_eq(s, direct)) { + n = direct_always; + } else if (lua_key_eq(s, page)) { + n = direct_page; + } else if (lua_key_eq(s, raw)) { + n = direct_raw; + } else if (lua_key_eq(s, origin)) { + n = set_origin; + } else { + /* normal_warning("vf command","invalid pdf literal type"); */ + n = set_origin ; + } + } else { + n = (int) lua_roundnumber(L, -1); + if (n < set_origin || n > direct_raw) { + n = set_origin ; + } + } + lua_rawgeti(L, -3, 3); + } else { + n = set_origin; + } + do_store_four(n); + s = luaL_checklstring(L, -1, &l); + if (l > 0) { + do_store_four(l); + m = (int) l; + while (m > 0) { + n = *s++; + m--; + append_packet(n); + } + } + lua_pop(L,ts == 3 ? 2 : 1); + break; case packet_special_code: case packet_lua_code: append_packet(cmd); @@ -1144,8 +1207,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int set_charinfo_tag(co, ext_tag); set_charinfo_extensible(co, top, bot, mid, rep); } else { - formatted_warning("font", "lua-loaded font %s char U+%X has an invalid extensible field", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid extensible field", font_name(f), (int) i); } } lua_pop(L, 1); @@ -1248,8 +1310,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int set_kern_item(ckerns[ctr], k, j); ctr++; } else { - formatted_warning("font", "lua-loaded font %s char U+%X has an invalid kern field", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid kern field", font_name(f), (int) i); } lua_pop(L, 1); } @@ -1258,13 +1319,13 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int set_kern_item(ckerns[ctr], end_kern, 0); set_charinfo_kerns(co, ckerns); } else { - formatted_warning("font", "lua-loaded font %s char U+%X has an invalid kerns field", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid kerns field", font_name(f), (int) i); } lua_pop(L, 1); } /* packet commands */ + lua_key_rawgeti(commands); if (lua_istable(L, -1)) { lua_pushnil(L); /* first key */ @@ -1307,8 +1368,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k, r); ctr++; } else { - formatted_warning("font", "lua-loaded font %s char U+%X has an invalid ligature field", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid ligature field", font_name(f), (int) i); } lua_pop(L, 1); /* iterator value */ } @@ -1317,8 +1377,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int set_ligature_item(cligs[ctr], 0, end_ligature, 0); set_charinfo_ligatures(co, cligs); } else { - formatted_warning("font", "lua-loaded font %s char U+%X has an invalid ligatures field", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid ligatures field", font_name(f), (int) i); } lua_pop(L, 1); /* ligatures table */ } @@ -1353,7 +1412,6 @@ int font_from_lua(lua_State * L, int f) lua_pop(L,1); /* the table is at stack index -1 */ - s = n_string_field_copy(L,lua_key_index(area), ""); set_font_area(f, s); s = n_string_field_copy(L, lua_key_index(filename), NULL); @@ -1468,20 +1526,19 @@ int font_from_lua(lua_State * L, int f) l_fonts[i] = find_font_id(ss, t); lua_settop(L, s_top); } else { - formatted_error("font","invalid local font in lua-loaded font '%s'", font_name(f)); + formatted_error("font","invalid local font at index %i in lua-loaded font '%s' (1)",i,font_name(f)); } lua_pop(L, 1); /* pop list entry */ } lua_pop(L, 1); /* pop font table */ } else if (font_type(f) == virtual_font_type) { - formatted_error("font","invalid local fonts in lua-loaded font '%s'", font_name(f)); + formatted_error("font","invalid local fonts in lua-loaded font '%s' (2)", font_name(f)); } else { l_fonts = xmalloc(3 * sizeof(int)); l_fonts[0] = 0; l_fonts[1] = f; l_fonts[2] = 0; } - /* parameters */ no_math = n_boolean_field(L, lua_key_index(nomath), 0); read_lua_parameters(L, f); @@ -1536,11 +1593,9 @@ int font_from_lua(lua_State * L, int f) } else if (lt == LUA_TSTRING) { const char *ss1 = lua_tostring(L, -2); if (lua_key_eq(ss1, left_boundary)) { - font_char_from_lua(L, f, left_boundarychar, l_fonts, - !no_math); + font_char_from_lua(L, f, left_boundarychar, l_fonts, !no_math); } else if (lua_key_eq(ss1, right_boundary)) { - font_char_from_lua(L, f, right_boundarychar, l_fonts, - !no_math); + font_char_from_lua(L, f, right_boundarychar, l_fonts, !no_math); } } lua_pop(L, 1); @@ -1561,7 +1616,6 @@ int font_from_lua(lua_State * L, int f) if (fstep != 0) { int fshrink = lua_numeric_field_by_index(L, lua_key_index(shrink), 0); int fstretch =lua_numeric_field_by_index(L, lua_key_index(stretch), 0); - int fexpand = n_boolean_field(L, lua_key_index(auto_expand), 0); if (fshrink < 0) fshrink = 0; if (fshrink > 500) @@ -1576,7 +1630,7 @@ int font_from_lua(lua_State * L, int f) fstretch -= (fstretch % fstep); if (fstretch < 0) fstretch = 0; - set_expand_params(f, fexpand, fstretch, fshrink, fstep); + set_expand_params(f, fstretch, fshrink, fstep); } } @@ -1601,6 +1655,129 @@ int font_from_lua(lua_State * L, int f) return true; } +int characters_from_lua(lua_State * L, int f) +{ + int i, n, t, lt; + int *l_fonts = NULL; + int s_top; + const char *ss; + boolean no_math = false; + /* speedup */ + no_math = n_boolean_field(L, lua_key_index(nomath), 0); + /* type */ + i = n_enum_field(L, lua_key_index(type), font_type(f), font_type_strings); + set_font_type(f, i); + /* fonts */ + count_hash_items(L, fonts, n); + if (n > 0) { + /* font table still on stack */ + l_fonts = xmalloc((unsigned) ((unsigned) (n + 2) * sizeof(int))); + memset(l_fonts, 0, (size_t) ((unsigned) (n + 2) * sizeof(int))); + for (i = 1; i <= n; i++) { + lua_rawgeti(L, -1, i); + if (lua_istable(L, -1)) { + lua_key_rawgeti(id); + if (lua_isnumber(L, -1)) { + l_fonts[i] = (int) lua_tointeger(L, -1); + if (l_fonts[i] == 0) { + l_fonts[i] = (int) f; + } + lua_pop(L, 2); /* pop id and entry */ + continue; + } + lua_pop(L, 1); /* pop id */ + }; + ss = NULL; + if (lua_istable(L, -1)) { + ss = n_string_field(L, lua_key_index(name)); + /* string is anchored */ + lua_pop(L,1); + } + if (ss != NULL) { + t = lua_numeric_field_by_index(L, lua_key_index(size), -1000); + /* TODO: the stack is messed up, otherwise this explicit resizing would not be needed */ + s_top = lua_gettop(L); + if (strcmp(font_name(f), ss) == 0) + l_fonts[i] = f; + else + l_fonts[i] = find_font_id(ss, t); + lua_settop(L, s_top); + } else { + formatted_error("font","invalid local font in lua-loaded font '%s' (3)", font_name(f)); + } + lua_pop(L, 1); /* pop list entry */ + } + lua_pop(L, 1); /* pop font table */ + } else if (font_type(f) == virtual_font_type) { + formatted_error("font","invalid local fonts in lua-loaded font '%s' (4)", font_name(f)); + } else { + l_fonts = xmalloc(3 * sizeof(int)); + l_fonts[0] = 0; + l_fonts[1] = f; + l_fonts[2] = 0; + } + /* characters */ + lua_key_rawgeti(characters); + if (lua_istable(L, -1)) { + /* find the array size values */ + int num = 0; /* number of charinfo's to add */ + int todo = 0; + int bc = font_bc(f); + int ec = font_ec(f); + lua_pushnil(L); /* first key */ + while (lua_next(L, -2) != 0) { + if (lua_isnumber(L, -2)) { + i = (int) lua_tointeger(L, -2); + if (i >= 0) { + if (lua_istable(L, -1)) { + todo++; + if (! quick_char_exists(f,i)) { + num++; + if (i > ec) + ec = i; + if (bc < 0) + bc = i; + if (bc >= 0 && i < bc) + bc = i; + } + } + } + } + lua_pop(L, 1); + } + if (todo > 0) { + font_malloc_charinfo(f, num); + set_font_bc(f, bc); + set_font_ec(f, ec); + lua_pushnil(L); /* first key */ + while (lua_next(L, -2) != 0) { + lt = lua_type(L,-2); + if (lt == LUA_TNUMBER) { + i = (int) lua_tointeger(L, -2); + if (i >= 0) { + if (quick_char_exists(f,i)) { + charinfo *co = char_info(f, i); + set_charinfo_name(co, NULL); + set_charinfo_tounicode(co, NULL); + set_charinfo_packets(co, NULL); + set_charinfo_ligatures(co, NULL); + set_charinfo_kerns(co, NULL); + set_charinfo_vert_variants(co, NULL); + set_charinfo_hor_variants(co, NULL); + } + font_char_from_lua(L, f, i, l_fonts, !no_math); + } + } + lua_pop(L, 1); + } + lua_pop(L, 1); + } + } + if (l_fonts != NULL) + free(l_fonts); + return true; +} + @* Ligaturing. @c @@ -1995,8 +2172,9 @@ halfword handle_ligaturing(halfword head, halfword tail) vlink(tail) = null; } - /* |if (fix_node_lists)| */ - fix_node_list(head); + if (fix_node_lists) { + fix_node_list(head); + } prev = head; cur = vlink(prev); @@ -2184,7 +2362,9 @@ static halfword run_lua_ligkern_callback(halfword head, halfword tail, int callb luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); return tail; } - fix_node_list(head); + if (fix_node_lists) { + fix_node_list(head); + } lua_settop(Luas, top); return tail; } diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.h b/Build/source/texk/web2c/luatexdir/font/texfont.h index 98557992f97..d415460b1e1 100644 --- a/Build/source/texk/web2c/luatexdir/font/texfont.h +++ b/Build/source/texk/web2c/luatexdir/font/texfont.h @@ -144,7 +144,6 @@ typedef struct texfont { int font_max_shrink; int font_max_stretch; int _font_step; /* amount of one step of expansion */ - boolean _font_auto_expand; /* this font is auto-expanded? */ char _font_tounicode; /* 1 if info is present */ fm_entry *_font_map; @@ -345,9 +344,6 @@ boolean cmp_font_area(int, str_number); # define font_step(a) font_tables[a]->_font_step # define set_font_step(a,b) font_step(a) = b -# define font_auto_expand(a) font_tables[a]->_font_auto_expand -# define set_font_auto_expand(a,b) font_auto_expand(a) = b - # define font_tounicode(a) font_tables[a]->_font_tounicode # define set_font_tounicode(a,b) font_tounicode(a) = b @@ -439,6 +435,7 @@ typedef enum { extern charinfo *get_charinfo(internal_font_number f, int c); extern int char_exists(internal_font_number f, int c); +extern int lua_glyph_not_found_callback(internal_font_number f, int c); extern charinfo *char_info(internal_font_number f, int c); /* @@ -627,6 +624,7 @@ typedef enum { packet_char_code, packet_end_code, packet_scale_code, packet_lua_code, + packet_pdf_code, } packet_command_codes; extern scaled store_scaled_f(scaled sq, int fw); @@ -655,9 +653,7 @@ extern internal_font_number tfm_lookup(char *s, scaled fs); extern int fix_expand_value(internal_font_number f, int e); -extern void set_expand_params(internal_font_number f, boolean auto_expand, - int stretch_limit, int shrink_limit, - int font_step); +extern void set_expand_params(internal_font_number f, int stretch_limit, int shrink_limit, int font_step); extern void read_expand_font(void); extern void new_letterspaced_font(small_number a); diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.w b/Build/source/texk/web2c/luatexdir/font/texfont.w index 0c64045752e..ce463326a86 100644 --- a/Build/source/texk/web2c/luatexdir/font/texfont.w +++ b/Build/source/texk/web2c/luatexdir/font/texfont.w @@ -348,12 +348,11 @@ int char_exists(internal_font_number f, int c) } @ @c -#if 0 -static int lua_char_exists_callback(internal_font_number f, int c) +int lua_glyph_not_found_callback(internal_font_number f, int c) { int callback_id; int ret = 0; - callback_id = callback_defined(char_exists_callback); + callback_id = callback_defined(glyph_not_found_callback); if (callback_id != 0) { if (!get_callback(Luas, callback_id)) { lua_pop(Luas, 2); @@ -368,10 +367,11 @@ static int lua_char_exists_callback(internal_font_number f, int c) } else { ret = lua_toboolean(Luas, -1); } + } else { + char_warning(f,c); } return ret; } -#endif @ @c extinfo *new_variant(int glyph, int startconnect, int endconnect, @@ -1535,7 +1535,6 @@ static void dump_font_entry(texfont * f) dump_int(f->font_max_shrink); dump_int(f->font_max_stretch); dump_int(f->_font_step); - dump_int(f->_font_auto_expand); dump_int(f->_font_tounicode); dump_int(f->_font_type); dump_int(f->_font_format); @@ -1715,7 +1714,6 @@ static void undump_font_entry(texfont * f) undump_int(x); f->font_max_shrink = x; undump_int(x); f->font_max_stretch = x; undump_int(x); f->_font_step = x; - undump_int(x); f->_font_auto_expand = x; undump_int(x); f->_font_tounicode = (char)x; undump_int(x); f->_font_type = x; undump_int(x); f->_font_format = x; @@ -1845,11 +1843,9 @@ int fix_expand_value(internal_font_number f, int e) } @ @c -void set_expand_params(internal_font_number f, boolean auto_expand, - int stretch_limit, int shrink_limit, int font_step) -{ /* expand a font with given parameters */ +void set_expand_params(internal_font_number f, int stretch_limit, int shrink_limit, int font_step) +{ set_font_step(f, font_step); - set_font_auto_expand(f, auto_expand); set_font_max_shrink(f, shrink_limit); set_font_max_stretch(f, stretch_limit); } @@ -1859,7 +1855,6 @@ void read_expand_font(void) { /* read font expansion spec and load expanded font */ int shrink_limit, stretch_limit, font_step; internal_font_number f; - boolean auto_expand; /* read font expansion parameters */ scan_font_ident(); f = cur_val; @@ -1885,15 +1880,13 @@ void read_expand_font(void) shrink_limit = 0; if ((stretch_limit == 0) && (shrink_limit == 0)) normal_error("font expansion", "invalid limit(s)"); - auto_expand = false; if (scan_keyword("autoexpand")) { - auto_expand = true; + normal_warning("font expansion", "autoexpand not supported"); /* Scan an optional space */ get_x_token(); if (cur_cmd != spacer_cmd) back_input(); } - if (font_step(f) != 0) { /* this font has been expanded, ensure the expansion parameters are identical */ if (font_step(f) != font_step) @@ -1908,14 +1901,10 @@ void read_expand_font(void) ((font_max_shrink(f) > 0) && (font_max_shrink(f) != shrink_limit))) normal_error("font expansion","font has been expanded with different shrink limit"); - - if (font_auto_expand(f) != auto_expand) - normal_error("font expansion","font has been expanded with different auto expansion value"); } else { if (font_used(f)) normal_warning("font expansion", "font should be expanded before its first use"); - set_expand_params(f, auto_expand, stretch_limit, shrink_limit, - font_step); + set_expand_params(f, stretch_limit, shrink_limit, font_step); } } diff --git a/Build/source/texk/web2c/luatexdir/font/vfpacket.w b/Build/source/texk/web2c/luatexdir/font/vfpacket.w index 5b76eb81f40..14a6ca61169 100644 --- a/Build/source/texk/web2c/luatexdir/font/vfpacket.w +++ b/Build/source/texk/web2c/luatexdir/font/vfpacket.w @@ -88,6 +88,9 @@ int vf_packet_bytes(charinfo * co) case packet_rule_code: vfp += 8; break; + case packet_pdf_code: + vfp += 4; + /* plus a string so we fall through */ case packet_special_code: packet_number(k); /* +4 */ vfp += (int) k; @@ -104,7 +107,7 @@ int vf_packet_bytes(charinfo * co) @c const char *packet_command_names[] = { "char", "font", "pop", "push", "special", "image", - "right", "down", "rule", "node", "nop", "end", "scale", "lua", NULL + "right", "down", "rule", "node", "nop", "end", "scale", "lua", "pdf", NULL }; @ @c @@ -135,7 +138,7 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph) eight_bits *vfp; posstructure *save_posstruct, localpos; vf_struct *save_vfstruct, localvfstruct, *vp; - int cmd, w; + int cmd, w, mode; unsigned k; scaledpos size; scaled i; @@ -218,7 +221,7 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph) packet_scaled(size.h, vp->fs_f); if (size.h > 0 && size.v > 0) backend_out[rule_node](pdf, 0, size); /* the 0 is unused */ - mat_p->pos.h += size.h; + mat_p->pos.h += size.h; break; case packet_right_code: packet_scaled(i, vp->fs_f); @@ -228,6 +231,18 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph) packet_scaled(i, vp->fs_f); mat_p->pos.v += i; break; + case packet_pdf_code: + packet_number(mode); + packet_number(k); + str_room(k); + while (k > 0) { + k--; + append_char(*(vfp++)); + } + s = make_string(); + pdf_literal(pdf, s, mode, false); + flush_str(s); + break; case packet_special_code: packet_number(k); str_room(k); @@ -387,6 +402,9 @@ replace_packet_fonts(internal_font_number f, int *old_fontid, case packet_rule_code: vfp += 8; break; + case packet_pdf_code: + vfp += 4; + /* plus a string so we fall through */ case packet_special_code: packet_number(k); vfp += k; diff --git a/Build/source/texk/web2c/luatexdir/font/writefont.w b/Build/source/texk/web2c/luatexdir/font/writefont.w index 76d88b68bc4..2ba81d61749 100644 --- a/Build/source/texk/web2c/luatexdir/font/writefont.w +++ b/Build/source/texk/web2c/luatexdir/font/writefont.w @@ -578,7 +578,7 @@ static void write_fontdescriptor(PDF pdf, fd_entry * fd) assert(0); } } - if ((! pdf->omit_cidset) && (cidset != 0)) { + if ((! pdf->omit_cidset) && (pdf->major_version == 1) && (cidset != 0) ) { pdf_dict_add_ref(pdf, "CIDSet", cidset); } /* @@ -901,6 +901,13 @@ ids, but the strings that are written out use CID indexes, and those are limited to 16-bit values. @c +/* + This is old code ... it fails when the order of using the same font at + different extends changes. Probably because widths get overwritten or + set wrong. The loop also looks kind of weird (why a loop). +*/ + +/* static void mark_cid_subset_glyphs(fo_entry * fo, internal_font_number f) { int i, k, l; @@ -925,6 +932,32 @@ static void mark_cid_subset_glyphs(fo_entry * fo, internal_font_number f) } } } +*/ + +/* + So, let's try the following. +*/ + +static void mark_cid_subset_glyphs(fo_entry * fo, internal_font_number f) +{ + glw_entry *j; + void *aa; + int l = font_size(f); + int i; + for (i = font_bc(f); i <= font_ec(f); i++) { + if (quick_char_exists(f, i) && char_used(f, i)) { + j = xtalloc(1, glw_entry); + j->id = (unsigned) char_index(f, i); + j->wd = divide_scaled_n(char_width(f, i), l, 10000.0); + if ((glw_entry *) avl_find(fo->fd->gl_tree, j) == NULL) { + aa = avl_probe(fo->fd->gl_tree, j); + assert(aa != NULL); + } else { + xfree(j); + } + } + } +} @ It is possible to compress the widths array even better, by using the alternate 'range' syntax and possibly even using /DW to set a default diff --git a/Build/source/texk/web2c/luatexdir/font/writetype2.w b/Build/source/texk/web2c/luatexdir/font/writetype2.w index dc1821c5e5f..81aefb1fb69 100644 --- a/Build/source/texk/web2c/luatexdir/font/writetype2.w +++ b/Build/source/texk/web2c/luatexdir/font/writetype2.w @@ -387,24 +387,26 @@ boolean make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buff, int buflen) /* CIDSet: a table of bits indexed by cid, bytes with high order bit first, each (set) bit is a (present) CID. */ if (is_subsetted(fd->fm)) { - cidset = pdf_create_obj(pdf, obj_type_others, 0); - if (cidset != 0) { - size_t l = (last_cid / 8) + 1; - char *stream = xmalloc(l); - memset(stream, 0, l); - for (cid = 1; cid <= (long) last_cid; cid++) { - if (used_chars[cid]) { - stream[(cid / 8)] |= (1 << (7 - (cid % 8))); + if ((! pdf->omit_cidset) && (pdf->major_version == 1)) { + cidset = pdf_create_obj(pdf, obj_type_others, 0); + if (cidset != 0) { + size_t l = (last_cid / 8) + 1; + char *stream = xmalloc(l); + memset(stream, 0, l); + for (cid = 1; cid <= (long) last_cid; cid++) { + if (used_chars[cid]) { + stream[(cid / 8)] |= (1 << (7 - (cid % 8))); + } } + pdf_begin_obj(pdf, cidset, OBJSTM_NEVER); + pdf_begin_dict(pdf); + pdf_dict_add_streaminfo(pdf); + pdf_end_dict(pdf); + pdf_begin_stream(pdf); + pdf_out_block(pdf, stream, l); + pdf_end_stream(pdf); + pdf_end_obj(pdf); } - pdf_begin_obj(pdf, cidset, OBJSTM_NEVER); - pdf_begin_dict(pdf); - pdf_dict_add_streaminfo(pdf); - pdf_end_dict(pdf); - pdf_begin_stream(pdf); - pdf_out_block(pdf, stream, l); - pdf_end_stream(pdf); - pdf_end_obj(pdf); } } |