Created
June 10, 2026 15:45
-
-
Save yarakos95/727db63152a2a7fa0a6c0b2c9ce99156 to your computer and use it in GitHub Desktop.
japanese-otfパッケージの `\UTF` と `\CID` を拡張して、otfパッケージが提供する7書体以外の論理フォントに対応する[LaTeX]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \msg_new:nnn { japanese-otf-ext } { no exist logical font } | |
| { The~#1~virtual~font~configuration~corresponding~to~the~specified~logical~font~`#2'~does~not~exist. } | |
| \prop_new:N \g__UTF_family_prop | |
| \NewDocumentCommand{ \SetUTFfamily }{ >{\TrimSpaces} m >{\TrimSpaces} m } | |
| { | |
| \prop_put:Nen \g__UTF_family_prop { #1 } { #2 } | |
| } | |
| \SetUTFfamily{ \mcdefault }{ utfj } | |
| \if@deluxe | |
| \SetUTFfamily{ \gtdefault }{ utfjg } | |
| \SetUTFfamily{ \mgdefault }{ utfjmg } | |
| \else | |
| \SetUTFfamily{ \gtdefault }{ utfj } | |
| \fi | |
| \let\@@UTF\UTF | |
| \RenewDocumentCommand{ \UTF }{ m } | |
| { | |
| \group_begin: | |
| \prop_get:NeNTF \g__UTF_family_prop { \k@family } \l_tmpa_tl | |
| { | |
| \if@deluxe\else | |
| \str_compare:eNeT { \k@family } = { \gtdefault } | |
| { \bfseries } | |
| \fi | |
| \kanjifamily{ \l_tmpa_tl } | |
| \set@character@="#1 | |
| } | |
| { \msg_warning:nnne { japanese-otf-ext } { no exist logical font } { UTF } \k@family } | |
| \group_end: | |
| } | |
| \prop_new:N \g__CID_family_prop | |
| \NewDocumentCommand{ \SetCIDfamily }{ >{\TrimSpaces} m >{\TrimSpaces} m } | |
| { | |
| \prop_put:Nen \g__CID_family_prop { #1 } { #2 } | |
| } | |
| \SetCIDfamily{ \mcdefault }{ cidj } | |
| \if@deluxe | |
| \SetCIDfamily{ \gtdefault }{ cidjg } | |
| \SetCIDfamily{ \mgdefault }{ cidjmg } | |
| \else | |
| \SetCIDfamily{ \gtdefault }{ cidj } | |
| \fi | |
| \let\@@CID\CID | |
| \RenewDocumentCommand{ \CID }{ m } | |
| { | |
| \group_begin: | |
| \prop_get:NeNTF \g__CID_family_prop { \k@family } \l_tmpa_tl | |
| { | |
| \if@deluxe\else | |
| \str_compare:eNeT { \k@family } = { \gtdefault } | |
| { \bfseries } | |
| \fi | |
| \kanjifamily{ \l_tmpa_tl } | |
| \set@character@=#1 | |
| } | |
| { \msg_warning:nnne { japanese-otf-ext } { no exist logical font } { CID } \k@family } | |
| \group_end: | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
japanese-otfパッケージでは
\UTFおよび\CIDが提供されているが、これらのコマンドによって出力される文字に割り当てられる論理フォントは\mcfamily、\gtfamily、\mgfamilyに限られる。そのため、新たな論理フォントを追加した場合、必要な仮想フォントを用意して利用できるようにしても、実際に出力される文字に対応することは無い。
このコードスニペットでは、以下の 2 つのコマンドを提供することで、新たな論理フォントに対してもそのフォントでの文字の出力を可能にする。
\SetUTFfamily{<論理フォント名>}{<UTF用の論理フォント名>}\SetCIDfamily{<論理フォント名>}{<CID用の論理フォント名>}例えば、
\hogedefaultのような論理フォント hoge を作成し、それに対応した UTF および CID 用の論理フォントhogeutf、hogecidが構成されているとする。このとき、上記のコードスニペットに加えて以下を追加することで、
\UTFおよび\CIDに論理フォント hoge が割り当てられるようになる。