summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-ttf.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-03-21 14:58:43 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-03-21 14:58:43 +0100
commit8516f1b516a309aebe2194af1c049dbfe76635e5 (patch)
tree51f6289fb13f673e03f96a0f4e0aff8eece0780a /tex/context/base/mkiv/font-ttf.lua
parent8e0089484acf80066e7393b1245d59dda211be09 (diff)
downloadcontext-8516f1b516a309aebe2194af1c049dbfe76635e5.tar.gz
2017-03-21 14:27:00
Diffstat (limited to 'tex/context/base/mkiv/font-ttf.lua')
-rw-r--r--tex/context/base/mkiv/font-ttf.lua65
1 files changed, 30 insertions, 35 deletions
diff --git a/tex/context/base/mkiv/font-ttf.lua b/tex/context/base/mkiv/font-ttf.lua
index d222de4ba..96c1d165a 100644
--- a/tex/context/base/mkiv/font-ttf.lua
+++ b/tex/context/base/mkiv/font-ttf.lua
@@ -135,11 +135,10 @@ end
-- begin of converter
local function curveto(m_x,m_y,l_x,l_y,r_x,r_y) -- todo: inline this
- return {
+ return
l_x + 2/3 *(m_x-l_x), l_y + 2/3 *(m_y-l_y),
r_x + 2/3 *(m_x-r_x), r_y + 2/3 *(m_y-r_y),
- r_x, r_y, "c" -- "curveto"
- }
+ r_x, r_y, "c"
end
-- We could omit the operator which saves some 10%:
@@ -228,9 +227,10 @@ end
-- round or not ?
+-- local quadratic = true -- both methods work, todo: install a directive
+local quadratic = false
+
local function contours2outlines_normal(glyphs,shapes) -- maybe accept the bbox overhead
- local quadratic = true
- -- local quadratic = false
for index=1,#glyphs do
local shape = shapes[index]
if shape then
@@ -305,7 +305,7 @@ local function contours2outlines_normal(glyphs,shapes) -- maybe accept the bbox
if quadratic then
segments[nofsegments] = { x1, y1, x2, y2, "q" } -- "quadraticto"
else
- x1, x2, x2, y2, px, py = curveto(x1, x2, px, py, x2, y2)
+ x1, y1, x2, y2, px, py = curveto(x1, y1, px, py, x2, y2)
segments[nofsegments] = { x1, y1, x2, y2, px, py, "c" } -- "curveto"
end
control_pt = false
@@ -316,7 +316,7 @@ local function contours2outlines_normal(glyphs,shapes) -- maybe accept the bbox
if quadratic then
segments[nofsegments] = { x1, y1, x2, y2, "q" } -- "quadraticto"
else
- x1, x2, x2, y2, px, py = curveto(x1, x2, px, py, x2, y2)
+ x1, y1, x2, y2, px, py = curveto(x1, y1, px, py, x2, y2)
segments[nofsegments] = { x1, y1, x2, y2, px, py, "c" } -- "curveto"
end
control_pt = current_pt
@@ -327,17 +327,16 @@ local function contours2outlines_normal(glyphs,shapes) -- maybe accept the bbox
-- we're already done, probably a simple curve
else
nofsegments = nofsegments + 1
+ local x2, y2 = first_pt[1], first_pt[2]
if not control_pt then
- segments[nofsegments] = { first_pt[1], first_pt[2], "l" } -- "lineto"
+ segments[nofsegments] = { x2, y2, "l" } -- "lineto"
elseif quadratic then
local x1, y1 = control_pt[1], control_pt[2]
- -- local x2, y2 = first_pt[1], first_pt[2]
- segments[nofsegments] = { x1, y1, first_pt[1], first_pt[2], "q" } -- "quadraticto"
+ segments[nofsegments] = { x1, y1, x2, y2, "q" } -- "quadraticto"
else
local x1, y1 = control_pt[1], control_pt[2]
- local x2, y2 = first_pt[1], first_pt[2]
- x1, x2, x2, y2, px, py = curveto(x1, x2, px, py, x2, y2)
- segments[nofsegments] = { x1, y1, y2, y2, px, py, "c" } -- "curveto"
+ x1, y1, x2, y2, px, py = curveto(x1, y1, px, py, x2, y2)
+ segments[nofsegments] = { x1, y1, x2, y2, px, py, "c" } -- "curveto"
-- px, py = x2, y2
end
end
@@ -352,8 +351,6 @@ local function contours2outlines_normal(glyphs,shapes) -- maybe accept the bbox
end
local function contours2outlines_shaped(glyphs,shapes,keepcurve)
- local quadratic = true
- -- local quadratic = false
for index=1,#glyphs do
local shape = shapes[index]
if shape then
@@ -447,7 +444,7 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
segments[nofsegments] = { x1, y1, x2, y2, "q" } -- "quadraticto"
end
else
- x1, x2, x2, y2, px, py = curveto(x1, x2, px, py, x2, y2)
+ x1, y1, x2, y2, px, py = curveto(x1, y1, px, py, x2, y2)
if x1 < xmin then xmin = x1 elseif x1 > xmax then xmax = x1 end
if y1 < ymin then ymin = y1 elseif y1 > ymax then ymax = y1 end
if x2 < xmin then xmin = x2 elseif x2 > xmax then xmax = x2 end
@@ -471,7 +468,7 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
segments[nofsegments] = { x1, y1, x2, y2, "q" } -- "quadraticto"
end
else
- x1, x2, x2, y2, px, py = curveto(x1, x2, px, py, x2, y2)
+ x1, y1, x2, y2, px, py = curveto(x1, y1, px, py, x2, y2)
if x1 < xmin then xmin = x1 elseif x1 > xmax then xmax = x1 end
if y1 < ymin then ymin = y1 elseif y1 > ymax then ymax = y1 end
if x2 < xmin then xmin = x2 elseif x2 > xmax then xmax = x2 end
@@ -494,30 +491,28 @@ local function contours2outlines_shaped(glyphs,shapes,keepcurve)
nofsegments = nofsegments + 1
segments[nofsegments] = { first_pt[1], first_pt[2], "l" } -- "lineto"
end
- elseif quadratic then
- local x1, y1 = control_pt[1], control_pt[2]
- -- local x2, y2 = first_pt[1], first_pt[2]
- if x1 < xmin then xmin = x1 elseif x1 > xmax then xmax = x1 end
- if y1 < ymin then ymin = y1 elseif y1 > ymax then ymax = y1 end
- if keepcurve then
- nofsegments = nofsegments + 1
- segments[nofsegments] = { x1, y1, first_pt[1], first_pt[2], "q" } -- "quadraticto"
- end
else
local x1, y1 = control_pt[1], control_pt[2]
local x2, y2 = first_pt[1], first_pt[2]
- x1, x2, x2, y2, px, py = curveto(x1, x2, px, py, x2, y2)
if x1 < xmin then xmin = x1 elseif x1 > xmax then xmax = x1 end
if y1 < ymin then ymin = y1 elseif y1 > ymax then ymax = y1 end
- if x2 < xmin then xmin = x2 elseif x2 > xmax then xmax = x2 end
- if y2 < ymin then ymin = y2 elseif y2 > ymax then ymax = y2 end
- if px < xmin then xmin = px elseif px > xmax then xmax = px end
- if py < ymin then ymin = py elseif py > ymax then ymax = py end
- if keepcurve then
- nofsegments = nofsegments + 1
- segments[nofsegments] = { x1, y1, y2, y2, px, py, "c" } -- "curveto"
+ if quadratic then
+ if keepcurve then
+ nofsegments = nofsegments + 1
+ segments[nofsegments] = { x1, y1, x2, y2, "q" } -- "quadraticto"
+ end
+ else
+ x1, y1, x2, y2, px, py = curveto(x1, y1, px, py, x2, y2)
+ if x2 < xmin then xmin = x2 elseif x2 > xmax then xmax = x2 end
+ if y2 < ymin then ymin = y2 elseif y2 > ymax then ymax = y2 end
+ if px < xmin then xmin = px elseif px > xmax then xmax = px end
+ if py < ymin then ymin = py elseif py > ymax then ymax = py end
+ if keepcurve then
+ nofsegments = nofsegments + 1
+ segments[nofsegments] = { x1, y1, x2, y2, px, py, "c" } -- "curveto"
+ end
+ -- px, py = x2, y2
end
- -- px, py = x2, y2
end
end
end