Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Commit 8e7e096

Browse files
asinghvi17SimonDanischgithub-actions[bot]
authored
work with new FreeTypeAbstraction
* refactor text * hmpf * Add FreeTypeAbstraction branch * CompatHelper: bump compat for "FreeTypeAbstraction" to "0.6" * fix tests * only allow 0.6 * refactor text * hmpf * Add FreeTypeAbstraction branch * CompatHelper: bump compat for "FreeTypeAbstraction" to "0.6" * fix tests * only allow 0.6 * No need for Makie here * try out a temp project * fix the FFMPEG version too...something must not like it * Add FFMPEG v0.3 support (#327) * Work with FFMPEG 0.3 * Override the Travis script to add MakieGallery master Co-authored-by: Simon <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent b21735d commit 8e7e096

File tree

11 files changed

+106
-84
lines changed

11 files changed

+106
-84
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ test:
1616
script:
1717
- mkdir $JULIA_DEPOT_PATH # Pkg.jl#325
1818
- julia -e 'using InteractiveUtils; versioninfo()'
19-
- julia --project -e 'using Pkg; Pkg.pkg"add Makie#master StatsMakie#master MakieGallery#master GLMakie#master; test"'
19+
- mkdir temporary_for_project
20+
- julia --project=temporary_for_project -e 'using Pkg; Pkg.pkg"dev --local .; add StatsMakie#master MakieGallery#master GLMakie#master [email protected]; test AbstractPlotting"'
2021

2122
artifacts:
2223
when: on_failure

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ matrix:
1616
allow_failures:
1717
- julia: 1.3
1818

19+
script:
20+
- export JL_PKG=AbstractPlotting
21+
- julia --color=yes -e "using Pkg; if VERSION >= v\"1.1.0-rc1\"; Pkg.build(verbose=true); else Pkg.build(); end"
22+
- julia -e 'using Pkg; pkg"add MakieGallery#master"'
23+
- julia --check-bounds=yes --color=yes -e "using Pkg; Pkg.test(coverage=true)"
24+
25+
26+
1927
## uncomment the following lines to override the default test script
2028
#script:
2129
# - julia -e 'Pkg.clone(pwd()); Pkg.build("AbstractPlotting"); Pkg.test("AbstractPlotting"; coverage=true)'

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ ColorTypes = "0.8, 0.9"
4242
Colors = "0.9, 0.10, 0.11"
4343
Contour = "0.5"
4444
DocStringExtensions = "0.8.0"
45-
FFMPEG = "0.2"
45+
FFMPEG = "0.2, 0.3"
4646
FileIO = "1.1"
4747
FixedPointNumbers = "0.6, 0.7, 0.8"
4848
FreeType = "2.1, 3.0"
49-
FreeTypeAbstraction = "0.4.2, 0.5"
49+
FreeTypeAbstraction = "0.6"
5050
GeometryTypes = "0.7.2"
5151
ImageMagick = "0.7, 1.0"
5252
IntervalSets = "0.3, 0.4"

src/basic_recipes/axis.jl

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ $(ATTRIBUTES)
144144
textcolor = (tick_color, tick_color, tick_color),
145145

146146
rotation = tickrotations3d,
147-
textsize = (tsize, tsize, tsize),
147+
textsize = (tsize, tsize, tsize),
148148
align = tickalign3d,
149149
gap = 1,
150150
font = lift(dim3, theme(scene, :font)),
@@ -248,16 +248,16 @@ default_labels(x::Tuple, ranges, formatter) = default_labels.(x, (ranges,), (for
248248
default_labels(x::AbstractVector{<: AbstractString}, ranges, formatter::Function) = x
249249
default_labels(x::AbstractVector{<: AbstractString}, ranges::AbstractVector, formatter::Function) = x
250250

251-
252-
253251
function convert_arguments(::Type{<: Axis2D}, limits::Rect)
254252
e = (minimum(limits), maximum(limits))
255253
(((e[1][1], e[2][1]), (e[1][2], e[2][2])),)
256254
end
255+
257256
function convert_arguments(::Type{<: Axis3D}, limits::Rect)
258257
e = (minimum(limits), maximum(limits))
259258
(((e[1][1], e[2][1]), (e[1][2], e[2][2]), (e[1][3], e[2][3])),)
260259
end
260+
261261
a_length(x::AbstractVector) = length(x)
262262
a_length(x::Automatic) = x
263263

@@ -302,17 +302,11 @@ function draw_tickmarks(
302302
pos = ntuple(i-> i != dim ? origin[i] : tick, Val(2))
303303
posf0 = Point2f0(pos)
304304
dirf0 = Pointf0{N}(dir)
305-
append!(linebuffer,
306-
[posf0, posf0 .+ dirf0],
307-
color = linecolor[dim], linewidth = linewidth[dim]
308-
)
305+
append!(linebuffer, [posf0, posf0 .+ dirf0],
306+
color = linecolor[dim], linewidth = linewidth[dim])
309307
end
310308
end
311309

312-
313-
314-
315-
316310
function draw_grid(
317311
linebuffer, dim, origin, ticks, dir::NTuple{N},
318312
linewidth, linecolor, linestyle

src/conversions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ function convert_attribute(x::Union{Symbol, String}, k::key"font")
581581
get!(_font_cache, str) do
582582
str == "default" && return convert_attribute("Dejavu Sans", k)
583583
fontpath = joinpath(@__DIR__, "..", "assets", "fonts")
584-
font = FreeTypeAbstraction.findfont(str, additional_fonts = fontpath)
584+
font = FreeTypeAbstraction.findfont(str; additional_fonts=fontpath)
585585
if font == nothing
586586
@warn("Could not find font $str, using Dejavu Sans")
587587
if "dejavu sans" == lowercase(str)
@@ -590,7 +590,7 @@ function convert_attribute(x::Union{Symbol, String}, k::key"font")
590590
end
591591
return convert_attribute("dejavu sans", k)
592592
end
593-
[font] # TODO do we really need the array around it!??!?
593+
return font # TODO do we really need the array around it!??!?
594594
end
595595
end
596596
convert_attribute(x::Vector{String}, k::key"font") = convert_attribute.(x, k)

src/display.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ struct VideoStream
290290
path::String
291291
end
292292

293+
# This is compat between FFMPEG versions 0.2 and 0.3,
294+
# where 0.3 uses artifacts but 0.2 does not.
295+
# Because of this, we need to check which variable will give FFMPEG's path.
296+
const _ffmpeg_path = isdefined(FFMPEG, :ffmpeg_path) ? FFMPEG.ffmpeg_path : FFMPEG.ffmpeg
297+
293298
"""
294299
VideoStream(scene::Scene, framerate = 24)
295300
@@ -309,7 +314,7 @@ function VideoStream(
309314
_xdim, _ydim = size(scene)
310315
xdim = _xdim % 2 == 0 ? _xdim : _xdim + 1
311316
ydim = _ydim % 2 == 0 ? _ydim : _ydim + 1
312-
process = @ffmpeg_env open(`$ffmpeg -loglevel quiet -f rawvideo -pixel_format rgb24 -r $framerate -s:v $(xdim)x$(ydim) -i pipe:0 -vf vflip -y $path`, "w")
317+
process = @ffmpeg_env open(`$_ffmpeg_path -loglevel quiet -f rawvideo -pixel_format rgb24 -r $framerate -s:v $(xdim)x$(ydim) -i pipe:0 -vf vflip -y $path`, "w")
313318
VideoStream(process.in, process, screen, abspath(path))
314319
end
315320

src/layouting/boundingbox.jl

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function boundingbox(x::Text, text::String)
9090
wh = widths(bb)
9191
whp = project_widths(pm, wh)
9292
aoffset = whp .* to_ndim(Vec3f0, align, 0f0)
93-
FRect3D(minimum(bb) .- aoffset, whp)
93+
return FRect3D(minimum(bb) .- aoffset, whp)
9494
end
9595

9696
boundingbox(x::Text) = boundingbox(x, to_value(x[1]))
@@ -106,6 +106,37 @@ function boundingbox(
106106

107107
end
108108

109+
# function boundingbox(
110+
# text::String, position, textsize, fonts,
111+
# align, rotation, model = Mat4f0(I)
112+
# )
113+
# isempty(text) && return FRect3D()
114+
# pos_per_char = !isa(position, VecTypes)
115+
#
116+
# start_pos = Vec(pos_per_char ? first(position) : position)
117+
# start_pos3d = project(model, to_ndim(Vec3f0, start_pos, 0.0))
118+
# bb = FRect3D(start_pos3d, Vec3f0(0))
119+
#
120+
# if pos_per_char
121+
# broadcast_foreach(position, textsize, fonts, collect(text)) do pos, scale, font, char
122+
# rect, extent = FreeTypeAbstraction.metrics_bb(char, font, scale)
123+
# bb = union(FRect3D(rect) + to_ndim(Vec3f0, pos, 0.0), bb)
124+
# @show pos scale
125+
# end
126+
# else
127+
# y_advance = 0.0
128+
# line_advance = FreeTypeAbstraction.get_extent(fonts, 'x').advance[2]
129+
# for line in split(text, r"(\r\n|\r|\n)")
130+
# rectangles = FreeTypeAbstraction.glyph_rects(line, fonts, textsize)
131+
# bb2d = reduce(union, rectangles)
132+
# bb2d = bb2d + Vec2f0(0, y_advance)
133+
# bb = union(bb, FRect3D(bb2d))
134+
# y_advance += line_advance
135+
# @show y_advance
136+
# end
137+
# end
138+
# return bb
139+
# end
109140

110141
function boundingbox(
111142
text::String, position, textsize, font,
@@ -138,5 +169,5 @@ function boundingbox(
138169
bb = GeometryTypes.update(bb, pos .+ srot)
139170
end
140171
end
141-
bb
172+
return bb
142173
end

src/types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ const automatic = Automatic()
531531
const Vecf0{N} = Vec{N, Float32}
532532
const Pointf0{N} = Point{N, Float32}
533533
export Vecf0, Pointf0
534-
const NativeFont = Vector{Ptr{FreeType.FT_FaceRec}}
534+
const NativeFont = FreeTypeAbstraction.FTFont
535535

536536
"""
537537
`PlotSpec{P<:AbstractPlot}(args...; kwargs...)`

0 commit comments

Comments
 (0)