--- a/tex/context/base/mkxl/font-ttf.lmt	2026-10-05 16:25:37
+++ b/tex/context/base/mkxl/font-ttf.lmt	2026-10-05 16:25:49
@@ -58,6 +58,7 @@
 local readinteger       = streamreader.readinteger1
 local readcardinaltable = streamreader.readcardinaltable
 local readintegertable  = streamreader.readintegertable
+local readstring        = streamreader.readstring
 
 directives.register("fonts.streamreader",function()
 
@@ -75,6 +76,7 @@
     readinteger       = streamreader.readinteger1
     readcardinaltable = streamreader.readcardinaltable
     readintegertable  = streamreader.readintegertable
+    readstring        = streamreader.readstring
 
 end)
 
@@ -929,7 +931,13 @@
                 for i=1,nofcontours do
                     r = r + 1 result[r] = toshort(contours[i]-1)
                 end
-                r = r + 1 result[r] = s_zero -- no instructions
+                local instructions = shape.instructions
+                if instructions then
+                    r = r + 1 result[r] = toshort(#instructions)
+                    r = r + 1 result[r] = instructions
+                else
+                    r = r + 1 result[r] = s_zero -- no instructions
+                end
                 local points   = shape.points
                 local currentx = 0
                 local currenty = 0
@@ -1055,7 +1063,7 @@
 -- local flag_overlap_simple <const> = 0x40
 -- local flag_reserved       <const> = 0x80
 
-local function readglyph(f,nofcontours,glyphend) -- read deltas here, saves space
+local function readglyph(f,nofcontours,glyphend,keephints) -- read deltas here, saves space
     local points          = { }
  -- local instructions    = { }
     local contours        = { } -- readintegertable(f,nofcontours,short)
@@ -1076,7 +1084,12 @@
     if getposition(f) + nofinstructions > glyphend then
         return
     end
-    skipbytes(f,nofinstructions)
+    local instructions = false
+    if keephints and nofinstructions > 0 then
+        instructions = readstring(f,nofinstructions)
+    else
+        skipbytes(f,nofinstructions)
+    end
     -- Because flags can repeat we don't know the amount ... in fact this is not
     -- that efficient (small files but more mem). Why bother.
     --
@@ -1156,10 +1169,11 @@
         points[i][2] = y
     end
     return {
-        type      = "glyph",
-        points    = points,
-        contours  = contours,
-        nofpoints = nofpoints,
+        type         = "glyph",
+        points       = points,
+        contours     = contours,
+        nofpoints    = nofpoints,
+        instructions = instructions or nil,
      -- overlap   = hasoverlap or nil
     }
 end
@@ -1330,6 +1344,22 @@
             local nothing    = { 0, 0, 0, 0 }
             local shapes     = { }
             local loadshapes = specification.shapes or specification.instance or specification.streams
+            local tables     = fontdata.tables
+            local keephints  = specification.keephints and specification.streams
+                and not specification.instance and not tables.gvar and not tables.fvar
+            if keephints then
+                -- copied verbatim, as pdftex's writettf does; their instructions refer to point
+                -- numbers that repackpoints keeps, composites are flattened and lose theirs
+                local hinttables = { }
+                for _, tag in next, { "cvt", "fpgm", "prep" } do
+                    local t = tables[tag]
+                    if t and t.length > 0 then
+                        setposition(f,t.offset)
+                        hinttables[tag] = readstring(f,t.length)
+                    end
+                end
+                fontdata.hinttables = hinttables
+            end
             for index=0,nofglyphs-1 do
                 local location = locations[index]
                 local length   = locations[index+1] - location
@@ -1353,7 +1383,7 @@
                     elseif nofcontours == 0 then
                         shapes[index] = readnothing(f)
                     elseif nofcontours > 0 then
-                        shapes[index] = readglyph(f,nofcontours,glyphend)
+                        shapes[index] = readglyph(f,nofcontours,glyphend,keephints)
                     else
                         shapes[index] = readcomposite(f,glyphend)
                     end
--- a/tex/context/base/mkxl/font-shp.lmt	2026-10-05 16:25:37
+++ b/tex/context/base/mkxl/font-shp.lmt	2026-10-05 16:26:02
@@ -28,6 +28,13 @@
 
 directives.register("fonts.streams.compact", function(v) compact_streams = v end)
 directives.register("fonts.streams.pack",    function(v) pack_outlines   = v end)
+
+-- When embedding a static TrueType font, keep its hinting: the glyph instructions and the cvt, fpgm
+-- and prep tables (variable fonts and composites stay as they are). Off by default.
+
+local keep_hints = false
+
+directives.register("fonts.truetype.keephints", function(v) keep_hints = v end)
 
 local function packoutlines(data,makesequence)
     if not pack_outlines then
@@ -243,10 +250,11 @@
     local sub  = tonumber(sub)
     local data = nil
     if size > 0 and (kind == "otf" or kind == "ttf" or kind == "ttc") then
-        local hash = makehash(filename,sub,instance,extrahash)
+        local hints = keep_hints and kind ~= "otf"
+        local hash  = makehash(filename,sub,instance,hints and ((extrahash or "") .. "hinted") or extrahash)
         data = containers.read(cache,hash)
         if not data or data.time ~= time or data.size ~= size then
-            data = otf.readers.loadshapes(filename,sub,instance,true) -- how about extrahash
+            data = otf.readers.loadshapes(filename,sub,instance,true,hints) -- how about extrahash
             if data then
                 local glyphs  = data.glyphs
                 local streams = { }
--- a/tex/context/base/mkxl/lpdf-emb.lmt	2026-10-05 16:25:37
+++ b/tex/context/base/mkxl/lpdf-emb.lmt	2026-10-05 16:29:20
@@ -680,7 +680,7 @@
                 end
             end
             list[1] = concat(index)
-            local off = #list[1] + headof + 1 + 8
+            local off = headof + 1 + 8 -- headof is already a file offset (it includes the table directory)
             list = concat(list)
             local csum = (0xB1B0AFBA - checksum(list)) % 0x100000000
             list = sub(list,1,off-1) .. tocardinal4(csum) .. sub(list,off+4,#list)
@@ -791,6 +791,11 @@
                 tocardinal2(t.metricdataformat),
                 tocardinal2(n) -- t.nofmetrics
             }
+        end
+
+        tablewriters.raw = function(fontfile,tag,data) -- copied verbatim (keephints)
+            register(fontfile,tag)
+            fontfile[tag] = data
         end
 
         tablewriters.maxp = function(fontfile)
@@ -984,6 +989,16 @@
             tablewriters.vmtx(fontfile)
         end
         --
+        local hinttables = streams.hinttables -- only when fonts.truetype.keephints is enabled
+        if hinttables then
+            for _, tag in next, { "cvt", "fpgm", "prep" } do
+                local data = hinttables[tag]
+                if data then
+                    tablewriters.raw(fontfile,tag,data)
+                end
+            end
+        end
+        --
         local fontdata = makefontfile(fontfile)
         local fontmeta = makemetadata(fontfile)
         --
--- a/tex/context/base/mkiv/font-otr.lua	2026-10-05 16:25:37
+++ b/tex/context/base/mkiv/font-otr.lua	2026-10-05 16:25:49
@@ -2381,11 +2381,12 @@
 
 -- we need even less, but we can have a 'detail' variant
 
-function readers.loadshapes(filename,n,instance,streams)
+function readers.loadshapes(filename,n,instance,streams,keephints)
     local fontdata = loadfont {
-        filename = filename,
-        shapes   = true,
-        streams  = streams,
+        filename  = filename,
+        shapes    = true,
+        streams   = streams,
+        keephints = keephints,
         variable = true,
         subfont  = n,
         instance = instance,
@@ -2418,6 +2419,7 @@
         maximumprofile   = fontdata.maximumprofile,
         names            = fontdata.names,
         postscript       = fontdata.postscript,
+        hinttables       = fontdata.hinttables,
     } or {
         filename = filename,
         format   = "unknown",
