summaryrefslogtreecommitdiff
path: root/tex/context/base/font-map.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/font-map.lua')
-rw-r--r--tex/context/base/font-map.lua35
1 files changed, 20 insertions, 15 deletions
diff --git a/tex/context/base/font-map.lua b/tex/context/base/font-map.lua
index 685f9beea..f9e52c10a 100644
--- a/tex/context/base/font-map.lua
+++ b/tex/context/base/font-map.lua
@@ -11,6 +11,7 @@ local tonumber = tonumber
local match, format, find, concat, gsub, lower = string.match, string.format, string.find, table.concat, string.gsub, string.lower
local P, R, S, C, Ct, Cc, lpegmatch = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Ct, lpeg.Cc, lpeg.match
local utfbyte = utf.byte
+local floor = math.floor
local trace_loading = false trackers.register("fonts.loading", function(v) trace_loading = v end)
local trace_mapping = false trackers.register("fonts.mapping", function(v) trace_unimapping = v end)
@@ -65,25 +66,27 @@ local function makenameparser(str)
end
end
---~ local parser = mappings.makenameparser("Japan1")
---~ local parser = mappings.makenameparser()
---~ local function test(str)
---~ local b, a = lpegmatch(parser,str)
---~ print((a and table.serialize(b)) or b)
---~ end
---~ test("a.sc")
---~ test("a")
---~ test("uni1234")
---~ test("uni1234.xx")
---~ test("uni12349876")
---~ test("index1234")
---~ test("Japan1.123")
+-- local parser = mappings.makenameparser("Japan1")
+-- local parser = mappings.makenameparser()
+-- local function test(str)
+-- local b, a = lpegmatch(parser,str)
+-- print((a and table.serialize(b)) or b)
+-- end
+-- test("a.sc")
+-- test("a")
+-- test("uni1234")
+-- test("uni1234.xx")
+-- test("uni12349876")
+-- test("index1234")
+-- test("Japan1.123")
local function tounicode16(unicode)
if unicode < 0x10000 then
return format("%04X",unicode)
+ elseif unicode < 0x1FFFFFFFFF then
+ return format("%04X%04X",floor(unicode/1024),unicode%1024+0xDC00)
else
- return format("%04X%04X",unicode/1024+0xD800,unicode%1024+0xDC00)
+ report_fonts("can't convert %s into tounicode",unicode)
end
end
@@ -93,8 +96,10 @@ local function tounicode16sequence(unicodes)
local unicode = unicodes[l]
if unicode < 0x10000 then
t[l] = format("%04X",unicode)
+ elseif unicode < 0x1FFFFFFFFF then
+ t[l] = format("%04X%04X",floor(unicode/1024),unicode%1024+0xDC00)
else
- t[l] = format("%04X%04X",unicode/1024+0xD800,unicode%1024+0xDC00)
+ report_fonts ("can't convert %s into tounicode",unicode)
end
end
return concat(t)