summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luaotfload/fontloader-util-fil.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/fontloader-util-fil.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luaotfload/fontloader-util-fil.lua29
1 files changed, 6 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-util-fil.lua b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-util-fil.lua
index d568a2e1fd0..9f96a01b911 100644
--- a/Master/texmf-dist/tex/luatex/luaotfload/fontloader-util-fil.lua
+++ b/Master/texmf-dist/tex/luatex/luaotfload/fontloader-util-fil.lua
@@ -6,6 +6,7 @@ if not modules then modules = { } end modules ['util-fil'] = {
license = "see context related readme files"
}
+local tonumber = tonumber
local byte = string.byte
local char = string.char
@@ -196,41 +197,23 @@ function files.readinteger4le(f)
end
end
--- function files.readfixed2(f)
--- local a, b = byte(f:read(2),1,2)
--- if a >= 0x80 then
--- return (0x100 * a + b - 0x10000)/256.0
--- else
--- return (0x100 * a + b)/256.0
--- end
--- end
-
function files.readfixed2(f)
local a, b = byte(f:read(2),1,2)
if a >= 0x80 then
- return (a - 0x100) + b/0x100
+ tonumber((a - 0x100) .. "." .. b)
else
- return (a ) + b/0x100
+ tonumber(( a ) .. "." .. b)
end
end
--- (real) (n>>16) + ((n&0xffff)/65536.0))
-
--- function files.readfixed4(f)
--- local a, b, c, d = byte(f:read(4),1,4)
--- if a >= 0x80 then
--- return (0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000)/65536.0
--- else
--- return (0x1000000 * a + 0x10000 * b + 0x100 * c + d)/65536.0
--- end
--- end
+-- (real) (n>>16) + ((n&0xffff)/65536.0)) but no cast in lua (we could use unpack)
function files.readfixed4(f)
local a, b, c, d = byte(f:read(4),1,4)
if a >= 0x80 then
- return (0x100 * a + b - 0x10000) + (0x100 * c + d)/0x10000
+ tonumber((0x100 * a + b - 0x10000) .. "." .. (0x100 * c + d))
else
- return (0x100 * a + b ) + (0x100 * c + d)/0x10000
+ tonumber((0x100 * a + b ) .. "." .. (0x100 * c + d))
end
end