summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-03-09 22:53:09 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-03-09 22:53:09 +0000
commit5fb8104fddfa73649ef0fde6b7b0cbfd53def358 (patch)
tree830d92cde3f9d6b168b949a28704a0c8960b55e9 /Build/source
parent1f16f479df5678daa28b623d9d747b84b3bd0e30 (diff)
web2c/luatexdir: sync sith the upstream
git-svn-id: svn://tug.org/texlive/trunk@39981 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/web2c/luatexdir/font/vfovf.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writecff.w6
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltexlib.c47
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luainit.w5
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luajitstuff.w23
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatex-api.h11
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c830
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c1258
-rw-r--r--Build/source/texk/web2c/luatexdir/luatex.c6
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/equivalents.h28
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/maincontrol.w48
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mathcodes.h1
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mathcodes.w15
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mlist.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mlist.w8
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/primitive.w10
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texnodes.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/textoken.h1
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/textoken.w56
19 files changed, 1234 insertions, 1127 deletions
diff --git a/Build/source/texk/web2c/luatexdir/font/vfovf.w b/Build/source/texk/web2c/luatexdir/font/vfovf.w
index 80b35f9ea22..df970ff4d11 100644
--- a/Build/source/texk/web2c/luatexdir/font/vfovf.w
+++ b/Build/source/texk/web2c/luatexdir/font/vfovf.w
@@ -217,7 +217,7 @@ vf_def_font(internal_font_number f, unsigned char *vf_buffer, int *vf_cr)
four_quarters cs;
memory_word tmp_w; /* accumulator */
int junk;
- unsigned long checksum;
+ unsigned int checksum;
cs.b0 = vf_buffer[(*vf_cr)];
cs.b1 = vf_buffer[(*vf_cr) + 1];
cs.b2 = vf_buffer[(*vf_cr) + 2];
diff --git a/Build/source/texk/web2c/luatexdir/font/writecff.w b/Build/source/texk/web2c/luatexdir/font/writecff.w
index 3f4a4e58879..5955104845f 100644
--- a/Build/source/texk/web2c/luatexdir/font/writecff.w
+++ b/Build/source/texk/web2c/luatexdir/font/writecff.w
@@ -3353,7 +3353,6 @@ void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd)
((2 * (unsigned) cid_count) * sizeof(unsigned char)));
memset(CIDToGIDMap, 0, (size_t) (2 * cid_count));
-
glyph = xtalloc(1, glw_entry);
/* insert notdef */
glyph->id = 0;
@@ -3367,7 +3366,10 @@ void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd)
for (cid = 0; cid <= CID_MAX; cid++) {
glyph->id = (unsigned) cid;
if (avl_find(fd->gl_tree, glyph) != NULL) {
- gid = (card16) cff_charsets_lookup(cffont, (card16) cid);
+ /*
+ gid = (card16) cff_charsets_lookup(cffont, (card16) cid);
+ */
+ gid = (card16) cid;
CIDToGIDMap[2 * cid] = (unsigned char) ((gid >> 8) & 0xff);
CIDToGIDMap[2 * cid + 1] = (unsigned char) (gid & 0xff);
last_cid = (card16) cid;
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
index 872b2994e23..03a97288a86 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -202,6 +202,39 @@ static int luacsprint(lua_State * L)
return do_luacprint(L, PARTIAL_LINE, DEFAULT_CAT_TABLE);
}
+static int luaccprint(lua_State * L)
+{
+ /* so a negative value is a specific catcode with offset 1 */
+ int cattable = lua_tointeger(L,1);
+ if (cattable < 0 || cattable > 15) {
+ cattable = - 12 - 0xFF ;
+ } else {
+ cattable = - cattable - 0xFF;
+ }
+ if (lua_type(L, 2) == LUA_TTABLE) {
+ int i;
+ for (i = 1;; i++) {
+ lua_rawgeti(L, 2, i);
+ if (lua_isstring(L,-1)) { /* or number */
+ luac_store(L, -1, PARTIAL_LINE, cattable);
+ lua_pop(L, 1);
+ } else {
+ break;
+ }
+ }
+ } else {
+ int i;
+ int n = lua_gettop(L);
+ for (i = 2; i <= n; i++) {
+ if (!lua_isstring(L,1)) { /* or number */
+ luaL_error(L, "no string to print");
+ }
+ luac_store(L, i, PARTIAL_LINE, cattable);
+ }
+ }
+ return 0;
+}
+
static int luactprint(lua_State * L)
{
int i, j;
@@ -1827,6 +1860,14 @@ static int getlist(lua_State * L)
alink(vlink(contrib_head)) = null ;
lua_pushinteger(L, vlink(contrib_head));
lua_nodelib_push(L);
+ } else if (lua_key_eq(str,page_discards_head)) {
+ alink(vlink(page_disc)) = null ;
+ lua_pushinteger(L, page_disc);
+ lua_nodelib_push(L);
+ } else if (lua_key_eq(str,split_discards_head)) {
+ alink(vlink(split_disc)) = null ;
+ lua_pushinteger(L, split_disc);
+ lua_nodelib_push(L);
} else if (lua_key_eq(str,page_head)) {
alink(vlink(page_head)) = null ;/*hh-ls */
lua_pushinteger(L, vlink(page_head));
@@ -1903,6 +1944,10 @@ static int setlist(lua_State * L)
page_tail = (n == 0 ? page_head : tail_of_list(n));
} else if (lua_key_eq(str,temp_head)) {
vlink(temp_head) = n;
+ } else if (lua_key_eq(str,page_discards_head)) {
+ page_disc = n;
+ } else if (lua_key_eq(str,split_discards_head)) {
+ split_disc = n;
} else if (lua_key_eq(str,hold_head)) {
vlink(hold_head) = n;
} else if (lua_key_eq(str,adjust_head)) {
@@ -2597,7 +2642,6 @@ static int tex_run_boot(lua_State * L)
unhide_lua_table(Luas, "tex", tex_table_id);
unhide_lua_table(Luas, "pdf", pdf_table_id);
unhide_lua_table(Luas, "token", token_table_id);
- unhide_lua_table(Luas, "oldtoken", oldtoken_table_id);
unhide_lua_table(Luas, "node", node_table_id);
lua_pushboolean(L, 1); /* true */
@@ -2824,6 +2868,7 @@ static const struct luaL_Reg texlib[] = {
{ "write", luacwrite },
{ "print", luacprint },
{ "tprint", luactprint },
+ { "cprint", luaccprint },
{ "error", texerror },
{ "sprint", luacsprint },
{ "set", settex },
diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w
index 016501df6c3..75559f9a403 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luainit.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w
@@ -399,7 +399,7 @@ static void parse_options(int ac, char **av)
/* Synchronize TeXnology: catching the command line option as a long */
synctexoption = (int) strtol(optarg, NULL, 0);
} else if (ARGUMENT_IS("recorder")) {
- recorderoption = 1 ;
+ recorderoption = 1 ;
} else if (ARGUMENT_IS("help")) {
usagehelp(LUATEX_IHELP, BUG_ADDRESS);
} else if (ARGUMENT_IS("version")) {
@@ -759,7 +759,6 @@ static void setup_lua_path(lua_State * L)
int tex_table_id;
int pdf_table_id;
int token_table_id;
-int oldtoken_table_id;
int node_table_id;
@ @c
@@ -955,7 +954,6 @@ void lua_initialize(int ac, char **av)
/* hide the 'tex' and 'pdf' table */
tex_table_id = hide_lua_table(Luas, "tex");
token_table_id = hide_lua_table(Luas, "token");
- oldtoken_table_id = hide_lua_table(Luas, "oldtoken");
node_table_id = hide_lua_table(Luas, "node");
pdf_table_id = hide_lua_table(Luas, "pdf");
@@ -988,7 +986,6 @@ void lua_initialize(int ac, char **av)
unhide_lua_table(Luas, "tex", tex_table_id);
unhide_lua_table(Luas, "pdf", pdf_table_id);
unhide_lua_table(Luas, "token", token_table_id);
- unhide_lua_table(Luas, "oldtoken", oldtoken_table_id);
unhide_lua_table(Luas, "node", node_table_id);
/* |kpse_init| */
diff --git a/Build/source/texk/web2c/luatexdir/lua/luajitstuff.w b/Build/source/texk/web2c/luatexdir/lua/luajitstuff.w
index e19338027b0..f219d5bd654 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luajitstuff.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luajitstuff.w
@@ -22,6 +22,7 @@
#include "lua/luatex-api.h"
#include "lua/lauxlib_bridge.h"
+
@ @c
lua_State *Luas = NULL;
@@ -161,23 +162,13 @@ static void do_openlibs(lua_State * L)
}
}
-@ @c
-static int load_aux (lua_State *L, int status) {
- if (status == 0) /* OK? */
- return 1;
- else {
- lua_pushnil(L);
- lua_insert(L, -2); /* put before error message */
- return 2; /* return nil plus error message */
- }
-}
@ @c
static int luatex_loadfile (lua_State *L) {
int status = 0;
const char *fname = luaL_optstring(L, 1, NULL);
const char *mode = luaL_optstring(L, 2, NULL);
- int env = !lua_isnone(L, 3); /* 'env' parameter? */
+ /*int env = !lua_isnone(L, 3);*/ /* 'env' parameter? */
if (!lua_only && !fname && interaction == batch_mode) {
lua_pushnil(L);
lua_pushstring(L, "reading from stdin is disabled in batch mode");
@@ -186,12 +177,12 @@ static int luatex_loadfile (lua_State *L) {
status = luaL_loadfilex(L, fname, mode);
if (status == LUA_OK) {
recorder_record_input(fname);
- if (env) { /* 'env' parameter? */
- lua_pushvalue(L, 3);
- lua_setupvalue(L, -2, 1); /* set it as 1st upvalue of loaded chunk */
- }
+ /* if (env) { *//* 'env' parameter? */
+ /* lua_pushvalue(L, 3); */
+ /* lua_setupvalue(L, -2, 1); *//* set it as 1st upvalue of loaded chunk */
+ /*} */
}
- return load_aux(L, status);
+ return RESERVED_load_aux_JIT(L, status,3);
}
@ @c
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
index c67522c06fc..5154a5d303d 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -128,7 +128,6 @@ extern int luaopen_vf(lua_State * L);
extern int font_to_lua(lua_State * L, int f);
extern int font_from_lua(lua_State * L, int f); /* return is boolean */
-extern int luaopen_oldtoken(lua_State * L);
extern int luaopen_token(lua_State * L);
extern void tokenlist_to_lua(lua_State * L, int p);
extern void tokenlist_to_luastring(lua_State * L, int p);
@@ -218,7 +217,6 @@ extern void init_tex_table(lua_State * L);
extern int tex_table_id;
extern int pdf_table_id;
extern int token_table_id;
-extern int oldtoken_table_id;
extern int node_table_id;
extern int main_initialize(void);
@@ -596,7 +594,6 @@ make_lua_key(lua);\
make_lua_key(lua_functions);\
make_lua_key(luatex);\
make_lua_key(luatex_node);\
-make_lua_key(luatex_oldtoken);\
make_lua_key(luatex_token);\
make_lua_key(mLTL);\
make_lua_key(mRTT);\
@@ -646,6 +643,7 @@ make_lua_key(pTLT);\
make_lua_key(pTRT);\
make_lua_key(page);\
make_lua_key(pages);\
+make_lua_key(page_discards_head);\
make_lua_key(page_head);\
make_lua_key(page_ins_head);\
make_lua_key(pageattributes);\
@@ -710,6 +708,7 @@ make_lua_key(space_stretch);\
make_lua_key(spacefactor);\
make_lua_key(spec);\
make_lua_key(special);\
+make_lua_key(split_discards_head);\
make_lua_key(split_keep);\
make_lua_key(split_off);\
make_lua_key(stack);\
@@ -933,7 +932,6 @@ init_lua_key(lua);\
init_lua_key(lua_functions);\
init_lua_key(luatex);\
init_lua_key(luatex_node);\
-init_lua_key(luatex_oldtoken);\
init_lua_key(luatex_token);\
init_lua_key(marginkern);\
init_lua_key(mark);\
@@ -973,6 +971,7 @@ init_lua_key(output);\
init_lua_key(overlay_accent);\
init_lua_key(page);\
init_lua_key(pages);\
+init_lua_key(page_discards_head);\
init_lua_key(page_head);\
init_lua_key(page_ins_head);\
init_lua_key(pageattributes);\
@@ -1036,6 +1035,7 @@ init_lua_key(space_stretch);\
init_lua_key(spacefactor);\
init_lua_key(spec);\
init_lua_key(special);\
+init_lua_key(split_discards_head);\
init_lua_key(split_keep);\
init_lua_key(split_off);\
init_lua_key(stack);\
@@ -1315,7 +1315,6 @@ use_lua_key(lua);
use_lua_key(lua_functions);
use_lua_key(luatex);
use_lua_key(luatex_node);
-use_lua_key(luatex_oldtoken);
use_lua_key(luatex_token);
use_lua_key(mLTL);
use_lua_key(mRTT);
@@ -1365,6 +1364,7 @@ use_lua_key(pTLT);
use_lua_key(pTRT);
use_lua_key(page);
use_lua_key(pages);
+use_lua_key(page_discards_head);
use_lua_key(page_head);
use_lua_key(page_ins_head);
use_lua_key(pagebox);
@@ -1429,6 +1429,7 @@ use_lua_key(space_stretch);
use_lua_key(spacefactor);
use_lua_key(spec);
use_lua_key(special);
+use_lua_key(split_discards_head);
use_lua_key(split_keep);
use_lua_key(split_off);
use_lua_key(stack);
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
index 5a3d3b58d20..1e8c09fceca 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
@@ -286,36 +286,35 @@ int MSLanguageFromLocale(void) {
int langcode, langlocalecode;
for ( i=0; envs[i]!=NULL; ++i ) {
- lang = getenv(envs[i]);
- if ( lang!=NULL ) {
- langlen = strlen(lang);
- if (( langlen>5 && lang[5]=='.' && lang[2]=='_' ) ||
- (langlen==5 && lang[2]=='_' ) ||
- (langlen==2) ||
- (langlen==3)) /* Some obscure languages have a 3 letter code */
- /* I understand this language */
- break;
- }
+ lang = getenv(envs[i]);
+ if ( lang!=NULL ) {
+ langlen = strlen(lang);
+ if (( langlen>5 && lang[5]=='.' && lang[2]=='_' ) ||
+ (langlen==5 && lang[2]=='_' ) ||
+ (langlen==2) ||
+ (langlen==3)) /* Some obscure languages have a 3 letter code */
+ /* I understand this language */
+ break;
+ }
}
if ( lang==NULL )
- lang = "en_US";
+ lang = "en_US";
strncpy(langcountry,lang,5); langcountry[5] = '\0';
strncpy(language,lang,3); language[3] = '\0';
if ( language[2]=='_' ) language[2] = '\0';
- langlen = strlen(language);
-
+ langlen = strlen(language);
langcode = langlocalecode = -1;
for ( i=0; ms_2_locals[i].loc_name!=NULL; ++i ) {
- if ( strmatch(langcountry,ms_2_locals[i].loc_name)==0 ) {
- langlocalecode = ms_2_locals[i].local_id;
- langcode = langlocalecode&0x3ff;
- break;
- } else if ( strncmp(language,ms_2_locals[i].loc_name,langlen)==0 )
- langcode = ms_2_locals[i].local_id&0x3ff;
+ if ( strmatch(langcountry,ms_2_locals[i].loc_name)==0 ) {
+ langlocalecode = ms_2_locals[i].local_id;
+ langcode = langlocalecode&0x3ff;
+ break;
+ } else if ( strncmp(language,ms_2_locals[i].loc_name,langlen)==0 )
+ langcode = ms_2_locals[i].local_id&0x3ff;
}
if ( langcode==-1 ) /* Default to English */
- langcode = 0x9;
-return( langlocalecode==-1 ? (langcode|0x400) : langlocalecode );
+ langcode = 0x9;
+ return( langlocalecode==-1 ? (langcode|0x400) : langlocalecode );
}
/* ************************************************************************** */
@@ -323,8 +322,8 @@ int getushort(FILE *ttf) {
int ch1 = getc(ttf);
int ch2 = getc(ttf);
if ( ch2==EOF )
-return( EOF );
-return( (ch1<<8)|ch2 );
+ return( EOF );
+ return( (ch1<<8)|ch2 );
}
int get3byte(FILE *ttf) {
@@ -332,8 +331,8 @@ int get3byte(FILE *ttf) {
int ch2 = getc(ttf);
int ch3 = getc(ttf);
if ( ch3==EOF )
-return( EOF );
-return( (ch1<<16)|(ch2<<8)|ch3 );
+ return( EOF );
+ return( (ch1<<16)|(ch2<<8)|ch3 );
}
int32 getlong(FILE *ttf) {
@@ -342,19 +341,19 @@ int32 getlong(FILE *ttf) {
int ch3 = getc(ttf);
int ch4 = getc(ttf);
if ( ch4==EOF )
-return( EOF );
-return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 );
+ return( EOF );
+ return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 );
}
static int32 getoffset(FILE *ttf, int offsize) {
if ( offsize==1 )
-return( getc(ttf));
+ return( getc(ttf));
else if ( offsize==2 )
-return( getushort(ttf));
+ return( getushort(ttf));
else if ( offsize==3 )
-return( get3byte(ttf));
+ return( get3byte(ttf));
else
-return( getlong(ttf));
+ return( getlong(ttf));
}
real getfixed(FILE *ttf) {
@@ -362,7 +361,7 @@ real getfixed(FILE *ttf) {
int mant = val&0xffff;
/* This oddity may be needed to deal with the first 16 bits being signed */
/* and the low-order bits unsigned */
-return( (real) (val>>16) + (mant/65536.0) );
+ return( (real) (val>>16) + (mant/65536.0) );
}
real get2dot14(FILE *ttf) {
@@ -370,7 +369,7 @@ real get2dot14(FILE *ttf) {
int mant = val&0x3fff;
/* This oddity may be needed to deal with the first 2 bits being signed */
/* and the low-order bits unsigned */
-return( (real) ((val<<16)>>(16+14)) + (mant/16384.0) );
+ return( (real) ((val<<16)>>(16+14)) + (mant/16384.0) );
}
static Encoding *enc_from_platspec(int platform,int specific) {
@@ -379,61 +378,62 @@ static Encoding *enc_from_platspec(int platform,int specific) {
enc = "Custom";
if ( platform==0 ) {
- enc = "Unicode";
+ enc = "Unicode";
if ( specific==4 )
enc = "UnicodeFull";
} else if ( platform==1 ) {
- if ( specific==0 )
- enc = "Mac";
- else if ( specific==1 )
- enc = "Sjis";
- else if ( specific==2 )
- enc = "Big5hkscs"; /* Or should we just guess big5? Both are wrong sometimes */
- else if ( specific==3 )
- enc = "EUC-KR";
- else if ( specific==25 )
- enc = "EUC-CN";
+ if ( specific==0 )
+ enc = "Mac";
+ else if ( specific==1 )
+ enc = "Sjis";
+ else if ( specific==2 )
+ enc = "Big5hkscs"; /* Or should we just guess big5? Both are wrong sometimes */
+ else if ( specific==3 )
+ enc = "EUC-KR";
+ else if ( specific==25 )
+ enc = "EUC-CN";
} else if ( platform==2 ) { /* obselete */
- if ( specific==0 )
- enc = "ASCII";
- else if ( specific==1 )
- enc = "Unicode";
- else if ( specific==2 )
- enc = "ISO8859-1";
+ if ( specific==0 )
+ enc = "ASCII";
+ else if ( specific==1 )
+ enc = "Unicode";
+ else if ( specific==2 )
+ enc = "ISO8859-1";
} else if ( platform==3 ) {
- if ( specific==1 || specific==0 ) /* symbol (sp=0) is just unicode (PUA) */
- enc = "Unicode";
- else if ( specific==2 )
- enc = "Sjis";
- else if ( specific==3 )
- enc = "EUC-CN";
- else if ( specific==4 )
- enc = "Big5hkscs";
- else if ( specific==5 )
- enc = "EUC-KR";
- else if ( specific==6 )
- enc = "Johab";
- else if ( specific==10 )
- enc = "UnicodeFull";
+ if ( specific==1 || specific==0 ) /* symbol (sp=0) is just unicode (PUA) */
+ enc = "Unicode";
+ else if ( specific==2 )
+ enc = "Sjis";
+ else if ( specific==3 )
+ enc = "EUC-CN";
+ else if ( specific==4 )
+ enc = "Big5hkscs";
+ else if ( specific==5 )
+ enc = "EUC-KR";
+ else if ( specific==6 )
+ enc = "Johab";
+ else if ( specific==10 )
+ enc = "UnicodeFull";
} else if ( platform==7 ) { /* Used internally in freetype, but */
- if ( specific==0 ) /* there's no harm in looking for it */
- enc = "AdobeStandard"; /* even if it never happens */
- else if ( specific==1 ) {
- /* adobe_expert */;
- } else if ( specific==2 ) {
- /* adobe_custom */;
- }
+ if ( specific==0 ) /* there's no harm in looking for it */
+ enc = "AdobeStandard"; /* even if it never happens */
+ else if ( specific==1 ) {
+ /* adobe_expert */;
+ } else if ( specific==2 ) {
+ /* adobe_custom */;
+ }
}
e = FindOrMakeEncoding(enc);
if ( e==NULL ) {
- static int p = -1,s = -1;
+ static int p = -1,s = -1;
if ( p!=platform || s!=specific ) {
LogError( _("The truetype encoding specified by platform=%d specific=%d (which we map to %s) is not supported by your version of iconv(3).\n"),
platform, specific, enc );
- p = platform; s = specific;
+ p = platform;
+ s = specific;
}
}
-return( e );
+ return( e );
}
static char *_readencstring(FILE *ttf,int offset,int len,
@@ -450,55 +450,55 @@ static char *_readencstring(FILE *ttf,int offset,int len,
/* Mac is screwy, there are several different varients of MacRoman */
/* depending on the language, they didn't get it right when they */
/* invented their script system */
- char *cstr, *cpt;
- cstr = cpt = galloc(len+1);
- for ( i=0; i<len; ++i )
+ char *cstr, *cpt;
+ cstr = cpt = galloc(len+1);
+ for ( i=0; i<len; ++i )
*cpt++ = getc(ttf);
- *cpt = '\0';
- ret = MacStrToUtf8(cstr,specific,language);
- free(cstr);
+ *cpt = '\0';
+ ret = MacStrToUtf8(cstr,specific,language);
+ free(cstr);
} else {
- enc = enc_from_platspec(platform,specific);
- if ( enc==NULL )
-return( NULL );
- if ( enc->is_unicodebmp ) {
- str = pt = galloc((sizeof(unichar_t)/2)*len+sizeof(unichar_t));
- for ( i=0; i<len/2; ++i ) {
- ch = getc(ttf)<<8;
- *pt++ = ch | getc(ttf);
- }
- *pt = 0;
- } else if ( enc->unicode!=NULL ) {
- str = pt = galloc(sizeof(unichar_t)*len+sizeof(unichar_t));
- for ( i=0; i<len; ++i )
- *pt++ = enc->unicode[getc(ttf)];
- *pt = 0;
- } else if ( enc->tounicode!=NULL ) {
- size_t inlen = len+1, outlen = sizeof(unichar_t)*(len+1);
- char *cstr = galloc(inlen);
- ICONV_CONST char *in = cstr;
- char *out;
+ enc = enc_from_platspec(platform,specific);
+ if ( enc==NULL )
+ return( NULL );
+ if ( enc->is_unicodebmp ) {
+ str = pt = galloc((sizeof(unichar_t)/2)*len+sizeof(unichar_t));
+ for ( i=0; i<len/2; ++i ) {
+ ch = getc(ttf)<<8;
+ *pt++ = ch | getc(ttf);
+ }
+ *pt = 0;
+ } else if ( enc->unicode!=NULL ) {
+ str = pt = galloc(sizeof(unichar_t)*len+sizeof(unichar_t));
+ for ( i=0; i<len; ++i )
+ *pt++ = enc->unicode[getc(ttf)];
+ *pt = 0;
+ } else if ( enc->tounicode!=NULL ) {
+ size_t inlen = len+1, outlen = sizeof(unichar_t)*(len+1);
+ char *cstr = galloc(inlen);
+ ICONV_CONST char *in = cstr;
+ char *out;
#ifdef UNICHAR_16
str = galloc(outlen+2);
#else
str = galloc(outlen+sizeof(unichar_t));
#endif
/*str = galloc(outlen+2);*/
- out = (char *) str;
- iconv(enc->tounicode,&in,&inlen,&out,&outlen);
- out[0] = '\0'; out[1] = '\0';
+ out = (char *) str;
+ iconv(enc->tounicode,&in,&inlen,&out,&outlen);
+ out[0] = '\0'; out[1] = '\0';
#ifndef UNICHAR_16
- out[2] = '\0'; out[3] = '\0';
+ out[2] = '\0'; out[3] = '\0';
#endif
- free(cstr);
- } else {
- str = uc_copy("");
- }
- ret = u2utf8_copy(str);
- free(str);
+ free(cstr);
+ } else {
+ str = uc_copy("");
+ }
+ ret = u2utf8_copy(str);
+ free(str);
}
fseek(ttf,pos,SEEK_SET);
-return( ret );
+ return( ret );
}
char *TTFGetFontName(FILE *ttf,int32 offset,int32 off2) {
@@ -519,15 +519,15 @@ char *TTFGetFontName(FILE *ttf,int32 offset,int32 off2) {
/* esel = */ getushort(ttf);
/* rshift = */ getushort(ttf);
for ( i=0; i<num; ++i ) {
- tag = getlong(ttf);
- /* checksum = */ getlong(ttf);
- nameoffset = off2+getlong(ttf);
- length = getlong(ttf);
- if ( tag==CHR('n','a','m','e'))
- break;
+ tag = getlong(ttf);
+ /* checksum = */ getlong(ttf);
+ nameoffset = off2+getlong(ttf);
+ length = getlong(ttf);
+ if ( tag==CHR('n','a','m','e'))
+ break;
}
if ( i==num )
-return( NULL );
+ return( NULL );
fseek(ttf,nameoffset,SEEK_SET);
/* format = */ getushort(ttf);
@@ -535,63 +535,62 @@ return( NULL );
stringoffset = nameoffset+getushort(ttf);
fullval = famval = 0;
for ( i=0; i<num; ++i ) {
- plat = getushort(ttf);
- spec = getushort(ttf);
- lang = getushort(ttf);
- name = getushort(ttf);
- len = getushort(ttf);
- off = getushort(ttf);
- enc = enc_from_platspec(plat,spec);
- if ( enc==NULL )
- continue;
- val = 0;
- if ( plat==3 && !enc->is_custom && lang==locale )
- val = 15;
- else if ( plat==3 && !enc->is_custom && (lang&0xff)==(locale&0xff) )
- val = 14;
- else if ( (plat==0 || plat==1) && !enc->is_custom && lang==maclang )
- val = 13;
- /* Ok, that didn't work, how about an english name? */
- else if ( plat==3 && !enc->is_custom && lang==0x409 )
- val = 12;
- else if ( plat==3 && !enc->is_custom && (lang&0xff)==0x09 )
- val = 11;
- else if ( (plat==0 || plat==1) && !enc->is_custom && lang==0 )
- val = 10;
- /* failing that I'll take what I can get */
- else if ( !enc->is_custom )
- val = 1;
- if ( name==4 && val>fullval ) {
- fullval = val;
- fullstr = off;
- fulllen = len;
- fullplat = plat;
- fullspec = spec;
- fulllang = lang;
- if ( val==12 )
- break;
- } else if ( name==1 && val>famval ) {
- famval = val;
- famstr = off;
- famlen = len;
- famplat = plat;
- famspec = spec;
- famlang = lang;
- }
+ plat = getushort(ttf);
+ spec = getushort(ttf);
+ lang = getushort(ttf);
+ name = getushort(ttf);
+ len = getushort(ttf);
+ off = getushort(ttf);
+ enc = enc_from_platspec(plat,spec);
+ if ( enc==NULL )
+ continue;
+ val = 0;
+ if ( plat==3 && !enc->is_custom && lang==locale )
+ val = 15;
+ else if ( plat==3 && !enc->is_custom && (lang&0xff)==(locale&0xff) )
+ val = 14;
+ else if ( (plat==0 || plat==1) && !enc->is_custom && lang==maclang )
+ val = 13;
+ /* Ok, that didn't work, how about an english name? */
+ else if ( plat==3 && !enc->is_custom && lang==0x409 )
+ val = 12;
+ else if ( plat==3 && !enc->is_custom && (lang&0xff)==0x09 )
+ val = 11;
+ else if ( (plat==0 || plat==1) && !enc->is_custom && lang==0 )
+ val = 10;
+ /* failing that I'll take what I can get */
+ else if ( !enc->is_custom )
+ val = 1;
+ if ( name==4 && val>fullval ) {
+ fullval = val;
+ fullstr = off;
+ fulllen = len;
+ fullplat = plat;
+ fullspec = spec;
+ fulllang = lang;
+ if ( val==12 )
+ break;
+ } else if ( name==1 && val>famval ) {
+ famval = val;
+ famstr = off;
+ famlen = len;
+ famplat = plat;
+ famspec = spec;
+ famlang = lang;
+ }
}
if ( fullval==0 ) {
- if ( famval==0 )
-return( NULL );
- fullstr = famstr;
- fulllen = famlen;
- fullplat = famplat;
- fullspec = famspec;
- fulllang = famlang;
- }
-return( _readencstring(ttf,stringoffset+fullstr,fulllen,fullplat,fullspec,fulllang));
+ if ( famval==0 )
+ return( NULL );
+ fullstr = famstr;
+ fulllen = famlen;
+ fullplat = famplat;
+ fullspec = famspec;
+ fulllang = famlang;
+ }
+ return( _readencstring(ttf,stringoffset+fullstr,fulllen,fullplat,fullspec,fulllang));
}
-
char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2) {
int i,num;
int32 tag, length, stringoffset;
@@ -605,15 +604,15 @@ char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2) {
/* esel = */ getushort(ttf);
/* rshift = */ getushort(ttf);
for ( i=0; i<num; ++i ) {
- tag = getlong(ttf);
- /* checksum = */ getlong(ttf);
- nameoffset = off2+getlong(ttf);
- length = getlong(ttf);
- if ( tag==CHR('n','a','m','e'))
- break;
+ tag = getlong(ttf);
+ /* checksum = */ getlong(ttf);
+ nameoffset = off2+getlong(ttf);
+ length = getlong(ttf);
+ if ( tag==CHR('n','a','m','e'))
+ break;
}
if ( i==num )
- return( NULL );
+ return( NULL );
fseek(ttf,nameoffset,SEEK_SET);
/* format = */ getushort(ttf);
@@ -621,23 +620,23 @@ char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2) {
stringoffset = nameoffset+getushort(ttf);
for ( i=0; i<num; ++i ) {
- /* plat */ getushort(ttf);
- /* spec */ getushort(ttf);
- /* lang */ getushort(ttf);
- name = getushort(ttf);
- len = getushort(ttf);
- off = getushort(ttf);
- if (name == 6) {
- char *str = malloc(len+1);
- if (str) {
- fseek (ttf, stringoffset+off, SEEK_SET);
- if(fread(str,1,len,ttf)==(size_t)len) {
- str[len] = '\0';
- return str;
- }
- free(str);
- }
- }
+ /* plat */ getushort(ttf);
+ /* spec */ getushort(ttf);
+ /* lang */ getushort(ttf);
+ name = getushort(ttf);
+ len = getushort(ttf);
+ off = getushort(ttf);
+ if (name == 6) {
+ char *str = malloc(len+1);
+ if (str) {
+ fseek (ttf, stringoffset+off, SEEK_SET);
+ if(fread(str,1,len,ttf)==(size_t)len) {
+ str[len] = '\0';
+ return str;
+ }
+ free(str);
+ }
+ }
}
return NULL;
}
@@ -661,16 +660,16 @@ static int PickTTFFont(FILE *ttf,char *filename,char **chosenname) {
names = galloc(cnt*sizeof(char *));
for ( i=j=0; i<cnt; ++i ) {
names[j] = TTFGetFontName(ttf,offsets[i],0);
- if ( names[j]!=NULL ) ++j;
+ if ( names[j]!=NULL )
+ ++j;
}
pt = strrchr(filename,'/');
- if ( pt==NULL ) pt = filename;
+ if ( pt==NULL )
+ pt = filename;
/* Someone gave me a font "Nafees Nastaleeq(Updated).ttf" and complained */
/* that ff wouldn't open it */
/* Now someone will complain about "Nafees(Updated).ttc(fo(ob)ar)" */
- if ( (lparen = strrchr(pt,'('))!=NULL &&
- (rparen = strrchr(lparen,')'))!=NULL &&
- rparen[1]=='\0' ) {
+ if ( (lparen = strrchr(pt,'('))!=NULL && (rparen = strrchr(lparen,')'))!=NULL && rparen[1]=='\0' ) {
char *find = copy(lparen+1);
pt = strchr(find,')');
if ( pt!=NULL ) *pt='\0';
@@ -687,9 +686,9 @@ static int PickTTFFont(FILE *ttf,char *filename,char **chosenname) {
char *fn = copy(filename);
fn[lparen-filename] = '\0';
ff_post_error(_("Not in Collection"),
-/* GT: The user is trying to open a font file which contains multiple fonts and */
-/* GT: has asked for a font which is not in that file. */
-/* GT: The string will look like: <fontname> is not in <filename> */
+ /* GT: The user is trying to open a font file which contains multiple fonts and */
+ /* GT: has asked for a font which is not in that file. */
+ /* GT: The string will look like: <fontname> is not in <filename> */
_("%1$s is not in %2$.100s"),find,fn);
free(fn);
}
@@ -712,14 +711,14 @@ static int PickCFFFont(char **fontnames) {
int cnt, i, choice;
for ( cnt=0; fontnames[cnt]!=NULL; ++cnt);
- names = gcalloc(cnt+1,sizeof(unichar_t *));
+ names = gcalloc(cnt+1,sizeof(unichar_t *));
for ( i=0; i<cnt; ++i )
- names[i] = uc_copy(fontnames[i]);
+ names[i] = uc_copy(fontnames[i]);
choice = 0;
for ( i=0; i<cnt; ++i )
- free(names[i]);
+ free(names[i]);
free(names);
-return( choice );
+ return( choice );
}
static void ParseSaveTablesPref(struct ttfinfo *info) {
@@ -729,40 +728,40 @@ static void ParseSaveTablesPref(struct ttfinfo *info) {
info->savecnt = 0;
info->savetab = NULL;
if ( SaveTablesPref==NULL || *SaveTablesPref=='\0' )
-return;
+ return;
for ( pt=SaveTablesPref, cnt=0; *pt; ++pt )
if ( *pt==',' )
++cnt;
info->savecnt = cnt+1;
info->savetab = gcalloc(cnt+1,sizeof(struct savetab));
for ( pt=spt=SaveTablesPref, cnt=0; ; ++pt ) {
- if ( *pt==',' || *pt=='\0' ) {
- uint32 tag;
- tag = ( ( spt <pt )? spt[0] : ' ' )<<24;
- tag |= ( ( spt+1<pt )? spt[1] : ' ' )<<16;
- tag |= ( ( spt+2<pt )? spt[2] : ' ' )<<8 ;
- tag |= ( ( spt+3<pt )? spt[3] : ' ' ) ;
- info->savetab[cnt++].tag = tag;
- if ( *pt )
- spt = pt+1;
- else
- break;
- }
+ if ( *pt==',' || *pt=='\0' ) {
+ uint32 tag;
+ tag = ( ( spt <pt )? spt[0] : ' ' )<<24;
+ tag |= ( ( spt+1<pt )? spt[1] : ' ' )<<16;
+ tag |= ( ( spt+2<pt )? spt[2] : ' ' )<<8 ;
+ tag |= ( ( spt+3<pt )? spt[3] : ' ' ) ;
+ info->savetab[cnt++].tag = tag;
+ if ( *pt )
+ spt = pt+1;
+ else
+ break;
+ }
}
}
static int32 filechecksum(FILE *file, int start, int len) {
uint32 sum = 0, chunk;
-
fseek(file,start,SEEK_SET);
- if ( len!=-1 ) len=(len+3)>>2;
+ if ( len!=-1 )
+ len=(len+3)>>2;
while ( len==-1 || --len>=0 ) {
- chunk = getlong(file);
- if ( feof(file))
- break;
- sum += chunk;
+ chunk = getlong(file);
+ if ( feof(file))
+ break;
+ sum += chunk;
}
-return( sum );
+ return( sum );
}
static void ValidateTTFHead(FILE *ttf,struct ttfinfo *info) {
@@ -772,10 +771,10 @@ static void ValidateTTFHead(FILE *ttf,struct ttfinfo *info) {
/* bather */
uint32 restore_this_pos = ftell(ttf);
struct tt_tables {
- uint32 tag;
- uint32 checksum;
- uint32 offset;
- uint32 length;
+ uint32 tag;
+ uint32 checksum;
+ uint32 offset;
+ uint32 length;
} *tabs, temp;
int i,j;
uint32 file_len;
@@ -792,77 +791,77 @@ static void ValidateTTFHead(FILE *ttf,struct ttfinfo *info) {
e_rs = info->numtables*16-e_sr;
if ( e_sr!=sr || e_es!=es || e_rs!=rs ) {
LogError( _("Unexpected values for binsearch header. Based on the number of tables I\n expect searchRange=%d (not %d), entrySel=%d (not %d) rangeShift=%d (not %d)\n"),
- e_sr, sr, e_es, es, e_rs, rs );
- info->bad_sfnt_header = true;
+ e_sr, sr, e_es, es, e_rs, rs );
+ info->bad_sfnt_header = true;
}
if ( info->numtables<=0 ) {
- LogError(_("An sfnt file must contain SOME tables, but this one does not."));
- info->bad_sfnt_header = true;
- fseek(ttf,restore_this_pos,SEEK_SET);
-return;
+ LogError(_("An sfnt file must contain SOME tables, but this one does not."));
+ info->bad_sfnt_header = true;
+ fseek(ttf,restore_this_pos,SEEK_SET);
+ return;
} else if ( info->numtables>1000 ) {
- LogError(_("An sfnt file may contain a large number of tables, but this one has over 1000\n and that seems like too many\n"));
- info->bad_sfnt_header = true;
- fseek(ttf,restore_this_pos,SEEK_SET);
-return;
+ LogError(_("An sfnt file may contain a large number of tables, but this one has over 1000\n and that seems like too many\n"));
+ info->bad_sfnt_header = true;
+ fseek(ttf,restore_this_pos,SEEK_SET);
+ return;
}
tabs = galloc(info->numtables*sizeof(struct tt_tables));
for ( i=0; i<info->numtables; ++i ) {
- tabs[i].tag = getlong(ttf);
- tabs[i].checksum = getlong(ttf);
- tabs[i].offset = getlong(ttf);
- tabs[i].length = getlong(ttf);
- if ( i!=0 && tabs[i].tag<tabs[i-1].tag && !info->bad_sfnt_header ) {
- LogError(_("Table tags should be in alphabetic order in the font header\n but '%c%c%c%c', appears after '%c%c%c%c'."),
- tabs[i-1].tag>>24, tabs[i-1].tag>>16, tabs[i-1].tag>>8, tabs[i-1].tag,
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
- info->bad_sfnt_header = true;
- }
+ tabs[i].tag = getlong(ttf);
+ tabs[i].checksum = getlong(ttf);
+ tabs[i].offset = getlong(ttf);
+ tabs[i].length = getlong(ttf);
+ if ( i!=0 && tabs[i].tag<tabs[i-1].tag && !info->bad_sfnt_header ) {
+ LogError(_("Table tags should be in alphabetic order in the font header\n but '%c%c%c%c', appears after '%c%c%c%c'."),
+ tabs[i-1].tag>>24, tabs[i-1].tag>>16, tabs[i-1].tag>>8, tabs[i-1].tag,
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
+ info->bad_sfnt_header = true;
+ }
}
fseek(ttf,0,SEEK_END);
file_len = ftell(ttf);
for ( i=0; i<info->numtables; ++i ) for ( j=i+1; j<info->numtables; ++j ) {
- if ( tabs[i].offset>tabs[j].offset ) {
- temp = tabs[i];
- tabs[i] = tabs[j];
- tabs[j] = temp;
- }
+ if ( tabs[i].offset>tabs[j].offset ) {
+ temp = tabs[i];
+ tabs[i] = tabs[j];
+ tabs[j] = temp;
+ }
}
for ( i=0; i<info->numtables-1; ++i ) {
- for ( j=i+1; j<info->numtables; ++j ) {
- if ( tabs[i].tag==tabs[j].tag ) {
- LogError(_("Same table tag, '%c%c%c%c', appears twice in sfnt header"),
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
- info->bad_sfnt_header = true;
- }
- }
- if ( tabs[i].offset+tabs[i].length > tabs[i+1].offset ) {
- LogError(_("Tables '%c%c%c%c' and '%c%c%c%c' overlap"),
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag,
- tabs[j].tag>>24, tabs[j].tag>>16, tabs[j].tag>>8, tabs[j].tag );
- }
+ for ( j=i+1; j<info->numtables; ++j ) {
+ if ( tabs[i].tag==tabs[j].tag ) {
+ LogError(_("Same table tag, '%c%c%c%c', appears twice in sfnt header"),
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
+ info->bad_sfnt_header = true;
+ }
+ }
+ if ( tabs[i].offset+tabs[i].length > tabs[i+1].offset ) {
+ LogError(_("Tables '%c%c%c%c' and '%c%c%c%c' overlap"),
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag,
+ tabs[j].tag>>24, tabs[j].tag>>16, tabs[j].tag>>8, tabs[j].tag );
+ }
}
if ( tabs[i].offset+tabs[i].length > file_len ) {
- LogError(_("Table '%c%c%c%c' extends beyond end of file."),
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
- info->bad_sfnt_header = true;
+ LogError(_("Table '%c%c%c%c' extends beyond end of file."),
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
+ info->bad_sfnt_header = true;
}
/* Checksums. First file as a whole, then each table */
if ( filechecksum(ttf,0,-1)!=(int)0xb1b0afba ) {
- LogError(_("File checksum is incorrect."));
- info->bad_sfnt_header = true;
+ LogError(_("File checksum is incorrect."));
+ info->bad_sfnt_header = true;
}
for ( i=0; i<info->numtables-1; ++i ) if ( tabs[i].tag!=CHR('h','e','a','d')) {
- if ( filechecksum(ttf,tabs[i].offset,tabs[i].length)!=(int)tabs[i].checksum ) {
- LogError(_("Table '%c%c%c%c' has a bad checksum."),
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
- info->bad_sfnt_header = true;
- }
+ if ( filechecksum(ttf,tabs[i].offset,tabs[i].length)!=(int)tabs[i].checksum ) {
+ LogError(_("Table '%c%c%c%c' has a bad checksum."),
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
+ info->bad_sfnt_header = true;
+ }
}
hashead = hashhea = hasmaxp = masos2 = haspost = hasname = hasos2 = false;
@@ -3671,10 +3670,10 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
cffinfofillup(info, dict, strings, scnt );
/* We'll set the encmap later */
- /*info->map = encmap = EncMapNew(info->glyph_cnt,info->glyph_cnt,&custom);*/
+ /* info->map = encmap = EncMapNew(info->glyph_cnt,info->glyph_cnt,&custom);*/
for ( j=0; subdicts[j]!=NULL; ++j );
- info->subfontcnt = j;
+ info->subfontcnt = j;
info->subfonts = gcalloc(j+1,sizeof(SplineFont *));
for ( j=0; subdicts[j]!=NULL; ++j ) {
info->subfonts[j] = cffsffillup(subdicts[j],strings,scnt,info);
@@ -3682,21 +3681,22 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
info->subfonts[j]->glyphmin = -1;
}
/* here we also deal with glyphmin */
-
for ( i=0; i<info->glyph_cnt; ++i ) {
sf = info->subfonts[ fdselect[i] ];
cid = dict->charset[i];
if ( cid>=sf->glyphcnt ) {
- if (sf->glyphmin == -1) {
- sf->glyphmin = cid;
- }
- sf->glyphcnt = sf->glyphmax = cid+1;
- }
- /*if ( cid>=encmap->enccount )
- encmap->enccount = cid+1;*/
+ if (sf->glyphmin == -1) {
+ /*
+ sf->glyphmin = cid;
+ */
+ }
+ sf->glyphcnt = sf->glyphmax = cid+1;
+ }
+ /* if ( cid>=encmap->enccount ) encmap->enccount = cid+1;*/
}
- for ( j=0; subdicts[j]!=NULL; ++j )
+ for ( j=0; subdicts[j]!=NULL; ++j ) {
info->subfonts[j]->glyphs = gcalloc(info->subfonts[j]->glyphcnt,sizeof(SplineChar *));
+ }
/*encmap->encmax = encmap->enccount;*/
/*encmap->map = galloc(encmap->enccount*sizeof(int));*/
@@ -3721,26 +3721,24 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
cstype = subdicts[j]->charstringtype;
pscontext.is_type2 = cstype-1;
pscontext.painttype = subdicts[j]->painttype;
- gsubrs->bias = cstype==1 ? 0 :
- gsubrs->cnt < 1240 ? 107 :
- gsubrs->cnt <33900 ? 1131 : 32768;
+ gsubrs->bias = cstype==1 ? 0 : gsubrs->cnt < 1240 ? 107 : gsubrs->cnt <33900 ? 1131 : 32768;
subrs = &subdicts[j]->local_subrs;
- subrs->bias = cstype==1 ? 0 :
- subrs->cnt < 1240 ? 107 :
- subrs->cnt <33900 ? 1131 : 32768;
- cid = dict->charset[i];
+ subrs->bias = cstype==1 ? 0 : subrs->cnt < 1240 ? 107 : subrs->cnt <33900 ? 1131 : 32768;
+ /*
+ cid = dict->charset[i];
+ */
+ cid = i ;
/*encmap->map[cid] = cid;*/
uni = CID2NameUni(map,cid,buffer,sizeof(buffer));
- info->chars[i] = PSCharStringToBB(
- dict->glyphs.values[i], dict->glyphs.lens[i],&pscontext,
- subrs,gsubrs,buffer);
+ info->chars[i] = PSCharStringToBB(dict->glyphs.values[i], dict->glyphs.lens[i],&pscontext,subrs,gsubrs,buffer);
info->chars[i]->vwidth = sf->ascent+sf->descent;
info->chars[i]->unicodeenc = uni;
sf->glyphs[cid] = info->chars[i];
sf->glyphs[cid]->parent = sf;
sf->glyphs[cid]->orig_pos = i; /* fixed in 0.80.1 */
- if ( sf->glyphs[cid]->layers[ly_fore].refs!=NULL )
+ if ( sf->glyphs[cid]->layers[ly_fore].refs!=NULL ) {
IError( "Reference found in CID font. Can't fix it up");
+ }
THPatchSplineChar(sf->glyphs[cid]);
if ( cstype==2 ) {
if ( sf->glyphs[cid]->width == (int16) 0x8000 )
@@ -3748,8 +3746,18 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
else
sf->glyphs[cid]->width += subdicts[j]->nominalwidthx;
}
+ /* moved here */
+ if (sf->glyphmin == -1) {
+ /* if (sf->glyphs[cid] != (struct splinechar *)-1) { */
+ sf->glyphmin = cid ;
+ /* } */
+ }
ff_progress_next();
}
+ /* bonus */
+ if (sf->glyphmin == -1) {
+ sf->glyphmin = 0 ;
+ }
/* No need to do a reference fixup here-- the chars aren't associated */
/* with any encoding as is required for seac */
}
@@ -3768,7 +3776,7 @@ static int readcffglyphs(FILE *ttf,struct ttfinfo *info) {
if ( getc(ttf)!='\1' ) { /* Major version */
LogError( _("CFF version mismatch\n" ));
info->bad_cff = true;
-return( 0 );
+ return 0;
}
getc(ttf); /* Minor version */
hdrsize = getc(ttf);
@@ -3778,13 +3786,14 @@ return( 0 );
fontnames = readcfffontnames(ttf,NULL,info);
which = 0;
if ( fontnames[1]!=NULL ) { /* More than one? Can that even happen in OpenType? */
- which = PickCFFFont(fontnames);
- if ( which==-1 ) {
- for ( i=0; fontnames[i]!=NULL; ++i )
- free(fontnames[i]);
- free(fontnames);
-return( 0 );
- }
+ which = PickCFFFont(fontnames);
+ if (which == -1) {
+ for (i=0; fontnames[i]!=NULL; ++i) {
+ free(fontnames[i]);
+ }
+ free(fontnames);
+ return 0;
+ }
}
dicts = readcfftopdicts(ttf,fontnames,info->cff_start,info, NULL);
/* String index is just the same as fontname index */
@@ -3792,60 +3801,60 @@ return( 0 );
readcffsubrs(ttf,&gsubs,info );
/* Can be many fonts here. Only decompose the one */
if ( dicts[which]->charstringsoff!=-1 ) {
- fseek(ttf,info->cff_start+dicts[which]->charstringsoff,SEEK_SET);
- readcffsubrs(ttf,&dicts[which]->glyphs,info);
+ fseek(ttf,info->cff_start+dicts[which]->charstringsoff,SEEK_SET);
+ readcffsubrs(ttf,&dicts[which]->glyphs,info);
}
if ( dicts[which]->private_offset!=-1 )
- readcffprivate(ttf,dicts[which],info);
+ readcffprivate(ttf,dicts[which],info);
if ( dicts[which]->charsetoff!=-1 )
- readcffset(ttf,dicts[which],info);
+ readcffset(ttf,dicts[which],info);
if ( dicts[which]->fdarrayoff==-1 )
- cfffigure(info,dicts[which],strings,scnt,&gsubs);
+ cfffigure(info,dicts[which],strings,scnt,&gsubs);
else {
- fseek(ttf,info->cff_start+dicts[which]->fdarrayoff,SEEK_SET);
- subdicts = readcfftopdicts(ttf,NULL,info->cff_start,info,dicts[which]);
- fseek(ttf,info->cff_start+dicts[which]->fdselectoff,SEEK_SET);
- fdselect = readfdselect(ttf,dicts[which]->glyphs.cnt,info);
- for ( j=0; subdicts[j]!=NULL; ++j ) {
- if ( subdicts[j]->private_offset!=-1 )
- readcffprivate(ttf,subdicts[j],info);
- if ( subdicts[j]->charsetoff!=-1 )
- readcffset(ttf,subdicts[j],info);
- }
- cidfigure(info,dicts[which],strings,scnt,&gsubs,subdicts,fdselect);
- for ( j=0; subdicts[j]!=NULL; ++j )
- TopDictFree(subdicts[j]);
- free(subdicts); free(fdselect);
+ fseek(ttf,info->cff_start+dicts[which]->fdarrayoff,SEEK_SET);
+ subdicts = readcfftopdicts(ttf,NULL,info->cff_start,info,dicts[which]);
+ fseek(ttf,info->cff_start+dicts[which]->fdselectoff,SEEK_SET);
+ fdselect = readfdselect(ttf,dicts[which]->glyphs.cnt,info);
+ for ( j=0; subdicts[j]!=NULL; ++j ) {
+ if ( subdicts[j]->private_offset!=-1 )
+ readcffprivate(ttf,subdicts[j],info);
+ if ( subdicts[j]->charsetoff!=-1 )
+ readcffset(ttf,subdicts[j],info);
+ }
+ cidfigure(info,dicts[which],strings,scnt,&gsubs,subdicts,fdselect);
+ for ( j=0; subdicts[j]!=NULL; ++j )
+ TopDictFree(subdicts[j]);
+ free(subdicts); free(fdselect);
}
if ( dicts[which]->encodingoff!=-1 )
- readcffenc(ttf,dicts[which],info,strings,scnt);
+ readcffenc(ttf,dicts[which],info,strings,scnt);
if ( dicts[which]->fdarrayoff==-1 ) {
- for ( i=0; i<info->glyph_cnt ; ++i )
- if ( info->chars[i]!=NULL )
- info->chars[i]->orig_pos = i;
- }
+ for ( i=0; i<info->glyph_cnt ; ++i )
+ if ( info->chars[i]!=NULL )
+ info->chars[i]->orig_pos = i;
+ }
if ( info->to_order2 ) {
- for ( i=0; i<info->glyph_cnt; ++i )
- SCConvertToOrder2(info->chars[i]);
+ for ( i=0; i<info->glyph_cnt; ++i )
+ SCConvertToOrder2(info->chars[i]);
}
for ( i=0; fontnames[i]!=NULL && i<1; ++i ) {
- free(fontnames[i]);
- TopDictFree(dicts[i]);
+ free(fontnames[i]);
+ TopDictFree(dicts[i]);
}
free(fontnames); free(dicts);
if ( strings!=NULL ) {
- for ( i=0; strings[i]!=NULL; ++i )
- free(strings[i]);
- free(strings);
+ for ( i=0; strings[i]!=NULL; ++i )
+ free(strings[i]);
+ free(strings);
}
for ( i=0; i<gsubs.cnt; ++i )
- free(gsubs.values[i]);
+ free(gsubs.values[i]);
free(gsubs.values); free(gsubs.lens);
-return( 1 );
+ return 1 ;
}
static int readtyp1glyphs(FILE *ttf,struct ttfinfo *info) {
@@ -3855,55 +3864,58 @@ static int readtyp1glyphs(FILE *ttf,struct ttfinfo *info) {
SplineChar *sc;
fseek(ttf,info->typ1_start,SEEK_SET);
-/* There appear to be about 20 bytes of garbage (well, I don't know what they */
-/* mean, so they are garbage to me) before the start of the PostScript. But */
-/* it's not exactly 20. I've seen 22 and 24. So see if we can find "%!PS-Adobe" */
-/* in the first few bytes of the file, and skip to there if found */
- { char buffer[41];
+
+ /* There appear to be about 20 bytes of garbage (well, I don't know what they */
+ /* mean, so they are garbage to me) before the start of the PostScript. But */
+ /* it's not exactly 20. I've seen 22 and 24. So see if we can find "%!PS-Adobe" */
+ /* in the first few bytes of the file, and skip to there if found */
+
+ {
+ char buffer[41];
if(fread(buffer,1,sizeof(buffer),ttf) != sizeof(buffer))
-return( false );
- buffer[40] = '\0';
- for ( i=39; i>=0; --i )
- if ( buffer[i]=='%' && buffer[i+1]=='!' )
- break;
- if ( i<0 )
- i = 0;
- fseek(ttf,info->typ1_start+i,SEEK_SET);
+ return( false );
+ buffer[40] = '\0';
+ for ( i=39; i>=0; --i )
+ if ( buffer[i]=='%' && buffer[i+1]=='!' )
+ break;
+ if ( i<0 )
+ i = 0;
+ fseek(ttf,info->typ1_start+i,SEEK_SET);
}
tmp = tmpfile();
for ( i=0; i<(int)info->typ1_length; ++i )
- putc(getc(ttf),tmp);
+ putc(getc(ttf),tmp);
rewind(tmp);
fd = _ReadPSFont(tmp);
fclose(tmp);
if ( fd!=NULL ) {
- SplineFont *sf = SplineFontFromPSFont(fd);
- PSFontFree(fd);
- info->emsize = (sf->ascent+sf->descent);
- info->ascent = sf->ascent;
- info->descent = sf->descent;
- if ( sf->subfontcnt!=0 ) {
- info->subfontcnt = sf->subfontcnt;
- info->subfonts = sf->subfonts;
- info->cidregistry = copy(sf->cidregistry);
- info->ordering = copy(sf->ordering);
- info->supplement = sf->supplement;
- info->cidfontversion = sf->cidversion;
- sf->subfonts = NULL;
- sf->subfontcnt = 0;
- } else {
- info->chars = sf->glyphs;
- info->glyph_cnt = sf->glyphcnt;
- for ( i=sf->glyphcnt-1; i>=0; --i ) if ( (sc=sf->glyphs[i])!=NULL )
- sc->parent = NULL;
- sf->glyphs = NULL;
- sf->glyphcnt = 0;
- }
- SplineFontFree(sf);
-return( true );
+ SplineFont *sf = SplineFontFromPSFont(fd);
+ PSFontFree(fd);
+ info->emsize = (sf->ascent+sf->descent);
+ info->ascent = sf->ascent;
+ info->descent = sf->descent;
+ if ( sf->subfontcnt!=0 ) {
+ info->subfontcnt = sf->subfontcnt;
+ info->subfonts = sf->subfonts;
+ info->cidregistry = copy(sf->cidregistry);
+ info->ordering = copy(sf->ordering);
+ info->supplement = sf->supplement;
+ info->cidfontversion = sf->cidversion;
+ sf->subfonts = NULL;
+ sf->subfontcnt = 0;
+ } else {
+ info->chars = sf->glyphs;
+ info->glyph_cnt = sf->glyphcnt;
+ for ( i=sf->glyphcnt-1; i>=0; --i ) if ( (sc=sf->glyphs[i])!=NULL )
+ sc->parent = NULL;
+ sf->glyphs = NULL;
+ sf->glyphcnt = 0;
+ }
+ SplineFontFree(sf);
+ return( true );
}
-return( false );
+ return( false );
}
static void readttfwidths(FILE *ttf,struct ttfinfo *info) {
@@ -4839,41 +4851,41 @@ return;
for ( i=0; i<count; ++i ) {
int gid = getushort(ttf);
if ( dounicode )
- info->chars[gid]->unicodeenc = first+i;
+ info->chars[gid]->unicodeenc = first+i;
if ( map!=NULL && first+i < map->enccount )
- map->map[first+i] = gid;
+ map->map[first+i] = gid;
}
} else if ( format==12 ) {
uint32 ngroups, start, end, startglyph;
if ( !enc->is_unicodefull ) {
- IError("I don't support 32 bit characters except for the UCS-4 (MS platform, specific=10)" );
- enc = FindOrMakeEncoding("UnicodeFull");
+ IError("I don't support 32 bit characters except for the UCS-4 (MS platform, specific=10)" );
+ enc = FindOrMakeEncoding("UnicodeFull");
}
ngroups = getlong(ttf);
for ( j=0; j<(int)ngroups; ++j ) {
- start = getlong(ttf);
- end = getlong(ttf);
- startglyph = getlong(ttf);
- if ( justinuse==git_justinuse ) {
- for ( i=start; i<=(int)end; ++i )
- if ( startglyph+i-start < (unsigned)info->glyph_cnt )
- info->inuse[startglyph+i-start]= 1;
- else
- break;
- } else
- for ( i=start; i<=(int)end; ++i ) {
- if ( startglyph+i-start >= (unsigned)info->glyph_cnt ||
- info->chars[startglyph+i-start]==NULL ) {
- LogError( _("Bad font: Encoding data out of range.\n") );
- info->bad_cmap = true;
- break;
- } else {
- if ( dounicode )
- info->chars[startglyph+i-start]->unicodeenc = i;
- if ( map!=NULL && i < map->enccount && i>=0)
- map->map[i] = startglyph+i-start;
- }
- }
+ start = getlong(ttf);
+ end = getlong(ttf);
+ startglyph = getlong(ttf);
+ if ( justinuse==git_justinuse ) {
+ for ( i=start; i<=(int)end; ++i )
+ if ( startglyph+i-start < (unsigned)info->glyph_cnt )
+ info->inuse[startglyph+i-start]= 1;
+ else
+ break;
+ } else {
+ for ( i=start; i<=(int)end; ++i ) {
+ if ( startglyph+i-start >= (unsigned)info->glyph_cnt || info->chars[startglyph+i-start]==NULL ) {
+ LogError( _("Bad font: Encoding data out of range.\n") );
+ info->bad_cmap = true;
+ break;
+ } else {
+ if ( dounicode )
+ info->chars[startglyph+i-start]->unicodeenc = i;
+ if ( map!=NULL && i < map->enccount && i>=0)
+ map->map[i] = startglyph+i-start;
+ }
+ }
+ }
}
}
}
@@ -5069,7 +5081,7 @@ static void readttfpostnames(FILE *ttf,struct ttfinfo *info) {
nm[j] = getc(ttf);
nm[j] = '\0';
if ( indexes[i]<info->glyph_cnt && info->chars[indexes[i]]!=NULL ) {
- if (info->chars[indexes[i]]->name)
+ if (info->chars[indexes[i]]->name)
free( info->chars[indexes[i]]->name );
info->chars[indexes[i]]->name = nm;
#if 0 /* Too many fonts have badly named glyphs */
@@ -6083,7 +6095,7 @@ static SplineFont *SFFillFromTTFInfo(struct ttfinfo *info) {
free(info->savetab);
if (info->chosenname)
- free(info->chosenname);
+ free(info->chosenname);
if ( sf->copyright==NULL )
sf->copyright = info->copyright;
else
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
index 91dcfeee028..afbf08520d4 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
@@ -35,7 +35,10 @@
#define FONT_GLYPHS_METATABLE "fontloader.splinefont.glyphs"
#define FONT_GLYPH_METATABLE "fontloader.splinefont.glyph"
-#define LUA_OTF_VERSION "0.4"
+#define LUA_OTF_VERSION "0.5"
+
+extern void normal_error(const char *t, const char *p);
+extern void formatted_error(const char *t, const char *fmt, ...);
static const char *possub_type_enum[] = {
"null", "position", "pair", "substitution",
@@ -276,6 +279,7 @@ static int ff_close(lua_State * L)
return 0;
}
+/*
static int notdef_loc(SplineFont * sf)
{
int k;
@@ -291,6 +295,20 @@ static int notdef_loc(SplineFont * sf)
l = sf->glyphcnt;
return l;
}
+*/
+
+static int notdef_loc(SplineFont * sf)
+{
+ int k;
+ for (k = 0; k < sf->glyphcnt; k++) {
+ if (sf->glyphs[k]) {
+ if (strcmp(sf->glyphs[k]->name, ".notdef") == 0) {
+ return k ;
+ }
+ }
+ }
+ return -1;
+}
static int ff_apply_featurefile(lua_State * L)
{
@@ -323,15 +341,15 @@ static int ff_apply_afmfile(lua_State * L)
fname = luaL_checkstring(L, 2);
CheckAfmOfPostscript(*sf, fname, (*sf)->map);
if (gww_error_count > 0) {
- int i;
- lua_newtable(L);
- for (i = 0; i < gww_error_count; i++) {
- lua_pushstring(L, gww_errors[i]);
- lua_rawseti(L, -2, (i + 1));
- }
- gwwv_errors_free();
+ int i;
+ lua_newtable(L);
+ for (i = 0; i < gww_error_count; i++) {
+ lua_pushstring(L, gww_errors[i]);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ gwwv_errors_free();
} else {
- lua_pushnil(L);
+ lua_pushnil(L);
}
return 1;
}
@@ -594,8 +612,6 @@ static int do_handle_lookup(lua_State * L, struct otlookup *lookup, SplineFont *
}
lua_setfield(L, -2, "flags");
-
-
dump_stringfield(L, "name", lookup->lookup_name);
if (lookup->features != NULL) {
@@ -967,9 +983,6 @@ static void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvm
lua_pushnumber(L, glyph->ymax);
lua_rawset(L, -3);
lua_setfield(L, -2, "boundingbox");
- if (glyph->orig_pos>=0) {
- dump_intfield(L,"orig_pos",glyph->orig_pos);
-}
if (hasvmetrics) {
dump_intfield(L, "vwidth", glyph->vwidth);
if (glyph->tsb != 0)
@@ -1205,31 +1218,17 @@ static void handle_pfminfo(lua_State * L, struct pfminfo pfm)
dump_intfield(L, "firstchar", pfm.firstchar);
dump_intfield(L, "lastchar", pfm.lastchar);
lua_createtable(L, 0, 10);
- dump_enumfield(L, "familytype",
- fix_range(panose_values_0_max, pfm.panose[0]),
- panose_values_0);
- dump_enumfield(L, "serifstyle",
- fix_range(panose_values_1_max, pfm.panose[1]),
- panose_values_1);
- dump_enumfield(L, "weight", fix_range(panose_values_2_max, pfm.panose[2]),
- panose_values_2);
- dump_enumfield(L, "proportion",
- fix_range(panose_values_3_max, pfm.panose[3]),
- panose_values_3);
- dump_enumfield(L, "contrast", fix_range(panose_values_4_max, pfm.panose[4]),
- panose_values_4);
- dump_enumfield(L, "strokevariation",
- fix_range(panose_values_5_max, pfm.panose[5]),
- panose_values_5);
- dump_enumfield(L, "armstyle", fix_range(panose_values_6_max, pfm.panose[6]),
- panose_values_6);
- dump_enumfield(L, "letterform",
- fix_range(panose_values_7_max, pfm.panose[7]),
- panose_values_7);
- dump_enumfield(L, "midline", fix_range(panose_values_8_max, pfm.panose[8]),
- panose_values_8);
- dump_enumfield(L, "xheight", fix_range(panose_values_9_max, pfm.panose[9]),
- panose_values_9);
+
+ dump_enumfield(L, "familytype", fix_range(panose_values_0_max, pfm.panose[0]), panose_values_0);
+ dump_enumfield(L, "serifstyle", fix_range(panose_values_1_max, pfm.panose[1]), panose_values_1);
+ dump_enumfield(L, "weight", fix_range(panose_values_2_max, pfm.panose[2]), panose_values_2);
+ dump_enumfield(L, "proportion", fix_range(panose_values_3_max, pfm.panose[3]), panose_values_3);
+ dump_enumfield(L, "contrast", fix_range(panose_values_4_max, pfm.panose[4]), panose_values_4);
+ dump_enumfield(L, "strokevariation", fix_range(panose_values_5_max, pfm.panose[5]), panose_values_5);
+ dump_enumfield(L, "armstyle", fix_range(panose_values_6_max, pfm.panose[6]), panose_values_6);
+ dump_enumfield(L, "letterform", fix_range(panose_values_7_max, pfm.panose[7]), panose_values_7);
+ dump_enumfield(L, "midline", fix_range(panose_values_8_max, pfm.panose[8]), panose_values_8);
+ dump_enumfield(L, "xheight", fix_range(panose_values_9_max, pfm.panose[9]), panose_values_9);
lua_setfield(L, -2, "panose");
dump_intfield(L, "fstype", pfm.fstype);
@@ -1325,8 +1324,7 @@ static char *do_handle_enc(lua_State * L, struct enc *enc)
dump_cond_intfield(L, "is_simplechinese", enc->is_simplechinese);
if (enc->iso_2022_escape_len > 0) {
- dump_lstringfield(L, "iso_2022_escape", enc->iso_2022_escape,
- enc->iso_2022_escape_len);
+ dump_lstringfield(L, "iso_2022_escape", enc->iso_2022_escape, enc->iso_2022_escape_len);
}
dump_intfield(L, "low_page", enc->low_page);
dump_intfield(L, "high_page", enc->high_page);
@@ -1366,9 +1364,11 @@ static void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc)
if (map->map[i] != -1) {
int l = map->map[i];
lua_pushnumber(L, i);
+ /*
if (l < notdef_loc)
lua_pushnumber(L, (l + 1));
else
+ */
lua_pushnumber(L, l);
lua_rawset(L, -3);
}
@@ -1379,13 +1379,12 @@ static void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc)
if (map->backmax > 0 && map->backmap != NULL) {
lua_newtable(L);
for (i = 0; i < map->backmax; i++) {
- if (map->backmap[i] != -1) { /* TODO: check this, because valgrind sometimes says
- "Conditional jump or move depends on uninitialised value(s)"
- needs a test file.
- */
+ if (map->backmap[i] != -1) {
+ /*
if (i < notdef_loc)
lua_pushnumber(L, (i + 1));
else
+ */
lua_pushnumber(L, i);
lua_pushnumber(L, map->backmap[i]);
lua_rawset(L, -3);
@@ -1399,7 +1398,7 @@ static void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc)
lua_newtable(L);
encname = do_handle_enc(L, map->enc);
lua_setfield(L, -2, "enc");
- lua_pushstring(L, encname);
+ lua_pushstring(L, encname);
lua_setfield(L, -2, "enc_name");
}
}
@@ -1438,13 +1437,12 @@ static void handle_ttflangname(lua_State * L, struct ttflangname *names)
static void do_handle_anchorclass(lua_State * L, struct anchorclass *anchor)
{
-
dump_stringfield(L, "name", anchor->name);
dump_subtable_name(L, "lookup", anchor->subtable);
dump_enumfield(L, "type", anchor->type, anchorclass_type_enum);
- /* uint8 has_base; */
- /* uint8 processed, has_mark, matches, ac_num; */
- /* uint8 ticked; */
+ /* uint8 has_base; */
+ /* uint8 processed, has_mark, matches, ac_num; */
+ /* uint8 ticked; */
}
static void handle_anchorclass(lua_State * L, struct anchorclass *anchor)
@@ -1473,19 +1471,19 @@ static int do_handle_kernclass(lua_State * L, struct kernclass *kerns, const cha
int k;
int match = 0;
if (name) {
- struct lookup_subtable *s = kerns->subtable;
- while (s != NULL) {
- if (strcmp(s->subtable_name,name)==0) {
- match = 1;
- break;
- }
+ struct lookup_subtable *s = kerns->subtable;
+ while (s != NULL) {
+ if (strcmp(s->subtable_name,name)==0) {
+ match = 1;
+ break;
+ }
s = s->next;
- }
+ }
} else {
- match = 1;
+ match = 1;
}
if (!match) {
- return 0;
+ return 0;
}
lua_checkstack(L, 4);
lua_createtable(L, kerns->first_cnt, 1);
@@ -1507,7 +1505,6 @@ static int do_handle_kernclass(lua_State * L, struct kernclass *kerns, const cha
if (!name) {
dump_subtable_name(L, "lookup", kerns->subtable);
}
-
lua_createtable(L, kerns->second_cnt * kerns->first_cnt, 1);
for (k = 0; k < (kerns->second_cnt * kerns->first_cnt); k++) {
if (kerns->offsets[k] != 0) {
@@ -1622,7 +1619,9 @@ static void handle_fpst_rule(lua_State * L, struct fpst_rule *rule, int format)
}
lua_setfield(L, -2, "lookups");
} else {
- /*fprintf(stderr,"handle_fpst_rule(): No lookups?\n"); */
+ /*
+ fprintf(stderr,"handle_fpst_rule(): No lookups?\n");
+ */
}
}
@@ -1901,7 +1900,7 @@ static void handle_mmset(lua_State * L, struct mmset *mm)
static void handle_splinefont(lua_State * L, struct splinefont *sf)
{
int k;
- int fix_notdef = 0;
+ int fix_notdef = 0; /* obsolete */
int l = -1;
dump_stringfield(L, "table_version", LUA_OTF_VERSION);
@@ -1918,6 +1917,7 @@ static void handle_splinefont(lua_State * L, struct splinefont *sf)
dump_floatfield(L, "uwidth", sf->uwidth);
dump_intfield(L, "ascent", sf->ascent);
dump_intfield(L, "descent", sf->descent);
+ dump_intfield(L, "notdef_loc",notdef_loc(sf));
if (sf->uniqueid!=0) {
dump_intfield(L, "uniqueid", sf->uniqueid);
}
@@ -1943,13 +1943,19 @@ static void handle_splinefont(lua_State * L, struct splinefont *sf)
/* This after-the-fact type discovery is not brilliant,
I should really add a 'format' key in the structure */
+
+ /*
if ((sf->origname != NULL) &&
(strmatch(sf->origname + strlen(sf->origname) - 4, ".pfa") == 0 ||
strmatch(sf->origname + strlen(sf->origname) - 4, ".pfb") == 0)) {
fix_notdef = 1;
}
+ */
if (fix_notdef) {
+
+ /* this is obsolete */
+
/* some code to ensure that the .notdef ends up in slot 0
(this will actually be enforced by the CFF writer) */
for (k = 0; k < sf->glyphcnt; k++) {
@@ -2249,7 +2255,7 @@ static void do_ff_info(lua_State * L, SplineFont * sf)
dump_stringfield(L, "weight", sf->weight);
dump_intfield(L, "units_per_em", sf->units_per_em);
- /* These are not assigned in info... */
+
/*dump_intfield(L, "design_range_bottom", sf->design_range_bottom);*/
/*dump_intfield(L, "design_range_top", sf->design_range_top);*/
/*dump_intfield(L, "design_size", sf->design_size);*/
@@ -2259,6 +2265,7 @@ static void do_ff_info(lua_State * L, SplineFont * sf)
lua_setfield(L, -2, "pfminfo");
/* Do we need this ? */
+
if (sf->names != NULL) {
lua_newtable(L);
handle_ttflangname(L, sf->names);
@@ -2317,7 +2324,7 @@ typedef enum {
FK_vkerns,
FK_gsub,
FK_gpos,
- /* FK_sm, */ /*this was removed because AAT is not supported anymore*/
+ /* FK_sm, */ /* AAT is not supported anymore */
FK_features,
FK_mm,
FK_chosenname,
@@ -2339,6 +2346,7 @@ typedef enum {
FK_horiz_base,
FK_vert_base,
FK_extrema_bound,
+ FK_notdef_loc,
} font_key_values;
const char *font_keys[] = {
@@ -2413,10 +2421,10 @@ const char *font_keys[] = {
"horiz_base",
"vert_base",
"extrema_bound",
+ "notdef_loc",
NULL
};
-
typedef enum {
GK_name = 0,
GK_unicode,
@@ -2441,7 +2449,6 @@ typedef enum {
GK_vert_variants,
GK_horiz_variants,
GK_mathkern,
- GK_orig_pos,
} font_glyph_key_values;
const char *font_glyph_keys[] = {
@@ -2468,7 +2475,6 @@ const char *font_glyph_keys[] = {
"vert_variants",
"horiz_variants",
"mathkern",
- "orig_pos",
NULL
};
@@ -2500,7 +2506,7 @@ static int ff_glyphs_index(lua_State * L)
SplineFont *sf;
int gid = 0;
int l = -1;
- int fix_notdef = 0;
+ int fix_notdef = 0; /* obsolete */
lua_pushstring(L, "__sf");
lua_rawget(L, 1);
/* sf = *check_isfont(L, -1); */
@@ -2518,21 +2524,27 @@ static int ff_glyphs_index(lua_State * L)
}
/* This after-the-fact type discovery is not brilliant,
I should really add a 'format' key in the structure */
+ /*
if ((sf->origname != NULL) &&
(strmatch(sf->origname + strlen(sf->origname) - 4, ".pfa") == 0 ||
strmatch(sf->origname + strlen(sf->origname) - 4, ".pfb") == 0)) {
fix_notdef = 1;
}
+ */
/* some code to ensure that the .notdef ends up in slot 0
(this will actually be enforced by the CFF writer) */
if (fix_notdef) {
+ /* this is obsolete */
l = notdef_loc(sf);
/* now l is the .notdef location, adjust gid if needed */
- if (l == sf->glyphcnt) { /* no .notdef at all, will be created at zero */
+ if (l == sf->glyphcnt) {
+ /* no .notdef at all, will be created at zero */
if (gid == 0) {
- gid = l; /* .notdef was added at end */
+ /* we ask for .notdef but .notdef was added at end */
+ gid = l;
} else {
- gid--; /* f.glyphs[gid] == sf->glyphs[gid-1] */
+ /* f.glyphs[gid] == sf->glyphs[gid-1] */
+ gid--;
}
} else if (l != 0) {
if (gid == 0) {
@@ -2542,11 +2554,11 @@ static int ff_glyphs_index(lua_State * L)
}
}
}
- /* push the glyph */
+
if (sf->glyphs[gid] && sf->glyphs[gid] != (struct splinechar *)-1) {
lua_ff_pushglyph(L, sf->glyphs[gid]);
} else {
- lua_pushnil(L);
+ lua_pushnil(L);
}
return 1;
}
@@ -2564,175 +2576,167 @@ static int ff_glyph_index(lua_State * L)
}
key = luaL_checkoption(L, 2, NULL, font_glyph_keys);
switch (key) {
- case GK_name:
- lua_pushstring(L, glyph->name);
- break;
- case GK_unicode:
- lua_pushnumber(L, glyph->unicodeenc);
- break;
- case GK_boundingbox:
- if (glyph->xmax == 0 && glyph->ymax == 0 && glyph->xmin == 0
- && glyph->ymin == 0) {
- DBounds bb;
- SplineCharFindBounds(glyph, &bb);
- glyph->xmin = bb.minx;
- glyph->ymin = bb.miny;
- glyph->xmax = bb.maxx;
- glyph->ymax = bb.maxy;
- }
- lua_createtable(L, 4, 0);
- lua_pushnumber(L, 1);
- lua_pushnumber(L, glyph->xmin);
- lua_rawset(L, -3);
- lua_pushnumber(L, 2);
- lua_pushnumber(L, glyph->ymin);
- lua_rawset(L, -3);
- lua_pushnumber(L, 3);
- lua_pushnumber(L, glyph->xmax);
- lua_rawset(L, -3);
- lua_pushnumber(L, 4);
- lua_pushnumber(L, glyph->ymax);
- lua_rawset(L, -3);
- break;
- case GK_vwidth:
- lua_pushnumber(L, glyph->vwidth);
- break;
- case GK_width:
- lua_pushnumber(L, glyph->width);
- break;
- case GK_lsidebearing:
- lua_pushnumber(L, glyph->lsidebearing);
- break;
- case GK_class:
- if (glyph->glyph_class > 0) {
- lua_pushstring(L, glyph_class_enum[glyph->glyph_class]);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_kerns:
- if (glyph->kerns != NULL) {
- lua_newtable(L);
- handle_kernpair(L, glyph->kerns);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_vkerns:
- if (glyph->vkerns != NULL) {
- lua_newtable(L);
- handle_kernpair(L, glyph->vkerns);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_dependents:
- if (glyph->dependents != NULL) {
- lua_newtable(L);
- handle_splinecharlist(L, glyph->dependents);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_lookups:
- if (glyph->possub != NULL) {
- lua_newtable(L);
- handle_generic_pst(L, glyph->possub);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_ligatures:
- if (glyph->ligofme != NULL) {
- lua_newtable(L);
- handle_liglist(L, glyph->ligofme);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_comment:
- lua_pushstring(L, glyph->comment);
- break;
- case GK_anchors:
- if (glyph->anchor != NULL) {
- lua_newtable(L);
- handle_anchorpoint(L, glyph->anchor);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_altuni:
- if (glyph->altuni != NULL) {
- lua_newtable(L);
- handle_altuni(L, glyph->altuni);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_tex_height:
- if (glyph->tex_height != TEX_UNDEF) {
- lua_pushnumber(L, glyph->tex_height);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_tex_depth:
- if (glyph->tex_height != TEX_UNDEF) {
- lua_pushnumber(L, glyph->tex_depth);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_is_extended_shape:
- lua_pushnumber(L, glyph->is_extended_shape);
- break;
- case GK_italic_correction:
- if (glyph->italic_correction != TEX_UNDEF) {
- lua_pushnumber(L, glyph->italic_correction);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_top_accent:
- if (glyph->top_accent_horiz != TEX_UNDEF) {
- lua_pushnumber(L, glyph->top_accent_horiz);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_vert_variants:
- if (glyph->vert_variants != NULL) {
- lua_newtable(L);
- handle_glyphvariants(L, glyph->vert_variants);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_horiz_variants:
- if (glyph->horiz_variants != NULL) {
- lua_newtable(L);
- handle_glyphvariants(L, glyph->horiz_variants);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_mathkern:
- if (glyph->mathkern != NULL) {
- lua_newtable(L);
- handle_mathkern(L, glyph->mathkern);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_orig_pos:
- if (glyph->orig_pos>=0) {
- lua_pushnumber(L, glyph->orig_pos);
- } else {
+ case GK_name:
+ lua_pushstring(L, glyph->name);
+ break;
+ case GK_unicode:
+ lua_pushnumber(L, glyph->unicodeenc);
+ break;
+ case GK_boundingbox:
+ if (glyph->xmax == 0 && glyph->ymax == 0 && glyph->xmin == 0 && glyph->ymin == 0) {
+ DBounds bb;
+ SplineCharFindBounds(glyph, &bb);
+ glyph->xmin = bb.minx;
+ glyph->ymin = bb.miny;
+ glyph->xmax = bb.maxx;
+ glyph->ymax = bb.maxy;
+ }
+ lua_createtable(L, 4, 0);
+ lua_pushnumber(L, 1);
+ lua_pushnumber(L, glyph->xmin);
+ lua_rawset(L, -3);
+ lua_pushnumber(L, 2);
+ lua_pushnumber(L, glyph->ymin);
+ lua_rawset(L, -3);
+ lua_pushnumber(L, 3);
+ lua_pushnumber(L, glyph->xmax);
+ lua_rawset(L, -3);
+ lua_pushnumber(L, 4);
+ lua_pushnumber(L, glyph->ymax);
+ lua_rawset(L, -3);
+ break;
+ case GK_vwidth:
+ lua_pushnumber(L, glyph->vwidth);
+ break;
+ case GK_width:
+ lua_pushnumber(L, glyph->width);
+ break;
+ case GK_lsidebearing:
+ lua_pushnumber(L, glyph->lsidebearing);
+ break;
+ case GK_class:
+ if (glyph->glyph_class > 0) {
+ lua_pushstring(L, glyph_class_enum[glyph->glyph_class]);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_kerns:
+ if (glyph->kerns != NULL) {
+ lua_newtable(L);
+ handle_kernpair(L, glyph->kerns);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_vkerns:
+ if (glyph->vkerns != NULL) {
+ lua_newtable(L);
+ handle_kernpair(L, glyph->vkerns);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_dependents:
+ if (glyph->dependents != NULL) {
+ lua_newtable(L);
+ handle_splinecharlist(L, glyph->dependents);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_lookups:
+ if (glyph->possub != NULL) {
+ lua_newtable(L);
+ handle_generic_pst(L, glyph->possub);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_ligatures:
+ if (glyph->ligofme != NULL) {
+ lua_newtable(L);
+ handle_liglist(L, glyph->ligofme);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_comment:
+ lua_pushstring(L, glyph->comment);
+ break;
+ case GK_anchors:
+ if (glyph->anchor != NULL) {
+ lua_newtable(L);
+ handle_anchorpoint(L, glyph->anchor);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_altuni:
+ if (glyph->altuni != NULL) {
+ lua_newtable(L);
+ handle_altuni(L, glyph->altuni);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_tex_height:
+ if (glyph->tex_height != TEX_UNDEF) {
+ lua_pushnumber(L, glyph->tex_height);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_tex_depth:
+ if (glyph->tex_height != TEX_UNDEF) {
+ lua_pushnumber(L, glyph->tex_depth);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_is_extended_shape:
+ lua_pushnumber(L, glyph->is_extended_shape);
+ break;
+ case GK_italic_correction:
+ if (glyph->italic_correction != TEX_UNDEF) {
+ lua_pushnumber(L, glyph->italic_correction);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_top_accent:
+ if (glyph->top_accent_horiz != TEX_UNDEF) {
+ lua_pushnumber(L, glyph->top_accent_horiz);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_vert_variants:
+ if (glyph->vert_variants != NULL) {
+ lua_newtable(L);
+ handle_glyphvariants(L, glyph->vert_variants);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_horiz_variants:
+ if (glyph->horiz_variants != NULL) {
+ lua_newtable(L);
+ handle_glyphvariants(L, glyph->horiz_variants);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_mathkern:
+ if (glyph->mathkern != NULL) {
+ lua_newtable(L);
+ handle_mathkern(L, glyph->mathkern);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ default:
lua_pushnil(L);
- }
- break;
- default:
- lua_pushnil(L);
}
return 1;
}
@@ -2742,12 +2746,10 @@ static int ff_index(lua_State * L)
SplineFont *sf;
int k, key;
/* sf = *check_isfont(L, 1); */
- if (!(is_userdata(L, 1, FONT_METATABLE) ||
- is_userdata(L, 1, FONT_SUBFONT_METATABLE))) {
+ if (!(is_userdata(L, 1, FONT_METATABLE) || is_userdata(L, 1, FONT_SUBFONT_METATABLE))) {
return luaL_error(L, "fontloader.__index: expected a (sub)font userdata object\n");
}
sf = *((SplineFont **)lua_touserdata(L, 1));
-
if (sf == NULL) {
lua_pushnil(L);
return 1;
@@ -2757,400 +2759,403 @@ static int ff_index(lua_State * L)
}
key = luaL_checkoption(L, 2, NULL, font_keys);
switch (key) {
- case FK_table_version:
- lua_pushstring(L, LUA_OTF_VERSION);
- break;
- case FK_fontname:
- lua_pushstring(L, sf->fontname);
- break;
- case FK_fullname:
- lua_pushstring(L, sf->fullname);
- break;
- case FK_familyname:
- lua_pushstring(L, sf->familyname);
- break;
- case FK_weight:
- lua_pushstring(L, sf->weight);
- break;
- case FK_copyright:
- lua_pushstring(L, sf->copyright);
- break;
- case FK_filename:
- lua_pushstring(L, sf->filename);
- break;
- case FK_version:
- lua_pushstring(L, sf->version);
- break;
- case FK_italicangle:
- lua_pushnumber(L, sf->italicangle);
- break;
- case FK_upos:
- lua_pushnumber(L, sf->upos);
- break;
- case FK_uwidth:
- lua_pushnumber(L, sf->uwidth);
- break;
- case FK_ascent:
- lua_pushnumber(L, sf->ascent);
- break;
- case FK_descent:
- lua_pushnumber(L, sf->descent);
- break;
- case FK_uniqueid:
- lua_pushnumber(L, sf->uniqueid);
- break;
- case FK_glyphcnt:
- if (sf->glyphcnt > 0) {
- lua_pushnumber(L, sf->glyphmax - sf->glyphmin + 1);
- } else {
- lua_pushnumber(L, 0);
- }
- break;
- case FK_glyphmax:
- lua_pushnumber(L, sf->glyphmax - 1);
- break;
- case FK_glyphmin:
- lua_pushnumber(L, sf->glyphmin);
- break;
- case FK_units_per_em:
- lua_pushnumber(L, sf->units_per_em);
- break;
- case FK_lookups:
- if (sf->possub != NULL) {
- lua_newtable(L);
- handle_generic_fpst(L, sf->possub);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_glyphs:
- lua_newtable(L); /* the virtual glyph table */
- lua_pushstring(L, "__sf");
- lua_pushvalue(L, 1); /* that is our font */
- lua_rawset(L, -3);
- luaL_getmetatable(L, FONT_GLYPHS_METATABLE);
- lua_setmetatable(L, -2); /* assign the metatable */
- break;
- case FK_hasvmetrics:
- lua_pushnumber(L, sf->hasvmetrics);
- break;
- case FK_onlybitmaps:
- lua_pushnumber(L, sf->onlybitmaps);
- break;
- case FK_serifcheck:
- lua_pushnumber(L, sf->serifcheck);
- break;
- case FK_isserif:
- lua_pushnumber(L, sf->isserif);
- break;
- case FK_issans:
- lua_pushnumber(L, sf->issans);
- break;
- case FK_encodingchanged:
- lua_pushnumber(L, sf->encodingchanged);
- break;
- case FK_strokedfont:
- lua_pushnumber(L, sf->strokedfont);
- break;
- case FK_use_typo_metrics:
- lua_pushnumber(L, sf->use_typo_metrics);
- break;
- case FK_weight_width_slope_only:
- lua_pushnumber(L, sf->weight_width_slope_only);
- break;
- case FK_head_optimized_for_cleartype:
- lua_pushnumber(L, sf->head_optimized_for_cleartype);
- break;
- case FK_uni_interp:
- lua_pushstring(L, uni_interp_enum[(sf->uni_interp + 1)]);
- break;
- case FK_map:
- if (sf->map != NULL) {
- lua_newtable(L);
- handle_encmap(L, sf->map, notdef_loc(sf));
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_origname:
- lua_pushstring(L, sf->origname);
- break;
- case FK_private:
- if (sf->private != NULL) {
- lua_newtable(L);
- handle_psdict(L, sf->private);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_xuid:
- lua_pushstring(L, sf->xuid);
- break;
- case FK_pfminfo:
- lua_createtable(L, 0, 40);
- handle_pfminfo(L, sf->pfminfo);
- break;
- case FK_names:
- if (sf->names != NULL) {
- lua_newtable(L);
- handle_ttflangname(L, sf->names);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_cidinfo:
- lua_createtable(L, 0, 4);
- dump_stringfield(L, "registry", sf->cidregistry);
- dump_stringfield(L, "ordering", sf->ordering);
- dump_intfield(L, "version", sf->cidversion);
- dump_intfield(L, "supplement", sf->supplement);
- break;
- case FK_subfonts:
- if (sf->subfontcnt > 0) {
- lua_createtable(L, sf->subfontcnt, 0);
- for (k = 0; k < sf->subfontcnt; k++) {
- lua_ff_pushsubfont(L, sf->subfonts[k]);
- lua_rawseti(L, -2, (k + 1));
+ case FK_table_version:
+ lua_pushstring(L, LUA_OTF_VERSION);
+ break;
+ case FK_fontname:
+ lua_pushstring(L, sf->fontname);
+ break;
+ case FK_fullname:
+ lua_pushstring(L, sf->fullname);
+ break;
+ case FK_familyname:
+ lua_pushstring(L, sf->familyname);
+ break;
+ case FK_weight:
+ lua_pushstring(L, sf->weight);
+ break;
+ case FK_copyright:
+ lua_pushstring(L, sf->copyright);
+ break;
+ case FK_filename:
+ lua_pushstring(L, sf->filename);
+ break;
+ case FK_version:
+ lua_pushstring(L, sf->version);
+ break;
+ case FK_italicangle:
+ lua_pushnumber(L, sf->italicangle);
+ break;
+ case FK_upos:
+ lua_pushnumber(L, sf->upos);
+ break;
+ case FK_uwidth:
+ lua_pushnumber(L, sf->uwidth);
+ break;
+ case FK_ascent:
+ lua_pushnumber(L, sf->ascent);
+ break;
+ case FK_descent:
+ lua_pushnumber(L, sf->descent);
+ break;
+ case FK_uniqueid:
+ lua_pushnumber(L, sf->uniqueid);
+ break;
+ case FK_glyphcnt:
+ if (sf->glyphcnt > 0) {
+ lua_pushnumber(L, sf->glyphmax - sf->glyphmin + 1);
+ } else {
+ lua_pushnumber(L, 0);
}
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_comments:
- lua_pushstring(L, sf->comments);
- break;
- case FK_fontlog:
- lua_pushstring(L, sf->fontlog);
- break;
- case FK_cvt_names:
- if (sf->cvt_names != NULL) {
- lua_newtable(L);
- for (k = 0; sf->cvt_names[k] != END_CVT_NAMES; ++k) {
- lua_pushstring(L, sf->cvt_names[k]);
- lua_rawseti(L, -2, (k + 1));
+ break;
+ case FK_glyphmax:
+ lua_pushnumber(L, sf->glyphmax - 1);
+ break;
+ case FK_glyphmin:
+ lua_pushnumber(L, sf->glyphmin);
+ break;
+ case FK_units_per_em:
+ lua_pushnumber(L, sf->units_per_em);
+ break;
+ case FK_lookups:
+ if (sf->possub != NULL) {
+ lua_newtable(L);
+ handle_generic_fpst(L, sf->possub);
+ } else {
+ lua_pushnil(L);
}
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_ttf_tables:
- if (sf->ttf_tables != NULL) {
- lua_newtable(L);
- handle_ttf_table(L, sf->ttf_tables);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_ttf_tab_saved:
- if (sf->ttf_tab_saved != NULL) {
- lua_newtable(L);
- handle_ttf_table(L, sf->ttf_tab_saved);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_texdata:
- if (sf->texdata.type != tex_unset) {
- lua_newtable(L);
- dump_enumfield(L, "type", sf->texdata.type, tex_type_enum);
- lua_newtable(L);
- for (k = 0; k < 22; k++) {
- lua_pushnumber(L, k);
- lua_pushnumber(L, sf->texdata.params[k]);
- lua_rawset(L, -3);
+ break;
+ case FK_glyphs:
+ lua_newtable(L); /* the virtual glyph table */
+ lua_pushstring(L, "__sf");
+ lua_pushvalue(L, 1); /* that is our font */
+ lua_rawset(L, -3);
+ luaL_getmetatable(L, FONT_GLYPHS_METATABLE);
+ lua_setmetatable(L, -2); /* assign the metatable */
+ break;
+ case FK_hasvmetrics:
+ lua_pushnumber(L, sf->hasvmetrics);
+ break;
+ case FK_onlybitmaps:
+ lua_pushnumber(L, sf->onlybitmaps);
+ break;
+ case FK_serifcheck:
+ lua_pushnumber(L, sf->serifcheck);
+ break;
+ case FK_isserif:
+ lua_pushnumber(L, sf->isserif);
+ break;
+ case FK_issans:
+ lua_pushnumber(L, sf->issans);
+ break;
+ case FK_encodingchanged:
+ lua_pushnumber(L, sf->encodingchanged);
+ break;
+ case FK_strokedfont:
+ lua_pushnumber(L, sf->strokedfont);
+ break;
+ case FK_use_typo_metrics:
+ lua_pushnumber(L, sf->use_typo_metrics);
+ break;
+ case FK_weight_width_slope_only:
+ lua_pushnumber(L, sf->weight_width_slope_only);
+ break;
+ case FK_head_optimized_for_cleartype:
+ lua_pushnumber(L, sf->head_optimized_for_cleartype);
+ break;
+ case FK_uni_interp:
+ lua_pushstring(L, uni_interp_enum[(sf->uni_interp + 1)]);
+ break;
+ case FK_map:
+ if (sf->map != NULL) {
+ lua_newtable(L);
+ handle_encmap(L, sf->map, 0); /* notdef_loc(sf)); */
+ } else {
+ lua_pushnil(L);
}
- lua_setfield(L, -2, "params");
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_anchor_classes:
- if (sf->anchor != NULL) {
- lua_newtable(L);
- handle_anchorclass(L, sf->anchor);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_kerns:
- if (sf->kerns != NULL) {
- lua_newtable(L);
- handle_kernclass(L, sf->kerns, NULL);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_vkerns:
- if (sf->vkerns != NULL) {
- lua_newtable(L);
- handle_kernclass(L, sf->vkerns, NULL);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_gsub:
- if (sf->gsub_lookups != NULL) {
- lua_newtable(L);
- handle_lookup(L, sf->gsub_lookups, sf);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_gpos:
- if (sf->gpos_lookups != NULL) {
- lua_newtable(L);
- handle_lookup(L, sf->gpos_lookups, sf);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_mm:
- if (sf->mm != NULL) {
- lua_newtable(L);
- handle_mmset(L, sf->mm);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_chosenname:
- lua_pushstring(L, sf->chosenname);
- break;
- case FK_macstyle:
- lua_pushnumber(L, sf->macstyle);
- break;
- case FK_fondname:
- lua_pushstring(L, sf->fondname);
- break;
- case FK_design_size:
- lua_pushnumber(L, sf->design_size);
- break;
- case FK_fontstyle_id:
- lua_pushnumber(L, sf->fontstyle_id);
- break;
- case FK_fontstyle_name:
- if (sf->fontstyle_name != NULL) {
- lua_newtable(L);
- handle_otfname(L, sf->fontstyle_name);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_design_range_bottom:
- lua_pushnumber(L, sf->design_range_bottom);
- break;
- case FK_design_range_top:
- lua_pushnumber(L, sf->design_range_top);
- break;
- case FK_strokewidth:
- lua_pushnumber(L, sf->strokewidth);
- break;
- case FK_mark_classes:
- if (sf->mark_class_cnt > 0) {
- lua_newtable(L);
- for (k = 0; k < sf->mark_class_cnt; k++) {
- if (sf->mark_class_names[k] != NULL) {
- lua_pushstring(L, sf->mark_class_names[k]);
- lua_pushstring(L, sf->mark_classes[k]);
+ break;
+ case FK_origname:
+ lua_pushstring(L, sf->origname);
+ break;
+ case FK_private:
+ if (sf->private != NULL) {
+ lua_newtable(L);
+ handle_psdict(L, sf->private);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_xuid:
+ lua_pushstring(L, sf->xuid);
+ break;
+ case FK_pfminfo:
+ lua_createtable(L, 0, 40);
+ handle_pfminfo(L, sf->pfminfo);
+ break;
+ case FK_names:
+ if (sf->names != NULL) {
+ lua_newtable(L);
+ handle_ttflangname(L, sf->names);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_cidinfo:
+ lua_createtable(L, 0, 4);
+ dump_stringfield(L, "registry", sf->cidregistry);
+ dump_stringfield(L, "ordering", sf->ordering);
+ dump_intfield(L, "version", sf->cidversion);
+ dump_intfield(L, "supplement", sf->supplement);
+ break;
+ case FK_subfonts:
+ if (sf->subfontcnt > 0) {
+ lua_createtable(L, sf->subfontcnt, 0);
+ for (k = 0; k < sf->subfontcnt; k++) {
+ lua_ff_pushsubfont(L, sf->subfonts[k]);
+ lua_rawseti(L, -2, (k + 1));
+ }
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_comments:
+ lua_pushstring(L, sf->comments);
+ break;
+ case FK_fontlog:
+ lua_pushstring(L, sf->fontlog);
+ break;
+ case FK_cvt_names:
+ if (sf->cvt_names != NULL) {
+ lua_newtable(L);
+ for (k = 0; sf->cvt_names[k] != END_CVT_NAMES; ++k) {
+ lua_pushstring(L, sf->cvt_names[k]);
+ lua_rawseti(L, -2, (k + 1));
+ }
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_ttf_tables:
+ if (sf->ttf_tables != NULL) {
+ lua_newtable(L);
+ handle_ttf_table(L, sf->ttf_tables);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_ttf_tab_saved:
+ if (sf->ttf_tab_saved != NULL) {
+ lua_newtable(L);
+ handle_ttf_table(L, sf->ttf_tab_saved);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_texdata:
+ if (sf->texdata.type != tex_unset) {
+ lua_newtable(L);
+ dump_enumfield(L, "type", sf->texdata.type, tex_type_enum);
+ lua_newtable(L);
+ for (k = 0; k < 22; k++) {
+ lua_pushnumber(L, k);
+ lua_pushnumber(L, sf->texdata.params[k]);
lua_rawset(L, -3);
}
+ lua_setfield(L, -2, "params");
+ } else {
+ lua_pushnil(L);
}
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_creationtime:
- lua_pushnumber(L, sf->creationtime);
- break;
- case FK_modificationtime:
- lua_pushnumber(L, sf->modificationtime);
- break;
- case FK_os2_version:
- lua_pushnumber(L, sf->os2_version);
- break;
- case FK_sfd_version:
- lua_pushnumber(L, sf->sfd_version);
- break;
- case FK_math:
- if (sf->MATH != NULL) {
- lua_newtable(L);
- handle_MATH(L, sf->MATH);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_validation_state:
- if (sf->loadvalidation_state != 0) {
- int val, st;
- lua_newtable(L);
- val = 1;
- st = sf->loadvalidation_state;
- if (st & lvs_bad_ps_fontname) {
- lua_pushliteral(L, "bad_ps_fontname");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_anchor_classes:
+ if (sf->anchor != NULL) {
+ lua_newtable(L);
+ handle_anchorclass(L, sf->anchor);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_glyph_table) {
- lua_pushliteral(L, "bad_glyph_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_kerns:
+ if (sf->kerns != NULL) {
+ lua_newtable(L);
+ handle_kernclass(L, sf->kerns, NULL);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_cff_table) {
- lua_pushliteral(L, "bad_cff_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_vkerns:
+ if (sf->vkerns != NULL) {
+ lua_newtable(L);
+ handle_kernclass(L, sf->vkerns, NULL);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_metrics_table) {
- lua_pushliteral(L, "bad_metrics_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_gsub:
+ if (sf->gsub_lookups != NULL) {
+ lua_newtable(L);
+ handle_lookup(L, sf->gsub_lookups, sf);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_cmap_table) {
- lua_pushliteral(L, "bad_cmap_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_gpos:
+ if (sf->gpos_lookups != NULL) {
+ lua_newtable(L);
+ handle_lookup(L, sf->gpos_lookups, sf);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_bitmaps_table) {
- lua_pushliteral(L, "bad_bitmaps_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_mm:
+ if (sf->mm != NULL) {
+ lua_newtable(L);
+ handle_mmset(L, sf->mm);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_gx_table) {
- lua_pushliteral(L, "bad_gx_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_chosenname:
+ lua_pushstring(L, sf->chosenname);
+ break;
+ case FK_macstyle:
+ lua_pushnumber(L, sf->macstyle);
+ break;
+ case FK_fondname:
+ lua_pushstring(L, sf->fondname);
+ break;
+ case FK_design_size:
+ lua_pushnumber(L, sf->design_size);
+ break;
+ case FK_fontstyle_id:
+ lua_pushnumber(L, sf->fontstyle_id);
+ break;
+ case FK_fontstyle_name:
+ if (sf->fontstyle_name != NULL) {
+ lua_newtable(L);
+ handle_otfname(L, sf->fontstyle_name);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_ot_table) {
- lua_pushliteral(L, "bad_ot_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_design_range_bottom:
+ lua_pushnumber(L, sf->design_range_bottom);
+ break;
+ case FK_design_range_top:
+ lua_pushnumber(L, sf->design_range_top);
+ break;
+ case FK_strokewidth:
+ lua_pushnumber(L, sf->strokewidth);
+ break;
+ case FK_mark_classes:
+ if (sf->mark_class_cnt > 0) {
+ lua_newtable(L);
+ for (k = 0; k < sf->mark_class_cnt; k++) {
+ if (sf->mark_class_names[k] != NULL) {
+ lua_pushstring(L, sf->mark_class_names[k]);
+ lua_pushstring(L, sf->mark_classes[k]);
+ lua_rawset(L, -3);
+ }
+ }
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_os2_version) {
- lua_pushliteral(L, "bad_os2_version");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_creationtime:
+ lua_pushnumber(L, sf->creationtime);
+ break;
+ case FK_modificationtime:
+ lua_pushnumber(L, sf->modificationtime);
+ break;
+ case FK_os2_version:
+ lua_pushnumber(L, sf->os2_version);
+ break;
+ case FK_sfd_version:
+ lua_pushnumber(L, sf->sfd_version);
+ break;
+ case FK_math:
+ if (sf->MATH != NULL) {
+ lua_newtable(L);
+ handle_MATH(L, sf->MATH);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_sfnt_header) {
- lua_pushliteral(L, "bad_sfnt_header");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_validation_state:
+ if (sf->loadvalidation_state != 0) {
+ int val, st;
+ lua_newtable(L);
+ val = 1;
+ st = sf->loadvalidation_state;
+ if (st & lvs_bad_ps_fontname) {
+ lua_pushliteral(L, "bad_ps_fontname");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_glyph_table) {
+ lua_pushliteral(L, "bad_glyph_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_cff_table) {
+ lua_pushliteral(L, "bad_cff_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_metrics_table) {
+ lua_pushliteral(L, "bad_metrics_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_cmap_table) {
+ lua_pushliteral(L, "bad_cmap_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_bitmaps_table) {
+ lua_pushliteral(L, "bad_bitmaps_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_gx_table) {
+ lua_pushliteral(L, "bad_gx_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_ot_table) {
+ lua_pushliteral(L, "bad_ot_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_os2_version) {
+ lua_pushliteral(L, "bad_os2_version");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_sfnt_header) {
+ lua_pushliteral(L, "bad_sfnt_header");
+ lua_rawseti(L, -2, val++);
+ }
+ } else {
+ lua_pushnil(L);
}
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_horiz_base:
- if (sf->horiz_base != NULL) {
- lua_newtable(L);
- handle_base(L, sf->horiz_base);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_vert_base:
- if (sf->vert_base != NULL) {
- lua_newtable(L);
- handle_base(L, sf->vert_base);
- } else {
+ break;
+ case FK_horiz_base:
+ if (sf->horiz_base != NULL) {
+ lua_newtable(L);
+ handle_base(L, sf->horiz_base);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_vert_base:
+ if (sf->vert_base != NULL) {
+ lua_newtable(L);
+ handle_base(L, sf->vert_base);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_extrema_bound:
+ lua_pushnumber(L, sf->extrema_bound);
+ break;
+ case FK_notdef_loc:
+ lua_pushinteger(L, notdef_loc(sf));
+ break;
+ default:
+ /* can't actually happen, |luaL_checkoption| raises an error instead */
lua_pushnil(L);
- }
- break;
- case FK_extrema_bound:
- lua_pushnumber(L, sf->extrema_bound);
- break;
- default:
- /* can't actually happen, |luaL_checkoption| raises an error instead */
- lua_pushnil(L);
- break;
+ break;
}
return 1;
}
@@ -3232,10 +3237,7 @@ static void ff_do_cff(SplineFont * sf, char *filename, unsigned char **buf,
fclose(f);
return;
}
- /* snprintf(errmsg, 255, "%s => CFF, failed", sf->filename); */
- /* normal_error("fontloader",errmsg); */ /* TODO */
- fprintf(stdout,"%s => CFF, failed", sf->filename);
- exit(EXIT_FAILURE);
+ formatted_error("fontloader","%s to CFF conversion failed", sf->filename);
}
/* exported for writecff.c */
@@ -3273,9 +3275,7 @@ int ff_get_ttc_index(char *ffname, char *psname)
sf = ReadSplineFontInfo((char *) ffname, openflags);
if (sf == NULL) {
- /* normal_error("fontloader","font loading failed unexpectedly"); */ /* TODO */
- fprintf(stdout,"font loading failed unexpectedly\n");
- exit(EXIT_FAILURE);
+ normal_error("fontloader","font loading failed unexpectedly");
}
while (sf != NULL) {
if (strcmp(sf->fontname, psname) == 0) {
@@ -3285,7 +3285,7 @@ int ff_get_ttc_index(char *ffname, char *psname)
sf = sf->next;
}
if (index>=0)
- return (i-index-1);
+ return (i-index-1);
return -1;
}
diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c
index c00fe177928..68f7db16da9 100644
--- a/Build/source/texk/web2c/luatexdir/luatex.c
+++ b/Build/source/texk/web2c/luatexdir/luatex.c
@@ -29,9 +29,9 @@
#define TeX
int luatex_version = 89; /* \.{\\luatexversion} */
-int luatex_revision = '2'; /* \.{\\luatexrevision} */
-int luatex_date_info = 2016022700; /* the compile date is now hardwired */
-const char *luatex_version_string = "beta-0.89.2";
+int luatex_revision = '3'; /* \.{\\luatexrevision} */
+int luatex_date_info = 2016022900; /* the compile date is now hardwired */
+const char *luatex_version_string = "beta-0.89.3";
const char *engine_name = my_name; /* the name of this engine */
#include <kpathsea/c-ctype.h>
diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.h b/Build/source/texk/web2c/luatexdir/tex/equivalents.h
index 09a63150cca..fe3907c0241 100644
--- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h
+++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h
@@ -279,23 +279,21 @@ the |number_regs| \.{\\dimen} registers.
# define math_display_skip_mode_code 88
# define math_scripts_mode_code 89
# define synctex_code 90 /* is synctex file generation enabled ? */
+# define first_valid_language_code 91
-# define math_no_italic_compensation_code 92 /* just for tracing, can change */
-# define math_no_char_italic_code 93 /* just for tracing, can change */
-# define math_use_old_fraction_scaling_code 94 /* just for tracing, can change */
-# define math_old_code 95 /* this one is stable */
-# define math_option_code 96
+# define math_option_code 92
-# define first_valid_language_code 97
+# define mathoption_int_base (int_base+93)
+# define mathoption_int_last (int_base+99)
-# define backend_int_base (int_base+98)
-# define backend_int_last (int_base+117)
+# define backend_int_base (int_base+100)
+# define backend_int_last (int_base+119)
-# define tex_int_pars (118) /* total number of integer parameters */
+# define tex_int_pars (120) /* total number of integer parameters */
# define page_direction_code (tex_int_pars)
# define body_direction_code (tex_int_pars+1)
-# define par_direction_code (tex_int_pars+2)
+# define par_direction_code (tex_int_pars+2)
# define text_direction_code (tex_int_pars+3)
# define math_direction_code (tex_int_pars+4)
@@ -425,6 +423,16 @@ extern void print_save_stack(void);
# define loc_par(A) equiv(local_base+(A))
# define glue_par(A) equiv(glue_base+(A))
+typedef enum {
+ c_mathoption_old_code = 0, /* this one is stable */
+ c_mathoption_no_italic_compensation_code, /* just for tracing, can change */
+ c_mathoption_no_char_italic_code, /* just for tracing, can change */
+ c_mathoption_use_old_fraction_scaling_code, /* just for tracing, can change */
+ c_mathoption_umathcode_meaning_code, /* this one is stable */
+} math_option_codes ;
+
+# define mathoption_int_par(A) eqtb[mathoption_int_base+(A)].cint
+
/* if nonzero, this magnification should be used henceforth */
extern int mag_set;
diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
index ff7e7279a07..f36283b58bb 100644
--- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
+++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
@@ -697,29 +697,28 @@ static void run_normal (void) {
/*
this is experimental and not used for production, only for testing and writing
- macros
+ macros (some options stay)
*/
+#define mathoption_set_int(A) \
+ scan_int(); \
+ word_define(mathoption_int_base+A, cur_val);
+
static void run_option(void) {
int a = 0 ;
switch (cur_chr) {
case math_option_code:
if (scan_keyword("old")) {
- scan_int();
- word_define(int_base+math_old_code, cur_val);
- /* math_no_char_italic = cur_val; */
+ mathoption_set_int(c_mathoption_old_code);
} else if (scan_keyword("noitaliccompensation")) {
- scan_int();
- word_define(int_base+math_no_italic_compensation_code, cur_val);
- /* math_no_italic_compensation = cur_val; */
+ mathoption_set_int(c_mathoption_no_italic_compensation_code);
} else if (scan_keyword("nocharitalic")) {
- scan_int();
- word_define(int_base+math_no_char_italic_code, cur_val);
- /* math_no_char_italic = cur_val; */
+ mathoption_set_int(c_mathoption_no_char_italic_code);
} else if (scan_keyword("useoldfractionscaling")) {
- scan_int();
- word_define(int_base+math_use_old_fraction_scaling_code, cur_val);
+ mathoption_set_int(c_mathoption_use_old_fraction_scaling_code);
+ } else if (scan_keyword("umathcodemeaning")) {
+ mathoption_set_int(c_mathoption_umathcode_meaning_code);
} else {
normal_warning("mathoption","unknown key");
}
@@ -973,8 +972,8 @@ void main_control(void)
begin_token_list(equiv(every_job_loc), every_job_text);
while (1) {
- if (main_control_state == goto_skip_token)
- main_control_state = goto_next; /* reset */
+ if (main_control_state == goto_skip_token)
+ main_control_state = goto_next; /* reset */
else
get_x_token();
@@ -992,7 +991,7 @@ void main_control(void)
(jump_table[(abs(mode) + cur_cmd)])(); /* run the command */
if (main_control_state == goto_return) {
- return;
+ return;
}
}
return; /* not reached */
@@ -2345,23 +2344,22 @@ void prefixed_command(void)
break;
case math_char_def_code:
mval = scan_mathchar(tex_mathcode);
- cur_val =
- (mval.class_value * 16 + mval.family_value) * 256 +
- mval.character_value;
- define(p, math_given_cmd, cur_val);
+ if (mathoption_int_par(c_mathoption_umathcode_meaning_code) == 1) {
+ cur_val = (mval.class_value + (8 * mval.family_value)) * (65536 * 32) + mval.character_value;
+ define(p, xmath_given_cmd, cur_val);
+ } else {
+ cur_val = (mval.class_value * 16 + mval.family_value) * 256 + mval.character_value;
+ define(p, math_given_cmd, cur_val);
+ }
break;
case xmath_char_def_code:
mval = scan_mathchar(umath_mathcode);
- cur_val =
- (mval.class_value + (8 * mval.family_value)) * (65536 * 32) +
- mval.character_value;
+ cur_val = (mval.class_value + (8 * mval.family_value)) * (65536 * 32) + mval.character_value;
define(p, xmath_given_cmd, cur_val);
break;
case umath_char_def_code:
mval = scan_mathchar(umathnum_mathcode);
- cur_val =
- (mval.class_value + (8 * mval.family_value)) * (65536 * 32) +
- mval.character_value;
+ cur_val = (mval.class_value + (8 * mval.family_value)) * (65536 * 32) + mval.character_value;
define(p, xmath_given_cmd, cur_val);
break;
default:
diff --git a/Build/source/texk/web2c/luatexdir/tex/mathcodes.h b/Build/source/texk/web2c/luatexdir/tex/mathcodes.h
index 1742e43cfd5..fe731ff2be5 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mathcodes.h
+++ b/Build/source/texk/web2c/luatexdir/tex/mathcodes.h
@@ -45,6 +45,7 @@ mathcodeval scan_delimiter_as_mathchar(int extcode);
mathcodeval mathchar_from_integer(int value, int extcode);
void show_mathcode_value(mathcodeval d);
+void show_mathcode_value_old(int value);
typedef struct delcodeval {
int class_value;
diff --git a/Build/source/texk/web2c/luatexdir/tex/mathcodes.w b/Build/source/texk/web2c/luatexdir/tex/mathcodes.w
index e161af0fe54..64efce9d898 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mathcodes.w
+++ b/Build/source/texk/web2c/luatexdir/tex/mathcodes.w
@@ -63,15 +63,23 @@ static sa_tree delcode_head = NULL;
two_hex((A)%256); \
} while (0)
+/*
+ At some point we will drop the mathchardef 8 bit storage (c_mathoption_umathcode_meaning_code => 1)
+ and then some of the conversion can go away. Like mathchar_from_integer: only wide characters are
+ possible then.
+*/
+
+
@ @c
mathcodeval mathchar_from_integer(int value, int extcode)
{
mathcodeval mval;
if (extcode == tex_mathcode) {
+ /* printf("can't happen: tex_mathcode\n"); */
mval.class_value = (value / 0x1000);
mval.family_value = ((value % 0x1000) / 0x100);
mval.character_value = (value % 0x100);
- } else { /* some xetexended xetex thing */
+ } else {
int mfam = (value / 0x200000) & 0x7FF;
mval.class_value = mfam % 0x08;
mval.family_value = mfam / 0x08;
@@ -81,6 +89,11 @@ mathcodeval mathchar_from_integer(int value, int extcode)
}
@ @c
+void show_mathcode_value_old(int value)
+{
+ print_char('"');
+ four_hex(value);
+}
void show_mathcode_value(mathcodeval c)
{
print_char('"');
diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.h b/Build/source/texk/web2c/luatexdir/tex/mlist.h
index b2600bcff1b..30bfa19fb8f 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mlist.h
+++ b/Build/source/texk/web2c/luatexdir/tex/mlist.h
@@ -24,9 +24,6 @@
extern int cur_size;
-/* extern int math_no_italic_compensation ; */ /* $$\int\limits_{|}^{|}$$ */
-/* extern int math_no_char_italic ; */ /* catcode"1D443=12 $$P( PP$$ \catcode"1D443=11 $$P( PP$$ */
-
extern void run_mlist_to_hlist(halfword, boolean, int);
extern void mlist_to_hlist(halfword, boolean, int);
extern void fixup_math_parameters(int fam_id, int size_id, int f, int lvl);
diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.w b/Build/source/texk/web2c/luatexdir/tex/mlist.w
index fbded284414..1a8e332136d 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mlist.w
+++ b/Build/source/texk/web2c/luatexdir/tex/mlist.w
@@ -51,10 +51,10 @@ to italics. Axis are another area of concern, as it looks like opentype math fon
already apply that shift.
@ @c
-#define math_old int_par(math_old_code)
-#define math_no_italic_compensation int_par(math_no_italic_compensation_code)
-#define math_no_char_italic int_par(math_no_char_italic_code)
-#define math_use_old_fraction_scaling int_par(math_use_old_fraction_scaling_code)
+#define math_old mathoption_int_par(c_mathoption_old_code)
+#define math_no_italic_compensation mathoption_int_par(c_mathoption_no_italic_compensation_code)
+#define math_no_char_italic mathoption_int_par(c_mathoption_no_char_italic_code)
+#define math_use_old_fraction_scaling mathoption_int_par(c_mathoption_use_old_fraction_scaling_code)
#define is_new_mathfont(A) ((font_math_params(A) >0) && (math_old == 0))
#define is_old_mathfont(A,B) ((font_math_params(A)==0) && (font_params(A)>=(B)))
diff --git a/Build/source/texk/web2c/luatexdir/tex/primitive.w b/Build/source/texk/web2c/luatexdir/tex/primitive.w
index 05f3cc1126c..a173e133d44 100644
--- a/Build/source/texk/web2c/luatexdir/tex/primitive.w
+++ b/Build/source/texk/web2c/luatexdir/tex/primitive.w
@@ -555,8 +555,14 @@ void print_cmd_chr(quarterword cmd, halfword chr_code)
print_hex(chr_code);
break;
case math_given_cmd:
- tprint_esc("mathchar");
- show_mathcode_value(mathchar_from_integer(chr_code, tex_mathcode));
+ if (mathoption_int_par(c_mathoption_umathcode_meaning_code) == 1) {
+ tprint_esc("Umathchar");
+ show_mathcode_value(mathchar_from_integer(chr_code, tex_mathcode));
+ } else {
+ /* better for old macro packages that mess with meaning */
+ tprint_esc("mathchar");
+ show_mathcode_value_old(chr_code);
+ }
break;
case xmath_given_cmd:
tprint_esc("Umathchar");
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
index d5198b92f03..aad7bfa026d 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h
+++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
@@ -66,7 +66,7 @@ extern void undump_node_mem(void);
# define node_size(a) varmem[(a)].hh.v.LH
# define rlink(a) vlink((a)+1) /* aka alink() */
-# define llink(a) vinfo((a)+1) /* overlaps with node_attr() */
+# define tlink(a) vinfo((a)+1) /* overlaps with node_attr() */
# define add_glue_ref(a) glue_ref_count(a)++ /* new reference to a glue spec */
@@ -167,7 +167,6 @@ typedef enum {
# define pre_break(a) vinfo((a)+3)
# define post_break(a) vlink((a)+3)
# define no_break(a) vlink((a)+4)
-# define tlink llink
# define vlink_pre_break(a) vlink(pre_break_head(a))
# define vlink_post_break(a) vlink(post_break_head(a))
diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.h b/Build/source/texk/web2c/luatexdir/tex/textoken.h
index 71c5777e1dc..d2174beb370 100644
--- a/Build/source/texk/web2c/luatexdir/tex/textoken.h
+++ b/Build/source/texk/web2c/luatexdir/tex/textoken.h
@@ -159,6 +159,7 @@ extern void conv_toks(void);
extern str_number the_convert_string(halfword c, int i);
extern void do_variable(void);
extern void do_feedback(void);
+extern void do_mathoption(void);
extern halfword lua_str_toks(lstring b);
extern boolean in_lua_escape;
diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w
index f8fb8b467a0..53220836f9b 100644
--- a/Build/source/texk/web2c/luatexdir/tex/textoken.w
+++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w
@@ -35,11 +35,24 @@
#define detokenized_line() (line_catcode_table==NO_CAT_TABLE)
-#define do_get_cat_code(a,b) do { \
- if (line_catcode_table!=DEFAULT_CAT_TABLE) \
- a=get_cat_code(line_catcode_table,b); \
- else \
- a=get_cat_code(cat_code_table,b); \
+/*
+#define do_get_cat_code(a,b) do { \
+ if (line_catcode_table<=-0xFF) \
+ a= - line_catcode_table - 0xFF ; \
+ else if (line_catcode_table!=DEFAULT_CAT_TABLE) \
+ a=get_cat_code(line_catcode_table,b); \
+ else \
+ a=get_cat_code(cat_code_table,b); \
+ } while (0)
+*/
+
+#define do_get_cat_code(a,b) do { \
+ if (line_catcode_table==DEFAULT_CAT_TABLE) \
+ a=get_cat_code(cat_code_table,b); \
+ else if (line_catcode_table>-0xFF) \
+ a=get_cat_code(line_catcode_table,b); \
+ else \
+ a= - line_catcode_table - 0xFF ; \
} while (0)
@@ -239,13 +252,11 @@ including the expansion of a macro or mark.
void print_meaning(void)
{
/* remap \mathchar onto \Umathchar */
+/*
if (cur_cmd == math_given_cmd) {
cur_cmd = xmath_given_cmd ;
- } /* else if (cur_cmd == math_char_num_cmd) {
- if (cur_chr == 0) {
- cur_chr = 1 ;
- }
- } */
+ }
+*/
print_cmd_chr((quarterword) cur_cmd, cur_chr);
if (cur_cmd >= call_cmd) {
print_char(':');
@@ -2869,6 +2880,31 @@ void do_variable(void)
}
}
+/*
+ The following code is not used as we can only set math options and not query them. If
+ an option is really important we will provide a proper variable. Most options are not
+ meant for users anyway but for development.
+*/
+
+/*
+
+#define do_mathoption_int(i) \
+ cur_cmd = assign_int_cmd; \
+ cur_val = mathoption_int_base + i; \
+ cur_tok = token_val(cur_cmd, cur_val); \
+ back_input();
+
+void do_mathoption(void)
+{
+ if (scan_keyword("old")) { do_mathoption_int(c_mathoption_no_italic_compensation_code); }
+ if (scan_keyword("noitaliccompensation")) { do_mathoption_int(c_mathoption_no_char_italic_code); }
+ else if (scan_keyword("nocharitalic")) { do_mathoption_int(c_mathoption_use_old_fraction_scaling_code); }
+ else if (scan_keyword("useoldfractionscaling")) { do_mathoption_int(c_mathoption_old_code); }
+ else if (scan_keyword("umathcodemeaning")) { do_mathoption_int(c_mathoption_umathcode_meaning_code); }
+}
+
+*/
+
@ This boolean is keeping track of the lua string escape state
@c
boolean in_lua_escape;