Closed aminophen closed 3 years ago
本来は jsclasses および jlreq の issue ですが,情報集約の為こちらに書きます。 @okumuralab @abenori
@FrankMittelbach ping on issue to track NFSS changes with platex
@davidcarlisle Thanks for the ping.
From here on, I'll try to post messages in English as far as possible. (When the content is too specific to JP developers, I'll post it in Japanese.)
@aminophen don't worry too much about the language, better to be inclusive with Japanese users to get issues sorted. If Frank and I can't follow with google translate then we can always ask for clarification.
@davidcarlisle ありがとうございます ;-)
@davidcarlisle どもありがとう for the ping
* TL2020 では mweights.sty が LaTeX2e カーネルに取り込まれるため,pLaTeX と jsclasses と jlreq を適切に改修すれば元の挙動に戻せるはず。
as far as I can see mweights is not implemented in jsarticle, is it? but jsarticle does alter \sffamily etc and this way now undoes some of the changes in the upcoming kernel. It would be helpful to understand what eactly is being done there. It looks to me as if a kanji family is maintained in parallel (which would make sense to me, so that when switching from say \rmfamily to \sffamily the kanji (and kana?) change from "normal" to "grotesk" (or something)?
providing some hook where this extra code could be added without the need to repeat the whole definition might be a good thing, so we should think about what would be best here ... advice welcome
@FrankMittelbach Thanks for your comments.
mweights is not implemented in jsarticle, is it?
No. (= Your understanding is correct.)
but jsarticle does alter \sffamily etc and this way now undoes some of the changes in the upcoming kernel.
Yes that's a concern of us.
It would be helpful to understand what exactly is being done there. It looks to me as if a kanji family is maintained in parallel (which would make sense to me, so that when switching from say \rmfamily to \sffamily the kanji (and kana?) change from "normal" to "grotesk" (or something)?
Right. The jsarticle's \sffamily is meant so that it changes both Latin and Japanese to San-Serif. Precisely, San-Serif in Japanese font is called "gothic" (or "gt" in shorthand), and Serif (normal) is called "mincho" (or "mc").
providing some hook where this extra code could be added without the need to repeat the whole definition might be a good thing,
That would be nice; 日本の皆様,いかがでしょうか? 良い方法の提案があればご意見をください。
The "up" warning problem is due the following line:
pldefs.ltx:34:\newcommand\kanjishapedefault{\updefault}
just change it to \newcommand\kanjishapedefault{n}
A redierection (which was also used in fonttext.ltx was never really sensible here and now it is wrong since updefault and ulcdefault point to "virtual" shapes that have no fonts directly associated with them.
(Note on jsarticle’s \sffamily
for the LaTeX team)
What makes the things complex is the fact that this kind of “synchronization of document families” is jsarticle’s choice and not that of PLaTeX kernel. The kernel does not redefine \sffamily
and users have to write \sffamily\gtfamily
to change everything to sans-serif. The jsarticle class has taken this choice because it is simply convenient and moreover it can better go along with other “pTeX-unaware” packages (that expect \sffamily
will change everything). There are several classes that have taken the same choice, whereas the other classes employ the original \sffamily
.
I see. So this makes a sensible hook even more desirable (then those classes can more easily adjust the the behavior of the commands. I'm currently looking at that and hope I'll have something for the -dev release we want to ship Monday or Tuesday
とりあえず、NFSSの仕様変更の内容についてまとめてみた。(日本語!)
①シリーズの実質的な多軸化
\DeclareFontSeriesChangeRule{<現シリーズ>}{<要求シリーズ>}{<新シリーズ>}{<代替シリーズ>}
: 「現在の\f@series
の値が<現シリーズ>
である時に\fontseries{<要求シリーズ>}
が実行されたら新しい\f@series
の値を<新シリーズ>
とする、ただしそれが使えない場合は<代替シリーズ>
とする」というシリーズ更新規則を宣言する。\fontseries{<要求シリーズ>}
:【変更】現存のシリーズ更新規則に従って、\f@series
の値を更新する。ただし「規則中の<新シリーズ>
と<代替シリーズ>
の何れも使えない場合」「該当する規則がない場合」は新しい\f@series
の値を<要求シリーズ>
とする。
m
”が削除される。\fontseriesforce{<シリーズ>}
: \f@series
の値を無条件に<シリーズ>
に更新する。※従来の\~series
命令はこの改修の影響は受けないはずだが、③の影響のため変更される。
②シリーズシェープの実質的な多軸化
\DeclareFontShapeChangeRule{<現シェープ>}{<要求シェープ>}{<新シェープ>}{<代替シェープ>}
: シェープ更新規則を宣言する。\DeclareFontSeriesChangeRule
のシェープ版。\fontshape{<要求シェープ>}
:【変更】現存のシェープ更新規則の規則に従って、\f@shape
の値を更新する。付帯規則も\fontseries
と同様。\fontshapeforce{<シェープ>}
: \f@shape
の値を無条件に<シェープ>
に更新する。\normalshape
: 要求シェープに\shapedefault
を指定した上でフォントを更新する。
\shapedefault
はn
でありこの場合はシェープが標準に戻る。\ulcshape
: 要求シェープに\ulcdefault
を指定した上でフォントを更新する。
ulc
は“upper- and lowercase”の略。\textulc
: \ulcshape
に対する引数型命令。\swshape
: 要求シェープに\swdefault
を指定した上でフォントを更新する。
\textsw
: \swshape
に対する引数型命令。\sscshape
: 要求シェープに\sscdefault
を指定した上でフォントを更新する。
ssc
シェープは「シェープ更新規則」には組み込まれていない。※従来の\~shape
命令はこの改修の影響は受けない。(ただし\updefault
の既定の値は変更されている。)
③総称ファミリごとの実シリーズ値の設定
\DeclareFontSeriesDefault[<総称ファミリ名>]{<総称シリーズ名>}{<シリーズ値>}
: 指定の総称ファミリについて、総称シリーズの実際のシリーズ値を<シリーズ値>
とする。
rm
・sf
・tt
の何れか。総称シリーズ名はbf
・md
の何れか。\DeclareFontSeriesDefault[YY]{XX}{ZZ}
は\XXseries@YY
をZZ
と定義する。\DeclareFontSeriesDefault{XX}{ZZ}
は\XXdefault
をZZ
と定義する。\XXseries@YY
(XX
は総称シリーズ名、YY
は総称ファミリ名): 総称ファミリYY
に対する総称シリーズXX
の実際のシリーズ値。\XXseries
(XX
は総称シリーズ名): 【変更】※以下の要領でフォントを変更する。
YY
について、現在の\f@family
が\YYdefault
の値と一致するなら、\XXseries@YY
を要求シリーズ名とする。\XXdefault
を要求シリーズ名とする。\YYfamily
(YY
は総称ファミリ名): 【変更】※以下の要領でフォントを変更する。
ZZ
とある総称シリーズ名XX
とについて、現在の\f@family
が\ZZdefault
の値と一致し、かつ現在の\f@series
が\XXseries@ZZ
の値または\XXdefault
の値に一致するなら、\f@series
を\XXseries@YY
に設定する。
\f@series
を直接書き換えていることに注意。\f@family
を\YYdefault
に設定する。④強調書体指定の一般化 ←とりあえず今は省略
⑤その他
\usefont{<エンコーディング>}{<ファミリ>}{<シリーズ>}{<シェープ>}
:【変更】※第3引数はシリーズ値、第4引数はシェープ値そのものを指定する。
\fontseries
・\fontshape
を使わずに\f@series
・\f@shape
を直接書き換えている。\normalfont
の実装は\usefont
を使っている。カーネルでの既定値
\fontseries
の引数)として正当なシリーズ値でないものも利用する: m?
など\fontshape
の引数)として正当なシェープ値でないものも利用する: up
などul
el
l
sl
m
sb
b
eb
ub
ec
c
sc
m
x
bx
lsc
m
の場合はそのm
を明示する: mx
lm
m
の場合は全体をm
とする: m
b
sc
m
の場合は他軸の位置に?
を補う: m?
?m
sc
ulc
とする。(※シェープ値ではない)it
sl
sc
sw
sw
はswash字形を表す。up
とする。(※シェープ値ではない)it
sw
sc
up
ulc
n
で両軸とも標準に変える: n
n
以外で両軸とも変更する場合は原則的に\fontshape
を2回使う(のだと思う)。
scit
up
およびulc
と他軸との組み合わせ(scup
やulcsl
など)は使えない。\~series@~
の値:
\bfseries@XX
はbx
。\mdseries@XX
はm
。\~default
の値:
\bfdefault
:【変更】b
(※元はbx
)\updefault
:【変更】up
(※元はn
)\ulcdefault
: ulc
\swdefault
: sw
\sscdefault
: ssc
\shapedefault
: 【変更】n
(※元は\updefault
)I have now reimplemented \sffamily and friends so tha tthey now look like this in the development branch:
\DeclareRobustCommand\sffamily{%
\not@math@alphabet\sffamily\mathsf
\prepare@family@series@update{sf}\sfdefault
\@sffamilyhook
\selectfont}
The \@sffamilyhook
where classes like jsarticle can add additional code without the need to alter the command itsell, i.e., via \@addtohook
(it is more less in the same place where current code is injected).
これが何らかの役に立つことを願っています。 おやすみなさい。
とりあえず、NFSSの仕様変更の内容についてまとめてみた。(日本語!)
nice summary. I have a few comments, but I'm too tired to write them up now.
試しに2通り実装してみました。なお,この機能は LaTeX2e 2020-02-02 pre-release-3 以降の「新 NFSS」が利用可能な場合のみ enable されます。
起動時のバナーは pLaTeX2e <2020-02-02>-pre-1
になります。
起動時のバナーは pLaTeX2e <2020-02-02>-pre-2
になります。
Candidate 2 の実装は,LuaTeX-ja の fafb8d6 と(\jttfamily はサポートしていないという点を除き)同等の実装です。
jsarticle.cls には現在,以下のように定義されています。
\DeclareRobustCommand\rmfamily
{\not@math@alphabet\rmfamily\mathrm
\romanfamily\rmdefault\kanjifamily\mcdefault\selectfont}
\DeclareRobustCommand\sffamily
{\not@math@alphabet\sffamily\mathsf
\romanfamily\sfdefault\kanjifamily\gtdefault\selectfont}
\DeclareRobustCommand\ttfamily
{\not@math@alphabet\ttfamily\mathtt
\romanfamily\ttdefault\kanjifamily\gtdefault\selectfont}
もし 'dev' を採用する場合は
\g@addto@macro\@rmfamilyhook{\kanjifamily\mcdefault}
\g@addto@macro\@sffamilyhook{\kanjifamily\gtdefault}
\g@addto@macro\@ttfamilyhook{\kanjifamily\gtdefault}
もし 'dev-j' を採用する場合は
\g@addto@macro\@rmfamilyhook{\prepare@family@series@update@kanji{mc}\mcdefault}
\g@addto@macro\@sffamilyhook{\prepare@family@series@update@kanji{gt}\gtdefault}
\g@addto@macro\@ttfamilyhook{\prepare@family@series@update@kanji{gt}\gtdefault}
に変更すればよくなります。
pLaTeX で和文 NFSS の新機能が実用されることはあまりないと思いますが,少なくとも「何もしない」という選択はあり得ません。つまり,少なくとも Candidate 1 は pLaTeX に確実に必要な変更です。(そうでなければ,pLaTeX が \fontseries と \fontshape の定義を上書きしてしまうので,LaTeX の新機能を破壊してしまいます。具体的には,\DeclareFontSeriesChangeRule や \DeclareFontShapeChangeRule によって作られた更新規則を無視することになる。)
論点は,Candidate 2 にまで踏み込むかどうかです。
どもありがとう for the efforts put into that. I agree that candidate 2 is probably something that is not going to be used much with Japanese fonts, but on the other hand I thought the same about Latin based fonts when I wrote NFSS initially and after a while I was proven wrong. Another advantage is that staying uniform in features has some merrits. As long as no family-specific series values are defined the defaults make the system behave as before so with candidate 2 you extend the possibilities but you don't loose anything.
@FrankMittelbach Thanks for your comments. I agree with you, so I will adopt the candidate 2 after confirming that it does not cause any compatibility issue with existing Japanese documents.
Now that LaTeX2e 2020-02-02 is released "official" (not "dev"), so I will make a release of pLaTeX2e as of 'dev-j' branch immediately.
https://github.com/texjporg/platex/blob/d93a652ca1f7abead5f6050e1e22cc10d4f67f97/plfonts.dtx#L2072
ここは、前にある\merge@kanji@series
と同じように
\begingroup\let\f@encoding\k@encoding\let\f@family\k@family
\maybe@load@fontshape\endgroup
なんじゃないですか?
指摘ありがとうございます。そのとおりです。 → 1c8facd7
(luatexja も同じミスがあったので修正された模様 → https://ja.osdn.net/projects/luatex-ja/scm/git/luatexja/commits/16d08fad502d01b3f1c2bbef50071547c3b4c3d0 )
See https://github.com/latex3/latex2e/commit/9a89f6b5be5b3dd522fe5db5520f4f421d6cb830 (\@defaultfamilyhook
will become available, renamed internal commands)
Again: https://github.com/latex3/latex2e/commit/c68b84b7d00ae4ad0fe6e15e397057bcb5f8fb5b
My expectation is that the PL2 will appear in a few days, if there are any comments on it they are (as always) very appreciated.
'latex277' ブランチで latex3/latex2e#277 への対策を始めました。
新しいNFSSでは、2種類の「シリーズ値」があるわけだけど:
\f@series
が保持する値(シリーズ値)\fonrseries
の引数になる値(要求シリーズ値)\bfdefault
とか\mdseries@rm
とかに入る値はどちらの種類のものなんだろう? 例えば、「medium weight, condensed width」を指定する場合はmc
とc
のどちらを使うべきなんだろう?
In the new NFSS, there are two types of “series values”:
\f@series
holds (series values).\fontseries
.(requested series values).Then, of which type is the value of \bfdefault
, \mdseries@rm
, etc.? For example, when you mean “medium weight, condensed width”, should you use mc
or c
?
thanks for the translation (makes it a bit easier than going back and forth between google translate and this page :-) ).
That is a seriously good question. And one that may have revealed a deficiency (or bug) but I have to think about it a bit longer.
My gut reaction would be to state that it should (or can) be the 要求シリーズ値, i.e. if you want to ensure that
\fontseries{sb}\selectfont ... \mdseries
as well as
\fontseries{sx}\selectfont ... \mdseries
both end up being "medium weight condensed width" (that is c
) then the correct value is mc
for \medium@rm
or \mddefault
because they are called via
\fontseries\mddefault
and are therefore "request series values" and only mc
resets the weight to medium + the width to condensed, while c
as "request series value" would not alter the weight .
The reason why I say there is a bug lurking is this line in \expand@font@defaults
:
\edef\mddef@ult{\mddefault}%
If \mddefault
is set to mc
then this gets stored in \mddef@ult
and is later tested against \f@series
which is never mc
but c
if we are currently typesetting in medium weight condensed width --- it is a real pain nowadays that LaTeX had so little memory when NFSS was initially designed that I had to save each and every token that I could.
This means that the test will always fail and thus make the detection "am I currently in the medium series in the current family?" wrong, while it may be right.
Without checking that this correct my guess is that in the end we need to have the following definition instead:
\def\expand@font@defaults{%
\edef\rmdef@ult{\rmdefault}%
\edef\sfdef@ult{\sfdefault}%
\edef\ttdef@ult{\ttdefault}%
\edef\bfdef@ult{\expandafter\series@drop@one@m\bfdefault mm\series@drop@one@m}%
\edef\mddef@ult{\expandafter\series@drop@one@m\mddefault mm\series@drop@one@m}%
\edef\famdef@ult{\familydefault}%
}
to make this work correctly. However, as I said, I need to think about this a bit further.
maybe I should have mentioned that it is is better not to directly set \mdseries@rm
but to use the new interface \DeclareFontSeriesDefault[rm]{md}{mc}
etc. At the moment the result is the same, but eventually the latter might do more than just setting the \...@rm
command.
See https://github.com/latex3/latex2e/issues/306; \bfseries
in plcore.ltx needs adapted.
If the request in this comment is accepted, then we can use the following patch
\let\fontseries@saved\fontseries
\def\pltx@patch@bfseries\not@math@alphabet#1#2#3\selectfont{%
\long\expandafter\def\csname bfseries \endcsname{%
\not@math@alphabet#1#2%
\let\fontseries\romanseries %%% \fontseries of pLaTeX tries to change both Latin and Japanese; here we want only Latin, so use \romanseries
#3%
\let\fontseries\fontseries@saved %%% recover
% changed \fontseries -> \kanjiseries
\ifx\k@family\mcdef@ult \kanjiseries\bfseries@mc
\else\ifx\k@family\gtdef@ult \kanjiseries\bfseries@gt
\else \kanjiseries\bfdefault
\fi\fi
\selectfont
}%
}
\expandafter\expandafter\expandafter\pltx@patch@bfseries\csname bfseries \endcsname
\g@addto@macro\reset@bfseries@family@default{%
\let\bfseries@mc\bfdef@ult
\let\bfseries@gt\bfdef@ult
}
instead of current method of "built-from-scratch redefinition" of \bfseries
using \DeclareRobustCommand
.
Done (957d587).
Done (957d587).
I'll alert you in case there is a name change of the hook(s)
@FrankMittelbach
I'll alert you in case there is a name change of the hook(s)
I appreciate your kindness ;-)
今度は latex3/latex2e#315 の対応で latex3/latex2e@3503b281381b56d1dd0d201b05884b242f9d71a6 の修正が入りました。
\expand@font@defaults
と \init@series@setup
の定義が変わるのですが,latex-dev と latex の両方を support するのは難しくなりました。 :-(
Am 14.04.20 um 14:12 schrieb Hironobu Yamashita:
|\expand@font@defaults| と |\init@series@setup| の定義が変わるのです が,latex-dev と latex の両方を support するのは難しくなりました。 :-(
what exactly are the difficulties? I may be able to do things differently if I know what is problematic or missing.
Note that I mean "難しくなりました" (= it becomes difficult) is not equal to "it's impossible" ;-)
In the current pLaTeX, we append to \expand@font@defaults
\edef\mcdef@ult{\mcdefault}%
\edef\gtdef@ult{\gtdefault}%
\edef\kanjidef@ult{\kanjifamilydefault}% <= !!
and we append to \init@series@setup
\ifx\kanjidef@ult\mcdef@ult \mcfamily % <= !!
\else\ifx\kanjidef@ult\gtdef@ult \gtfamily % <= !!
\fi\fi
both of which are based on the previous implementation of LaTeX 2020-02-02.
After the change latex3/latex2e@3503b28, I see that \init@series@setup
no longer executes \expand@font@defaults
and it executes \reset@font
instead.
For me the new code seems better, so I will have to think of detecting which code is used by LaTeX2e and conditionally appends suitable hooks to set \kanjiseriesdefault
(= Japanese font series default).
Am 14.04.20 um 14:36 schrieb Hironobu Yamashita:
Note that I mean "難しくなりました" (= it becomes difficult) is not equal to "it's impossible" ;-)
true :-) but I asked "what are the difficulties not what are the impossibilities" :-)
Mr. Google translated it correctly to "difficult"
After the change latex3/latex2e@3503b28 https://github.com/latex3/latex2e/commit/3503b28, I see that |\init@series@setup| no longer executes |\expand@font@defaults| and it executes |\reset@font| instead.
after thinking a bit about the edge case in 315 I realized that my solution before was unnecessarily complicated so I took \famdef@ult out and avoided unnecessarily calling \expand@font@defaults
For me the new code seems better, so I will have to think of detecting which code is used by LaTeX2e and conditionally appends suitable hooks to set |\kanjiseries@default| (= Japanese font series default).
well, think about it, and if it needs some extra hook somewhere to do it cleanly we can discuss if that can be offered, or how else it could be done properly.
sorry for making extra work here, I guess we will need a few more rounds to arrive at a stable and for all parties useful version, but I think we are getting there. It turns out to be more complicated than I hoped when trying to make the new stuff work well while supporting various legacy usages.
well, think about it, and if it needs some extra hook somewhere to do it cleanly we can discuss if that can be offered, or how else it could be done properly.
OK ;-)
sorry for making extra work here, I guess we will need a few more rounds to arrive at a stable and for all parties useful version, but I think we are getting there. It turns out to be more complicated than I hoped when trying to make the new stuff work well while supporting various legacy usages.
No problem at all, and thanks for the useful new stuff.
pLaTeX2e 2020-10-01 will use new hook management system to add codes into \bfseries etc, almost done.
latex3/latex2e リポジトリの develop branch を試し始めたのですが,
という単純なソースで
のように警告が出ます。
まだ全容はつかめていませんが,ltnews31.tex を読むと NFSS(LaTeX2e 式の欧文フォント選択システム)が大きく変わっているように思います。これは LaTeX2e 2020-02-02 として TeX Live 2020 pretest でリリースされる予定なので,対応を間に合わせる必要があります。
私が理解した範囲には,以下の変更が含まれます:
これが pLaTeX の日本語フォントと欧文フォントの両方を切り替えるルーチンにどう影響するかはまだ調査中です。ほかの変更点も追って調査します。