summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-03-04 22:11:56 +0000
committerKarl Berry <karl@freefriends.org>2019-03-04 22:11:56 +0000
commit01c4eb229994ba11e086f958fb74bb7fc7406cfb (patch)
treedf380307fd731a26e8788aaf0a8f2e2c01035f5e /Master/texmf-dist/tex
parent6f09c23604d01bfecf6c820a6097dd5174c18f21 (diff)
impnattypo (4mar19)
git-svn-id: svn://tug.org/texlive/trunk@50227 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty77
1 files changed, 46 insertions, 31 deletions
diff --git a/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty b/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
index 52eff956ef5..1344a5dba7c 100644
--- a/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
+++ b/Master/texmf-dist/tex/latex/impnattypo/impnattypo.sty
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% Copyright (C) 2011-2012 by Raphaël Pinson <raphink@gmail.com>
+%% Copyright (C) 2011-2015 by Raphaël Pinson <raphink@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -20,7 +20,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{impnattypo}
- [2015/02/25 1.4 Typographic utilities inspired by the French Imprimerie Nationale]
+ [2019/03/04 1.5 Typographic utilities inspired by the French Imprimerie Nationale]
\ProvidesPackage{impnattypo}
\RequirePackage{ifluatex}
\RequirePackage{kvoptions}
@@ -64,12 +64,15 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
local prevent_single_letter = function (head)
while head do
- if head.id == 37 then -- glyph
+ if head.id == glyph_id then -- glyph
if unicode.utf8.match(unicode.utf8.char(head.char),"%a") then -- some kind of letter
- if head.prev.id == 10 and head.next.id == 10 then -- only if we are at a one letter word
+ if head.prev.id == glue_id and head.next.id == glue_id then -- only if we are at a one letter word
local p = node.new("penalty")
p.penalty = 10000
@@ -104,10 +107,14 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
+
last_line_twice_parindent = function (head)
while head do
local _w,_h,_d = node.dimensions(head)
- if head.id == 10 and head.subtype ~= 15 and (_w < 2 * tex.parindent) then
+ if head.id == glue_id and head.subtype ~= 15 and (_w < 2 * tex.parindent) then
-- we are at a glue and have less then 2*\parindent to go
local p = node.new("penalty")
@@ -140,6 +147,10 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+ local glyph_id = node.id "glyph"
+ local glue_id = node.id "glue"
+ local hlist_id = node.id "hlist"
+
compare_lines = function (line1,line2)
local head1 = line1.head
local head2 = line2.head
@@ -148,30 +159,30 @@
local word_count = 0
while head1 and head2 do
- if (head1.id == 37 and head2.id == 37
+ if (head1.id == glyph_id and head2.id == glyph_id
and head1.char == head2.char) -- identical glyph
- or (head1.id == 10 and head2.id == 10) then -- glue
+ or (head1.id == glue_id and head2.id == glue_id) then -- glue
- if head1.id == 37 then -- glyph
+ if head1.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif char_count > 0 and head1.id == 10 then -- glue
+ elseif char_count > 0 and head1.id == glue_id then -- glue
word_count = word_count + 1
end
head1 = head1.next
head2 = head2.next
elseif (head1.id == 0 or head2.id == 0) then -- end of line
break
- elseif (head1.id ~= 37 and head1.id ~= 10) then -- some other kind of node
+ elseif (head1.id ~= glyph_id and head1.id ~= glue_id) then -- some other kind of node
head1 = head1.next
- elseif (head2.id ~= 37 and head2.id ~= 10) then -- some other kind of node
+ elseif (head2.id ~= glyph_id and head2.id ~= glue_id) then -- some other kind of node
head2 = head2.next
else -- no match, no special node
break
end
end
-- analyze last non-matching node, check for punctuation
- if ((head1 and head1.id == 37 and head1.char > 49)
- or (head2 and head2.id == 37 and head2.char > 49)) then
+ if ((head1 and head1.id == glyph_id and head1.char > 49)
+ or (head2 and head2.id == glyph_id and head2.char > 49)) then
-- not a word
elseif char_count > 0 then
word_count = word_count + 1
@@ -187,34 +198,34 @@
local word_count = 0
while head1 and head2 do
- if (head1.id == 37 and head2.id == 37
+ if (head1.id == glyph_id and head2.id == glyph_id
and head1.char == head2.char) -- identical glyph
- or (head1.id == 10 and head2.id == 10) then -- glue
+ or (head1.id == glue_id and head2.id == glue_id) then -- glue
- if head1.id == 37 then -- glyph
+ if head1.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif char_count > 0 and head1.id == 10 then -- glue
+ elseif char_count > 0 and head1.id == glue_id then -- glue
word_count = word_count + 1
end
head1 = head1.prev
head2 = head2.prev
elseif (head1.id == 0 or head2.id == 0) then -- start of line
break
- elseif (head1.id ~= 37 and head1.id ~= 10) then -- some other kind of node
+ elseif (head1.id ~= glyph_id and head1.id ~= glue_id) then -- some other kind of node
head1 = head1.prev
- elseif (head2.id ~= 37 and head2.id ~= 10) then -- some other kind of node
+ elseif (head2.id ~= glyph_id and head2.id ~= glue_id) then -- some other kind of node
head2 = head2.prev
- elseif (head1.id == 37 and head1.char < 48) then -- punctuation
+ elseif (head1.id == glyph_id and head1.char < 48) then -- punctuation
head1 = head1.prev
- elseif (head2.id == 37 and head2.char < 48) then -- punctuation
+ elseif (head2.id == glyph_id and head2.char < 48) then -- punctuation
head2 = head2.prev
else -- no match, no special node
break
end
end
-- analyze last non-matching node, check for punctuation
- if ((head1 and head1.id == 37 and head1.char > 49)
- or (head2 and head2.id == 37 and head2.char > 49)) then
+ if ((head1 and head1.id == glyph_id and head1.char > 49)
+ or (head2 and head2.id == glyph_id and head2.char > 49)) then
-- not a word
elseif char_count > 0 then
word_count = word_count + 1
@@ -260,10 +271,10 @@
local max_word = tonumber(\inthomeoarchymaxwords)
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
prev_line = cur_line
cur_line = head
- if prev_line.id == 0 then
+ if prev_line.id == hlist_id then
-- homeoarchy
char_count,word_count,prev_head,cur_head = compare_lines(prev_line,cur_line)
if char_count >= max_char or word_count >= max_word then
@@ -297,12 +308,12 @@
local linecounter = 0
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
linecounter = linecounter + 1
if linecounter > 1 then
prev_line = cur_line
cur_line = head
- if prev_line.id == 0 then
+ if prev_line.id == hlist_id then
-- homoioteleuton
char_count,word_count,prev_head,cur_head = compare_lines_reverse(prev_line,cur_line)
if char_count >= max_char or word_count >= max_word then
@@ -338,11 +349,15 @@
\ifluatex
\RequirePackage{luatexbase,luacode}
\begin{luacode}
+local glyph_id = node.id "glyph"
+local glue_id = node.id "glue"
+local hlist_id = node.id "hlist"
+
river_analyze_line = function(line,dim1,dim2,precision)
local head = line.head
while head do
- if head.id == 10 then -- glue node
+ if head.id == glue_id then -- glue node
local w1,h1,d1 = node.dimensions(line.glue_set,line.glue_sign,line.glue_order,line.head,head.prev)
local w2,h2,d2 = node.dimensions(line.glue_set,line.glue_sign,line.glue_order,line.head,head)
--print("dim1:"..dim1.."; dim2:"..dim2.."; w1:"..w1.."; w2:"..w2)
@@ -368,7 +383,7 @@ rivers = function (head)
local linecounter = 0
while head do
- if head.id == 0 then -- new line
+ if head.id == hlist_id then -- new line
linecounter = linecounter + 1
prev_prev_line = prev_line
prev_line = cur_line
@@ -378,9 +393,9 @@ rivers = function (head)
char_count = 0
while cur_node do
- if cur_node.id == 37 then -- glyph
+ if cur_node.id == glyph_id then -- glyph
char_count = char_count + 1
- elseif cur_node.id == 10 and char_count > 0 and cur_node.next then -- glue node
+ elseif cur_node.id == glue_id and char_count > 0 and cur_node.next then -- glue node
-- prev_line
local w1,h1,d1 = node.dimensions(head.glue_set,head.glue_sign,head.glue_order,head.head,cur_node.prev)
local w2,h2,d2 = node.dimensions(head.glue_set,head.glue_sign,head.glue_order,head.head,cur_node)