diff options
author | Karl Berry <karl@freefriends.org> | 2014-05-13 22:13:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-05-13 22:13:08 +0000 |
commit | 8ed901e81f474c7cf2946183f99b5836d40ffcd7 (patch) | |
tree | 0022083d26affb19815426f497b91ad443d74ebe /Master/texmf-dist/tex/luatex/luatexko/luatexko.sty | |
parent | bd7687e8abb5975905db822498e640ca7e2e1b2c (diff) |
luatexko (11may14)
git-svn-id: svn://tug.org/texlive/trunk@34018 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexko/luatexko.sty')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luatexko/luatexko.sty | 537 |
1 files changed, 340 insertions, 197 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty index 5d6d6d69fa8..a34b53bae9a 100644 --- a/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty +++ b/Master/texmf-dist/tex/luatex/luatexko/luatexko.sty @@ -1,6 +1,6 @@ % luatexko.sty % -% Copyright (c) 2013 Dohyun Kim <nomos at ktug org> +% Copyright (c) 2013-2014 Dohyun Kim <nomos at ktug org> % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c @@ -22,162 +22,282 @@ \expandafter\endinput \fi -\ProvidesPackage{luatexko}[2014/01/15 v1.4 Typesetting Korean with LuaLaTeX] -\RequirePackage{fontspec} -\RequirePackage{luatexko-core} - -%% fontspec Korean options -\ExplSyntaxOn - -\DeclareDocumentCommand \newhangulfontfeature {mmmm} - { - \fontspec_define_font_feature:n {#1} - \keys_define:nn {fontspec} - { - #1 .default:n = {#3} , - #1 / unknown .code:n = { - \fontspec_update_fontid:n {#2:##1} - \fontspec_update_featstr:n {#2=##1}#4 - } - } - } - -\fontspec_define_font_feature:n {YetHangul} -\keys_define:nn {fontspec} - { - YetHangul .default:n = {On} , - YetHangul / On .code:n = { - \fontspec_update_fontid:n {yethangul:on} - \fontspec_update_featstr:n {script=hang;+ccmp;+ljmo;+vjmo;+tjmo} - } , - YetHangul / Off .code:n = { - \fontspec_update_fontid:n {yethangul:off} - \fontspec_update_featstr:n {-ljmo;-vjmo;-tjmo} - } - } - -\ExplSyntaxOff - -\newhangulfontfeature{InterHangul}{interhangul}{0}{} -\newhangulfontfeature{InterLatinCJK}{interlatincjk}{0}{} -\newhangulfontfeature{PunctRaise}{punctraise}{0}{} -\newhangulfontfeature{CharRaise}{charraise}{0}{} -\newhangulfontfeature{Protrusion}{protrusion}{default}{\aftergroup\pdfprotrudechars\aftergroup\tw@} -\newhangulfontfeature{Expansion}{expansion}{default}{\aftergroup\pdfadjustspacing\aftergroup\tw@} - -%% macros for Korean fonts -\protected\def\setmainhangulfont{\newfontfamily\serifhangul@font} -\protected\def\setmainhanjafont {\newfontfamily\serifhanja@font} -\protected\def\setmainfallbackfont{\newfontfamily\seriffallback@font} -\protected\def\setsanshangulfont{\newfontfamily\sanshangul@font} -\protected\def\setsanshanjafont {\newfontfamily\sanshanja@font} -\protected\def\setsansfallbackfont{\newfontfamily\sansfallback@font} -\protected\def\setmonohangulfont{\newfontfamily\monohangul@font} -\protected\def\setmonohanjafont {\newfontfamily\monohanja@font} -\protected\def\setmonofallbackfont{\newfontfamily\monofallback@font} - -\protected\def\newhangulfontfamily#1{% - \protected\def#1{\expandafter\let\expandafter\hangul@font - \csname luatexko@\string#1\endcsname - \luatexko@hangul@selectfont}\expandafter\newfontfamily - \csname luatexko@\string#1\endcsname} -\protected\def\newhanjafontfamily#1{% - \protected\def#1{\expandafter\let\expandafter\hanja@font - \csname luatexko@\string#1\endcsname - \luatexko@hanja@selectfont}\expandafter\newfontfamily - \csname luatexko@\string#1\endcsname} -\protected\def\newfallbackfontfamily#1{% - \protected\def#1{\expandafter\let\expandafter\fallback@font - \csname luatexko@\string#1\endcsname - \luatexko@fallback@selectfont}\expandafter\newfontfamily - \csname luatexko@\string#1\endcsname} +\ProvidesPackage{luatexko}[2014/05/11 v1.5 Typesetting Korean with LuaLaTeX] -\protected\def\newhangulfontface#1{% - \protected\def#1{\expandafter\let\expandafter\hangul@font - \csname luatexko@\string#1\endcsname - \luatexko@hangul@selectfont}\expandafter\newfontface - \csname luatexko@\string#1\endcsname} -\protected\def\newhanjafontface#1{% - \protected\def#1{\expandafter\let\expandafter\hanja@font - \csname luatexko@\string#1\endcsname - \luatexko@hanja@selectfont}\expandafter\newfontface - \csname luatexko@\string#1\endcsname} -\protected\def\newfallbackfontface#1{% - \protected\def#1{\expandafter\let\expandafter\fallback@font - \csname luatexko@\string#1\endcsname - \luatexko@fallback@selectfont}\expandafter\newfontface - \csname luatexko@\string#1\endcsname} +%% package options +\newif\if@hangul +\newif\if@hanja +\newif\if@unfonts +\newif\if@luatexko@loadfontspec\@luatexko@loadfontspectrue +\DeclareOption{hangul}{\@hangultrue} +\DeclareOption{hanja}{\@hangultrue\@hanjatrue} +\DeclareOption{unfonts}{\@unfontstrue} +\DeclareOption{nofontspec}{\@luatexko@loadfontspecfalse} +\ProcessOptions\relax -\protected\def\hangulfontspec#1#{% - \def\luatexko@fontspec@temp{#1}\hangulfontspec@} -\def\hangulfontspec@#1{% - \expandafter\newfontfamily\expandafter\hangul@font\luatexko@fontspec@temp{#1}% - \luatexko@hangul@selectfont\ignorespaces} -\let\adhochangulfont\hangulfontspec -\protected\def\hanjafontspec#1#{% - \def\luatexko@fontspec@temp{#1}\hanjafontspec@} -\def\hanjafontspec@#1{% - \expandafter\newfontfamily\expandafter\hanja@font\luatexko@fontspec@temp{#1}% - \luatexko@hanja@selectfont\ignorespaces} -\let\adhochanjafont\hanjafontspec -\protected\def\fallbackfontspec#1#{% - \def\luatexko@fontspec@temp{#1}\fallbackfontspec@} -\def\fallbackfontspec@#1{% - \expandafter\newfontfamily\expandafter\fallback@font\luatexko@fontspec@temp{#1}% - \luatexko@fallback@selectfont\ignorespaces} -\let\adhocfallbackfont\fallbackfontspec +\if@luatexko@loadfontspec + %% euenc redefines \f@size by \DeclareErrorFont. sigh + \let\luatexko@f@size\f@size + \RequirePackage{fontspec} + \let\f@size\luatexko@f@size +\fi -% add{hangul/hanja}fontfeature -\protected\def\addhangulfontfeature#1{% - \begingroup - \check@hangul@family - \ifdefined\hangul@font\hangul@font\fi\addfontfeature{#1}% - \global\let\luatexko@fontspec@temp\f@family - \endgroup - \def\hangul@font{\fontfamily\luatexko@fontspec@temp\selectfont}% - \luatexko@hangul@selectfont \ignorespaces} -\let\addhangulfontfeatures\addhangulfontfeature -\protected\def\addhanjafontfeature#1{% - \begingroup - \check@hanja@family - \ifdefined\hanja@font\hanja@font\fi\addfontfeature{#1}% - \global\let\luatexko@fontspec@temp\f@family - \endgroup - \def\hanja@font{\fontfamily\luatexko@fontspec@temp\selectfont}% - \luatexko@hanja@selectfont \ignorespaces} -\let\addhanjafontfeatures\addhanjafontfeature -\protected\def\addfallbackfontfeature#1{% - \begingroup - \check@fallback@family - \ifdefined\fallback@font\fallback@font\fi\addfontfeature{#1}% - \global\let\luatexko@fontspec@temp\f@family - \endgroup - \def\fallback@font{\fontfamily\luatexko@fontspec@temp\selectfont}% - \luatexko@fallback@selectfont \ignorespaces} -\let\addfallbackfontfeatures\addfallbackfontfeature +\RequirePackage{luatexko-core} -% check hangul/hanja family -\def\check@hangul@family{% - \unless\ifdefined\hangul@font - \ifx\f@family\sfdefault \let\hangul@font\sanshangul@font - \else\ifx\f@family\ttdefault \let\hangul@font\monohangul@font - \else \let\hangul@font\serifhangul@font - \fi\fi\fi -} -\def\check@hanja@family{% - \unless\ifdefined\hanja@font - \ifx\f@family\sfdefault \let\hanja@font\sanshanja@font - \else\ifx\f@family\ttdefault \let\hanja@font\monohanja@font - \else \let\hanja@font\serifhanja@font - \fi\fi\fi -} -\def\check@fallback@family{% - \unless\ifdefined\fallback@font - \ifx\f@family\sfdefault \let\fallback@font\sansfallback@font - \else\ifx\f@family\ttdefault \let\fallback@font\monofallback@font - \else \let\fallback@font\seriffallback@font - \fi\fi\fi -} +\if@luatexko@loadfontspec + %% fontspec Korean options + \newfontfeature{YetHangul}{script=hang} + \newfontfeature{InterHangul}{interhangul=#1} + \newfontfeature{InterLatinCJK}{interlatincjk=#1} + \newfontfeature{PunctRaise}{punctraise=#1} + \newfontfeature{CharRaise}{charraise=#1} + \ExplSyntaxOn + \DeclareDocumentCommand \newhangulfontfeature {mmmm} + { + \keys_define:nn { fontspec } + { + #1 .code:n = + { + \fontspec_update_featstr:n {#2=##1} + #4 + }, + #1 .default:n = {#3} + } + } + \newhangulfontfeature{Protrusion}{protrusion}{default} + {\aftergroup\pdfprotrudechars\aftergroup\tw@} + \newhangulfontfeature{Expansion}{expansion}{default} + {\aftergroup\pdfadjustspacing\aftergroup\tw@} + %% macros for Korean fonts + \DeclareDocumentCommand \setmainhangulfont { O{} m } + { + \newfontfamily \serifhangul@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \rmdefault + { + \cs_set_eq:NN \hangul@font \serifhangul@font + \luatexko@hangul@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \setmainhanjafont { O{} m } + { + \newfontfamily \serifhanja@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \rmdefault + { + \cs_set_eq:NN \hanja@font \serifhanja@font + \luatexko@hanja@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \setmainfallbackfont { O{} m } + { + \newfontfamily \seriffallback@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \rmdefault + { + \cs_set_eq:NN \fallback@font \seriffallback@font + \luatexko@fallback@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \setsanshangulfont { O{} m } + { + \newfontfamily \sanshangul@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \sfdefault + { + \cs_set_eq:NN \hangul@font \sanshangul@font + \luatexko@hangul@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \setsanshanjafont { O{} m } + { + \newfontfamily \sanshanja@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \sfdefault + { + \cs_set_eq:NN \hanja@font \sanshanja@font + \luatexko@hanja@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \setsansfallbackfont { O{} m } + { + \newfontfamily \sansfallback@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \sfdefault + { + \cs_set_eq:NN \fallback@font \sansfallback@font + \luatexko@fallback@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \setmonohangulfont { O{} m } + { + \newfontfamily \monohangul@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \ttdefault + { + \cs_set_eq:NN \hangul@font \monohangul@font + \luatexko@hangul@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \setmonohanjafont { O{} m } + { + \newfontfamily \monohanja@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \ttdefault + { + \cs_set_eq:NN \hanja@font \monohanja@font + \luatexko@hanja@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \setmonofallbackfont { O{} m } + { + \newfontfamily \monofallback@font [#1] {#2} + \str_if_eq_x:nnT \familydefault \ttdefault + { + \cs_set_eq:NN \fallback@font \monofallback@font + \luatexko@fallback@selectfont + } + \ignorespaces + } + \DeclareDocumentCommand \newhangulfontfamily { m O{} m } + { + \exp_after:wN \newfontfamily + \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3} + \DeclareRobustCommand #1 + { + \cs_set_eq:Nc \hangul@font { luatexkofont@ \token_to_str:N #1 } + \luatexko@hangul@selectfont + } + } + \DeclareDocumentCommand \newhanjafontfamily { m O{} m } + { + \exp_after:wN \newfontfamily + \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3} + \DeclareRobustCommand #1 + { + \cs_set_eq:Nc \hanja@font { luatexkofont@ \token_to_str:N #1 } + \luatexko@hanja@selectfont + } + } + \DeclareDocumentCommand \newfallbackfontfamily { m O{} m } + { + \exp_after:wN \newfontfamily + \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3} + \DeclareRobustCommand #1 + { + \cs_set_eq:Nc \fallback@font { luatexkofont@ \token_to_str:N #1 } + \luatexko@fallback@selectfont + } + } + \DeclareDocumentCommand \newhangulfontface { m O{} m } + { + \exp_after:wN \newfontface + \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3} + \DeclareRobustCommand #1 + { + \cs_set_eq:Nc \hangul@font { luatexkofont@ \token_to_str:N #1 } + \luatexko@hangul@selectfont + } + } + \DeclareDocumentCommand \newhanjafontface { m O{} m } + { + \exp_after:wN \newfontface + \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3} + \DeclareRobustCommand #1 + { + \cs_set_eq:Nc \hanja@font { luatexkofont@ \token_to_str:N #1 } + \luatexko@hanja@selectfont + } + } + \DeclareDocumentCommand \newfallbackfontface { m O{} m } + { + \exp_after:wN \newfontface + \cs:w luatexkofont@ \token_to_str:N #1 \cs_end: [#2] {#3} + \DeclareRobustCommand #1 + { + \cs_set_eq:Nc \fallback@font { luatexkofont@ \token_to_str:N #1 } + \luatexko@fallback@selectfont + } + } + \DeclareDocumentCommand \hangulfontspec { O{} m } + { + \newfontfamily \hangul@font [#1] {#2} + \luatexko@hangul@selectfont + \ignorespaces + } + \cs_set_eq:NN \adhochangulfont \hangulfontspec + \DeclareDocumentCommand \hanjafontspec { O{} m } + { + \newfontfamily \hanja@font [#1] {#2} + \luatexko@hanja@selectfont + \ignorespaces + } + \cs_set_eq:NN \adhochanjafont \hanjafontspec + \DeclareDocumentCommand \fallbackfontspec { O{} m } + { + \newfontfamily \fallback@font [#1] {#2} + \luatexko@fallback@selectfont + \ignorespaces + } + \cs_set_eq:NN \adhocfallbackfont \fallbackfontspec + \DeclareDocumentCommand \addhangulfontfeature { m } + { + \group_begin: + \cs_if_exist:NT \hangul@font { \hangul@font } + \addfontfeature {#1} + \use:x + { + \group_end: + \exp_not:N \tl_set:Nn \exp_not:N \hangul@font + { + \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont + } + } + \luatexko@hangul@selectfont + \ignorespaces + } + \cs_set_eq:NN \addhangulfontfeatures \addhangulfontfeature + \DeclareDocumentCommand \addhanjafontfeature { m } + { + \group_begin: + \cs_if_exist:NT \hanja@font { \hanja@font } + \addfontfeature {#1} + \use:x + { + \group_end: + \exp_not:N \tl_set:Nn \exp_not:N \hanja@font + { + \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont + } + } + \luatexko@hanja@selectfont + \ignorespaces + } + \cs_set_eq:NN \addhanjafontfeatures \addhanjafontfeature + \DeclareDocumentCommand \addfallbackfontfeature { m } + { + \group_begin: + \cs_if_exist:NT \fallback@font { \fallback@font } + \addfontfeature {#1} + \use:x + { + \group_end: + \exp_not:N \tl_set:Nn \exp_not:N \fallback@font + { + \exp_not:N \fontfamily { \f@family } \exp_not:N \selectfont + } + } + \luatexko@fallback@selectfont + \ignorespaces + } + \cs_set_eq:NN \addfallbackfontfeatures \addfallbackfontfeature + % hangul math font command + \DeclareDocumentCommand \setmathhangulfont { O{} m } + { + \fontspec_set_family:Nnn \luatexko@math@hangul@family {#1} {#2} + } + \ExplSyntaxOff +\fi \RequirePackage{everysel} \EverySelectfont{% @@ -186,33 +306,55 @@ \luatexko@fallback@selectfont } -% don't forget to redefine \normalfont -\protected\edef\normalfont{\unexpanded{% - \let\hangul@font\luatexko@undefined - \let\hanja@font\luatexko@undefined - \let\fallback@font\luatexko@undefined - }% - \unexpanded\expandafter{\normalfont}} -\let\reset@font\normalfont - -% normal : finemathattr = 1 +% serif : finemathattr = 2 +% sans : finemathattr = 1 % tt : finemathattr = 0 -% verbatim : finemathattr = off -\protected\edef\ttfamily{\unexpanded\expandafter{\ttfamily - \finemathattr\z@}} +% verbatim : finemathattr = nil +\def\luatexko@serif@fonts{% + \let\hangul@font\serifhangul@font + \let\hanja@font\serifhanja@font + \let\fallback@font\seriffallback@font + \finemathattr\tw@ +} +\def\luatexko@sans@fonts{% + \let\hangul@font\sanshangul@font + \let\hanja@font\sanshanja@font + \let\fallback@font\sansfallback@font + \finemathattr\@ne +} +\def\luatexko@mono@fonts{% + \let\hangul@font\monohangul@font + \let\hanja@font\monohanja@font + \let\fallback@font\monofallback@font + \finemathattr\z@ +} + +\protected\edef\rmfamily{% + \unexpanded{\luatexko@serif@fonts}\unexpanded\expandafter{\rmfamily}} +\protected\edef\sffamily{% + \unexpanded{\luatexko@sans@fonts}\unexpanded\expandafter{\sffamily}} +\protected\edef\ttfamily{% + \unexpanded{\luatexko@mono@fonts}\unexpanded\expandafter{\ttfamily}} \edef\verbatim@font{\unexpanded\expandafter{\verbatim@font \unsetluatexattribute\finemathattr}} -%% package options -\newif\if@hangul -\newif\if@hanja -\newif\if@unfonts -\DeclareOption{hangul}{\@hangultrue} -\DeclareOption{hanja}{\@hangultrue\@hanjatrue} -\DeclareOption{unfonts}{\@unfontstrue} -\ProcessOptions\relax +% don't forget to redefine \normalfont +\expandafter\ifx\familydefault\rmdefault + \protected\edef\normalfont{% + \unexpanded{\luatexko@serif@fonts}\unexpanded\expandafter{\normalfont}} + \finemathattr\tw@ +\else\expandafter\ifx\familydefault\sfdefault + \protected\edef\normalfont{% + \unexpanded{\luatexko@sans@fonts}\unexpanded\expandafter{\normalfont}} + \finemathattr\@ne +\else + \protected\edef\normalfont{% + \unexpanded{\luatexko@mono@fonts}\unexpanded\expandafter{\normalfont}} + \finemathattr\z@ +\fi\fi +\let\reset@font\normalfont -\if@unfonts +\if@unfonts\if@luatexko@loadfontspec \setmainhangulfont[ InterHangul=-0.04em, InterLatinCJK=0.125em, @@ -238,15 +380,15 @@ BoldSlantedFont=*Bold, BoldSlantedFeatures={FakeSlant=0.2}, BoldItalicFont=*Bold, BoldItalicFeatures={FakeSlant=0.2}, ]{UnDotum} -\fi +\fi\fi \AtBeginDocument{ \unless\ifdefined\serifhangul@font\let\serifhangul@font\sanshangul@font\fi \unless\ifdefined\sanshangul@font \let\sanshangul@font\serifhangul@font\fi \unless\ifdefined\monohangul@font \let\monohangul@font\sanshangul@font \fi -\luatexko@hangul@selectfont -\luatexko@hanja@selectfont -\luatexko@fallback@selectfont +\unless\ifdefined\serifhangul@font\unless\ifdefined\sanshangul@font + \hangulpunctuations=0 % nanumtype1 +\fi\fi % for hyperref \@ifpackageloaded{hyperref}{\pdfstringdefDisableCommands{% \let\dotemph\@firstofone @@ -258,6 +400,8 @@ \let\uwave\@firstofone \let\dashuline\@firstofone \let\dotuline\@firstofone + \let\actualtext\@firstofone + \let\inhibitglue\empty \def\는{는}% \def\은{은}% \def\을{을}% @@ -272,25 +416,24 @@ }}{} } -%% hangul in math --- latex -\protected\def\setmathhangulfont{% - \@ifnextchar[{\setmathhangul@font@}{\setmathhangul@font@[]}} -\def\setmathhangul@font@[#1]#2{% - \zf@fontspec{#1}{#2}\xdef\luatexko@math@hangul@family{\zf@family}} -\AtBeginDocument{% - \begingroup - \unless\ifdefined\luatexko@math@hangul@family - \check@hangul@family - \ifdefined\hangul@font \hangul@font \fi - \xdef\luatexko@math@hangul@family{\f@family}% +\if@luatexko@loadfontspec + %% hangul in math --- latex + \AtBeginDocument{ + \begingroup + \unless\ifdefined\luatexko@math@hangul@family + \ifdefined\hangul@font \hangul@font \fi + \xdef\luatexko@math@hangul@family{\f@family}% + \fi + \endgroup + \DeclareSymbolFont{mathhangul}% + \zf@enc\luatexko@math@hangul@family\mddefault\updefault + \ifcsname\zf@enc/\luatexko@math@hangul@family/\bfdefault/\updefault\endcsname + \SetSymbolFont{mathhangul}{bold}% + \zf@enc\luatexko@math@hangul@family\bfdefault\updefault \fi - \endgroup - \DeclareSymbolFont{mathhangul}\zf@enc\luatexko@math@hangul@family\mddefault\updefault - \ifcsname\zf@enc/\luatexko@math@hangul@family/\bfdefault/\updefault\endcsname - \SetSymbolFont{mathhangul}{bold}\zf@enc\luatexko@math@hangul@family\bfdefault\updefault - \fi - \setmathhangulblock{AC00}{D7A3} -} + \setmathhangulblock{AC00}{D7A3} + } +\fi \RequirePackage{kolabels-utf} \if@hangul |