diff options
author | Karl Berry <karl@freefriends.org> | 2016-08-30 22:09:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-08-30 22:09:13 +0000 |
commit | 5d57911ad9007b3033d3a7026a4c80eb84544c8a (patch) | |
tree | 5583a028dfbecb644a3b444f16748b8787e55d85 /Master | |
parent | cbed1c425c3661149b661eb627dd7e57f0182b0f (diff) |
cstypo (30aug16)
git-svn-id: svn://tug.org/texlive/trunk@41957 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/cstypo/LICENSE | 21 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/cstypo/README.md | 11 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/cstypo/cstypo.pdf | bin | 0 -> 67456 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex | 114 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf | bin | 0 -> 21174 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex | 80 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty | 30 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex | 16 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/cstypo/cstypo.lua | 128 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-luatex.tlpsrc | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/cstypo.tlpsrc | 0 |
12 files changed, 402 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/lualatex/cstypo/LICENSE b/Master/texmf-dist/doc/lualatex/cstypo/LICENSE new file mode 100644 index 00000000000..872ab4f9e10 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/cstypo/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Václav Haisman + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Master/texmf-dist/doc/lualatex/cstypo/README.md b/Master/texmf-dist/doc/lualatex/cstypo/README.md new file mode 100644 index 00000000000..db71a70026b --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/cstypo/README.md @@ -0,0 +1,11 @@ +# cstypo + +This package provides macros for Czech language typography rules using +Lua(La)TeX. + +- License is MIT license. See `LICENSE` file. + +- Author is [Václav Haisman](mailto:vhaisman+cstypo@gmail.com?subject=[cstypo]) + +- Source code on GitHub in [`wilx/cstypo`](https://github.com/wilx/cstypo) + repository. diff --git a/Master/texmf-dist/doc/lualatex/cstypo/cstypo.pdf b/Master/texmf-dist/doc/lualatex/cstypo/cstypo.pdf Binary files differnew file mode 100644 index 00000000000..98610d9d79e --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/cstypo/cstypo.pdf diff --git a/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex b/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex new file mode 100644 index 00000000000..9e87d617b90 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/cstypo/cstypo.tex @@ -0,0 +1,114 @@ +\documentclass[paper=B5,DIV=calc,parskip=half]{scrartcl} +\usepackage{ifluatex} + +\usepackage{fontspec} +%\defaultfontfeatures{Ligatures={TeX,Common},Scale=MatchLowercase} +\setmainfont[]{Charis SIL} +\setsansfont[Ligatures={TeX,Common}, Scale=MatchLowercase]{TeX Gyre Heros} +\setmonofont[Ligatures=,Scale=MatchLowercase]{DejaVu Sans Mono} + +\usepackage{listings} +\usepackage{enumitem} +%\usepackage{enumitem-zref} +\usepackage{polyglossia} +\setmainlanguage[]{english} + +\author{Václav Haisman\texorpdfstring{% + \\{\small\href{mailto:vhaisman+cstypo@gmail.com?subject=[cstypo]}{vhaisman@gmail.com}}}{}} +\date{\today} +\title{\texttt{cstypo} user manual} + +\PassOptionsToPackage{unicode}{hyperref} +\usepackage{bookmark} +\usepackage{xcolor} +\hypersetup{ + colorlinks, + linkcolor={red!50!black}, + citecolor={blue!50!black}, + urlcolor={blue!80!black}, + breaklinks=true} +\urlstyle{same} % don't use monospace font for urls + +\usepackage{microtype} +\usepackage{metalogo} + +\setlength{\emergencystretch}{3em} % prevent overfull lines + +\lstdefinestyle{myLatexStyle}{ + language=[LaTeX]{Tex}, + basicstyle=\ttfamily +} + + +\begin{document} +\begin{titlepage} + \maketitle +\end{titlepage} + +\tableofcontents + +\section{Introduction} +The \href{https://www.ctan.org/pkg/cstypo}{\texttt{cstypo}}\footnote{Source + code is on GitHub in + \href{https://github.com/wilx/cstypo}{\texttt{wilx/cstypo}} repository.} +package provides macros that enforce basic Czech typography rules through Lua +hooks available in \LuaTeX{}. + +\begin{enumerate}%[name=rulesList] +\item\label{itm:singleletter} There should be no line break between single + letter preprosition and single letter conjugations and word following them. +\item\label{itm:percents} There should be no line break between number and \% + symbol. +\end{enumerate} + +There are obviously more rules than these two but only the above rules are +enforcable through this package. + +\section{User interface} + +The following two macros allow to enable and disable hook that enforces +penalization of line breaks after single letter words: +%(\refitem{rulesList{itm:singleletter}): + +\begin{lstlisting}[style=myLatexStyle] +\cstypoSingleLetterEnable +\cstypoSingleLetterDisable +\end{lstlisting} + +The following two macros allow to enable and disable hook that enforces the +same rule as above but for ‘a’ conjugation. The reason that this is separete +from the rest of the single letter prepositions and conjugations is that line +break after ‘a’ is tolerated for narrow column texts. It might be desirable +to have this rule enforced for all of the single letter words except for the +‘a’. + +\begin{lstlisting}[style=myLatexStyle] +\cstypoALetterEnable +\cstypoALetterDisable +\end{lstlisting} + +The following two macros allow to enable and disable hook that enforces +penalization of line breaks between number and \% symbol. + +\begin{lstlisting}[style=myLatexStyle] +\cstypoPercentsEnable +\cstypoPercentsDisable +\end{lstlisting} + +\section{History} + +This package was inspired by +\texttt{\href{http://www.ctan.org/pkg/impnattypo}{impnattypo}} French +typography package. It would not be possible without help and comments from +people of +\href{http://chat.stackexchange.com/rooms/41/tex-latex-and-friends}{\TeX{}, + \LaTeX{} and Friends} StackExchange chat room and the +\href{http://tex.stackexchange.com/}{\TeX.SE} site itself. + +\begin{description}[style=nextline, labelwidth=4.5em, leftmargin=!, labelindent=0em] +\item[\texttt{v0.02}] Fixed some packaging and documentation issues found by + CTAN submission review. +\item[\texttt{v0.01}] First published version of this package. +\end{description} + +\end{document} diff --git a/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf b/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf Binary files differnew file mode 100644 index 00000000000..9752e42b352 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.pdf diff --git a/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex b/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex new file mode 100644 index 00000000000..bd94218c940 --- /dev/null +++ b/Master/texmf-dist/doc/lualatex/cstypo/cstypotest.tex @@ -0,0 +1,80 @@ +\documentclass{article} +\usepackage{lmodern} +\usepackage{ifluatex} +\usepackage[a6paper]{geometry} +\usepackage{parskip} +\usepackage{polyglossia} +\setmainlanguage[]{czech} +\setotherlanguage{english} +\usepackage{microtype} + +\setlength{\emergencystretch}{3em} % prevent overfull lines +\newcommand{\expl}[1]{\begin{english}\sffamily #1\end{english}} + +\usepackage{cstypo} + +\begin{document} +\section{Bad line breaks} +\expl{The follwing text has prepostions `O' and `k' at end of line which + is incorrect according to Czech language typography standards:} + +Mezi oblíbené dětské pohádky patří pohádky \emph{O Palečkovi, Alenka v říši + divů} a \emph{Socialismem k lepším zítřkům.} + +\expl{The follwing text is the same as above but parentheses are used to test + that a preposition stay (or not stay, in this case) with following word + even if the prepostion is preceeded with a parenthesis:} + +Mezi oblíbené dětské pohádky patří pohádky \emph{[O Palečkovi], Alenka v říši + divů} a \emph{Socialismem (k lepším zítřkům).} + +\expl{Next line shows bad line break between number and the \% symbol.} + +Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce. + +\section{Better line breaks} +\expl{And here we add Lua code to penalize single letter words. It results in +following line layout:} + +\cstypoSingleLetterEnable{} +\cstypoPercentsEnable{} +\cstypoALetterEnable{} +Mezi oblíbené dětské pohádky patří pohádky \emph{O Palečkovi, Alenka v říši + divů} a \emph{Socialismem k lepším zítřkům.} + +\expl{The follwing text is the same as above but parentheses are used to test + that a preposition stay with following word even if the prepostion is + preceeded with a parenthesis:} + +Mezi oblíbené dětské pohádky patří pohádky \emph{[O Palečkovi], Alenka v říši + divů} a \emph{Socialismem (k lepším zítřkům).} + +\expl{Here, the \% symbol should be together with the number.} + +Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce. + +\section{Bad line breaks again} +\expl{This section shows that disabling of the hook works and that the + prepositions are again left at the end of their line.} + +\cstypoSingleLetterDisable{} +\cstypoPercentsDisable{} +\cstypoALetterDisable{} + +Mezi oblíbené dětské pohádky patří pohádky \emph{O Palečkovi, Alenka v říši + divů} a \emph{Socialismem k lepším zítřkům.} + +\expl{The follwing text is the same as above but parentheses are used to test + that a preposition stay (or not stay, in this case) with following word + even if the prepostion is preceeded with a parenthesis:} + +Mezi oblíbené dětské pohádky patří pohádky \emph{[O Palečkovi], Alenka v říši + divů} a \emph{Socialismem (k lepším zítřkům).} + +\expl{And here, line break is inserted before the \% symbol again.} + +Se správným nastavením fontů znak \% v `na 100 \%' skončí na další řádce. + + + +\end{document} diff --git a/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty b/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty new file mode 100644 index 00000000000..5fe04b38d35 --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/cstypo/cstypo.sty @@ -0,0 +1,30 @@ +% LaTeX package to enforce some basic Czech language typography +% rules. Requires LuaLaTeX. +% +% (c) 2016 Václav Haisman +% +%% This program can be redistributed and/or modified under the terms of the +%% MIT license. See LICENSE file. +% +\NeedsTeXFormat{LaTeX2e}[1994/06/01] +\ProvidesPackage{cstypo} + [2016/08/30 v0.02 LaTeX package to enforce some basic Czech language + typography rules. Requires Lua(La)TeX.] + +\RequirePackage{ifluatex} + +\ifluatex +\input{cstypo-tex} +\else +\PackageError{cstypo}{% + This requires LuaTeX or LuaLaTeX +}{% + Compile this with LuaTeX or LuaLaTeX. +} + +\fi + +\endinput + +%% +%% End of file `cstypo.sty'. diff --git a/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex b/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex new file mode 100644 index 00000000000..2b768f783dd --- /dev/null +++ b/Master/texmf-dist/tex/luatex/cstypo/cstypo-tex.tex @@ -0,0 +1,16 @@ +\directlua{require('cstypo')} + +\long\def\cstypoSingleLetterEnable{% + \directlua{cstypo_single_letter_enable()}} +\long\def\cstypoSingleLetterDisable{% + \directlua{cstypo_single_letter_disable()}} + +\long\def\cstypoALetterEnable{% + \directlua{cstypo_a_letter_enable()}} +\long\def\cstypoALetterDisable{% + \directlua{cstypo_a_letter_disable()}} + +\long\def\cstypoPercentsEnable{% + \directlua{cstypo_percents_enable()}} +\long\def\cstypoPercentsDisable{% + \directlua{cstypo_percents_disable()}} diff --git a/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua b/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua new file mode 100644 index 00000000000..9012ce385ce --- /dev/null +++ b/Master/texmf-dist/tex/luatex/cstypo/cstypo.lua @@ -0,0 +1,128 @@ +--[[-- +(c) 2016 Václav Haisman + +This program can be redistributed and/or modified under the terms of the MIT +license. See LICENSE file. +--]]-- + +local GLYPH = node.id("glyph") +--print('GLYPH value: ', GLYPH) + +local GLUE = node.id("glue") +--print('GLUE value: ', GLUE) + + +local function prevent_single_letter (head) + --print('prevent_single_letter hook is executing', head) + while head do + -- glyph + --print('inside prevent_single_letter loop, head.id: ', head.id) + if head.id == GLYPH then + -- only if we are at one letter word + if unicode.utf8.match(unicode.utf8.char(head.char), "[zZsSuUkKoOvViI]") then + -- and left of it is either a space + if ((head.prev.id == GLUE + -- or one of '{[(' + or (head.prev.id == GLYPH + and unicode.utf8.match(unicode.utf8.char(head.prev.char), + "[%[%]()%{%}]"))) + -- and right of the one letter word is also a space + and head.next.id == GLUE) then + -- then avoid line break between the single letter word and the + -- word following it + local p = node.new("penalty") + p.penalty = 10000 + node.insert_after(head, head, p) + --print('inserting penalty at ', head) + end + end + end + head = head.next + end + return true +end + +function cstypo_single_letter_enable () + print('cstypo: Enabling single letter hook.') + luatexbase.add_to_callback("pre_linebreak_filter", prevent_single_letter, + "cstyposingleletter") +end + +function cstypo_single_letter_disable () + print('cstypo: Disabling single letter hook.') + luatexbase.remove_from_callback("pre_linebreak_filter", "cstyposingleletter") +end + + +local function prevent_a_letter (head) + while head do + -- glyph + if head.id == GLYPH then + -- only if we are at one letter word + if unicode.utf8.match(unicode.utf8.char(head.char), "[aA]") then + -- and previous is space + if ((head.prev.id == GLUE + -- or previous is one of '{[(' + or (head.prev.id == GLYPH + and unicode.utf8.match(unicode.utf8.char(head.prev.char), + "[%[%]()%{%}]"))) + -- and right of the one letter word is also a space + and head.next.id == GLUE) then + -- then avoid line break between the single letter word and the + -- word following it + local p = node.new("penalty") + p.penalty = 10000 + node.insert_after(head, head, p) + end + end + end + head = head.next + end + return true +end + +function cstypo_a_letter_enable () + print('cstypo: Enabling \'a\' letter hook.') + luatexbase.add_to_callback("pre_linebreak_filter", prevent_a_letter, + "cstypoaletter") +end + +function cstypo_a_letter_disable () + print('cstypo: Disabling \'a\' letter hook.') + luatexbase.remove_from_callback("pre_linebreak_filter", "cstypoaletter") +end + + +local function prevent_percents (head) + while head do + -- glyph + if head.id == GLYPH then + -- only if we are at percentage sign + if unicode.utf8.match(unicode.utf8.char(head.char), "%%") then + -- and left of it is a space + if (head.prev.id == GLUE + -- and left of the space is a digit. + and head.prev.prev.id == GLYPH + and unicode.utf8.match(unicode.utf8.char(head.prev.prev.char), + "[0-9]")) then + local p = node.new("penalty") + p.penalty = 10000 + node.insert_after(head.prev.prev, head.prev.prev, p) + end + end + end + head = head.next + end + return true +end + +function cstypo_percents_enable() + print('cstypo: Enabling percents hook.') + luatexbase.add_to_callback("pre_linebreak_filter", prevent_percents, + "cstypopercents") +end + +function cstypo_percents_disable() + print('cstypo: Disabling percents hook.') + luatexbase.remove_from_callback("pre_linebreak_filter", "cstypopercents") +end diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 2e0a086cf0f..8ed24810098 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -173,7 +173,7 @@ my @TLP_working = qw( cprotect cquthesis crbox crimson crop crossreference crossrefware crossword crosswrd cryptocode cryst - cs csbulletin cslatex csplain csquotes csquotes-de csvsimple cstex + cs csbulletin cslatex csplain csquotes csquotes-de cstypo csvsimple cstex ctan_chk ctanify ctanupload ctable ctablestack ctex ctex-faq cursolatex cuisine currfile currvita curve curve2e curves diff --git a/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc b/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc index 309041aacaf..b4c183526aa 100644 --- a/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc @@ -8,6 +8,7 @@ depend collection-basic depend checkcites depend chickenize depend cloze +depend cstypo depend ctablestack depend enigma depend interpreter diff --git a/Master/tlpkg/tlpsrc/cstypo.tlpsrc b/Master/tlpkg/tlpsrc/cstypo.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/cstypo.tlpsrc |