OSDN Git Service

Further optimization of mk_rml() for speed.
authorKazuki Maeda <kmaeda@users.sourceforge.jp>
Thu, 5 May 2011 09:25:44 +0000 (18:25 +0900)
committerKazuki Maeda <kmaeda@users.sourceforge.jp>
Thu, 5 May 2011 09:25:44 +0000 (18:25 +0900)
Trivial fix to test01-noembed.tex: Ryumin-Lightfile -> Ryumin-Light

src/luatexja-rmlgbm.lua
test/test01-noembed.pdf
test/test01-noembed.tex

index 1a7dbfc..8cace65 100644 (file)
@@ -1,7 +1,7 @@
 local rmlgbm_data = require('luatexja-rmlgbm-data')
+local cache_chars = { [655360] = rmlgbm_data.characters }
 
 local function mk_rml(name, size, id)
-
    local specification = fonts.define.analyze(name,size)
    specification = fonts.define.specify[':'](specification)
    local features = specification.features.normal
@@ -12,7 +12,8 @@ local function mk_rml(name, size, id)
       fontdata[k] = v
       cachedata[k] = v
    end
-
+   fontdata.characters = nil
+   cachedata.characters = nil
    fontdata.unicodes = nil
    fontdata.shared = nil
    cachedata.shared = {}
@@ -25,19 +26,19 @@ local function mk_rml(name, size, id)
    shared.processes, shared.features = fonts.otf.set_features(cachedata,fonts.define.check(features,fonts.otf.features.default))
    
    -- characters & scaling
-   local characters = {}
-   local orig_chars = rmlgbm_data.characters
    if size < 0 then size = -size * 655.36 end
    local scale = size / 655360
-   -- local size_cache = {}
-   for k, v in pairs(orig_chars) do
-      characters[k] = {}
-      characters[k].index = v.index
-      characters[k].width = v.width * scale
-      characters[k].tounicode = v.tounicode
+   if not cache_chars[size] then
+      cache_chars[size]  = {}
+      for k, v in pairs(cache_chars[655360]) do
+         cache_chars[size][k] = {}
+         cache_chars[size][k].index = v.index
+         cache_chars[size][k].width = v.width * scale
+         cache_chars[size][k].tounicode = v.tounicode
+      end
    end
-   fontdata.characters = characters
-   cachedata.characters = characters
+   fontdata.characters = cache_chars[size]
+   cachedata.characters = cache_chars[size]
 
    local parameters = {}
    for k, v in pairs(rmlgbm_data.parameters) do
index aa9c0fc..ab3a9e3 100644 (file)
Binary files a/test/test01-noembed.pdf and b/test/test01-noembed.pdf differ
index d670d8d..81e0393 100644 (file)
@@ -57,8 +57,8 @@
 \bigskip
 {\noindent\bf\tengt ■{\tt differentjfm}による挙動の違い}
 
-\jfont\tenMa={psft:Ryumin-Lightfile:jfm=ujis}
-\jfont\tenMb={psft:Ryumin-Lightfile:jfm=ujis;jfmvar=a}
+\jfont\tenMa={psft:Ryumin-Light:jfm=ujis}
+\jfont\tenMb={psft:Ryumin-Light:jfm=ujis;jfmvar=a}
 \jfont\tenGa={psft:GothicBBB-Medium:jfm=ujis} at 15pt
 \jfont\tenGb={psft:GothicBBB-Medium:jfm=ujis;jfmvar=a} at 15pt\relax