From 966c8c981c3264bf82e6c256dc35c7d2d27f49ba Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 2 May 2016 01:30:05 +0000 Subject: microtype (30apr16) git-svn-id: svn://tug.org/texlive/trunk@40825 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/latex/microtype/microtype-utf.dtx | 126 ++++++++++++++++----- 1 file changed, 95 insertions(+), 31 deletions(-) (limited to 'Master/texmf-dist/source/latex/microtype/microtype-utf.dtx') diff --git a/Master/texmf-dist/source/latex/microtype/microtype-utf.dtx b/Master/texmf-dist/source/latex/microtype/microtype-utf.dtx index b35af6be1f9..eb10bc5d2fd 100644 --- a/Master/texmf-dist/source/latex/microtype/microtype-utf.dtx +++ b/Master/texmf-dist/source/latex/microtype/microtype-utf.dtx @@ -2,11 +2,11 @@ % ^^A messages to WinEdt: % !Mode:: "TeX:DTX:UK" % !smartQuote:: "English" -% !DTXversion:: "2.5a" +% !DTXversion:: "2.6" % ------------------------------------------------------------------------ % The `microtype' package % Subliminal refinements towards typographical perfection -% Copyright (c) 2004--2013 R Schlicht +% Copyright (c) 2004--2016 R Schlicht % % This work may be distributed and/or modified under the conditions of the % LaTeX Project Public License, either version 1.3c of this license or (at @@ -17,8 +17,8 @@ % This work has the LPPL maintenance status `author-maintained'. % % This work consists of the files microtype.dtx and microtype.ins and the -% derived files microtype.sty, microtype-pdftex.def, microtype-xetex.def, -% microtype-luatex.def, microtype.lua and letterspace.sty. +% derived files microtype.sty, microtype-pdftex.def, microtype-luatex.def, +% microtype-xetex.def, microtype.lua and letterspace.sty. % % Modified versions of the configuration files (*.cfg) may be distributed % provided that: (1) the original copyright statement is not removed, and @@ -27,7 +27,7 @@ % \ProvidesFile %<*driver> - {\jobname.dtx}[2013/05/23 v2.5a] + {\jobname.dtx}[2016/05/01 v2.6] % % {mt-CharisSIL.cfg}[2013/03/13 v1.0 microtype config. file: Charis SIL (RS)] % {mt-LatinModernRoman.cfg}[2013/03/13 v1.0 microtype config. file: Latin Modern Roman (RS)] @@ -35,15 +35,77 @@ %<*driver> \documentclass[10pt,a4paper]{ltxdoc} \usepackage{fontspec} -\usepackage{microtype-doc} % there will be errors with luatex because of the non-utf \nobreakspace -- just ignore them! +\usepackage{luatexbase} +\RequireLuaModule{luainputenc} \makeatletter - \def\setmacrofont#1{\def\macro@font{#1}} +% microtype-doc.sty is 8-bit, and the following is a hack +\luatexbase@directlua{luatexbase.add_to_callback('process_input_buffer', luainputenc.fake_utf_read, 'luainputenc.fake_utf_read')} +\usepackage{microtype-doc} +\luatexbase@directlua{luatexbase.remove_from_callback('process_input_buffer', 'luainputenc.fake_utf_read')} + \def\setmacrofont#1{\par\def\macro@font{#1}\footnotesize} \newfontface\LMR{Latin Modern Roman} \newfontface\CharisSIL{Charis SIL} \newfontface\PalatinoLinotype{TeX Gyre Pagella} -\linespread{1.07} % this isn't set correctly for some reason -\textheight=626pt +\textheight=626pt % this isn't set correctly for some reason +\usepackage{luacode} +\tracinglostchars2 +% we replace any missing characters (in Palatino) with CharisSIL +% the lua code is mostly stolen from http://tex.stackexchange.com/a/120529 and http://tex.stackexchange.com/a/119945 +{\CharisSIL\footnotesize\global\expandafter\let\expandafter\fallbackfont\the\font} +\begin{luacode} +local fontcharacters = { } +local nullfont = 0 +local glyph_t = nodes.nodecodes.glyph +local whatsit_t = nodes.nodecodes.whatsit +local colorst_t = node.subtype("pdf_colorstack") +local color_push = node.new(whatsit_t,colorst_t) +local color_pop = node.new(whatsit_t,colorst_t) +color_push.stack, color_pop.stack = 0,0 +color_push.command,color_pop.command = 1,2 +color_push.data = "0.97 0.04 0.07 rg" -- red +local fallbackfont = font.id("fallbackfont") +table.setmetatableindex(fontcharacters, function (t, k) + if k == true then + return fontcharacters[currentfont()] + else + local tfmdata = fonts.hashes.identifiers[k] + if not tfmdata then --- unsafe + tfmdata = font.fonts[k] + if not (tfmdata and type (tfmdata) == "table") then + return false + end + end + local characters = tfmdata.characters + t[k] = characters + return characters + end +end) +local nodeprocessor = function (head) + local lastfont, characters = nil, nil + for n in node.traverse_id(glyph_t, head) do + local currfont = n.font + local char = n.char + if currfont ~= lastfont and currfont ~= nullfont then + characters = fontcharacters[currfont] + end + if characters ~= false then + lastfont = currfont + if not characters[char] then + head = node.insert_before(head,n,node.copy(color_push)) + node.insert_after(head,n,node.copy(color_pop)) + n.font = fallbackfont + if not fontcharacters[fallbackfont][char] then -- not even in Charis SIL + n.char = 0xFFFD + end + end + end + end + return head, false +end +luatexbase.add_to_callback("pre_linebreak_filter", nodeprocessor, "replace missing glyphs") +\end{luacode} \DisableCrossrefs +\RecordChanges \begin{document} \DocInput{\jobname.dtx} \end{document} @@ -51,7 +113,9 @@ % \fi %\StopEventually{} % -%\GeneralChanges* +%\GeneralChanges{Documentation} +%\changes{v2.5a}{2013/05/15}{include OpenType configuration files} +%\changes{v2.6}{2015/12/07}{missing characters printed with Charis } %\ImplementationSettings %\InputIfFileExists{microtype-utf.tmp}\relax\relax %\edef\startpage{\thepage} @@ -62,17 +126,16 @@ % %\section{OpenType configuration files} % -% These are the configuration files for the following OpenType fonts:\footnote{This is file \file{microtype-utf.dtx}.} +% These are the configuration files for the following OpenType fonts:\footnote{This is file \file{\jobname.dtx}.} % %\begin{itemize} % \item {\LMR % Latin Modern Roman} % \item {\CharisSIL -% Charis }\footnote{This font is available at -% \url{http://scripts.sil.org/CharisSILfont}.} +% Charis }\footnote{Available at \url{http://scripts.sil.org/CharisSILfont}.} % \item {\PalatinoLinotype % Palatino Linotype}\footnote{These settings have been contributed by -% \contributor Loren Davis .} +% \contributor Loren B. Davis .} %\end{itemize} % %\noindent @@ -92,10 +155,10 @@ %%% ----------------------------------------------------------------------- %%% INHERITANCE -%% for xetex (EU1) and luatex (EU2) +%% for xetex (EU1) and luatex (EU2), resp. both (TU) %<*LatinModernRoman> \DeclareCharacterInheritance - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = Latin Modern Roman } % \end{macrocode} %{\setmacrofont\LMR @@ -162,7 +225,7 @@ % %<*CharisSIL> \DeclareCharacterInheritance - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = Charis SIL } % \end{macrocode} %{\setmacrofont\CharisSIL @@ -293,12 +356,13 @@ % %<*PalatinoLinotype> \DeclareCharacterInheritance - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = {PalatinoLinotype} } % \end{macrocode} % Unfortunately, I don't have a Palatino variant containing all of the following -% glyphs, which will therefore not show up here. The following is typeset in -% \TeX\ Gyre Pagella. +% glyphs. The settings are typeset in \TeX\ Gyre Pagella; +% missing glyphs, printed in red, are taken from Charis ; +% glyphs missing even in Charis appear as `\char"FFFD'. % To see the real settings, consult \file{mt-PalatinoLinotype.cfg}. %{\setmacrofont\PalatinoLinotype % \begin{macrocode} @@ -372,7 +436,7 @@ %<*LatinModernRoman> \SetProtrusion [ name = LMR-default ] - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = Latin Modern Roman } { % \end{macrocode} @@ -431,7 +495,7 @@ « = {300,200}, » = {100,400}, ¡ = {100, }, ¿ = {100, }, ( = {300, }, ) = { ,300}, - < = {200,100}, > = {100,200}, + < = {200,100}, > = {100,200}, /braceleft = {400,200}, /braceright = {200,400}, /angleleft = {400, }, /angleright = { ,400}, † = {100,100}, @@ -478,7 +542,7 @@ \SetProtrusion [ name = LMR-it ] - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = Latin Modern Roman, shape = {it,sl} } { @@ -627,7 +691,7 @@ %<*CharisSIL> \SetProtrusion [ name = Charis-default ] - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = Charis SIL } { % \end{macrocode} @@ -697,7 +761,7 @@ « = {200,200}, » = {150,300}, ¡ = {100, }, ¿ = {100, }, ( = {200, }, ) = { ,200}, - < = {200,150}, > = {100,200}, + < = {200,150}, > = {100,200}, [ = {100, }, ] = { ,100}, /braceleft = {200, }, /braceright = { ,300}, † = { 80, 80}, @@ -806,7 +870,7 @@ \SetProtrusion [ name = Charis-it ] - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = Charis SIL, shape = {it,sl} } { @@ -863,7 +927,7 @@ ‹ = {300,400}, › = {200,500}, « = {200,300}, » = {150,400}, ( = {200, }, ) = { ,200}, - < = {200,200}, > = {200,200}, + < = {200,200}, > = {200,200}, /braceleft = {300, }, /braceright = { ,200}, % Cyrillic Ж = {50,30}, @@ -917,7 +981,7 @@ \SetProtrusion [ name = Charis-sc, load = Charis-default ] - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = Charis SIL, shape = {sc} } { @@ -951,7 +1015,7 @@ %<*PalatinoLinotype> \SetProtrusion [ name = palatino-default ] - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = {PalatinoLinotype} } { % \end{macrocode} @@ -1053,7 +1117,7 @@ \SetProtrusion [ name = palatino-it ] - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = {PalatinoLinotype}, shape = {it,sl} } { @@ -1152,7 +1216,7 @@ \SetProtrusion [ name = palatino-sc, load = palatino-default ] - { encoding = {EU1,EU2}, + { encoding = {EU1,EU2,TU}, family = {PalatinoLinotype}, shape = sc } { -- cgit v1.2.3