OSDN Git Service

luatexja-preset.sty: add settings for Yu Mincho and Yu Gothic (bundled with Win8.1).
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 26 Oct 2013 06:44:05 +0000 (15:44 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sat, 26 Oct 2013 06:44:05 +0000 (15:44 +0900)
src/addons/luatexja-preset.sty
src/ltj-setwidth.lua

index 0134a78..fbcfa45 100644 (file)
@@ -1,11 +1,12 @@
 % luatexja-preset.sty
-\ProvidesPackage{luatexja-preset}[2013/05/25 Japanese font presets]
+\ProvidesPackage{luatexja-preset}[2013/10/26 Japanese font presets]
 %% Sync with PXchfon 0.6a
 
 \RequirePackage{expl3}
 \RequirePackage{luatexja-fontspec}
 \ExplSyntaxOn
 
+%%%% message
 
 \bool_new:N \l_ltjpreset_bold_bool % bold
 \bool_set_false:N \l_ltjpreset_bold_bool
 
 % 漢字字形
 \tl_new:N \l_ltjpreset_kanji_shape_tl
-\DeclareOption{90jis}{  
-  \tl_set:Nn \l_ltjpreset_kanji_shape_tl { , CJKShape=JIS1990 }
-} % 90jis
-\DeclareOption{jis2004}{
-  \tl_set:Nn \l_ltjpreset_kanji_shape_tl { , CJKShape=JIS2004 }
-} % jis2004
+\DeclareOption{90jis}{  \tl_set:Nn \l_ltjpreset_kanji_shape_tl { , CJKShape=JIS1990 }} % 90jis
+\DeclareOption{jis2004}{\tl_set:Nn \l_ltjpreset_kanji_shape_tl { , CJKShape=JIS2004 }} % jis2004
 
 % font preset
 \bool_new:N \l_ltjpreset_office_bool  % MS Office の HG 系フォントを使っているか
 
 
 
-% kozuka
+% 小塚 (Adobe)
 \DeclareOption{kozuka-pro}{
   \ltjpreset_set_multi:n {
     KozMinPro-Regular.otf , KozMinPro-Bold.otf, % mc/m, mc/bx
   }
 }
 
-% hiragino
+% ヒラギノ (OSX)
 \DeclareOption{hiragino-pro}{
   \ltjpreset_set_multi:n {
     HiraMinPro-W3.otf      , HiraMinPro-W6.otf,   % mc/m, mc/bx
   }
 }
 
-% morisawa
+% モリサワ
 \DeclareOption{morisawa-pro}{
   \ltjpreset_set_multi:n {
     A-OTF-RyuminPro-Light.otf , A-OTF-FutoMinA101Pro-Bold.otf ,    % mc/m, mc/bx
   }
 }
 
+% 游明朝/游ゴシック (Win8.1)
+\DeclareOption{yu}{
+  \ltjpreset_set_multi:n {
+    yumin.ttf , yumindb.ttf ,     % mc/m, mc/bx
+    yugothic.ttf , yugothib.ttf , % gt/m, gt/bx (multiweight))
+    yugothic.ttf , yugothib.ttf , % gt/m (uni), gt/eb
+    yugothib.ttf                  % mg/m
+  }
+}
+
 
 % ipa, ipaex, ms
 \DeclareOption{ipa}{
 %%%% (丸)ゴシック体の設定: bold option もここで
 \int_compare:nTF { \l_ltjpreset_deluxe_int ==  2 } {
 %%% mg
 \newjfontfamily \mgfamily [
-      BoldFont = \ltjpreset_font_mg:, 
+ \newjfontfamily \mgfamily [
+      BoldFont = \ltjpreset_font_mg:,
       \tl_use:N \l_ltjpreset_add_features_tl
       \bool_if:NT \l_ltjpreset_noembed_bool { , NoEmbed }, 
       \tl_use:N \l_ltjpreset_add_features_tl 
     ] { \ltjpreset_font_mg: }
-  \DeclareTextFontCommand{\textmg}{\mgfamily}
-%%% gteb
+    \DeclareTextFontCommand{\textmg}{\mgfamily}
+%%% gt/eb
   \newjfontfamily \gtebfamily [
       BoldFont = \ltjpreset_font_gt_eb:, 
       \tl_use:N \l_ltjpreset_add_features_tl
 %%%% 実際の fontspec の呼びだし
 
 \defaultjfontfeatures{ Kerning=Off }
+
 \setmainjfont [ 
   BoldFont = \ltjpreset_font_mc_bx:
   \bool_if:NT \l_ltjpreset_noembed_bool { , NoEmbed }, 
   \tl_use:N \l_ltjpreset_add_features_tl 
 ] { \ltjpreset_font_gt_m: }
 
-
 \ExplSyntaxOff
 \endinput
\ No newline at end of file
index d20bb15..9b7f0e1 100644 (file)
@@ -51,7 +51,7 @@ do
 end
 local get_pr_begin_flag = get_pr_begin_flag
 
-head = nil
+head = nil;
 
 luatexbase.create_callback("luatexja.set_width", "data", 
                           function (fstable, fmtable, jchar_class) 
@@ -66,15 +66,17 @@ function capsule_glyph(p, dir, mode, met, class)
    if not char_data then return node_next(p) end
    local fwidth, pwidth = char_data.width, p.width
    fwidth = (fwidth ~= 'prop') and fwidth or pwidth
-   local fheight, fdepth = char_data.height, char_data.depth
    fshift.down = char_data.down; fshift.left = char_data.left
    fshift = luatexbase.call_callback("luatexja.set_width", fshift, met, class)
+   local fheight, fdepth = char_data.height, char_data.depth
+   fheight = (fheight ~= 'prop') and fheight or p.height
+   fdepth  = (fdepth  ~= 'prop') and fdepth  or p.depth 
    if (mode or pwidth ~= fwidth or p.height ~= fheight or p.depth ~= fdepth) then
       local y_shift, ca
          = - p.yoffset + (has_attr(p,attr_ykblshift) or 0), char_data.align
       local q; head, q = node.remove(head, p)
       p.yoffset, p.next = -fshift.down, nil
-      if total ~= 0 and ca~='left'  then
+      if ca~='left'  then
         p.xoffset = p.xoffset - fshift.left
            + (((ca=='right') and fwidth - pwidth) or round((fwidth - pwidth)*0.5))
       else
@@ -100,8 +102,9 @@ function set_ja_width(ahead, dir)
    local p = ahead; head  = ahead
    local m = false -- is in math mode?
    while p do
-      if (p.id==id_glyph) 
-      and ((has_attr(p, attr_icflag) or 0)%PROCESSED_BEGIN_FLAG)<=0 then
+      local pid = p.id
+      if (pid==id_glyph) 
+        and ((has_attr(p, attr_icflag) or 0)%PROCESSED_BEGIN_FLAG)<=0 then
       local pf = p.font
         if pf == has_attr(p, attr_curjfnt) then
            p = capsule_glyph(p, dir, false, ltjf_font_metric_table[pf], 
@@ -114,9 +117,9 @@ function set_ja_width(ahead, dir)
         m = (p.subtype==0); p = node_next(p)
       else
         if m then
-           if p.id==id_hlist or p.id==id_vlist then
+           if pid==id_hlist or pid==id_vlist then
               p.shift = p.shift + (has_attr(p,attr_yablshift) or 0)
-           elseif p.id==id_rule then
+           elseif pid==id_rule then
               local v = has_attr(p,attr_yablshift) or 0
               p.height = p.height - v; p.depth = p.depth + v 
            end