local ltjr_cidfont_data = ltjr.cidfont_data
local ltjc_is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char
-local OTF = luatexja.userid_table.OTF
+luatexja.userid_table.OTF = luatexbase.newuserwhatsitid('char_by_cid', 'luatexja')
+luatexja.userid_table.VSR = luatexbase.newuserwhatsitid('replace_vs', 'luatexja')
+local OTF, VSR = luatexja.userid_table.OTF, luatexja.userid_table.VSR
local function get_ucs_from_rmlgbm(c)
local v = ltjr_cidfont_data["Adobe-Japan1"].resources.unicodes["Japan1." .. tostring(c)]
local v
while p do
if p.id==id_whatsit then
- if p.subtype==sid_user and p.user_id==OTF then
- local g = node_new(id_glyph)
- g.subtype = 0; g.char = p.value
- v = has_attr(p, attr_curjfnt); g.font = v
- set_attr(g, attr_curjfnt, v)
- v = has_attr(p, attr_yablshift)
- if v then
- set_attr(g, attr_yablshift, v)
- else
- unset_attr(g, attr_yablshift)
- end
- head = node_insert_after(head, p, g)
- head = node_remove(head, p)
- node_free(p); p = g
- end
+ if p.subtype==sid_user then
+ local puid = p.user_id
+ if puid==OTF or puid==VSR then
+ local g = node_new(id_glyph)
+ g.subtype = 0; g.char = p.value
+ v = has_attr(p, attr_curjfnt); g.font = v
+ set_attr(g, attr_curjfnt,
+ puid==OTF and v or 0)
+ -- VSR yields ALchar
+ v = has_attr(p, attr_yablshift)
+ if v then
+ set_attr(g, attr_yablshift, v)
+ else
+ unset_attr(g, attr_yablshift)
+ end
+ head = node_insert_after(head, p, g)
+ head = node_remove(head, p)
+ node_free(p); p = g
+ end
+ end
end
p = node_next(p)
end
end
-- 組版時
- local function ivs_jglyph(char, bp, pf)
+ local function ivs_jglyph(char, bp, pf, uid)
local p = node_new(id_whatsit,sid_user)
- p.user_id=OTF; p.type=100; p.value=char
+ p.user_id=uid; p.type=100; p.value=char
set_attr(p, attr_curjfnt, pf)
set_attr(p, attr_yablshift, has_attr(bp, attr_ykblshift) or 0)
return p
local pid = p.id
if pid==id_glyph then
local pf = p.font
- if (has_attr(p, attr_curjfnt) or 0) == pf then
- -- only works with JAchars
- local q = node_next(p) -- the next node of p
- if q and q.id==id_glyph then
- local qc = q.char
- if (qc>=0xFE00 and qc<=0xFE0F) or (qc>=0xE0100 and qc<0xE01F0) then
- -- q is a variation selector
- if qc>=0xE0100 then qc = qc - 0xE0100 end
- local pt = font_ivs_table[pf]
- pt = pt and pt[p.char]; pt = pt and pt[qc]
- head = node_remove(head,q)
- if pt then
- local np = ivs_jglyph(pt, p, pf)
- head = node_insert_after(head, p, np)
- head = node_remove(head,p)
- p = np
- end
+ local q = node_next(p) -- the next node of p
+ if q and q.id==id_glyph then
+ local qc = q.char
+ if (qc>=0xFE00 and qc<=0xFE0F) or (qc>=0xE0100 and qc<0xE01F0) then
+ -- q is a variation selector
+ if qc>=0xE0100 then qc = qc - 0xE0100 end
+ local pt = font_ivs_table[pf]
+ pt = pt and pt[p.char]; pt = pt and pt[qc]
+ head = node_remove(head,q)
+ if pt then
+ local np = ivs_jglyph(pt, p, pf,
+ (has_attr(p,attr_curjfnt) or 0)==pf and OTF or VSR)
+ head = node_insert_after(head, p, np)
+ head = node_remove(head,p)
+ p = np
end
end
end
\def\ltjlistingsvsstdcmd#1{\@tempdima=\f@size pt%
\smash{\raisebox{.35\@tempdima}{\tt%
\fboxsep=.1\@tempdima\fbox{\fontsize{.5\@tempdima}{\z@}\selectfont
- \oalign{\hss VS\hss\crcr#1\crcr}}}}}
+ \oalign{\hss VS\hss\crcr\hss#1\hss\crcr}}}}}
\def\ltj@lst@vscmd{\ltjlistingsvsstdcmd}
% override \lst@FillFixed@
\fi
}
+% Variation Selector
+\def\ltj@lst@ProcessVS#1{%
+ \lst@whitespacefalse
+ \if@ltj@lst@vsraw
+ \lst@Append#1\advance\lst@length\m@ne
+ \else
+ \lst@TrackNewLines\lst@OutputLostSpace \lst@PrintToken
+ \setbox\@tempboxa\hbox to 2\lst@width{\hss
+ \expandafter\expandafter\expandafter\ltj@lst@vscmd
+ \expandafter{\the\numexpr`#1-"FDFF\relax}%"
+ \hss}%
+ \lst@CalcLostSpaceAndOutput\lst@whitespacefalse
+ \fi
+}
+
% 半角カナ,異体字セレクタはアクティブ化
\def\ltj@@listing@jpsetN#1#2#3{% for (not large) range
}
\@temptokena{}
\ltj@@listing@jpsetN{65377}{65439}{\ltj@lst@ProcessJALetterHalf}
+\ltj@@listing@jpsetN{65024}{65039}{\ltj@lst@ProcessVS}
\ltj@@listing@jpsetN{917760}{917999}{\ltj@lst@ProcessIVS}
\xdef\ltj@@listing@jpcmd{\the\@temptokena}\@temptokena{}
\catcode"FFFFF=13%"
\SetCatcodeRange{"FF61}{"FF9F}{13}% 半角カナ
\SetCatcodeRange{"E0100}{"E01EF}{13}% 漢字用異体字セレクタ
+ \SetCatcodeRange{"FE00}{"FE0F}{13}% Variation Selector
}
% We redefine \lst@BeginDropInput, since now we have
\fi}%
\lst@lAddTo\lst@PreGotoTabStop{\lst@WFAppend{^^I}}%
\lst@lAddTo\lst@ProcessSpace{\lst@WFAppend{ }}%
- \def\ltj@lst@ProcessIVS##1{\lst@whitespacefalse\lst@Append##1}
+ \def\ltj@lst@ProcessIVS##1{\lst@whitespacefalse\lst@Append##1}%
+ \def\ltj@lst@ProcessVS##1{\lst@whitespacefalse\lst@Append##1}%
\let\lst@DeInit\lst@WFDeInit
\let\lst@MProcessListing\lst@WFMProcessListing
\lst@WFifopen\else