Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/MathTeXEngine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/engine/layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))],
Expand All @@ -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))
Expand Down Expand Up @@ -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]
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion src/engine/texelements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions src/prototype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down