Skip to content

Commit

Permalink
Replace textsize with fontsize everywhere (#2387)
Browse files Browse the repository at this point in the history
* remove textsize for fontsize everywhere

* add previous fontsize to test

* fix one more text test
  • Loading branch information
jkrumbiegel committed Nov 23, 2022
1 parent 5e92300 commit 1fecf4a
Show file tree
Hide file tree
Showing 40 changed files with 123 additions and 107 deletions.
2 changes: 1 addition & 1 deletion GLMakie/src/drawing_primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ function draw_atomic(screen::Screen, scene::Scene,
# These are liftkeys without model
!(k in (
:position, :space, :markerspace, :font,
:textsize, :rotation, :justification
:fontsize, :rotation, :justification
)) # space,
end

Expand Down
6 changes: 3 additions & 3 deletions MakieCore/src/basic_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ Plots one or multiple texts passed via the `text` keyword.
- `font::Union{String, Vector{String}} = "TeX Gyre Heros Makie"` sets the font for the string or each character.
- `justification::Union{Real, Symbol} = automatic` sets the alignment of text w.r.t its bounding box. Can be `:left, :center, :right` or a fraction. Will default to the horizontal alignment in `align`.
- `rotation::Union{Real, Quaternion}` rotates text around the given position.
- `textsize::Union{Real, Vec2f}` sets the size of each character.
- `markerspace::Symbol = :pixel` sets the space in which `textsize` acts. See `Makie.spaces()` for possible inputs.
- `fontsize::Union{Real, Vec2f}` sets the size of each character.
- `markerspace::Symbol = :pixel` sets the space in which `fontsize` acts. See `Makie.spaces()` for possible inputs.
- `strokewidth::Real = 0` sets the width of the outline around a marker.
- `strokecolor::Union{Symbol, <:Colorant} = :black` sets the color of the outline around a marker.
- `glowwidth::Real = 0` sets the size of a glow effect around the marker.
Expand Down Expand Up @@ -521,7 +521,7 @@ Plots one or multiple texts passed via the `text` keyword.
strokewidth = 0,
align = (:left, :bottom),
rotation = 0.0,
textsize = 20,
fontsize = theme(scene, :fontsize),
position = (0.0, 0.0),
justification = automatic,
lineheight = 1.0,
Expand Down
4 changes: 2 additions & 2 deletions MakieRecipes/src/pipeline_integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function plot_series_annotations!(plt, args, pt, plotattributes)

@debug("Series annotations say hi")

annotations!(plt, strs, positions; textsize = fontsize/30, align = (:center, :center), color = get(plotattributes, :textcolor, :black))
annotations!(plt, strs, positions; fontsize = fontsize/30, align = (:center, :center), color = get(plotattributes, :textcolor, :black))

end

Expand All @@ -326,7 +326,7 @@ function plot_annotations!(plt, args, pt, plotattributes)

@debug("Annotations say hi")

annotations!(plt, strs, positions; textsize = fontsizes ./ 80, align = (:center, :center), color = get(plotattributes, :textcolor, :black))
annotations!(plt, strs, positions; fontsize = fontsizes ./ 80, align = (:center, :center), color = get(plotattributes, :textcolor, :black))

end

Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## master

- **Breaking** The attribute `textsize` has been removed everywhere in favor of the attribute `fontsize` which had also been in use.
To migrate, search and replace all uses of `textsize` to `fontsize`.

## v0.18.3

- Add `render_on_demand` flag for `GLMakie.Screen`. Setting this to `true` will skip rendering until plots get updated. This is the new default [#2336](https://github.com/MakieOrg/Makie.jl/pull/2336), [#2397](https://github.com/MakieOrg/Makie.jl/pull/2397).
Expand Down
2 changes: 1 addition & 1 deletion ReferenceTests/src/tests/attributes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end

@reference_test "position" begin
fig, ax, sc = scatter(RNG.rand(10), color=:red)
text!(ax, 5, 1.1, text = "adding text", textsize=0.6)
text!(ax, 5, 1.1, text = "adding text", fontsize=0.6)
fig
end

Expand Down
14 changes: 7 additions & 7 deletions ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ end
". This is an annotation!",
position=(300, 200),
align=(:center, :center),
textsize=60,
fontsize=60,
font="Blackchancery"
)
end
Expand All @@ -172,7 +172,7 @@ end
push!(posis, p)
text!(ax, "test",
position=p,
textsize=50,
fontsize=50,
rotation=1.5pi - r,
align=(:center, :center)
)
Expand Down Expand Up @@ -378,7 +378,7 @@ end
markersize = 5scales[j], space = space, markerspace = mspace)
text!(
ax, "$space\n$mspace", position = Point2f(xs[i][i], xs[i][j]),
textsize = scales[j], space = space, markerspace = mspace,
fontsize = scales[j], space = space, markerspace = mspace,
align = (:center, :center), color = :black)
end
end
Expand Down Expand Up @@ -420,7 +420,7 @@ end
markersize = 5scales[j], space = space, markerspace = mspace)
text!(
ax, "$space\n$mspace", position = Point2f(xs[i][i], xs[i][j]),
textsize = scales[j], space = space, markerspace = mspace,
fontsize = scales[j], space = space, markerspace = mspace,
align = (:center, :center), color = :black)
end
end
Expand All @@ -430,7 +430,7 @@ end
@reference_test "Scatter & Text transformations" begin
# Check that transformations apply in `space = :data`
fig, ax, p = scatter(Point2f(100, 0.5), marker = 'a', markersize=50)
t = text!(Point2f(100, 0.5), text = "Test", textsize = 50)
t = text!(Point2f(100, 0.5), text = "Test", fontsize = 50)
translate!(p, -100, 0, 0)
translate!(t, -100, 0, 0)

Expand All @@ -440,7 +440,7 @@ end
scale!(p2, 0.5, 0.5, 1)

# but do act on glyphs of text
t2 = text!(ax, 1, 0, text = "Test", textsize = 50)
t2 = text!(ax, 1, 0, text = "Test", fontsize = 50)
Makie.rotate!(t2, pi/4)
scale!(t2, 0.5, 0.5, 1)

Expand Down Expand Up @@ -557,7 +557,7 @@ end
)
tooltip!(ax, Point2f(0), "below", placement = :below, outline_color = :red, outline_linestyle = :dot)
tooltip!(
ax, 0, 0, text = "right", placement = :right, textsize = 30,
ax, 0, 0, text = "right", placement = :right, fontsize = 30,
outline_linewidth = 5, offset = 30, triangle_size = 15,
strokewidth = 2f0, strokecolor = :cyan
)
Expand Down
4 changes: 2 additions & 2 deletions ReferenceTests/src/tests/examples3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ end
axis[:names, :axisnames] = ("\\bf{ℜ}[u]", "\\bf{𝕴}[u]", " OK\n\\bf{δ}\n γ")
tstyle = axis[:names] # or just get the nested attributes and work directly with them

tstyle[:textsize] = 10
tstyle[:fontsize] = 10
tstyle[:textcolor] = (:red, :green, :black)
tstyle[:font] = "helvetica"

Expand All @@ -270,7 +270,7 @@ end
"Multipole Representation of first resonances of U-238",
position=(wh[1] / 2.0, wh[2] - 20.0),
align=(:center, :center),
textsize=20,
fontsize=20,
font="helvetica"
)
c = lines!(scene, Circle(Point2f(0.1, 0.5), 0.1f0), color=:red, offset=Vec3f(0, 0, 1))
Expand Down
2 changes: 1 addition & 1 deletion ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ end
lorem_ipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
fig = Figure(resolution = (1000, 660))
m!(fig, lbl) = mesh!(fig.scene, lbl.layoutobservables.computedbbox, color = (:red, 0.5), shading=false)
lbl1 = Label(fig[1, 1:2], "HEADER "^10, textsize = 40, word_wrap = true)
lbl1 = Label(fig[1, 1:2], "HEADER "^10, fontsize = 40, word_wrap = true)
m!(fig, lbl1)

lbl2 = Label(fig[2, 1], lorem_ipsum, word_wrap = true, justification = :left)
Expand Down
26 changes: 13 additions & 13 deletions ReferenceTests/src/tests/text.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
position = [Point2f(x, y) for x in 1:10 for y in 1:10],
align = (:center, :center),
color = ifelse.(vec(values') .< 0.3, :white, :black),
textsize = 12)
fontsize = 12)
fig
end

Expand All @@ -22,7 +22,7 @@ end
axis = (aspect = DataAspect(),),
markerspace = :data,
align = (:center, :center),
textsize = 2)
fontsize = 2)
scatter!(pos)
fig
end
Expand Down Expand Up @@ -116,7 +116,7 @@ end
position = [(200, 200) .+ 60 * Point2f(cos(a), sin(a)) for a in pi/4:pi/2:7pi/4],
rotation = pi/4:pi/2:7pi/4,
align = (:left, :center),
textsize = 30,
fontsize = 30,
markerspace = :data
)

Expand All @@ -127,7 +127,7 @@ end
position = [(200, 600) .+ 60 * Point2f(cos(a), sin(a)) for a in pi/4:pi/2:7pi/4],
rotation = pi/4:pi/2:7pi/4,
align = (:left, :center),
textsize = 30,
fontsize = 30,
markerspace = :pixel
)

Expand All @@ -146,7 +146,7 @@ end
position = (200, 200) .+ 60 * Point2f(cos(a), sin(a)),
rotation = a,
align = (:left, :center),
textsize = 30,
fontsize = 30,
markerspace = :data
)

Expand All @@ -157,7 +157,7 @@ end
position = (200, 600) .+ 60 * Point2f(cos(a), sin(a)),
rotation = a,
align = (:left, :center),
textsize = 30,
fontsize = 30,
markerspace = :pixel
)

Expand All @@ -175,7 +175,7 @@ end
position = [Point3f(0, 0, i/2) for i in 1:7],
color = [cgrad(:viridis)[x] for x in LinRange(0, 1, 7)],
align = (:left, :baseline),
textsize = 1,
fontsize = 1,
markerspace = :data
)
end
Expand Down Expand Up @@ -204,7 +204,7 @@ end
fill("Annotation", 10),
position = positions,
align = (:center, :center),
textsize = 20,
fontsize = 20,
markerspace = :pixel,
overdraw=false)
fig
Expand Down Expand Up @@ -262,7 +262,7 @@ end
end

@reference_test "latex hlines in axis" begin
text(1, 1, text = L"\frac{\sqrt{x + y}}{\sqrt{x + y}}", textsize = 50, rotation = pi/4,
text(1, 1, text = L"\frac{\sqrt{x + y}}{\sqrt{x + y}}", fontsize = 50, rotation = pi/4,
align = (:center, :center))
end

Expand Down Expand Up @@ -351,10 +351,10 @@ end

fig = Figure(resolution=(600, 500))
ax = Axis(fig[1, 1])
text!(ax, 0, 0, text = latexstring(L"$1$ " * lorem_ipsum), word_wrap_width=250, textsize = 12, align = (:left, :bottom), justification = :left, color = :black)
text!(ax, 0, 0, text = lorem_ipsum, word_wrap_width=250, textsize = 12, align = (:left, :top), justification = :right, color = :black)
text!(ax, 0, 0, text = lorem_ipsum, word_wrap_width=250, textsize = 12, align = (:right, :bottom), justification = :center, color = :red)
text!(ax, -0.3, 0, text = lorem_ipsum, word_wrap_width=200, textsize = 12, align = (:center, :top), color = :blue)
text!(ax, 0, 0, text = latexstring(L"$1$ " * lorem_ipsum), word_wrap_width=250, fontsize = 12, align = (:left, :bottom), justification = :left, color = :black)
text!(ax, 0, 0, text = lorem_ipsum, word_wrap_width=250, fontsize = 12, align = (:left, :top), justification = :right, color = :black)
text!(ax, 0, 0, text = lorem_ipsum, word_wrap_width=250, fontsize = 12, align = (:right, :bottom), justification = :center, color = :red)
text!(ax, -0.3, 0, text = lorem_ipsum, word_wrap_width=200, fontsize = 12, align = (:center, :top), color = :blue)
xlims!(ax, -0.8, 0.8)
ylims!(ax, -0.8, 0.6)
fig
Expand Down
2 changes: 1 addition & 1 deletion ReferenceTests/src/tests/updating.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@reference_test "updating 2d primitives" begin
fig = Figure()
t = Observable(1)
text(fig[1, 1], lift(i-> map(j-> ("$j", Point2f(j*30, 0)), 1:i), t), axis=(limits=(0, 380, -10, 10),), textsize=50)
text(fig[1, 1], lift(i-> map(j-> ("$j", Point2f(j*30, 0)), 1:i), t), axis=(limits=(0, 380, -10, 10),), fontsize=50)
scatter(fig[1, 2], lift(i-> Point2f.((1:i).*30, 0), t), axis=(limits=(0, 330, -10, 10),), markersize=50)
linesegments(fig[2, 1], lift(i-> Point2f.((2:2:4i).*30, 0), t), axis=(limits=(30, 650, -10, 10),), linewidth=20)
lines(fig[2, 2], lift(i-> Point2f.((2:2:4i).*30, 0), t), axis=(limits=(30, 650, -10, 10),), linewidth=20)
Expand Down
14 changes: 7 additions & 7 deletions docs/examples/blocks/gridlayout.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ for i in 1:3
Axis(f[end+1, :])
end

Label(f[0, :], text = "Super Title", textsize = 50)
Label(f[end+1, :], text = "Sub Title", textsize = 50)
Label(f[1:end-1, 0], text = "Left Text", textsize = 50,
Label(f[0, :], text = "Super Title", fontsize = 50)
Label(f[end+1, :], text = "Sub Title", fontsize = 50)
Label(f[1:end-1, 0], text = "Left Text", fontsize = 50,
rotation = pi/2)
Label(f[1:end-1, end+1], text = "Right Text", textsize = 50,
Label(f[1:end-1, end+1], text = "Right Text", fontsize = 50,
rotation = -pi/2)

f
Expand All @@ -239,9 +239,9 @@ for i in 1:3, j in 1:3
Axis(f[i, j])
end

Label(f[0, :], text = "First Supertitle", textsize = 20)
Label(f[-1, :], text = "Second Supertitle", textsize = 30)
Label(f[-2, :], text = "Third Supertitle", textsize = 40)
Label(f[0, :], text = "First Supertitle", fontsize = 20)
Label(f[-1, :], text = "Second Supertitle", fontsize = 30)
Label(f[-2, :], text = "Third Supertitle", fontsize = 40)

f
```
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/blocks/label.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fig = Figure()

fig[1:2, 1:3] = [Axis(fig) for _ in 1:6]

supertitle = Label(fig[0, :], "Six plots", textsize = 30)
supertitle = Label(fig[0, :], "Six plots", fontsize = 30)

sideinfo = Label(fig[2:3, 0], "This text is vertical", rotation = pi/2)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/plotting_functions/rainclouds.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ rainclouds!(Axis(fig[5, 1:2]), category_labels, data_array;
dist_between_categories = 0.5,
color = colors[indexin(category_labels, unique(category_labels))])

supertitle = Label(fig[0, :], "Cloud Plot Testing (Scatter, Violin, Boxplot)", textsize=30)
supertitle = Label(fig[0, :], "Cloud Plot Testing (Scatter, Violin, Boxplot)", fontsize=30)
fig
```
\end{examplefigure}
2 changes: 1 addition & 1 deletion docs/examples/plotting_functions/scatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ CairoMakie.activate!() # hide


f, ax, sc = scatter(1, 1, marker = 'A', markersize = 50)
text!(2, 1, text = "A", textsize = 50, align = (:center, :center))
text!(2, 1, text = "A", fontsize = 50, align = (:center, :center))
xlims!(ax, -1, 4)
f
```
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/plotting_functions/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ text!(
rotation = [i / 7 * 1.5pi for i in 1:7],
color = [cgrad(:viridis)[x] for x in LinRange(0, 1, 7)],
align = (:left, :baseline),
textsize = 1,
fontsize = 1,
markerspace = :data
)

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/layout-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ colsize!(gd, 2, Auto(n_day_2))

for (label, layout) in zip(["A", "B", "C", "D"], [ga, gb, gc, gd])
Label(layout[1, 1, TopLeft()], label,
textsize = 26,
fontsize = 26,
font = "TeX Gyre Heros Bold",
padding = (0, 5, 5, 0),
halign = :right)
Expand Down Expand Up @@ -484,7 +484,7 @@ That will leave all other alignments intact, because we're not creating any new
```julia
for (label, layout) in zip(["A", "B", "C", "D"], [ga, gb, gc, gd])
Label(layout[1, 1, TopLeft()], label,
textsize = 26,
fontsize = 26,
font = "TeX Gyre Heros Bold",
padding = (0, 5, 5, 0),
halign = :right)
Expand Down
2 changes: 1 addition & 1 deletion src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export broadcast_foreach, to_vector, replace_automatic!

# conversion infrastructure
export @key_str, convert_attribute, convert_arguments
export to_color, to_colormap, to_rotation, to_font, to_align, to_textsize, categorical_colors, resample_cmap
export to_color, to_colormap, to_rotation, to_font, to_align, to_fontsize, categorical_colors, resample_cmap
export to_ndim, Reverse

# Transformations
Expand Down
Loading

0 comments on commit 1fecf4a

Please sign in to comment.