summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/luametatex/source/libraries/mimalloc/cmake/mimalloc-config-version.cmake2
-rw-r--r--source/luametatex/source/libraries/mimalloc/include/mimalloc.h2
-rw-r--r--source/luametatex/source/libraries/mimalloc/include/mimalloc/prim.h8
-rw-r--r--source/luametatex/source/libraries/mimalloc/readme.md6
-rw-r--r--source/luametatex/source/libraries/mimalloc/src/alloc.c10
-rw-r--r--source/luametatex/source/libraries/mimalloc/src/arena.c3
-rw-r--r--source/luametatex/source/libraries/mimalloc/src/bitmap.c2
-rw-r--r--source/luametatex/source/libraries/mimalloc/src/options.c2
-rw-r--r--source/luametatex/source/libraries/mimalloc/src/os.c6
-rw-r--r--source/luametatex/source/libraries/mimalloc/src/page.c2
-rw-r--r--source/luametatex/source/libraries/mimalloc/src/prim/unix/prim.c8
-rw-r--r--source/luametatex/source/lua/lmtnodelib.c57
-rw-r--r--source/luametatex/source/lua/lmttexiolib.c39
-rw-r--r--source/luametatex/source/lua/lmttexlib.c53
-rw-r--r--source/luametatex/source/luacore/lua54/src/Makefile3
-rw-r--r--source/luametatex/source/luacore/lua54/src/lua.h4
-rw-r--r--source/luametatex/source/luametatex.h2
-rw-r--r--source/luametatex/source/tex/texmaincontrol.c10
-rw-r--r--source/luametatex/source/tex/texmath.c16
-rw-r--r--source/luametatex/source/tex/texmlist.c125
-rw-r--r--source/luametatex/source/tex/texnodes.h5
-rw-r--r--source/luametatex/source/tex/textypes.h6
22 files changed, 246 insertions, 125 deletions
diff --git a/source/luametatex/source/libraries/mimalloc/cmake/mimalloc-config-version.cmake b/source/luametatex/source/libraries/mimalloc/cmake/mimalloc-config-version.cmake
index 842c733ee..855c44d22 100644
--- a/source/luametatex/source/libraries/mimalloc/cmake/mimalloc-config-version.cmake
+++ b/source/luametatex/source/libraries/mimalloc/cmake/mimalloc-config-version.cmake
@@ -1,6 +1,6 @@
set(mi_version_major 2)
set(mi_version_minor 1)
-set(mi_version_patch 0)
+set(mi_version_patch 1)
set(mi_version ${mi_version_major}.${mi_version_minor})
set(PACKAGE_VERSION ${mi_version})
diff --git a/source/luametatex/source/libraries/mimalloc/include/mimalloc.h b/source/luametatex/source/libraries/mimalloc/include/mimalloc.h
index 1372cb3f2..800cfd7e4 100644
--- a/source/luametatex/source/libraries/mimalloc/include/mimalloc.h
+++ b/source/luametatex/source/libraries/mimalloc/include/mimalloc.h
@@ -8,7 +8,7 @@ terms of the MIT license. A copy of the license can be found in the file
#ifndef MIMALLOC_H
#define MIMALLOC_H
-#define MI_MALLOC_VERSION 210 // major + 2 digits minor
+#define MI_MALLOC_VERSION 211 // major + 2 digits minor
// ------------------------------------------------------
// Compiler specific attributes
diff --git a/source/luametatex/source/libraries/mimalloc/include/mimalloc/prim.h b/source/luametatex/source/libraries/mimalloc/include/mimalloc/prim.h
index 68f0871e8..10378c922 100644
--- a/source/luametatex/source/libraries/mimalloc/include/mimalloc/prim.h
+++ b/source/luametatex/source/libraries/mimalloc/include/mimalloc/prim.h
@@ -113,6 +113,10 @@ void _mi_prim_thread_associate_default_heap(mi_heap_t* heap);
// for each thread (unequal to zero).
//-------------------------------------------------------------------
+// defined in `init.c`; do not use these directly
+extern mi_decl_thread mi_heap_t* _mi_heap_default; // default heap to allocate from
+extern bool _mi_process_is_initialized; // has mi_process_init been called?
+
static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept;
#if defined(_WIN32)
@@ -230,10 +234,6 @@ We try to circumvent this in an efficient way:
- DragonFly: defaults are working but seem slow compared to freeBSD (see PR #323)
------------------------------------------------------------------------------------------- */
-// defined in `init.c`; do not use these directly
-extern mi_decl_thread mi_heap_t* _mi_heap_default; // default heap to allocate from
-extern bool _mi_process_is_initialized; // has mi_process_init been called?
-
static inline mi_heap_t* mi_prim_get_default_heap(void);
#if defined(MI_MALLOC_OVERRIDE)
diff --git a/source/luametatex/source/libraries/mimalloc/readme.md b/source/luametatex/source/libraries/mimalloc/readme.md
index 98b9af675..408f3cb1f 100644
--- a/source/luametatex/source/libraries/mimalloc/readme.md
+++ b/source/luametatex/source/libraries/mimalloc/readme.md
@@ -12,8 +12,8 @@ is a general purpose allocator with excellent [performance](#performance) charac
Initially developed by Daan Leijen for the runtime systems of the
[Koka](https://koka-lang.github.io) and [Lean](https://github.com/leanprover/lean) languages.
-Latest release tag: `v2.1.0` (2023-03-29).
-Latest stable tag: `v1.8.0` (2023-03-29).
+Latest release tag: `v2.1.1` (2023-04-03).
+Latest stable tag: `v1.8.1` (2023-04-03).
mimalloc is a drop-in replacement for `malloc` and can be used in other programs
without code changes, for example, on dynamically linked ELF-based systems (Linux, BSD, etc.) you can use it as:
@@ -78,6 +78,8 @@ Note: the `v2.x` version has a new algorithm for managing internal mimalloc page
and fragmentation compared to mimalloc `v1.x` (especially for large workloads). Should otherwise have similar performance
(see [below](#performance)); please report if you observe any significant performance regression.
+* 2023-04-03, `v1.8.1`, `v2.1.1`: Fixes build issues on some platforms.
+
* 2023-03-29, `v1.8.0`, `v2.1.0`: Improved support dynamic overriding on Windows 11. Improved tracing precision
with [asan](#asan) and [Valgrind](#valgrind), and added Windows event tracing [ETW](#ETW) (contributed by Xinglong He). Created an OS
abstraction layer to make it easier to port and separate platform dependent code (in `src/prim`). Fixed C++ STL compilation on older Microsoft C++ compilers, and various small bug fixes.
diff --git a/source/luametatex/source/libraries/mimalloc/src/alloc.c b/source/luametatex/source/libraries/mimalloc/src/alloc.c
index 24045162d..147e11094 100644
--- a/source/luametatex/source/libraries/mimalloc/src/alloc.c
+++ b/source/luametatex/source/libraries/mimalloc/src/alloc.c
@@ -75,8 +75,8 @@ extern inline void* _mi_page_malloc(mi_heap_t* heap, mi_page_t* page, size_t siz
ptrdiff_t delta = ((uint8_t*)padding - (uint8_t*)block - (size - MI_PADDING_SIZE));
#if (MI_DEBUG>=2)
mi_assert_internal(delta >= 0 && mi_page_usable_block_size(page) >= (size - MI_PADDING_SIZE + delta));
- mi_track_mem_defined(padding,sizeof(mi_padding_t)); // note: re-enable since mi_page_usable_block_size may set noaccess
#endif
+ mi_track_mem_defined(padding,sizeof(mi_padding_t)); // note: re-enable since mi_page_usable_block_size may set noaccess
padding->canary = (uint32_t)(mi_ptr_encode(page,block,page->keys));
padding->delta = (uint32_t)(delta);
#if MI_PADDING_CHECK
@@ -401,8 +401,8 @@ static mi_decl_noinline void _mi_free_block_mt(mi_page_t* page, mi_block_t* bloc
#endif
}
- #if (MI_DEBUG!=0) && !MI_TRACK_ENABLED && !MI_TSAN // note: when tracking, cannot use mi_usable_size with multi-threading
- if (segment->kind != MI_SEGMENT_HUGE) { // not for huge segments as we just reset the content
+ #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN // note: when tracking, cannot use mi_usable_size with multi-threading
+ if (segment->kind != MI_SEGMENT_HUGE) { // not for huge segments as we just reset the content
memset(block, MI_DEBUG_FREED, mi_usable_size(block));
}
#endif
@@ -455,7 +455,7 @@ static inline void _mi_free_block(mi_page_t* page, bool local, mi_block_t* block
// owning thread can free a block directly
if mi_unlikely(mi_check_is_double_free(page, block)) return;
mi_check_padding(page, block);
- #if (MI_DEBUG!=0) && !MI_TRACK_ENABLED && !MI_TSAN
+ #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN
if (!mi_page_is_huge(page)) { // huge page content may be already decommitted
memset(block, MI_DEBUG_FREED, mi_page_block_size(page));
}
@@ -551,7 +551,7 @@ void mi_free(void* p) mi_attr_noexcept
if mi_unlikely(mi_check_is_double_free(page, block)) return;
mi_check_padding(page, block);
mi_stat_free(page, block);
- #if (MI_DEBUG!=0) && !MI_TRACK_ENABLED && !MI_TSAN
+ #if (MI_DEBUG>0) && !MI_TRACK_ENABLED && !MI_TSAN
memset(block, MI_DEBUG_FREED, mi_page_block_size(page));
#endif
mi_track_free_size(p, mi_page_usable_size_of(page,block)); // faster then mi_usable_size as we already know the page and that p is unaligned
diff --git a/source/luametatex/source/libraries/mimalloc/src/arena.c b/source/luametatex/source/libraries/mimalloc/src/arena.c
index 43defe009..35cbcde6a 100644
--- a/source/luametatex/source/libraries/mimalloc/src/arena.c
+++ b/source/luametatex/source/libraries/mimalloc/src/arena.c
@@ -27,7 +27,6 @@ The arena allocation needs to be thread safe and we use an atomic bitmap to allo
#include "bitmap.h" // atomic bitmap
-
/* -----------------------------------------------------------
Arena allocation
----------------------------------------------------------- */
@@ -186,7 +185,7 @@ static mi_decl_noinline void* mi_arena_allocate(int numa_node, size_t size, size
bool* is_pinned, bool* is_zero,
mi_arena_id_t req_arena_id, size_t* memid, mi_os_tld_t* tld )
{
- MI_UNUSED_RELEASE(alignment);
+ MI_UNUSED(alignment);
mi_assert_internal(alignment <= MI_SEGMENT_ALIGN);
const size_t max_arena = mi_atomic_load_relaxed(&mi_arena_count);
const size_t bcount = mi_block_count_of_size(size);
diff --git a/source/luametatex/source/libraries/mimalloc/src/bitmap.c b/source/luametatex/source/libraries/mimalloc/src/bitmap.c
index 6fe745ac1..ee94edb98 100644
--- a/source/luametatex/source/libraries/mimalloc/src/bitmap.c
+++ b/source/luametatex/source/libraries/mimalloc/src/bitmap.c
@@ -300,7 +300,7 @@ bool _mi_bitmap_try_find_from_claim_across(mi_bitmap_t bitmap, const size_t bitm
// Helper for masks across fields; returns the mid count, post_mask may be 0
static size_t mi_bitmap_mask_across(mi_bitmap_index_t bitmap_idx, size_t bitmap_fields, size_t count, size_t* pre_mask, size_t* mid_mask, size_t* post_mask) {
- MI_UNUSED_RELEASE(bitmap_fields);
+ MI_UNUSED(bitmap_fields);
const size_t bitidx = mi_bitmap_index_bit_in_field(bitmap_idx);
if mi_likely(bitidx + count <= MI_BITMAP_FIELD_BITS) {
*pre_mask = mi_bitmap_mask_(count, bitidx);
diff --git a/source/luametatex/source/libraries/mimalloc/src/options.c b/source/luametatex/source/libraries/mimalloc/src/options.c
index c39e20526..450bc2f3f 100644
--- a/source/luametatex/source/libraries/mimalloc/src/options.c
+++ b/source/luametatex/source/libraries/mimalloc/src/options.c
@@ -289,7 +289,7 @@ static void mi_recurse_exit(void) {
}
void _mi_fputs(mi_output_fun* out, void* arg, const char* prefix, const char* message) {
- if (out==NULL || (FILE*)out==stdout || (FILE*)out==stderr) { // TODO: use mi_out_stderr for stderr?
+ if (out==NULL || (void*)out==(void*)stdout || (void*)out==(void*)stderr) { // TODO: use mi_out_stderr for stderr?
if (!mi_recurse_enter()) return;
out = mi_out_get_default(&arg);
if (prefix != NULL) out(prefix, arg);
diff --git a/source/luametatex/source/libraries/mimalloc/src/os.c b/source/luametatex/source/libraries/mimalloc/src/os.c
index 75895c1b1..6145ccb36 100644
--- a/source/luametatex/source/libraries/mimalloc/src/os.c
+++ b/source/luametatex/source/libraries/mimalloc/src/os.c
@@ -403,10 +403,8 @@ static bool mi_os_resetx(void* addr, size_t size, bool reset, mi_stats_t* stats)
else _mi_stat_decrease(&stats->reset, csize);
if (!reset) return true; // nothing to do on unreset!
- #if (MI_DEBUG>1) && !MI_TRACK_ENABLED // && !MI_TSAN
- if (MI_SECURE==0) {
- memset(start, 0, csize); // pretend it is eagerly reset
- }
+ #if (MI_DEBUG>1) && !MI_SECURE && !MI_TRACK_ENABLED // && !MI_TSAN
+ memset(start, 0, csize); // pretend it is eagerly reset
#endif
int err = _mi_prim_reset(start, csize);
diff --git a/source/luametatex/source/libraries/mimalloc/src/page.c b/source/luametatex/source/libraries/mimalloc/src/page.c
index d0da87a1f..cae6b5813 100644
--- a/source/luametatex/source/libraries/mimalloc/src/page.c
+++ b/source/luametatex/source/libraries/mimalloc/src/page.c
@@ -383,7 +383,7 @@ void _mi_page_abandon(mi_page_t* page, mi_page_queue_t* pq) {
mi_assert_internal(mi_page_thread_free_flag(page)==MI_NEVER_DELAYED_FREE);
mi_page_set_heap(page, NULL);
-#if MI_DEBUG>1
+#if (MI_DEBUG>1) && !MI_TRACK_ENABLED
// check there are no references left..
for (mi_block_t* block = (mi_block_t*)pheap->thread_delayed_free; block != NULL; block = mi_block_nextx(pheap, block, pheap->keys)) {
mi_assert_internal(_mi_ptr_page(block) != page);
diff --git a/source/luametatex/source/libraries/mimalloc/src/prim/unix/prim.c b/source/luametatex/source/libraries/mimalloc/src/prim/unix/prim.c
index 8d9c7a723..0c1fbb3e2 100644
--- a/source/luametatex/source/libraries/mimalloc/src/prim/unix/prim.c
+++ b/source/luametatex/source/libraries/mimalloc/src/prim/unix/prim.c
@@ -79,9 +79,9 @@ static int mi_prim_access(const char *fpath, int mode) {
#elif !defined(__APPLE__) // avoid unused warnings
static int mi_prim_open(const char* fpath, int open_flags) {
- return open(fpath,open_flags,0);
+ return open(fpath,open_flags);
}
-static mi_ssize_t mi_prim_read(int fd, void* buf, size_t bufsize) {
+static ssize_t mi_prim_read(int fd, void* buf, size_t bufsize) {
return read(fd,buf,bufsize);
}
static int mi_prim_close(int fd) {
@@ -169,7 +169,7 @@ static void* unix_mmap_prim(void* addr, size_t size, size_t try_alignment, int p
p = mmap(addr, size, protect_flags, flags | MAP_ALIGNED(n), fd, 0);
if (p==MAP_FAILED || !_mi_is_aligned(p,try_alignment)) {
int err = errno;
- _mi_warning_message("unable to directly request aligned OS memory (error: %d (0x%x), size: 0x%zx bytes, alignment: 0x%zx, hint address: %p)\n", err, err, size, try_alignment, hint);
+ _mi_warning_message("unable to directly request aligned OS memory (error: %d (0x%x), size: 0x%zx bytes, alignment: 0x%zx)\n", err, err, size, try_alignment);
}
if (p!=MAP_FAILED) return p;
// fall back to regular mmap
@@ -391,7 +391,7 @@ int _mi_prim_reset(void* start, size_t size) {
err = unix_madvise(start, size, MADV_DONTNEED);
}
#else
- int err = unix_madvise(start, csize, MADV_DONTNEED);
+ int err = unix_madvise(start, size, MADV_DONTNEED);
#endif
return err;
}
diff --git a/source/luametatex/source/lua/lmtnodelib.c b/source/luametatex/source/lua/lmtnodelib.c
index d4a325c21..7896eff65 100644
--- a/source/luametatex/source/lua/lmtnodelib.c
+++ b/source/luametatex/source/lua/lmtnodelib.c
@@ -4871,32 +4871,33 @@ static int nodelib_shared_fields(lua_State *L)
/* These should move to texlib ... which might happen. */
-static int nodelib_shared_values(lua_State *L)
-{
- if (lua_type(L, 1) == LUA_TSTRING) {
- /*
- delimiter options (bit set)
- delimiter modes (bit set)
- */
- const char *s = lua_tostring(L, 1);
- if (lua_key_eq(s, glue) || lua_key_eq(s, fill)) {
- return lmt_push_info_values(L, lmt_interface.node_fill_values);
- } else if (lua_key_eq(s, dir)) {
- return lmt_push_info_values(L, lmt_interface.direction_values);
- } else if (lua_key_eq(s, math)) {
- /*tex A bit strange place, so moved to lmttexlib. */
- return lmt_push_info_keys(L, lmt_interface.math_parameter_values);
- } else if (lua_key_eq(s, style)) {
- /*tex A bit strange place, so moved to lmttexlib. */
- return lmt_push_info_values(L, lmt_interface.math_style_values);
- } else if (lua_key_eq(s, page)) {
- /*tex These are never used, whatsit related. */
- return lmt_push_info_values(L, lmt_interface.page_contribute_values);
- }
- }
- lua_pushnil(L);
- return 1;
-}
+// static int nodelib_shared_values(lua_State *L)
+// {
+// if (lua_type(L, 1) == LUA_TSTRING) {
+// /*
+// delimiter options (bit set)
+// delimiter modes (bit set)
+// */
+// const char *s = lua_tostring(L, 1);
+// if (lua_key_eq(s, glue) || lua_key_eq(s, fill)) {
+// return lmt_push_info_values(L, lmt_interface.node_fill_values);
+// } else if (lua_key_eq(s, dir)) {
+// /* moved to lmttexlib */
+// return lmt_push_info_values(L, lmt_interface.direction_values);
+// } else if (lua_key_eq(s, math)) {
+// /* moved to lmttexlib */
+// return lmt_push_info_keys(L, lmt_interface.math_parameter_values);
+// } else if (lua_key_eq(s, style)) {
+// /* moved to lmttexlib */
+// return lmt_push_info_values(L, lmt_interface.math_style_values);
+// } else if (lua_key_eq(s, page)) {
+// /*tex These are never used, whatsit related. */
+// return lmt_push_info_values(L, lmt_interface.page_contribute_values);
+// }
+// }
+// lua_pushnil(L);
+// return 1;
+// }
static int nodelib_shared_subtypes(lua_State *L)
{
@@ -9916,7 +9917,7 @@ static const struct luaL_Reg nodelib_direct_function_list[] = {
{ "types", nodelib_shared_types },
{ "fields", nodelib_shared_fields },
{ "subtypes", nodelib_shared_subtypes },
- { "values", nodelib_shared_values },
+ /* { "values", nodelib_shared_values }, */ /* finally all are now in tex. */
{ "id", nodelib_shared_id },
{ "getcachestate", nodelib_shared_getcachestate },
{ "todirect", nodelib_shared_todirect },
@@ -9966,7 +9967,7 @@ static const struct luaL_Reg nodelib_function_list[] = {
{ "types", nodelib_shared_types },
{ "fields", nodelib_shared_fields },
{ "subtypes", nodelib_shared_subtypes },
- { "values", nodelib_shared_values },
+ /* { "values", nodelib_shared_values }, */ /* finally all are now in tex. */
{ "id", nodelib_shared_id },
{ "getcachestate", nodelib_shared_getcachestate },
{ "todirect", nodelib_shared_todirect },
diff --git a/source/luametatex/source/lua/lmttexiolib.c b/source/luametatex/source/lua/lmttexiolib.c
index 416293164..48b28e3dc 100644
--- a/source/luametatex/source/lua/lmttexiolib.c
+++ b/source/luametatex/source/lua/lmttexiolib.c
@@ -252,6 +252,18 @@ static int texiolib_closeinput(lua_State *L)
return 0 ;
}
+static int texiolib_getinputindex(lua_State *L)
+{
+ lua_pushinteger(L, lmt_input_state.cur_input.index);
+ return 1;
+}
+
+static int texiolib_getsourcefilename(lua_State *L)
+{
+ lua_pushstring(L, lmt_input_state.in_stack[lmt_input_state.in_stack_data.ptr].full_source_filename);
+ return 1;
+}
+
/*tex
This is a private hack, handy for testing runtime math font patches in lfg files with a bit of
low level tracing. Setting the logfile is already handles by a callback so we don't support
@@ -278,16 +290,25 @@ static int texiolib_setlogfile(lua_State *L)
return 0;
}
+static int texiolib_forceendoffile(lua_State *L)
+{
+ lmt_token_state.force_eof = 1;
+ return 0;
+}
+
static const struct luaL_Reg texiolib_function_list[] = {
- { "write", texiolib_write },
- { "writenl", texiolib_write_nl },
- { "write_nl", texiolib_write_nl }, /* depricated */
- { "writeselector", texiolib_write_selector },
- { "writeselectornl", texiolib_write_selector_nl },
- { "writeselectorlf", texiolib_write_selector_lf },
- { "closeinput", texiolib_closeinput },
- { "setlogfile", texiolib_setlogfile },
- { NULL, NULL },
+ { "write", texiolib_write },
+ { "writenl", texiolib_write_nl },
+ { "write_nl", texiolib_write_nl }, /* depricated */
+ { "writeselector", texiolib_write_selector },
+ { "writeselectornl", texiolib_write_selector_nl },
+ { "writeselectorlf", texiolib_write_selector_lf },
+ { "closeinput", texiolib_closeinput },
+ { "setlogfile", texiolib_setlogfile },
+ { "getinputindex", texiolib_getinputindex }, /*tex temporary, testing only */
+ { "getsourcefilename", texiolib_getsourcefilename }, /*tex temporary, testing only */
+ { "forceendoffile", texiolib_forceendoffile }, /*tex temporary, testing only */
+ { NULL, NULL },
};
static const struct luaL_Reg texiolib_function_list_only[] = {
diff --git a/source/luametatex/source/lua/lmttexlib.c b/source/luametatex/source/lua/lmttexlib.c
index e87a88292..426ca222b 100644
--- a/source/luametatex/source/lua/lmttexlib.c
+++ b/source/luametatex/source/lua/lmttexlib.c
@@ -45,6 +45,7 @@
# define TEX_METATABLE_UCCODE "tex.uccode"
# define TEX_METATABLE_HCCODE "tex.hccode"
# define TEX_METATABLE_HMCODE "tex.hmcode"
+# define TEX_METATABLE_AMCODE "tex.amcode"
# define TEX_METATABLE_CATCODE "tex.catcode"
# define TEX_METATABLE_MATHCODE "tex.mathcode"
# define TEX_METATABLE_DELCODE "tex.delcode"
@@ -2107,6 +2108,23 @@ static int texlib_sethmcode(lua_State *L)
return 0;
}
+static int texlib_setamcode(lua_State *L)
+{
+ int top = lua_gettop(L);
+ if (top >= 2) {
+ quarterword level;
+ int slot = lmt_check_for_level(L, 1, &level, cur_level);
+ int ch = lmt_checkinteger(L, slot++);
+ if (character_in_range(ch)) {
+ halfword val = lmt_checkhalfword(L, slot);
+ tex_set_am_code(ch, val, level);
+ } else {
+ texlib_aux_show_character_error(L, ch);
+ }
+ }
+ return 0;
+}
+
static int texlib_getlccode(lua_State *L)
{
int ch = lmt_checkinteger(L, 1);
@@ -2167,6 +2185,18 @@ static int texlib_gethmcode(lua_State *L)
return 1;
}
+static int texlib_getamcode(lua_State *L)
+{
+ int ch = lmt_checkinteger(L, 1);
+ if (character_in_range(ch)) {
+ lua_pushinteger(L, tex_get_am_code(ch));
+ } else {
+ texlib_aux_show_character_error(L, ch);
+ lua_pushinteger(L, 0);
+ }
+ return 1;
+}
+
/* [global] [cattable] code value */
static int texlib_setcatcode(lua_State *L)
@@ -4884,6 +4914,7 @@ static int texlib_getnoadoptionvalues(lua_State *L)
lua_push_key_at_index(L, shrink, noad_option_shrink);
lua_push_key_at_index(L, stretch, noad_option_stretch);
lua_push_key_at_index(L, center, noad_option_center);
+ lua_push_key_at_index(L, scale, noad_option_scale);
return 1;
}
@@ -4924,7 +4955,7 @@ static int texlib_getlistsignvalues(lua_State *L)
return 1;
}
-static int texlib_getlistgeometryalues(lua_State *L)
+static int texlib_getlistgeometryvalues(lua_State *L)
{
lua_createtable(L, 3, 0);
lua_set_string_by_index(L, offset_geometry, "offset");
@@ -5107,7 +5138,7 @@ static int texlib_getkerneloptionvalues(lua_State *L)
static int texlib_getcharactertagvalues(lua_State *L)
{
- lua_createtable(L, 2, 12);
+ lua_createtable(L, 2, 15);
lua_set_string_by_index(L, no_tag, "normal");
lua_set_string_by_index(L, ligatures_tag, "ligatures");
lua_set_string_by_index(L, kerns_tag, "kerns");
@@ -5305,6 +5336,16 @@ static int texlib_gettextcontrolvalues(lua_State *L)
return 1;
}
+static int texlib_getfillvalues(lua_State *L)
+{
+ return lmt_push_info_values(L, lmt_interface.node_fill_values);
+}
+
+static int texlib_getdirectionvalues(lua_State *L)
+{
+ return lmt_push_info_values(L, lmt_interface.direction_values);
+}
+
/* relatively new */
static int texlib_getinsertdistance(lua_State *L)
@@ -5482,6 +5523,8 @@ static const struct luaL_Reg texlib_function_list[] = {
{ "gethccode", texlib_gethccode },
{ "sethmcode", texlib_sethmcode },
{ "gethmcode", texlib_gethmcode },
+ { "setamcode", texlib_setamcode },
+ { "getamcode", texlib_getamcode },
{ "setlccode", texlib_setlccode },
{ "getlccode", texlib_getlccode },
{ "setmathcode", texlib_setmathcode },
@@ -5567,7 +5610,7 @@ static const struct luaL_Reg texlib_function_list[] = {
{ "getdiscoptionvalues", texlib_getdiscoptionvalues },
{ "getlistanchorvalues", texlib_getlistanchorvalues },
{ "getlistsignvalues", texlib_getlistsignvalues },
- { "getlistgeometryvalues", texlib_getlistgeometryalues },
+ { "getlistgeometryvalues", texlib_getlistgeometryvalues },
{ "getdiscstatevalues", texlib_getdiscstatevalues },
{ "getmathparametervalues", texlib_getmathparametervalues },
{ "getmathstylenamevalues", texlib_getmathstylenamevalues },
@@ -5589,6 +5632,8 @@ static const struct luaL_Reg texlib_function_list[] = {
{ "getmathclassoptionvalues", texlib_getmathclassoptionvalues },
{ "getnormalizelinevalues", texlib_getnormalizelinevalues },
{ "getnormalizeparvalues", texlib_getnormalizeparvalues },
+ { "getdirectionvalues", texlib_getdirectionvalues },
+ { "getfillvalues", texlib_getfillvalues },
{ "geterrorvalues", texlib_geterrorvalues },
{ "getiovalues", texlib_getiovalues },
{ "getprimitiveorigins", texlib_getprimitiveorigins },
@@ -5642,6 +5687,7 @@ defineindexers(lccode)
defineindexers(uccode)
defineindexers(hccode)
defineindexers(hmcode)
+defineindexers(amcode)
defineindexers(catcode)
defineindexers(mathcode)
defineindexers(delcode)
@@ -5673,6 +5719,7 @@ int luaopen_tex(lua_State *L)
lmt_make_table(L, "uccode", TEX_METATABLE_UCCODE, texlib_index_uccode, texlib_newindex_uccode);
lmt_make_table(L, "hccode", TEX_METATABLE_HCCODE, texlib_index_hccode, texlib_newindex_hccode);
lmt_make_table(L, "hmcode", TEX_METATABLE_HMCODE, texlib_index_hmcode, texlib_newindex_hmcode);
+ lmt_make_table(L, "amcode", TEX_METATABLE_AMCODE, texlib_index_amcode, texlib_newindex_amcode);
lmt_make_table(L, "catcode", TEX_METATABLE_CATCODE, texlib_index_catcode, texlib_newindex_catcode);
lmt_make_table(L, "mathcode", TEX_METATABLE_MATHCODE, texlib_index_mathcode, texlib_newindex_mathcode);
lmt_make_table(L, "delcode", TEX_METATABLE_DELCODE, texlib_index_delcode, texlib_newindex_delcode);
diff --git a/source/luametatex/source/luacore/lua54/src/Makefile b/source/luametatex/source/luacore/lua54/src/Makefile
index ee56c6720..38e21f1f5 100644
--- a/source/luametatex/source/luacore/lua54/src/Makefile
+++ b/source/luametatex/source/luacore/lua54/src/Makefile
@@ -8,7 +8,6 @@ CWARNSCPP= \
-Wfatal-errors \
-Wextra \
-Wshadow \
- -Wsign-compare \
-Wundef \
-Wwrite-strings \
-Wredundant-decls \
@@ -60,7 +59,7 @@ CWARNS= $(CWARNSCPP) $(CWARNSC) $(CWARNGCC)
# The following options help detect "undefined behavior"s that seldom
# create problems; some are only available in newer gcc versions. To
-# use some of them, we also have to define an enrivonment variable
+# use some of them, we also have to define an environment variable
# ASAN_OPTIONS="detect_invalid_pointer_pairs=2".
# -fsanitize=undefined
# -fsanitize=pointer-subtract -fsanitize=address -fsanitize=pointer-compare
diff --git a/source/luametatex/source/luacore/lua54/src/lua.h b/source/luametatex/source/luacore/lua54/src/lua.h
index feb3dbc55..01927c6d9 100644
--- a/source/luametatex/source/luacore/lua54/src/lua.h
+++ b/source/luametatex/source/luacore/lua54/src/lua.h
@@ -25,7 +25,7 @@
#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
-#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2022 Lua.org, PUC-Rio"
+#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2023 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
@@ -496,7 +496,7 @@ struct lua_Debug {
/******************************************************************************
-* Copyright (C) 1994-2022 Lua.org, PUC-Rio.
+* Copyright (C) 1994-2023 Lua.org, PUC-Rio.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
diff --git a/source/luametatex/source/luametatex.h b/source/luametatex/source/luametatex.h
index a318342c7..e9a2d3724 100644
--- a/source/luametatex/source/luametatex.h
+++ b/source/luametatex/source/luametatex.h
@@ -92,7 +92,7 @@
# define luametatex_version 210
# define luametatex_revision 8
# define luametatex_version_string "2.10.08"
-# define luametatex_development_id 20230331
+# define luametatex_development_id 20230407
# define luametatex_name_camelcase "LuaMetaTeX"
# define luametatex_name_lowercase "luametatex"
diff --git a/source/luametatex/source/tex/texmaincontrol.c b/source/luametatex/source/tex/texmaincontrol.c
index e901906c4..6d6a2c031 100644
--- a/source/luametatex/source/tex/texmaincontrol.c
+++ b/source/luametatex/source/tex/texmaincontrol.c
@@ -5939,10 +5939,10 @@ void tex_assign_internal_int_value(int a, halfword p, int val)
goto DEFINE;
*/
case eu_factor_code:
- if (val < 1) {
- val = 1;
- } else if (val > 50) {
- val = 50;
+ if (val < eu_min_factor) {
+ val = eu_min_factor;
+ } else if (val > eu_max_factor) {
+ val = eu_max_factor;
}
tex_word_define(a, p, val);
break;
@@ -6584,7 +6584,7 @@ void tex_initialize_variables(void)
math_font_control_par = assumed_math_control;
math_eqno_gap_step_par = default_eqno_gap_step;
px_dimen_par = one_bp;
- eu_factor_par = 1000;
+ eu_factor_par = eu_def_factor;
show_node_details_par = 2; /*tex $>1$: |[subtype]| $>2$: |[attributes]| */
ex_hyphen_char_par = '-';
escape_char_par = '\\';
diff --git a/source/luametatex/source/tex/texmath.c b/source/luametatex/source/tex/texmath.c
index 7ace4f113..dff87b5cc 100644
--- a/source/luametatex/source/tex/texmath.c
+++ b/source/luametatex/source/tex/texmath.c
@@ -4132,8 +4132,20 @@ void tex_run_math_fence(void)
}
break;
case 's': case 'S':
- if (tex_scan_mandate_keyword("source", 1)) {
- source = tex_scan_int(0, NULL);
+ switch (tex_scan_character("coCO", 0, 0, 0)) {
+ case 'c': case 'C':
+ if (tex_scan_mandate_keyword("scale", 2)) {
+ options |= noad_option_scale;
+ }
+ break;
+ case 'o': case 'O':
+ if (tex_scan_mandate_keyword("source", 2)) {
+ source = tex_scan_int(0, NULL);
+ }
+ break;
+ default:
+ tex_aux_show_keyword_error("scale|source");
+ goto CHECK_PAIRING;
}
break;
case 't': case 'T':
diff --git a/source/luametatex/source/tex/texmlist.c b/source/luametatex/source/tex/texmlist.c
index 53a0bd198..91bb864d7 100644
--- a/source/luametatex/source/tex/texmlist.c
+++ b/source/luametatex/source/tex/texmlist.c
@@ -413,6 +413,11 @@ inline static int tex_aux_math_engine_control(halfword fnt, halfword control)
*/
+inline static scaled tex_aux_math_math_scale(scaled v)
+{
+ return v ? scaledround(0.001 * lmt_math_state.scale * v) : 0;
+}
+
inline static scaled tex_aux_math_glyph_scale(scaled v)
{
return v ? scaledround(0.001 * glyph_scale_par * v) : 0;
@@ -530,17 +535,19 @@ static int tex_aux_math_followed_by_italic_kern(halfword current, const char *tr
return 0;
}
-inline static int tex_aux_checked_left_kern_fnt_chr(halfword fnt, halfword chr, halfword state, halfword subtype)
+inline static int tex_aux_checked_left_kern_fnt_chr(halfword fnt, halfword chr, halfword state, halfword subtype, halfword size)
{
halfword top = 0;
halfword bot = 0;
halfword hastop = (state & prime_script_state) || (state & post_super_script_state);
halfword hasbot = state & post_sub_script_state;
if (hastop && tex_math_has_class_option(subtype, left_top_kern_class_option)) {
- top = tex_char_top_left_kern_from_font(fnt, chr);
+// top = tex_char_top_left_kern_from_font(fnt, chr);
+top = tex_aux_math_x_size_scaled(fnt, tex_char_top_left_kern_from_font(fnt, chr), size);
}
if (hasbot && tex_math_has_class_option(subtype, left_bottom_kern_class_option)) {
- bot = tex_char_bottom_left_kern_from_font(fnt, chr);
+// bot = tex_char_bottom_left_kern_from_font(fnt, chr);
+bot = tex_aux_math_x_size_scaled(fnt, tex_char_bottom_left_kern_from_font(fnt, chr), size);
}
if (hastop && hasbot) {
return top > bot ? top : bot;
@@ -551,26 +558,28 @@ inline static int tex_aux_checked_left_kern_fnt_chr(halfword fnt, halfword chr,
}
}
-inline static int tex_aux_checked_left_kern(halfword list, halfword state, halfword subtype)
+inline static int tex_aux_checked_left_kern(halfword list, halfword state, halfword subtype, halfword size)
{
if (list && node_type(list) == glyph_node) {
- return tex_aux_checked_left_kern_fnt_chr(glyph_font(list), glyph_character(list), state, subtype);
+ return tex_aux_checked_left_kern_fnt_chr(glyph_font(list), glyph_character(list), state, subtype, size);
} else {
return 0;
}
}
-inline static int tex_aux_checked_right_kern_fnt_chr(halfword fnt, halfword chr, halfword state, halfword subtype)
+inline static int tex_aux_checked_right_kern_fnt_chr(halfword fnt, halfword chr, halfword state, halfword subtype, halfword size)
{
halfword top = 0;
halfword bot = 0;
halfword hastop = state & pre_super_script_state;
halfword hasbot = state & pre_sub_script_state;
if (hastop && tex_math_has_class_option(subtype, right_top_kern_class_option)) {
- top = tex_char_top_right_kern_from_font(fnt, chr);
+// top = tex_char_top_right_kern_from_font(fnt, chr);
+top = tex_aux_math_x_size_scaled(fnt, tex_char_top_right_kern_from_font(fnt, chr), size);
}
if (hasbot && tex_math_has_class_option(subtype, right_bottom_kern_class_option)) {
- bot = tex_char_bottom_right_kern_from_font(fnt, chr);
+// bot = tex_char_bottom_right_kern_from_font(fnt, chr);
+bot = tex_aux_math_x_size_scaled(fnt, tex_char_bottom_right_kern_from_font(fnt, chr), size);
}
if (hastop && hasbot) {
return top < bot ? bot : top;
@@ -581,10 +590,10 @@ inline static int tex_aux_checked_right_kern_fnt_chr(halfword fnt, halfword chr,
}
}
-inline static int tex_aux_checked_right_kern(halfword list, halfword state, halfword subtype)
+inline static int tex_aux_checked_right_kern(halfword list, halfword state, halfword subtype, halfword size)
{
if (list && node_type(list) == glyph_node) {
- return tex_aux_checked_right_kern_fnt_chr(glyph_font(list), glyph_character(list), state, subtype);
+ return tex_aux_checked_right_kern_fnt_chr(glyph_font(list), glyph_character(list), state, subtype, size);
} else {
return 0;
}
@@ -1418,8 +1427,8 @@ static halfword tex_aux_make_delimiter(halfword target, halfword delimiter, int
/*tex are we trying the large variant? */
int large_attempt = 0;
int do_parts = 0;
- int shrink = flat && tex_has_noad_option(target, noad_option_shrink);
- int stretch = flat && tex_has_noad_option(target, noad_option_stretch);
+ int shrink = flat && has_noad_option_shrink(target);
+ int stretch = flat && has_noad_option_stretch(target);
/*tex to save the current attribute list */
halfword att = null;
if (extremes) {
@@ -2378,20 +2387,24 @@ static void tex_aux_assign_radical(halfword target, halfword radical)
radical_right_delimiter(target) = null;
}
-static void tex_aux_set_radical_kerns(delimiterextremes *extremes, kernset *kerns)
+static void tex_aux_set_radical_kerns(delimiterextremes *extremes, kernset *kerns, halfword size)
{
if (kerns && extremes->tfont) {
if (tex_math_has_class_option(radical_noad_subtype, carry_over_left_top_kern_class_option)) {
- kerns->topleft = tex_char_top_left_kern_from_font(extremes->tfont, extremes->tchar);
+// kerns->topleft = tex_char_top_left_kern_from_font(extremes->tfont, extremes->tchar);
+kerns->topleft = tex_aux_math_x_size_scaled(extremes->tfont, tex_char_top_left_kern_from_font(extremes->tfont, extremes->tchar), size);
}
if (tex_math_has_class_option(radical_noad_subtype, carry_over_left_bottom_kern_class_option)) {
- kerns->bottomleft = tex_char_bottom_left_kern_from_font(extremes->bfont, extremes->bchar);
+// kerns->bottomleft = tex_char_bottom_left_kern_from_font(extremes->bfont, extremes->bchar);
+kerns->bottomleft = tex_aux_math_x_size_scaled(extremes->bfont, tex_char_bottom_left_kern_from_font(extremes->bfont, extremes->bchar), size);
}
if (tex_math_has_class_option(radical_noad_subtype, carry_over_right_top_kern_class_option)) {
- kerns->topright = tex_char_top_right_kern_from_font(extremes->tfont, extremes->tchar);
+// kerns->topright = tex_char_top_right_kern_from_font(extremes->tfont, extremes->tchar);
+kerns->topright = tex_aux_math_x_size_scaled(extremes->tfont, tex_char_top_right_kern_from_font(extremes->tfont, extremes->tchar), size);
}
if (tex_math_has_class_option(radical_noad_subtype, carry_over_right_bottom_kern_class_option)) {
- kerns->bottomright = tex_char_bottom_right_kern_from_font(extremes->bfont, extremes->bchar);
+// kerns->bottomright = tex_char_bottom_right_kern_from_font(extremes->bfont, extremes->bchar);
+kerns->bottomright = tex_aux_math_x_size_scaled(extremes->bfont, tex_char_bottom_right_kern_from_font(extremes->bfont, extremes->bchar), size);
}
if (tex_math_has_class_option(radical_noad_subtype, prefer_delimiter_dimensions_class_option)) {
kerns->height = extremes->height;
@@ -2478,7 +2491,7 @@ static void tex_aux_make_root_radical(halfword target, int style, int size, kern
}
}
/* */
- tex_aux_set_radical_kerns(&extremes, kerns);
+ tex_aux_set_radical_kerns(&extremes, kerns, size);
/*
Radicals in traditional fonts have their shape below the baseline which makes them unuseable
as stand alone characters but here we compensate for that fact. Opentype fonts derived from
@@ -2588,7 +2601,7 @@ static void tex_aux_make_delimited_radical(halfword target, int style, int size,
/*tex For now we assume symmetry and same height and depth! */
companion = tex_aux_make_delimiter(target, companion, size, total, 0, style, 2, NULL, NULL, 0, has_noad_option_nooverflow(target), &extremes, depth);
}
- tex_aux_set_radical_kerns(&extremes, kerns);
+ tex_aux_set_radical_kerns(&extremes, kerns, size);
radical = tex_aux_link_radical(nucleus, delimiter, companion, rightdelimiter);
tex_aux_assign_radical(target, radical);
}
@@ -2954,6 +2967,7 @@ static void tex_aux_do_make_math_accent(halfword target, halfword accentfnt, hal
halfword stretch = (flags & stretch_accent_code) == stretch_accent_code;
halfword basefnt = null_font;
halfword basechr = 0;
+ int found = 0;
/*tex
Compute the amount of skew, or set |skew| to an alignment point. This will be true if a
top-accent has been determined.
@@ -3059,12 +3073,14 @@ static void tex_aux_do_make_math_accent(halfword target, halfword accentfnt, hal
}
if (! accent) {
/*tex Italic gets added to width for traditional fonts (no italic anyway): */
- accent = tex_aux_char_box(accentfnt, accentchr, attrlist, NULL, glyph_math_accent_subtype, basewidth, style, 0, 0); // usedwidth
+// accent = tex_aux_char_box(accentfnt, accentchr, attrlist, NULL, glyph_math_accent_subtype, basewidth, style, 0, 0); // usedwidth
+ accent = tex_aux_char_box(accentfnt, accentchr, attrlist, NULL, glyph_math_accent_subtype, usedwidth, style, 0, 0); // usedwidth
+ found = 1;
}
if (flags & top_accent_code) {
scaled b = tex_get_math_y_parameter(style, math_parameter_accent_base_height);
- scaled u = tex_get_math_y_parameter(style, stretch ? math_parameter_flattened_accent_top_shift_up : math_parameter_accent_top_shift_up);
- if (! tex_aux_math_engine_control(accentfnt, math_control_ignore_flat_accents)) {
+ scaled u = found ? tex_get_math_y_parameter(style, stretch ? math_parameter_flattened_accent_top_shift_up : math_parameter_accent_top_shift_up) : undefined_math_parameter;
+ if (found && ! tex_aux_math_engine_control(accentfnt, math_control_ignore_flat_accents)) {
scaled f = tex_get_math_y_parameter(style, math_parameter_flattened_accent_base_height);
if (f != undefined_math_parameter && baseheight > f) {
halfword flatchr = tex_char_flat_accent_from_font(accentfnt, accentchr);
@@ -3327,16 +3343,20 @@ static void tex_aux_wrap_fraction_result(halfword target, int style, int size, h
right = tex_aux_make_delimiter(target, right_delimiter, size, delta, 0, style, 1, NULL, NULL, 0, has_noad_option_nooverflow(target), &extremes, 0);
if (kerns && extremes.tfont) {
if (tex_math_has_class_option(fraction_noad_subtype, carry_over_left_top_kern_class_option)) {
- kerns->topleft = tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar);
+// kerns->topleft = tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar);
+kerns->topleft = tex_aux_math_x_size_scaled(extremes.tfont, tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar), size);
}
if (tex_math_has_class_option(fraction_noad_subtype, carry_over_left_bottom_kern_class_option)) {
- kerns->bottomleft = tex_char_bottom_left_kern_from_font(extremes.bfont, extremes.bchar);
+// kerns->bottomleft = tex_char_bottom_left_kern_from_font(extremes.bfont, extremes.bchar);
+kerns->bottomleft = tex_aux_math_x_size_scaled(extremes.bfont, tex_char_bottom_left_kern_from_font(extremes.bfont, extremes.bchar), size);
}
if (tex_math_has_class_option(fraction_noad_subtype, carry_over_right_top_kern_class_option)) {
- kerns->topright = tex_char_top_right_kern_from_font(extremes.tfont, extremes.tchar);
+// kerns->topright = tex_char_top_right_kern_from_font(extremes.tfont, extremes.tchar);
+kerns->topright = tex_aux_math_x_size_scaled(extremes.tfont, tex_char_top_right_kern_from_font(extremes.tfont, extremes.tchar), size);
}
if (tex_math_has_class_option(fraction_noad_subtype, carry_over_right_bottom_kern_class_option)) {
- kerns->bottomright = tex_char_bottom_right_kern_from_font(extremes.bfont, extremes.bchar);
+// kerns->bottomright = tex_char_bottom_right_kern_from_font(extremes.bfont, extremes.bchar);
+kerns->bottomright = tex_aux_math_x_size_scaled(extremes.bfont, tex_char_bottom_right_kern_from_font(extremes.bfont, extremes.bchar), size);
}
if (tex_math_has_class_option(fraction_noad_subtype, prefer_delimiter_dimensions_class_option)) {
kerns->height = extremes.height;
@@ -3570,10 +3590,12 @@ static halfword tex_aux_make_skewed_fraction(halfword target, int style, int siz
ngap = hgap;
dgap = hgap;
if (tex_math_has_class_option(fraction_noad_subtype, carry_over_left_top_kern_class_option)) {
- ngap += tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar);
+// ngap += tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar);
+ngap += tex_aux_math_x_size_scaled(extremes.tfont, tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar), size);
}
if (tex_math_has_class_option(fraction_noad_subtype, carry_over_right_bottom_kern_class_option)) {
- dgap += tex_char_bottom_right_kern_from_font(extremes.tfont, extremes.tchar);
+// dgap += tex_char_bottom_right_kern_from_font(extremes.bfont, extremes.bchar);
+dgap += tex_aux_math_x_size_scaled(extremes.bfont, tex_char_bottom_right_kern_from_font(extremes.bfont, extremes.bchar), size);
}
if (ngap || dgap) {
// todo: only add when non zero
@@ -4556,6 +4578,7 @@ static scaled tex_aux_math_kern_at(halfword fnt, int chr, int side, int value)
scaled *kerns_heights;
int n_of_kerns = tex_get_charinfo_math_kerns(ci, side);
if (n_of_kerns == 0) {
+ /*tex These are yet unscaled. */
switch (side) {
case top_left_kern:
return tex_char_top_left_kern_from_font(fnt, chr);
@@ -5512,6 +5535,10 @@ static halfword tex_aux_make_left_right(halfword target, int style, scaled max_d
extremes->height = 0;
extremes->depth = 0;
}
+ if (has_noad_option_scale(target)) {
+ height = tex_aux_math_math_scale(height);
+ depth = tex_aux_math_math_scale(depth);
+ }
tex_aux_set_current_math_size(style);
if (height || depth || has_noad_option_exact(target)) {
halfword lst;
@@ -5522,15 +5549,15 @@ static halfword tex_aux_make_left_right(halfword target, int style, scaled max_d
/*tex
Beware, a stacked delimiter has a shift but no corrected height/depth (yet).
*/
-/* or do we need has_noad_option_check(target) */
-if (! stack && has_noad_option_exact(target)) {
- if (extremes && extremes->height < height) {
- height = extremes->height;
- }
- if (extremes && extremes->depth < depth) {
- depth = extremes->depth;
- }
-}
+ /* or do we need has_noad_option_check(target) */
+ if (! stack && has_noad_option_exact(target)) {
+ if (extremes && extremes->height < height) {
+ height = extremes->height;
+ }
+ if (extremes && extremes->depth < depth) {
+ depth = extremes->depth;
+ }
+ }
if (stack) {
box_shift_amount(tmp) = depth;
}
@@ -5563,7 +5590,7 @@ if (! stack && has_noad_option_exact(target)) {
if (leftoperator && has_noad_option_auto(target)) {
/*tex Todo: option for skipping this. */
if (style < text_style) {
- scaled s = scaledround((double) tex_get_math_parameter(style, math_parameter_operator_size, NULL));
+ scaled s = tex_get_math_y_parameter_checked(style, math_parameter_operator_size);
if (s > max_h + max_d) {
max_h = scaledround(s / 2.0);
max_d = max_h;
@@ -5608,10 +5635,12 @@ if (! stack && has_noad_option_exact(target)) {
/* maybe elsewhere as the above case */
if (extremes && extremes->tfont) {
if (tex_math_has_class_option(fenced_noad_subtype, carry_over_right_top_kern_class_option)) {
- kerns.topright = tex_char_top_right_kern_from_font(extremes->tfont, extremes->tchar);
+// kerns.topright = tex_char_top_right_kern_from_font(extremes->tfont, extremes->tchar);
+kerns.topright = tex_aux_math_x_size_scaled(extremes->tfont, tex_char_top_right_kern_from_font(extremes->tfont, extremes->tchar), size);
}
if (tex_math_has_class_option(fenced_noad_subtype, carry_over_right_bottom_kern_class_option)) {
- kerns.bottomright = tex_char_bottom_right_kern_from_font(extremes->bfont, extremes->bchar);
+// kerns.bottomright = tex_char_bottom_right_kern_from_font(extremes->bfont, extremes->bchar);
+kerns.bottomright = tex_aux_math_x_size_scaled(extremes->bfont, tex_char_bottom_right_kern_from_font(extremes->bfont, extremes->bchar), size);
}
if (tex_math_has_class_option(fenced_noad_subtype, prefer_delimiter_dimensions_class_option)) {
kerns.height = extremes->height;
@@ -6177,10 +6206,12 @@ static void tex_aux_finish_fenced(halfword current, halfword main_style, scaled
case left_fence_side:
case extended_left_fence_side:
if (tex_math_has_class_option(fenced_noad_subtype, carry_over_left_top_kern_class_option)) {
- kerns->topleft = tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar);
+ // kerns->topleft = tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar);
+ kerns->topleft = tex_aux_math_x_size_scaled(extremes.tfont, tex_char_top_left_kern_from_font(extremes.tfont, extremes.tchar), main_style);
}
if (tex_math_has_class_option(fenced_noad_subtype, carry_over_left_bottom_kern_class_option)) {
- kerns->bottomleft = tex_char_bottom_left_kern_from_font(extremes.bfont, extremes.bchar);
+ // kerns->bottomleft = tex_char_bottom_left_kern_from_font(extremes.bfont, extremes.bchar);
+ kerns->bottomleft = tex_aux_math_x_size_scaled(extremes.bfont, tex_char_bottom_left_kern_from_font(extremes.bfont, extremes.bchar), main_style);
}
if (tex_math_has_class_option(fenced_noad_subtype, prefer_delimiter_dimensions_class_option)) {
kerns->height = extremes.height;
@@ -6194,10 +6225,12 @@ static void tex_aux_finish_fenced(halfword current, halfword main_style, scaled
case left_operator_side:
case no_fence_side:
if (tex_math_has_class_option(fenced_noad_subtype, carry_over_right_top_kern_class_option)) {
- kerns->topright = tex_char_top_right_kern_from_font(extremes.tfont, extremes.tchar);
+// kerns->topright = tex_char_top_right_kern_from_font(extremes.tfont, extremes.tchar);
+kerns->topright = tex_aux_math_x_size_scaled(extremes.tfont, tex_char_top_right_kern_from_font(extremes.tfont, extremes.tchar), main_style);
}
if (tex_math_has_class_option(fenced_noad_subtype, carry_over_right_bottom_kern_class_option)) {
- kerns->bottomright = tex_char_bottom_right_kern_from_font(extremes.bfont, extremes.bchar);
+// kerns->bottomright = tex_char_bottom_right_kern_from_font(extremes.bfont, extremes.bchar);
+kerns->bottomright = tex_aux_math_x_size_scaled(extremes.bfont, tex_char_bottom_right_kern_from_font(extremes.bfont, extremes.bchar), main_style);
}
if (tex_math_has_class_option(fenced_noad_subtype, prefer_delimiter_dimensions_class_option)) {
kerns->height = extremes.height;
@@ -7040,7 +7073,7 @@ static void tex_mlist_to_hlist_finalize_list(mliststate *state)
/*tex Append inter-element spacing based on |r_type| and |t| */
if (current_plus_glyph && recent_script_state) {
/*tex This is a very special case and used {x^2 / 3| kind of situations: */
- halfword plus = tex_aux_checked_left_kern(current_plus_glyph, recent_script_state, current_subtype);
+ halfword plus = tex_aux_checked_left_kern(current_plus_glyph, recent_script_state, current_subtype, lmt_math_state.size);
if (plus) {
halfword kern = tex_new_kern_node(plus, math_shape_kern_subtype);
tex_attach_attribute_list_copy(kern, current);
@@ -7081,7 +7114,7 @@ static void tex_mlist_to_hlist_finalize_list(mliststate *state)
}
if (recent_plus_glyph && current_script_state) {
/*tex This is a very special case and used {x^2 / 3| kind of situations: */
- halfword plus = tex_aux_checked_right_kern(recent_plus_glyph, current_script_state, recent_subtype);
+ halfword plus = tex_aux_checked_right_kern(recent_plus_glyph, current_script_state, recent_subtype, lmt_math_state.size);
if (plus) {
halfword kern = tex_new_kern_node(plus, math_shape_kern_subtype);
tex_attach_attribute_list_copy(kern, current);
diff --git a/source/luametatex/source/tex/texnodes.h b/source/luametatex/source/tex/texnodes.h
index cb666f874..f8766c430 100644
--- a/source/luametatex/source/tex/texnodes.h
+++ b/source/luametatex/source/tex/texnodes.h
@@ -1791,6 +1791,7 @@ typedef enum noad_options {
# define noad_option_stretch 0x1000000000
# define noad_option_shrink 0x2000000000
# define noad_option_center 0x4000000000
+# define noad_option_scale 0x8000000000
# define has_option(a,b) (((a) & (b)) == (b))
# define unset_option(a,b) ((a) & ~(b))
@@ -1849,7 +1850,11 @@ inline static int has_noad_no_script_option(halfword n, halfword option)
# define has_noad_option_source_on_nucleus(a) (has_option(noad_options(a), noad_option_source_on_nucleus))
# define has_noad_option_fixed_super_or_sub_script(a) (has_option(noad_options(a), noad_option_fixed_super_or_sub_script))
# define has_noad_option_fixed_super_and_sub_script(a) (has_option(noad_options(a), noad_option_fixed_super_and_sub_script))
+# define has_noad_option_stretch(a) (has_option(noad_options(a), noad_option_stretch))
+# define has_noad_option_shrink(a) (has_option(noad_options(a), noad_option_shrink))
# define has_noad_option_auto_base(a) (has_option(noad_options(a), noad_option_auto_base))
+# define has_noad_option_center(a) (has_option(noad_options(a), noad_option_center))
+# define has_noad_option_scale(a) (has_option(noad_options(a), noad_option_scale))
/*tex
In the meantime the codes and subtypes are in sync. The variable component does not really
diff --git a/source/luametatex/source/tex/textypes.h b/source/luametatex/source/tex/textypes.h
index 399839227..c4f917d4f 100644
--- a/source/luametatex/source/tex/textypes.h
+++ b/source/luametatex/source/tex/textypes.h
@@ -576,7 +576,7 @@ typedef union tokenword {
# define stp_language_size 250
/*tex
- Units. At some point these will be used in texscanning and lmtexlib.
+ Units. At some point these will be used in texscanning and lmtexlib (3 times replacement).
*/
@@ -616,6 +616,10 @@ typedef union tokenword {
# define ts_numerator 4588 // tove
# define ts_denonimator 645
+# define eu_min_factor 1
+# define eu_max_factor 50
+# define eu_def_factor 10
+
/*tex
These are used in the code, so when we want them to adapt, which is needed when we make them