From 1322a68f39039ed20ebf57ff278be74f209a399f Mon Sep 17 00:00:00 2001 From: Marius Date: Thu, 29 Aug 2013 00:20:29 +0300 Subject: beta 2013.08.28 23:08 --- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4108 -> 4110 bytes tex/context/base/context.mkiv | 2 +- tex/context/base/font-afm.lua | 2 +- tex/context/base/font-con.lua | 22 ++----- tex/context/base/font-ctx.lua | 73 +++++++++++++++++---- tex/context/base/font-ini.mkvi | 11 +++- tex/context/base/font-otf.lua | 2 +- tex/context/base/m-hemistich.mkiv | 2 +- tex/context/base/mlib-pps.lua | 7 ++ tex/context/base/mult-mps.lua | 1 + tex/context/base/spac-ver.mkiv | 2 +- tex/context/base/status-files.pdf | Bin 24755 -> 24725 bytes tex/context/base/status-lua.log | 2 +- tex/context/base/typo-drp.lua | 63 ++++++++++-------- tex/context/base/typo-drp.mkiv | 26 +++++--- tex/generic/context/luatex/luatex-fonts-merged.lua | 18 ++--- 17 files changed, 152 insertions(+), 83 deletions(-) (limited to 'tex') diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 4483e54e5..2d8f76d93 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.08.26 16:41} +\newcontextversion{2013.08.28 23:08} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf index 142d68af1..465b5c002 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 0213ba936..4a3fd8877 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -25,7 +25,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.08.26 16:41} +\edef\contextversion{2013.08.28 23:08} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/font-afm.lua b/tex/context/base/font-afm.lua index ac27d652c..1c68dc706 100644 --- a/tex/context/base/font-afm.lua +++ b/tex/context/base/font-afm.lua @@ -637,7 +637,7 @@ local function copytotfm(data) parameters.x_height = 400 parameters.quad = 1000 -- - if italicangle then + if italicangle and italicangle ~= 0 then parameters.italicangle = italicangle parameters.italicfactor = math.cos(math.rad(90+italicangle)) parameters.slant = - math.tan(italicangle*math.pi/180) diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua index c5f891f27..4a84d441a 100644 --- a/tex/context/base/font-con.lua +++ b/tex/context/base/font-con.lua @@ -380,7 +380,7 @@ function constructors.scale(tfmdata,specification) targetproperties.mode = properties.mode or "base" -- inherited -- local askedscaledpoints = scaledpoints - local scaledpoints, delta = constructors.calculatescale(tfmdata,scaledpoints) -- no shortcut, dan be redefined + local scaledpoints, delta = constructors.calculatescale(tfmdata,scaledpoints,nil,specification) -- no shortcut, dan be redefined -- local hdelta = delta local vdelta = delta @@ -1000,21 +1000,11 @@ function constructors.hashinstance(specification,force) size = math.round(constructors.scaled(size,designsizes[hash])) specification.size = size end - -- local mathsize = specification.mathsize or 0 - -- if mathsize > 0 then - -- local textsize = specification.textsize - -- if fallbacks then - -- return hash .. ' @ ' .. tostring(size) .. ' [ ' .. tostring(mathsize) .. ' : ' .. tostring(textsize) .. ' ] @ ' .. fallbacks - -- else - -- return hash .. ' @ ' .. tostring(size) .. ' [ ' .. tostring(mathsize) .. ' : ' .. tostring(textsize) .. ' ]' - -- end - -- else - if fallbacks then - return hash .. ' @ ' .. tostring(size) .. ' @ ' .. fallbacks - else - return hash .. ' @ ' .. tostring(size) - end - -- end + if fallbacks then + return hash .. ' @ ' .. tostring(size) .. ' @ ' .. fallbacks + else + return hash .. ' @ ' .. tostring(size) + end end function constructors.setname(tfmdata,specification) -- todo: get specification from tfmdata diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index 229915fb8..8b44d1c36 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -801,12 +801,16 @@ local value = C((leftparent * (1-rightparent)^0 * rightparent + (1-space) local dimension = C((space/"" + P(1))^1) local rest = C(P(1)^0) local scale_none = Cc(0) -local scale_at = P("at") * Cc(1) * spaces * dimension -- value -local scale_sa = P("sa") * Cc(2) * spaces * dimension -- value -local scale_mo = P("mo") * Cc(3) * spaces * dimension -- value -local scale_scaled = P("scaled") * Cc(4) * spaces * dimension -- value +local scale_at = P("at") * Cc(1) * spaces * dimension -- dimension +local scale_sa = P("sa") * Cc(2) * spaces * dimension -- number +local scale_mo = P("mo") * Cc(3) * spaces * dimension -- number +local scale_scaled = P("scaled") * Cc(4) * spaces * dimension -- number +local scale_ht = P("ht") * Cc(5) * spaces * dimension -- dimension +local scale_cp = P("cp") * Cc(6) * spaces * dimension -- dimension -local sizepattern = spaces * (scale_at + scale_sa + scale_mo + scale_scaled + scale_none) +local specialscale = { [5] = "ht", [6] = "cp" } + +local sizepattern = spaces * (scale_at + scale_sa + scale_mo + scale_ht + scale_cp + scale_scaled + scale_none) local splitpattern = spaces * value * spaces * rest function helpers.splitfontpattern(str) @@ -884,7 +888,7 @@ local function nice_cs(cs) end function commands.definefont_two(global,cs,str,size,inheritancemode,classfeatures,fontfeatures,classfallbacks,fontfallbacks, - mathsize,textsize,relativeid,classgoodies,goodies,classdesignsize,fontdesignsize) + mathsize,textsize,relativeid,classgoodies,goodies,classdesignsize,fontdesignsize,scaledfontmode) if trace_defining then report_defining("start stage two: %s (size %s)",str,size) end @@ -914,6 +918,7 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature local id = tonumber(relativeid) or 0 specification.relativeid = id > 0 and id end + -- specification.name = name specification.size = size specification.sub = (sub and sub ~= "" and sub) or specification.sub @@ -922,6 +927,7 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature specification.goodies = goodies specification.cs = cs specification.global = global + specification.scalemode = scaledfontmode -- context specific if detail and detail ~= "" then specification.method = method or "*" specification.detail = detail @@ -991,7 +997,9 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature csnames[tfmdata] = specification.cs texdefinefont(global,cs,tfmdata) -- resolved (when designsize is used): - setsomefontsize((fontdata[tfmdata].parameters.size or 0) .. "sp") + local size = fontdata[tfmdata].parameters.size or 0 + setsomefontsize(size .. "sp") +texsetcount("scaledfontsize",size) lastfontid = tfmdata else -- setting the extra characters will move elsewhere @@ -1016,7 +1024,9 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks) end -- resolved (when designsize is used): - setsomefontsize((tfmdata.parameters.size or 655360) .. "sp") + local size = tfmdata.parameters.size or 655360 + setsomefontsize(size .. "sp") +texsetcount("scaledfontsize",size) lastfontid = id end if trace_defining then @@ -1149,9 +1159,25 @@ end) local calculatescale = constructors.calculatescale -function constructors.calculatescale(tfmdata,scaledpoints,relativeid) - local scaledpoints, delta = calculatescale(tfmdata,scaledpoints) - -- if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific +function constructors.calculatescale(tfmdata,scaledpoints,relativeid,specification) + if specification then + local scalemode = specification.scalemode + local special = scalemode and specialscale[scalemode] + if special then + -- we also have available specification.textsize + local parameters = tfmdata.parameters + local designsize = parameters.designsize + if special == "ht" then + local height = parameters.ascender * designsize / parameters.units + scaledpoints = (scaledpoints/height) * designsize + elseif special == "cp" then + local height = (tfmdata.descriptions[utf.byte("X")].height or parameters.ascender) * designsize / parameters.units + scaledpoints = (scaledpoints/height) * designsize + end + end + end + scaledpoints, delta = calculatescale(tfmdata,scaledpoints) + -- if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific (we need to hash rscale then) -- local relativedata = fontdata[relativeid] -- local rfmdata = relativedata and relativedata.unscaled and relativedata.unscaled -- local id_x_height = rfmdata and rfmdata.parameters and rfmdata.parameters.x_height @@ -1165,6 +1191,31 @@ function constructors.calculatescale(tfmdata,scaledpoints,relativeid) return scaledpoints, delta end +local designsizes = constructors.designsizes + +function constructors.hashinstance(specification,force) + local hash, size, fallbacks = specification.hash, specification.size, specification.fallbacks + if force or not hash then + hash = constructors.hashfeatures(specification) + specification.hash = hash + end + if size < 1000 and designsizes[hash] then + size = math.round(constructors.scaled(size,designsizes[hash])) + specification.size = size + end + if fallbacks then + return hash .. ' @ ' .. tostring(size) .. ' @ ' .. fallbacks + else + local scalemode = specification.scalemode + local special = scalemode and specialscale[scalemode] + if special then + return hash .. ' @ ' .. tostring(size) .. ' @ ' .. special + else + return hash .. ' @ ' .. tostring(size) + end + end +end + -- We overload the (generic) resolver: local resolvers = definers.resolvers diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi index 768fea070..0d356895e 100644 --- a/tex/context/base/font-ini.mkvi +++ b/tex/context/base/font-ini.mkvi @@ -700,6 +700,7 @@ \let\somefontsize\zerocount \newcount\scaledfontmode % also used at the lua end +\newcount\scaledfontsize % also used at the lua end \newcount\lastfontid % also used at the lua end / tex end \newtoks \everydefinefont @@ -755,6 +756,9 @@ \or % scaled, don't use this one as it's unpredictable \d_font_scaled_font_size-\somefontsize\scaledpoint + \else % ht cp + % experiment, yet undocumented + \d_font_scaled_font_size\somefontsize \fi \relax \d_font_scaled_font_size\v_font_size_relative\d_font_scaled_font_size @@ -770,7 +774,7 @@ \else \d_font_scaled_text_face\textface \fi - \edef\somefontspec{at \number\d_font_scaled_font_size sp}% + \edef\somefontspec{at \number\d_font_scaled_font_size sp}% probably no longer used, needs checking \edef\somefontfile{\truefontname\somefontname}% \ifx\somefontfile\s!unknown \edef\somefontfile{\defaultfontfile}% @@ -797,9 +801,10 @@ "\m_font_class_goodies", % experiment (not yet used) "\m_font_goodies", "\m_font_class_designsize", - "\m_font_designsize" + "\m_font_designsize", + \number\scaledfontmode )}% - \edef\somefontspec{at \number\d_font_scaled_font_size sp}% we need the resolved designsize (for fallbacks) + \edef\somefontspec{at \number\scaledfontsize sp}% we need the resolved designsize (for fallbacks) \expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname \the\everydefinefont \c_font_feature_inheritance_mode\c_font_feature_inheritance_default} diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 7e267b15b..c694211b9 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -2087,7 +2087,7 @@ local function copytotfm(data,cache_id) if spaceunits < 2*units/5 then -- todo: warning end - if italicangle then + if italicangle and italicangle ~= 0 then parameters.italicangle = italicangle parameters.italicfactor = math.cos(math.rad(90+italicangle)) parameters.slant = - math.tan(italicangle*math.pi/180) diff --git a/tex/context/base/m-hemistich.mkiv b/tex/context/base/m-hemistich.mkiv index 70c467c7b..55fde7b92 100644 --- a/tex/context/base/m-hemistich.mkiv +++ b/tex/context/base/m-hemistich.mkiv @@ -71,7 +71,7 @@ \setuphemistich [leftcolor=darkred, - middlecolor=darkgreen, + separatorcolor=darkgreen, rightcolor=darkblue] \setupwhitespace diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index 4a887150d..96d5c092f 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -809,6 +809,7 @@ local function tx_reset() end local fmt = formatters["%s %s %s % t"] +local pat = lpeg.tsplitat(":") local function tx_analyze(object,prescript) -- todo: hash content and reuse them local tx_stage = prescript.tx_stage @@ -817,6 +818,12 @@ local function tx_analyze(object,prescript) -- todo: hash content and reuse them local tx_number = tonumber(prescript.tx_number) local s = object.postscript or "" local c = object.color -- only simple ones, no transparency + if #c == 0 then + local txc = prescript.tx_color + if txc then + c = lpegmatch(pat,txc) + end + end local a = prescript.tr_alternative local t = prescript.tr_transparency local h = fmt(tx_number,a or "?",t or "?",c) diff --git a/tex/context/base/mult-mps.lua b/tex/context/base/mult-mps.lua index 48fe36b52..fa93f7ef8 100644 --- a/tex/context/base/mult-mps.lua +++ b/tex/context/base/mult-mps.lua @@ -51,6 +51,7 @@ return { "top", "bot", "lft", "rt", "ulft", "urt", "llft", "lrt", -- "redpart", "greenpart", "bluepart", "cyanpart", "magentapart", "yellowpart", "blackpart", "greypart", + "prescriptpart", "postscriptpart", "rgbcolor", "cmykcolor", "greycolor", "graycolor", "colormodel", "graypart", "dashpart", "penpart", diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv index 12d864e96..3b60c28bb 100644 --- a/tex/context/base/spac-ver.mkiv +++ b/tex/context/base/spac-ver.mkiv @@ -984,7 +984,7 @@ \setcharstrut\m_strut \fi} -\unexpanded\def\showstruts +\unexpanded\def\showstruts % adapts .. is wrong {\setteststrut \settestcrlf} diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 84a07b1c0..a984f1c6b 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.log b/tex/context/base/status-lua.log index 44685e6c7..ae1d43e6c 100644 --- a/tex/context/base/status-lua.log +++ b/tex/context/base/status-lua.log @@ -1,6 +1,6 @@ (cont-yes.mkiv -ConTeXt ver: 2013.08.26 16:41 MKIV beta fmt: 2013.8.26 int: english/english +ConTeXt ver: 2013.08.28 23:08 MKIV beta fmt: 2013.8.28 int: english/english system > 'cont-new.mkiv' loaded (cont-new.mkiv) diff --git a/tex/context/base/typo-drp.lua b/tex/context/base/typo-drp.lua index b7815efc2..1f935802d 100644 --- a/tex/context/base/typo-drp.lua +++ b/tex/context/base/typo-drp.lua @@ -6,9 +6,8 @@ if not modules then modules = { } end modules ['typo-drp'] = { license = "see context related readme files" } --- A playground for experiments. Currently we only have a dropped caps as special --- but there might be more, so for the moment we keep this 'paragraphs' namespace --- for this. +-- This ons is sensitive for order (e.g. when combined with first line +-- processing. local tonumber, type, next = tonumber, type, next local ceil = math.ceil @@ -29,7 +28,9 @@ local hpack_nodes = nodes.hpack local nodecodes = nodes.nodecodes local whatsitcodes = nodes.whatsitcodes -local new_kern = nodes.pool.kern +local nodepool = nodes.pool +local new_kern = nodepool.kern + local insert_before = nodes.insert_before local insert_after = nodes.insert_after @@ -109,6 +110,9 @@ actions[v_default] = function(head,setting) if setting.font then first.font = setting.font end + if setting.dynamic > 0 then + first[0] = setting.dynamic + end -- can be a helper local ma = setting.ma or 0 local ca = setting.ca @@ -121,33 +125,38 @@ actions[v_default] = function(head,setting) first[a_transparency] = ta end -- - local width = first.width - local height = first.height - local depth = first.depth - local distance = setting.distance or 0 - local voffset = setting.voffset or 0 - local hoffset = setting.hoffset or 0 - first.xoffset = - width - hoffset - distance - parindent - first.yoffset = - height - voffset - if true then - -- needed till we can store parindent with localpar - first.prev = nil - first.next = nil - local h = hpack_nodes(first) - h.width = 0 - h.height = 0 - h.depth = 0 - prev.next = h - next.prev = h - h.next = next - h.prev = prev - end + local width = first.width + local height = first.height + local depth = first.depth + local distance = setting.distance or 0 + local voffset = setting.voffset or 0 + local hoffset = setting.hoffset or 0 + local parindent = tex.parindent + local baseline = texget("baselineskip").width + local lines = tonumber(setting.n) or 0 + -- + first.xoffset = - width - hoffset - distance - parindent + first.yoffset = - voffset -- no longer - height here + -- We pack so that successive handling cannot touch the dropped cap. Packaging + -- in a hlist is also needed because we cannot locally adapt e.g. parindent (not + -- yet stored in with localpar). + first.prev = nil + first.next = nil + local h = hpack_nodes(first) + h.width = 0 + h.height = 0 + h.depth = 0 + prev.next = h + next.prev = h + h.next = next + h.prev = prev + + -- end of packaging if setting.location == v_margin then -- okay else - local lines = tonumber(setting.n) or 0 if lines == 0 then -- safeguard, not too precise - lines = ceil((height+voffset) / texget("baselineskip").width) + lines = ceil((height+voffset) / baseline) end -- We cannot set parshape yet ... when we can I'll add a slope -- option (positive and negative, in emwidth). diff --git a/tex/context/base/typo-drp.mkiv b/tex/context/base/typo-drp.mkiv index c78ed8d61..78f6df0a2 100644 --- a/tex/context/base/typo-drp.mkiv +++ b/tex/context/base/typo-drp.mkiv @@ -52,17 +52,17 @@ \installcommandhandler \??initial {initial} \??initial -\def\v_typo_initials_auto_scale % magic - {\the\dimexpr\lineheight*\initialparameter\c!n-\initialparameter\c!voffset\relax} +\definemeasure[initial:n][\lineheight*\initialparameter\c!n - \strutdp] \setupinitial [\c!location=\v!text, \c!n=3, % \s!font=Bold sa 4, - \s!font=Bold at \v_typo_initials_auto_scale, - \c!distance=.125em, + % \s!font=Bold ht \measure{initial:n}, + \s!font=Bold cp \measure{initial:n}, + \c!distance=.125\emwidth, \c!hoffset=\zeropoint, - \c!voffset=-1ex, + \c!voffset=\v!line, % \dimexp\lineheight*\initialparameter\c!n-\lineheight\relax] \c!style=, \c!color=, \c!before=\blank] @@ -85,6 +85,12 @@ {\dontleavehmode \begingroup \edef\currentinitial{#1}% + \scratchcounter \initialparameter\c!n\relax + \scratchdistance\initialparameter\c!distance\relax + \scratchhoffset \initialparameter\c!hoffset \relax + \edef\p_voffset{\initialparameter\c!voffset}% + \scratchvoffset\dimexpr\ifx\p_voffset\v!line\scratchcounter\lineheight-\lineheight\else\p_voffset\fi\relax + \resetfontfeature % might be needed in more places \doifelsenothing{\initialparameter\c!style} {\definedfont[\initialparameter\s!font]} {\useinitialstyleparameter\c!style}% @@ -92,15 +98,15 @@ \ctxcommand{setinitial{ location = "\initialparameter\c!location", enabled = true, - n = \number\initialparameter\c!n, - distance = \number\dimexpr\initialparameter\c!distance, - hoffset = \number\dimexpr\initialparameter\c!hoffset, - voffset = \number\dimexpr\initialparameter\c!voffset, + n = \number\scratchcounter, + distance = \number\scratchdistance, + hoffset = \number\scratchhoffset, + voffset = \number\scratchvoffset, ma = \the\attribute\colormodelattribute , ca = \the\attribute\colorattribute , ta = \the\attribute\transparencyattribute, font = \fontid\font, - dynamic = \number\attribute\zerocount, + dynamic = \number\attribute\zerocount, % it's a bit over the top to support this here }}% \stopluacode \kern\zeropoint % we need a node diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 649c5371d..ff4758068 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 : 08/26/13 16:41:50 +-- merge date : 08/28/13 23:08:58 do -- begin closure to overcome local limits and interference @@ -3770,7 +3770,7 @@ function constructors.scale(tfmdata,specification) targetproperties.script=properties.script or "dflt" targetproperties.mode=properties.mode or "base" local askedscaledpoints=scaledpoints - local scaledpoints,delta=constructors.calculatescale(tfmdata,scaledpoints) + local scaledpoints,delta=constructors.calculatescale(tfmdata,scaledpoints,nil,specification) local hdelta=delta local vdelta=delta target.designsize=parameters.designsize @@ -4286,11 +4286,11 @@ function constructors.hashinstance(specification,force) size=math.round(constructors.scaled(size,designsizes[hash])) specification.size=size end - if fallbacks then - return hash..' @ '..tostring(size)..' @ '..fallbacks - else - return hash..' @ '..tostring(size) - end + if fallbacks then + return hash..' @ '..tostring(size)..' @ '..fallbacks + else + return hash..' @ '..tostring(size) + end end function constructors.setname(tfmdata,specification) if constructors.namemode=="specification" then @@ -5705,7 +5705,7 @@ local function copytotfm(data) parameters.space_shrink=333 parameters.x_height=400 parameters.quad=1000 - if italicangle then + if italicangle and italicangle~=0 then parameters.italicangle=italicangle parameters.italicfactor=math.cos(math.rad(90+italicangle)) parameters.slant=- math.tan(italicangle*math.pi/180) @@ -7996,7 +7996,7 @@ local function copytotfm(data,cache_id) parameters.quad=units if spaceunits<2*units/5 then end - if italicangle then + if italicangle and italicangle~=0 then parameters.italicangle=italicangle parameters.italicfactor=math.cos(math.rad(90+italicangle)) parameters.slant=- math.tan(italicangle*math.pi/180) -- cgit v1.2.3