diff --git a/Project.toml b/Project.toml index 6aa4b77..d65ec21 100644 --- a/Project.toml +++ b/Project.toml @@ -18,6 +18,6 @@ AbstractTrees = "0.3" Automa = "0.8" DataStructures = "0.18" FreeTypeAbstraction = "0.9" -GeometryBasics = "0.3" +GeometryBasics = "0.4.1" LaTeXStrings = "1.2" julia = "1.3" diff --git a/src/MathTeXEngine.jl b/src/MathTeXEngine.jl index a6afce9..bccf520 100644 --- a/src/MathTeXEngine.jl +++ b/src/MathTeXEngine.jl @@ -12,7 +12,7 @@ import DataStructures: Stack import FreeTypeAbstraction: ascender, boundingbox, descender, get_extent, hadvance, inkheight, inkwidth, leftinkbound, rightinkbound, topinkbound, bottominkbound -import GeometryBasics: Point2f0 +import GeometryBasics: Point2f import REPL.REPLCompletions: latex_symbols const re = Automa.RegExp diff --git a/src/engine/layout.jl b/src/engine/layout.jl index 603517e..ab6a893 100644 --- a/src/engine/layout.jl +++ b/src/engine/layout.jl @@ -19,7 +19,7 @@ function tex_layout(expr, fontset) return Group( [core, sub, super], - Point2f0[ + Point2f[ (0, 0), (core_width, -0.2), (core_width, xheight(core) - 0.5 * descender(super))], @@ -41,7 +41,7 @@ function tex_layout(expr, fontset) # TODO Check what the algorithm should be there # Center the delimiters in the middle of the bot and top baselines ? return Group(elements, - Point2f0[ + Point2f[ (xs[1], -bottominkbound(left) + bottominkbound(content)), (xs[2], 0), (xs[3], -bottominkbound(right) + bottominkbound(content)) @@ -73,7 +73,7 @@ function tex_layout(expr, fontset) return Group( [line, numerator, denominator], - Point2f0[(0,y0), (x1, ytop), (x2, ybottom)] + Point2f[(0,y0), (x1, ytop), (x2, ybottom)] ) elseif head == :function name = args[1] @@ -95,7 +95,7 @@ function tex_layout(expr, fontset) return Group( [int, sub, super], - Point2f0[ + Point2f[ (0, h/2 + xheight(fontset)/2), ( 0.15 - inkwidth(sub)*shrink/2, @@ -141,7 +141,7 @@ function tex_layout(expr, fontset) return Group( [sqrt, vline, hline, content], - Point2f0[ + Point2f[ (0, y0), (rightinkbound(sqrt) - lw/2, y), (rightinkbound(sqrt) - lw/2, y - lw/2), @@ -166,7 +166,7 @@ function tex_layout(expr, fontset) return Group( [core, sub, super], - Point2f0[ + Point2f[ (x0, 0), (x0 + dxsub, under_offset), (x0 + dxsuper, over_offset) @@ -208,7 +208,7 @@ function horizontal_layout(elements) dxs = advance.(elements) xs = [0, cumsum(dxs[1:end-1])...] - return Group(elements, Point2f0.(xs, 0)) + return Group(elements, Point2f.(xs, 0)) end function layout_text(string, fontset) @@ -224,7 +224,7 @@ end Flatten the layouted TeXElement and produce a single list of base element with their associated absolute position and scale. """ -function unravel(group::Group, parent_pos=Point2f0(0), parent_scale=1.0f0) +function unravel(group::Group, parent_pos=Point2f(0), parent_scale=1.0f0) positions = [parent_pos .+ pos for pos in parent_scale .* group.positions] scales = group.scales .* parent_scale elements = [] diff --git a/src/engine/texelements.jl b/src/engine/texelements.jl index 8f35728..3ef825a 100644 --- a/src/engine/texelements.jl +++ b/src/engine/texelements.jl @@ -207,7 +207,7 @@ Positions and scales are relative to the group. """ struct Group{T} <: TeXElement elements::Vector{<:TeXElement} - positions::Vector{Point2f0} + positions::Vector{Point2f} scales::Vector{T} end diff --git a/src/prototype.jl b/src/prototype.jl index a362dbd..1295126 100644 --- a/src/prototype.jl +++ b/src/prototype.jl @@ -12,7 +12,7 @@ function draw_texelement!(ax, texchar::TeXChar, position, scale ; size=64) x = (position[1] + leftinkbound(texchar)) * size y = (position[2] + descender(texchar.font) * scale) * size text!(ax, string(texchar.char), font=texchar.font, - position=Point2f0(x, y), + position=Point2f(x, y), textsize=size*scale, space=:data) end @@ -23,7 +23,7 @@ function draw_texelement!(ax, line::VLine, position, scale ; size=64) x0 = xmid - lw x1 = xmid + lw y1 = y0 + line.height - points = Point2f0[(x0, y0), (x0, y1), (x1, y1), (x1, y0)] + points = Point2f[(x0, y0), (x0, y1), (x1, y1), (x1, y0)] poly!(ax, points .* size, color=:black, shading=false, linewidth=0) end @@ -33,7 +33,7 @@ function draw_texelement!(ax, line::HLine, position, scale ; size=64) x1 = x0 + line.width y0 = ymid - lw y1 = ymid + lw - points = Point2f0[(x0, y0), (x0, y1), (x1, y1), (x1, y0)] + points = Point2f[(x0, y0), (x0, y1), (x1, y1), (x1, y0)] mesh!(ax, points .* size, color=:black, shading=false) end @@ -54,7 +54,7 @@ function draw_texelement_helpers!(ax, texchar::TeXChar, position, scale ; size=6 # The space between th origin and the left ink bound mesh!(ax, - Point2f0[ + Point2f[ (x, y + d), (x + left, y + d), (x + left, y + h), @@ -66,7 +66,7 @@ function draw_texelement_helpers!(ax, texchar::TeXChar, position, scale ; size=6 # The advance after the right inkbound mesh!(ax, - Point2f0[ + Point2f[ (x + right, y + d), (x + a, y + d), (x + a, y + h), @@ -78,7 +78,7 @@ function draw_texelement_helpers!(ax, texchar::TeXChar, position, scale ; size=6 # The descender mesh!(ax, - Point2f0[ + Point2f[ (x + left, y), (x + right, y), (x + right, y + d), @@ -90,7 +90,7 @@ function draw_texelement_helpers!(ax, texchar::TeXChar, position, scale ; size=6 # The inkbound above the baseline mesh!(ax, - Point2f0[ + Point2f[ (x + left, y), (x + right, y), (x + right, y + h),