X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fltj-rmlgbm.lua;h=f7553d0ceb043567ae736a60d08c24629d962c4a;hb=cf51a2259a27eeed9a3d5d0c40c767a5e6bc403e;hp=b7e9d8f3d7225d92ce97a5c69e489c9e10248f47;hpb=1f6e2a583ebcd0f9c9ef3ae2941843adeca7aa50;p=luatex-ja%2Fluatexja.git diff --git a/src/ltj-rmlgbm.lua b/src/ltj-rmlgbm.lua index b7e9d8f..f7553d0 100644 --- a/src/ltj-rmlgbm.lua +++ b/src/ltj-rmlgbm.lua @@ -3,8 +3,7 @@ -- luatexbase.provides_module({ name = 'luatexja.rmlgbm', - date = '2013/03/17', - version = '0.4', + date = '2013/05/14', description = 'Definitions of non-embedded Japanese (or other CJK) fonts', }) module('luatexja.rmlgbm', package.seeall) @@ -120,6 +119,7 @@ do end function make_cid_font() local kx = cid_replace[cid_name] + if not kx then return end local k = { cidinfo = { ordering=cid_order, registry=cid_reg, supplement=kx[3] }, encodingbytes = 2, extend=1000, format = 'opentype', @@ -194,36 +194,36 @@ do k.characters[46].width = math.floor(655360/14); -- Standard fonts are ``seriffed''. table.tofile(savepath, k,'return', false, true, false ) + ltjb.package_info_no_line('luatexja', "saved :'" .. savepath .. "'", '') else - ltjb.package_warning('luatexja', - 'failed to save informations of non-embedded 2-byte fonts', '') + ltjb.package_warning_no_line('luatexja', "failed to save to '" .. savepath .. "'", '') end end end local make_cid_font = make_cid_font -- +local function cid_cache_load(fullpath) + cidfont_data[cid_name] = require(fullpath) + cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters } +end + local function read_cid_font() -- local v = "ltj-cid-" .. string.lower(cid_name) .. ".lua" local v = "ltj-cid-auto-" .. string.lower(cid_name) .. ".lua" - local localpath = file.join(path.localdir, v) - local systempath = file.join(path.systemdir, v) + local localpath = file.join(path.localdir .. '/luatexja', v) + local systempath = file.join(path.systemdir .. '/luatexja' , v) local kpsefound = kpse.find_file(v) if kpsefound and file.isreadable(kpsefound) then - cidfont_data[cid_name] = require(kpsefound) - cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters } + cid_cache_load(kpsefound) elseif file.isreadable(localpath) then - cidfont_data[cid_name] = require(localpath) - cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters } + cid_cache_load(localpath) elseif file.isreadable(systempath) then - cidfont_data[cid_name] = require(systempath) - cache_chars[cid_name] = { [655360] = cidfont_data[cid_name].characters } + cid_cache_load(systempath) + else + -- Now we must create the virtual metrics from CMap. + make_cid_font() end - -- Now we must create the virtual metrics from CMap. - ltjb.package_info('luatexja', - 'I try to generate informations of non-embedded 2-byte fonts...', '') - make_cid_font() - if cidfont_data[cid_name] then for i,v in pairs(cidfont_data[cid_name].characters) do if not v.width then v.width = 655360 end @@ -306,12 +306,12 @@ local function mk_rml(name, size, id) -- no embedding local var = '' - local s = string.match(specification.detail, 'slant=([+-]*[0-9]*%.[0-9]*)') - if s and e~=1 then + local s = string.match(specification.detail, 'slant=([+-]*%d*%.?%d)') + if s and e~=0 then s = s * 1000 var, fontdata.slant = var .. 's' .. tostring(s), s end - local e = string.match(specification.detail, 'extend=([+-]*[0-9]*%.[0-9]*)') + local e = string.match(specification.detail, 'extend=([+-]*%d*%.?%d)') if e and e~=1 then e = e * 1000 var, fontdata.extend = var .. 'x' .. tostring(e), e @@ -330,6 +330,11 @@ function font_callback(name, size, id, fallback) local s = "Adobe-Japan1-6" local basename = utf.sub(name,p+1) local p = utf.find(basename, ":") + local q = utf.find(basename, "/[BI][BI]?") + if q and p and q<=p then + basename = utf.gsub(basename, '/[BI][BI]?', '', 1) + p = utf.find(basename, ":") + end if p then local xname = utf.sub(basename, p+1) p = 1