Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate text align #4651

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Validate text align #4651

wants to merge 1 commit into from

Conversation

jkrumbiegel
Copy link
Member

Before, you'd get a pretty obscure error when accidentally doing text(..., align = :center)

ERROR: MethodError: no method matching getindex(::Symbol, ::Int64)
The function `getindex` exists, but no method is defined for this combination of argument types.
Stacktrace:
  [1] layout_text(string::String, fontsize::Float32, font::FreeTypeAbstraction.FTFont, fonts::Attributes, align::Symbol, rotation::Quaternion{…}, justification::MakieCore.Automatic, lineheight::Float64, color::ColorTypes.RGBA{…}, strokecolor::ColorTypes.RGBA{…}, strokewidth::Int64, word_wrap_width::Int64)
    @ Makie ~/.julia/dev/Makie/src/layouting/text_layouting.jl:55
  [2] _get_glyphcollection_and_linesegments(str::String, index::Int64, ts::Float32, f::FreeTypeAbstraction.FTFont, fs::Attributes, al::Symbol, rot::Quaternion{…}, jus::MakieCore.Automatic, lh::Float64, col::ColorTypes.RGBA{…}, scol::ColorTypes.RGBA{…}, swi::Int64, www::Int64, offs::Vec{…})
    @ Makie ~/.julia/dev/Makie/src/basic_recipes/text.jl:111
  [3] (::Makie.var"#push_args#2369"{Vector{…}, Vector{…}, Vector{…}, Vector{…}, Vector{…}})(::String, ::Vararg{Any})
    @ Makie ~/.julia/dev/Makie/src/basic_recipes/text.jl:51
  [4] (::Makie.var"#2365#2368"{…})(str::String, ts::Int64, f::Symbol, fs::Attributes, al::Symbol, rot::Float64, jus::MakieCore.Automatic, lh::Float64, cs::Symbol, cmap::Symbol, scol::Tuple{…}, swi::Int64, www::Int64, offs::Tuple{…})
    @ Makie ~/.julia/dev/Makie/src/basic_recipes/text.jl:66
  [5] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:1055
  [6] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:1052
  [7] (::Observables.OnAny)(value::Any)
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:420
  [8] #invokelatest#2
    @ ./essentials.jl:1055 [inlined]
  [9] invokelatest

So I've added more explicit validation. I can't use to_align because that transforms into floats from 0 to 1 and the y component takes :baseline which cannot be converted this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

1 participant