summaryrefslogtreecommitdiff
path: root/macros/generic/upzhkinsoku
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/generic/upzhkinsoku
Initial commit
Diffstat (limited to 'macros/generic/upzhkinsoku')
-rw-r--r--macros/generic/upzhkinsoku/README17
-rw-r--r--macros/generic/upzhkinsoku/upzhkinsoku-doc.pdfbin0 -> 204584 bytes
-rw-r--r--macros/generic/upzhkinsoku/upzhkinsoku-doc.tex82
-rw-r--r--macros/generic/upzhkinsoku/upzhkinsoku.sty168
4 files changed, 267 insertions, 0 deletions
diff --git a/macros/generic/upzhkinsoku/README b/macros/generic/upzhkinsoku/README
new file mode 100644
index 0000000000..7645a0376c
--- /dev/null
+++ b/macros/generic/upzhkinsoku/README
@@ -0,0 +1,17 @@
+
+
+The upzhkinsoku package --- Supplementary Chinese kinsoku for Unicode *pTeX
+
+CTAN Homepage: https://ctan.org/pkg/upzhkinsoku
+
+Repository: https://github.com/Man-Ting-Fang/upzhkinsoku
+
+Version: 2018-04-07 v0.5
+
+Copyright 2017--2018 Yue ZHANG
+
+License: Knuth License (https://ctan.org/license/knuth)
+
+This package provides supplementary Chinese kinsoku (line breaking rules etc.)
+settings for Unicode (e-)upTeX ((e-)upTeX when using Unicode as its internal
+encoding) and ApTeX. Both LaTeX and plain TeX are supported.
diff --git a/macros/generic/upzhkinsoku/upzhkinsoku-doc.pdf b/macros/generic/upzhkinsoku/upzhkinsoku-doc.pdf
new file mode 100644
index 0000000000..aa7fe80f4d
--- /dev/null
+++ b/macros/generic/upzhkinsoku/upzhkinsoku-doc.pdf
Binary files differ
diff --git a/macros/generic/upzhkinsoku/upzhkinsoku-doc.tex b/macros/generic/upzhkinsoku/upzhkinsoku-doc.tex
new file mode 100644
index 0000000000..a6c191eddf
--- /dev/null
+++ b/macros/generic/upzhkinsoku/upzhkinsoku-doc.tex
@@ -0,0 +1,82 @@
+
+
+% upzhkinsoku-doc.tex
+
+% !TeX encoding = UTF-8
+% !TeX program = pdfLaTeX
+
+\RequirePackage{fix-cm}
+
+\documentclass[a4paper]{article}
+
+\usepackage[OT1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage[UKenglish]{babel}
+\usepackage[babel]{microtype}
+\usepackage{etoolbox}
+
+\AtBeginEnvironment{verbatim}{\microtypesetup{activate=false}}
+
+\newcommand\NormalSans{\normalfont\sffamily}
+\newcommand\pkg[1]{{\protect\NormalSans#1}}
+
+\newcommand\pTeX{p\kern-0.15em\TeX}
+\newcommand\e{\ensuremath{\varepsilon}}
+\newcommand\upTeX{u\pTeX}
+\newcommand\ApTeX{A\kern-0.1em\pTeX}
+
+\newcommand\kn{test}
+\newcommand\sk{test}
+
+\font\kn=ipxm-r-u79 at 9.62216pt
+\font\sk=ipxm-r-u52 at 9.62216pt
+
+\begin{document}
+
+\title{The \pkg{upzhkinsoku} package%
+ \thanks{CTAN Homepage: \texttt{https://ctan.org/pkg/upzhkinsoku}}
+ \thanks{Repository: \texttt{https://github.com/Man-Ting-Fang/upzhkinsoku}}}
+\author{Yue \textsc{Zhang}}
+\date{2018-04-07\quad v0.5}
+
+\maketitle
+
+\begin{abstract}
+This package provides supplementary Chinese kinsoku (line breaking rules etc.)
+settings for Unicode (\e-)\upTeX\footnote{(\e-)\upTeX\ when using Unicode as its
+internal encoding.} and \ApTeX. Both \LaTeX\ and plain \TeX\ are supported.
+\end{abstract}
+
+\section{Introduction}
+
+\textit{Kinsoku} is the romanisation of the Japanese word ``{\kn\char"81\relax
+\sk\char"47}'' which means ``prohibition rules''. It is a set of rules to avoid
+prohibited line breaks in CJK typography, such as ``line-start prohibition
+rules'', ``line-end prohibition rules'', inseparable or unbreakable character
+sequences and so on.\footnote{\textit{Requirements for Japanese Text Layout}:
+\texttt{https://www.w3.org/TR/jlreq/}}
+
+(\e-)\upTeX\ and \ApTeX's default kinsoku parameters are set in
+\verb|ukinsoku.tex|. However, the default settings do not satisfy Chinese
+typesetting,\footnote{\textit{Requirements for Chinese Text Layout}:
+\texttt{https://www.w3.org/TR/clreq/}} thus this package provides supplementary
+Chinese kinsoku settings for Unicode (\e-)\upTeX\ and \ApTeX.
+
+Please note that this package is specifically optimised for Chinese typesetting,
+so it is usually not suitable for document whose main language is not Chinese.
+
+\section{Usage}
+
+This package has no options, just load it as usual:
+\begin{itemize}
+\item \LaTeX: \verb|\usepackage{upzhkinsoku}|
+\item Plain \TeX: \verb|\input upzhkinsoku.sty|
+\end{itemize}
+If you are using \LaTeX\ and would like to change some kinsoku parameters (this
+is usually unnecessary, however), please do that after \verb|\begin{document}|,
+or via \verb|\AtBeginDocument| after loading this package; otherwise they may be
+overridden.\footnote{For technical reasons, the actual execution of this package
+is delayed to \texttt{\char"5C begin\char"7B document\char"7D}, also via
+\texttt{\char"5C AtBeginDocument}.}
+
+\end{document}
diff --git a/macros/generic/upzhkinsoku/upzhkinsoku.sty b/macros/generic/upzhkinsoku/upzhkinsoku.sty
new file mode 100644
index 0000000000..9f14e317b6
--- /dev/null
+++ b/macros/generic/upzhkinsoku/upzhkinsoku.sty
@@ -0,0 +1,168 @@
+
+
+% upzhkinsoku.sty
+% Copyright 2017--2018 Yue ZHANG
+% License: Knuth License (https://ctan.org/license/knuth)
+
+\csname ENDINPUTUPZHKINSOKUDOTSTY\endcsname
+
+\let\ENDINPUTUPZHKINSOKUDOTSTY=\endinput
+
+\begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname ProvidesPackage\endcsname\relax
+ \else
+ \ProvidesPackage{upzhkinsoku}[2018/04/07 v0.5
+ Supplementary Chinese kinsoku for Unicode *pTeX]%
+ \fi
+
+\edef\UPZHKINSOKUDOTSTYRESTORECATCODE{%
+ \catcode`\noexpand\@=\the\catcode`\@\relax}
+
+\catcode`\@=11\relax
+
+\def\upzhkinsoku@ifprimitive#1{%
+ \begingroup
+ \edef\upzhkinsoku@temp@meaning{\meaning#1}%
+ \edef\upzhkinsoku@temp@string{\string#1}%
+ \expandafter
+ \endgroup
+ \ifx\upzhkinsoku@temp@meaning\upzhkinsoku@temp@string}
+
+\upzhkinsoku@ifprimitive\ucs
+\else
+ \errmessage{upTeX / e-upTeX / ApTeX is required}%
+ \UPZHKINSOKUDOTSTYRESTORECATCODE
+ \expandafter\endinput
+\fi
+
+\ifnum\ucs"3000="3000\relax
+\else
+ \errmessage{Unicode upTeX / Unicode e-upTeX / ApTeX is required}%
+ \UPZHKINSOKUDOTSTYRESTORECATCODE
+ \expandafter\endinput
+\fi
+
+\def\upzhkinsoku@setpenalties{%
+ \postbreakpenalty"23=10000\relax % #
+% \postbreakpenalty"24=10000\relax % $ (variable slot)
+ \prebreakpenalty"25=10000\relax % %
+ \prebreakpenalty"26=10000\relax % &
+ \prebreakpenalty"2A=10000\relax % *
+ \prebreakpenalty"2B=10000\relax % + (\+ is \outer in plain.tex)
+ \prebreakpenalty"2F=10000\relax % /
+ \prebreakpenalty"3D=10000\relax % =
+ \postbreakpenalty"40=10000\relax % @
+ \prebreakpenalty"5E=10000\relax % ^
+ \prebreakpenalty"7E=10000\relax % ~
+ \prebreakpenalty\ucs"301E=10000\relax % 〞
+ \postbreakpenalty\ucs"2329=10000\relax % 〈
+ \prebreakpenalty\ucs"232A=10000\relax % 〉
+ \postbreakpenalty\ucs"301A=10000\relax % 〚
+ \prebreakpenalty\ucs"301B=10000\relax % 〛
+ \prebreakpenalty\ucs"00B7=10000\relax % ·
+ \prebreakpenalty\ucs"2022=10000\relax % •
+ \prebreakpenalty\ucs"2027=10000\relax % ‧
+ \prebreakpenalty\ucs"2010=10000\relax % ‐
+ \prebreakpenalty\ucs"2013=10000\relax % –
+ \prebreakpenalty\ucs"FF0D=10000\relax % -
+ \prebreakpenalty\ucs"2026=0\relax % …
+ \prebreakpenalty\ucs"2025=0\relax % ‥
+ \prebreakpenalty\ucs"FF0F=10000\relax % /
+ \prebreakpenalty\ucs"FF5E=10000\relax % ~
+ \prebreakpenalty\ucs"301C=10000\relax % 〜
+}
+\def\upzhkinsoku@setxspcodes{%
+ \xspcode"21=2\relax % !
+ \xspcode"23=1\relax % #
+% \xspcode"24=1\relax % $ (variable slot)
+ \xspcode"25=2\relax % %
+ \xspcode"26=3\relax % &
+ \xspcode"3A=2\relax % :
+ \xspcode"3F=2\relax % ?
+ \xspcode"40=1\relax % @
+}
+\def\upzhkinsoku@setinhibitxspcodes{%
+ \inhibitxspcode\ucs"301E=1\relax % 〞
+ \inhibitxspcode\ucs"2329=2\relax % 〈
+ \inhibitxspcode\ucs"232A=1\relax % 〉
+ \inhibitxspcode\ucs"301A=2\relax % 〚
+ \inhibitxspcode\ucs"301B=1\relax % 〛
+ \inhibitxspcode\ucs"00B7=0\relax % ·
+ \inhibitxspcode\ucs"2022=0\relax % •
+ \inhibitxspcode\ucs"2027=0\relax % ‧
+ \inhibitxspcode\ucs"30FB=0\relax % ・
+ \inhibitxspcode\ucs"FF1A=1\relax % :
+ \inhibitxspcode\ucs"FF01=1\relax % !
+ \inhibitxspcode\ucs"2010=0\relax % ‐
+ \inhibitxspcode\ucs"2013=0\relax % –
+ \inhibitxspcode\ucs"2E3A=0\relax % ⸺
+ \inhibitxspcode\ucs"FF0D=0\relax % -
+ \inhibitxspcode\ucs"2025=0\relax % ‥
+ \inhibitxspcode\ucs"FF0F=0\relax % /
+}
+
+\def\upzhkinsoku@setwith@ascii{% variable slots
+ \prebreakpenalty"22=0\relax % "
+ \prebreakpenalty"3C=10000\relax % <
+ \prebreakpenalty"3E=10000\relax % >
+ \prebreakpenalty"5C=10000\relax % \
+ \prebreakpenalty"5F=10000\relax % _
+ \postbreakpenalty"7B=10000\relax % {
+ \prebreakpenalty"7C=10000\relax % |
+ \prebreakpenalty"7D=10000\relax % }
+ \xspcode"22=0\relax % "
+ \xspcode"3C=0\relax % <
+ \xspcode"3E=0\relax % >
+ \xspcode"5C=0\relax % \
+ \xspcode"7B=1\relax % {
+ \xspcode"7D=2\relax % }
+}
+\def\upzhkinsoku@setwith@otlatin{% variable slots
+ \prebreakpenalty"22=10000\relax % ”
+ \postbreakpenalty"3C=10000\relax % ¡
+ \postbreakpenalty"3E=10000\relax % ¿
+ \postbreakpenalty"5C=10000\relax % “
+ \prebreakpenalty"5F=0\relax % ˙
+ \prebreakpenalty"7B=10000\relax % –
+ \prebreakpenalty"7C=0\relax % —
+ \prebreakpenalty"7D=0\relax % ˝
+ \xspcode"22=2\relax % ”
+ \xspcode"3C=1\relax % ¡
+ \xspcode"3E=1\relax % ¿
+ \xspcode"5C=1\relax % “
+ \xspcode"7B=0\relax % –
+ \xspcode"7D=0\relax % ˝
+}
+
+\def\DisableOTLatinVariableSlotsKinsoku{\upzhkinsoku@setwith@ascii}
+\def\EnableOTLatinVariableSlotsKinsoku{\upzhkinsoku@setwith@otlatin}
+
+\def\upzhkinsoku@otone{OT1}
+\def\upzhkinsoku@otfour{OT4}
+
+\def\setupzhkinsokuwith#1{%
+% \input ukinsoku.tex\relax
+ \upzhkinsoku@setpenalties
+ \upzhkinsoku@setxspcodes
+ \upzhkinsoku@setinhibitxspcodes
+ \edef\upzhkinsoku@defaultfontenc{#1}%
+ \ifx\upzhkinsoku@defaultfontenc\upzhkinsoku@otone
+ \upzhkinsoku@setwith@otlatin
+ \else
+ \ifx\upzhkinsoku@defaultfontenc\upzhkinsoku@otfour
+ \upzhkinsoku@setwith@otlatin
+ \else
+ \upzhkinsoku@setwith@ascii
+ \fi
+ \fi}
+
+\begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname encodingdefault\endcsname\relax
+ \setupzhkinsokuwith{\upzhkinsoku@otone}%
+ \else
+ \AtBeginDocument{\setupzhkinsokuwith{\encodingdefault}}%
+ \fi
+
+\UPZHKINSOKUDOTSTYRESTORECATCODE
+
+\endinput