summaryrefslogtreecommitdiff
path: root/tex/generic
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2015-07-27 20:15:05 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2015-07-27 20:15:05 +0200
commit840fb4a9d8351042ac6a73a3bb1ae1146fc9cbc1 (patch)
tree18f3acde560cfe4594753af86dfa39bfde1d21ba /tex/generic
parent619d3b4f6f8f86d8ed2f67b6eadce948ba951aec (diff)
downloadcontext-840fb4a9d8351042ac6a73a3bb1ae1146fc9cbc1.tar.gz
2015-07-27 19:38:00
Diffstat (limited to 'tex/generic')
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua125
-rw-r--r--tex/generic/context/luatex/luatex-gadgets.lua75
-rw-r--r--tex/generic/context/luatex/luatex-gadgets.tex25
-rw-r--r--tex/generic/context/luatex/luatex-plain.tex2
4 files changed, 171 insertions, 56 deletions
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index beff7cf61..5de00c5d4 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 07/24/15 13:58:54
+-- merge date : 07/27/15 19:36:10
do -- begin closure to overcome local limits and interference
@@ -4492,21 +4492,28 @@ function constructors.scale(tfmdata,specification)
target.nomath=true
target.mathparameters=nil
end
- local italickey="italic"
- local useitalics=true
if hasmath then
- autoitalicamount=false
- elseif properties.textitalics then
- italickey="italic_correction"
- useitalics=false
- if properties.delaytextitalics then
+ local mathitalics=properties.mathitalics
+ if mathitalics==false then
+ if trace_defining then
+ report_defining("%s italics %s for font %a, fullname %a, filename %a","math",hasitalics and "ignored" or "disabled",name,fullname,filename)
+ end
+ hasitalics=false
+ autoitalicamount=false
+ end
+ else
+ local textitalics=properties.textitalics
+ if textitalics==false then
+ if trace_defining then
+ report_defining("%s italics %s for font %a, fullname %a, filename %a","text",hasitalics and "ignored" or "disabled",name,fullname,filename)
+ end
+ hasitalics=false
autoitalicamount=false
end
end
if trace_defining then
report_defining("defining tfm, name %a, fullname %a, filename %a, hscale %a, vscale %a, math %a, italics %a",
- name,fullname,filename,hdelta,vdelta,
- hasmath and "enabled" or "disabled",useitalics and "enabled" or "disabled")
+ name,fullname,filename,hdelta,vdelta,hasmath and "enabled" or "disabled",hasitalics and "enabled" or "disabled")
end
constructors.beforecopyingcharacters(target,tfmdata)
local sharedkerns={}
@@ -4604,22 +4611,6 @@ function constructors.scale(tfmdata,specification)
chr.right_protruding=protrusionfactor*width*vr
end
end
- if autoitalicamount then
- local vi=description.italic
- if not vi then
- local vi=description.boundingbox[3]-description.width+autoitalicamount
- if vi>0 then
- chr[italickey]=vi*hdelta
- end
- elseif vi~=0 then
- chr[italickey]=vi*hdelta
- end
- elseif hasitalics then
- local vi=description.italic
- if vi and vi~=0 then
- chr[italickey]=vi*hdelta
- end
- end
if hasmath then
local vn=character.next
if vn then
@@ -4657,7 +4648,7 @@ function constructors.scale(tfmdata,specification)
end
end
end
- local va=character.top_accent
+ local va=character.accent
if va then
chr.top_accent=vdelta*va
end
@@ -4680,6 +4671,27 @@ function constructors.scale(tfmdata,specification)
chr.mathkern=kerns
end
end
+ if hasitalics then
+ local vi=character.italic
+ if vi and vi~=0 then
+ chr.italic=vi*hdelta
+ end
+ end
+ elseif autoitalicamount then
+ local vi=description.italic
+ if not vi then
+ local vi=description.boundingbox[3]-description.width+autoitalicamount
+ if vi>0 then
+ chr.italic=vi*hdelta
+ end
+ elseif vi~=0 then
+ chr.italic=vi*hdelta
+ end
+ elseif hasitalics then
+ local vi=character.italic
+ if vi and vi~=0 then
+ chr.italic=vi*hdelta
+ end
end
if haskerns then
local vk=character.kerns
@@ -4742,6 +4754,7 @@ function constructors.scale(tfmdata,specification)
end
targetcharacters[unicode]=chr
end
+ properties.setitalics=hasitalics
constructors.aftercopyingcharacters(target,tfmdata)
constructors.trytosharefont(target,tfmdata)
return target
@@ -7110,7 +7123,7 @@ local report_otf=logs.reporter("fonts","otf loading")
local fonts=fonts
local otf=fonts.handlers.otf
otf.glists={ "gsub","gpos" }
-otf.version=2.817
+otf.version=2.818
otf.cache=containers.define("fonts","otf",otf.version,true)
local hashes=fonts.hashes
local definers=fonts.definers
@@ -8524,11 +8537,11 @@ local function check_variants(unicode,the_variants,splitter,unicodes)
parts=nil
end
end
- local italic_correction=the_variants.italic_correction
- if italic_correction and italic_correction==0 then
- italic_correction=nil
+ local italic=the_variants.italic
+ if italic and italic==0 then
+ italic=nil
end
- return variants,parts,italic_correction
+ return variants,parts,italic
end
actions["analyze math"]=function(data,filename,raw)
if raw.math then
@@ -8538,13 +8551,14 @@ actions["analyze math"]=function(data,filename,raw)
for unicode,description in next,data.descriptions do
local glyph=description.glyph
local mathkerns=glyph.mathkern
- local horiz_variants=glyph.horiz_variants
- local vert_variants=glyph.vert_variants
- local top_accent=glyph.top_accent
- if mathkerns or horiz_variants or vert_variants or top_accent then
+ local hvariants=glyph.horiz_variants
+ local vvariants=glyph.vert_variants
+ local accent=glyph.top_accent
+ local italic=glyph.italic_correction
+ if mathkerns or hvariants or vvariants or accent or italic then
local math={}
- if top_accent then
- math.top_accent=top_accent
+ if accent then
+ math.accent=accent
end
if mathkerns then
for k,v in next,mathkerns do
@@ -8560,15 +8574,14 @@ actions["analyze math"]=function(data,filename,raw)
end
math.kerns=mathkerns
end
- if horiz_variants then
- math.horiz_variants,math.horiz_parts,math.horiz_italic_correction=check_variants(unicode,horiz_variants,splitter,unicodes)
+ if hvariants then
+ math.hvariants,math.hparts,math.hitalic=check_variants(unicode,hvariants,splitter,unicodes)
end
- if vert_variants then
- math.vert_variants,math.vert_parts,math.vert_italic_correction=check_variants(unicode,vert_variants,splitter,unicodes)
+ if vvariants then
+ math.vvariants,math.vparts,math.vitalic=check_variants(unicode,vvariants,splitter,unicodes)
end
- local italic_correction=description.italic
- if italic_correction and italic_correction~=0 then
- math.italic_correction=italic_correction
+ if italic and italic~=0 then
+ math.italic=italic
end
description.math=math
end
@@ -9104,8 +9117,9 @@ local function copytotfm(data,cache_id)
local d=descriptions[unicode]
local m=d.math
if m then
- local variants=m.horiz_variants
- local parts=m.horiz_parts
+ local italic=m.italic
+ local variants=m.hvariants
+ local parts=m.hparts
if variants then
local c=character
for i=1,#variants do
@@ -9116,9 +9130,10 @@ local function copytotfm(data,cache_id)
c.horiz_variants=parts
elseif parts then
character.horiz_variants=parts
+ italic=m.hitalic
end
- local variants=m.vert_variants
- local parts=m.vert_parts
+ local variants=m.vvariants
+ local parts=m.vparts
if variants then
local c=character
for i=1,#variants do
@@ -9129,14 +9144,14 @@ local function copytotfm(data,cache_id)
c.vert_variants=parts
elseif parts then
character.vert_variants=parts
+ italic=m.vitalic
end
- local italic_correction=m.vert_italic_correction
- if italic_correction then
- character.vert_italic_correction=italic_correction
+ if italic and italic~=0 then
+ character.italic=italic
end
- local top_accent=m.top_accent
- if top_accent then
- character.top_accent=top_accent
+ local accent=m.accent
+ if accent then
+ character.accent=accent
end
local kerns=m.kerns
if kerns then
diff --git a/tex/generic/context/luatex/luatex-gadgets.lua b/tex/generic/context/luatex/luatex-gadgets.lua
new file mode 100644
index 000000000..9bf423fda
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-gadgets.lua
@@ -0,0 +1,75 @@
+if not modules then modules = { } end modules ['luatex-gadgets'] = {
+ version = 1.001,
+ comment = "companion to luatex-gadgets.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+if context then return end
+
+-- This module contains some maybe useful gadgets. More might show up here
+-- as side effect of tutorials or articles. Don't use this file in ConTeXt
+-- because we often have similar mechanisms already.
+
+gadgets = gadgets or { } -- global namespace
+
+-- marking content for optional removal
+
+local marking = { }
+gadgets.marking = marking
+
+local marksignal = 5001 -- will be set in the tex module
+local lastmarked = 0
+local marked = { }
+local local_par = 6
+local whatsit_node = 8
+
+function marking.setsignal(n)
+ marksignal = tonumber(n) or marksignal
+end
+
+function marking.mark(str)
+ local currentmarked = marked[str]
+ if not currentmarked then
+ lastmarked = lastmarked + 1
+ currentmarked = lastmarked
+ marked[str] = currentmarked
+ end
+ tex.setattribute(marksignal,currentmarked)
+end
+
+function marking.remove(str)
+ local attr = marked[str]
+ if not attr then
+ return
+ end
+ local list = tex.nest[tex.nest.ptr]
+ if list then
+ local head = list.head
+ local tail = list.tail
+ local last = tail
+ if last[marksignal] == attr then
+ local first = last
+ while true do
+ local prev = first.prev
+ if not prev
+ or prev[marksignal] ~= attr
+ or (prev.id == whatsit_node and prev.subtype == local_par) then
+ break
+ else
+ first = prev
+ end
+ end
+ if first == head then
+ list.head = nil
+ list.tail = nil
+ else
+ local prev = first.prev
+ list.tail = prev
+ prev.next = nil
+ end
+ node.flush_list(first)
+ end
+ end
+end
diff --git a/tex/generic/context/luatex/luatex-gadgets.tex b/tex/generic/context/luatex/luatex-gadgets.tex
new file mode 100644
index 000000000..0faba7f97
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-gadgets.tex
@@ -0,0 +1,25 @@
+%D \module
+%D [ file=luatex-gadgets,
+%D version=2015.05.12,
+%D title=\LUATEX\ Support Macros,
+%D subtitle=Useful stuff from articles,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+
+\directlua{dofile(resolvers.findfile('luatex-gadgets.lua'))}
+
+% optional removal of marked content
+%
+% before\marksomething{gone}{\em HERE}\unsomething{gone}after
+% before\marksomething{kept}{\em HERE}\unsomething{gone}after
+% \marksomething{gone}{\em HERE}\unsomething{gone}last
+% \marksomething{kept}{\em HERE}\unsomething{gone}last
+
+\def\setmarksignal #1{\directlua{gadgets.marking.setsignal(\number#1)}}
+\def\marksomething#1#2{{\directlua{gadgets.marking.mark("#1")}{#2}}}
+\def\unsomething #1{\directlua{gadgets.marking.remove("#1")}}
+
+\newattribute\gadgetmarkattribute \setmarksignal\gadgetmarkattribute
+
+\endinput
diff --git a/tex/generic/context/luatex/luatex-plain.tex b/tex/generic/context/luatex/luatex-plain.tex
index f209f4792..2c04a27c0 100644
--- a/tex/generic/context/luatex/luatex-plain.tex
+++ b/tex/generic/context/luatex/luatex-plain.tex
@@ -39,7 +39,7 @@
\input {luatex-math}%
\input {luatex-languages}%
\input {luatex-mplib}%
- % \input {luatex-gadgets}%
+ \input {luatex-gadgets}%
}
% We also patch the version number: