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

Font / Text error #2003

Closed
zsoerenm opened this issue May 31, 2022 · 16 comments
Closed

Font / Text error #2003

zsoerenm opened this issue May 31, 2022 · 16 comments
Labels
GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie.

Comments

@zsoerenm
Copy link

After some time, I've used GLMakie again.
I tried the following:

using GLMakie
positions = Observable(rand(Point2f, 10))
fig, ax, p = scatter(positions)

However, it seems that there is an error with the font.
image
Each number is displayed as a box (see figure).
How can I regenerate the font? There is no error thrown.

@SimonDanisch
Copy link
Member

SimonDanisch commented May 31, 2022

Can you try rm(Makie.get_cache_path()) and then restart GLMakie?

@zsoerenm
Copy link
Author

Yes, this regenerated the font:

julia> fig, ax, p = scatter(positions)
[ Info: Makie is caching fonts, this may take a while. Needed only on first run!

However, the figure is still outputted with boxes instead of numbers (like in the figure above).

@jkrumbiegel
Copy link
Member

Can you try any other previously unused font? Just to check that it's not font-related

@ffreyer
Copy link
Collaborator

ffreyer commented May 31, 2022

Checking what image(Makie.get_texture_atlas().data) looks like might also be helpful

@zsoerenm
Copy link
Author

I tried a different font:

f = Figure(backgroundcolor = RGBf(0.98, 0.98, 0.98),
           resolution = (400, 200))
ga = f[1, 1] = GridLayout()
Label(ga[1, 1:2, Top()], "Stimulus ratings", valign = :bottom,
           font = "Noto",
           padding = (0, 0, 5, 0))

image
The output of

image(Makie.get_texture_atlas().data)

looks like this:
image

BTW:
I've put

"terminal.integrated.env.linux": {
        "LD_PRELOAD": "/usr/lib64/libstdc++.so.6"
    },

into my VSCode settings, because otherwise I run into the following error

libGL error: MESA-LOADER: failed to open radeonsi: /usr/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/lib/dri/radeonsi_dri.so) (search paths /usr/lib/dri, suffix _dri)
libGL error: failed to load driver: radeonsi
libGL error: MESA-LOADER: failed to open radeonsi: /usr/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/lib/dri/radeonsi_dri.so) (search paths /usr/lib/dri, suffix _dri)
libGL error: failed to load driver: radeonsi
libGL error: MESA-LOADER: failed to open swrast: /usr/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/lib/dri/swrast_dri.so) (search paths /usr/lib/dri, suffix _dri)

@ffreyer
Copy link
Collaborator

ffreyer commented May 31, 2022

The entries in the texture atlas look pretty weird. Does this generate a normal looking "a"?

using Makie.FreeTypeAbstraction
image(renderface(findfont("Noto"), 'a', 100)[1][:, end:-1:1])

If not maybe rebuilding FreeTypeAbstraction helps?

@zsoerenm
Copy link
Author

It works:

using Makie.FreeTypeAbstraction
image(renderface(findfont("Noto"), 'a', 100)[1][:, end:-1:1])

grafik

@ffreyer
Copy link
Collaborator

ffreyer commented May 31, 2022

But text("a", font = "Noto") renders a box too, right? Can you show me the texture atlas again after that?

Does

img = renderface(findfont("Noto"), 'a', 100)[1][:, end:-1:1]
sdf = Makie.sdistancefield(img, 4, 16)
image(sdf)

look like a blurry "a"?

@zsoerenm
Copy link
Author

Yes, text("a", font = "Noto") renders a box in the center of the scene.

Texture atlas again after that:
grafik

img = renderface(findfont("Noto"), 'a', 100)[1][:, end:-1:1]
sdf = Makie.sdistancefield(img, 4, 16)
image(sdf)

grafik

@SimonDanisch
Copy link
Member

Wow, what platform and Julia version is this? Makie.sdistancefield(img, 4, 16) is pure julia code, and seems to be the culprit here...

@ffreyer
Copy link
Collaborator

ffreyer commented May 31, 2022

For reference - this is what image(sdf) should look like:

Screenshot from 2022-05-31 14-59-39

The function is here:
https://github.com/JuliaPlots/Makie.jl/blob/c6931d0c08a929bc1449c8e4dc38a8cf7a396730/src/utilities/texture_atlas.jl#L238-L256

Maybe you can play around with it a bit to see what goes wrong? in_or_out should be a sharp "a" (i.e. with hard edges instead of antialiased ones). sdf() is from https://github.com/JuliaGraphics/SignedDistanceFields.jl I believe. The bug might also be there

@ffreyer
Copy link
Collaborator

ffreyer commented May 31, 2022

These white to black rings kinda look like integer overflows to me. Maybe there is an issue with Int or Float16? Maybe it's also worth checking sdistancefield() without the Float16.() at the end?

@zsoerenm
Copy link
Author

zsoerenm commented May 31, 2022

I've tried julia v1.7.2 and julia v1.7.3

image(in_or_out)

grafik

image(Makie.sdf(in_or_out, xres, yres) ./ downsample)

grafik

julia> maximum(Makie.sdf(in_or_out, xres, yres) ./ downsample)
24.218729870931817
julia> Float16(maximum(Makie.sdf(in_or_out, xres, yres) ./ downsample))
Float16(3.135e-5)
image(Float16.(Makie.sdf(in_or_out, xres, yres) ./ downsample))

grafik

EDIT: Okay there does seem to be an error with Float16:

julia> Float16(4.)
Float16(0.0)

EDIT2: This does work though:

julia> Float16(4f0)
Float16(4.0)
image(Float16.(Float32.(Makie.sdf(in_or_out, xres, yres) ./ downsample)))

grafik
The a, however, does not look like in your example

I created an issue at julia: JuliaLang/julia#45528

@ffreyer
Copy link
Collaborator

ffreyer commented May 31, 2022

julia> Float16(maximum(Makie.sdf(in_or_out, xres, yres) ./ downsample))
Float16(3.135e-5)

I get

julia> Float16(24.218729870931817)
Float16(24.22)

so I guess that's part of the issue.

Without the Float16 I still get the same plot for 'a'. So I guess there's a bit more to this. Here's the raw output of

img = renderface(findfont("Noto"), 'a', 100)[1][:, end:-1:1]
sdf = Makie.sdistancefield(img, 4, 16) # without Float16 conversion

if you want to continue investigating. in_and_out looks fine to me.

https://gist.github.com/ffreyer/c952fcb74d4529e3b9023e1d151326c6

@zsoerenm
Copy link
Author

zsoerenm commented May 31, 2022

okay, the culprit does seem to be the LD_PRELOAD. I had to start Julia with the following, because of this error: JuliaGL/GLFW.jl#198 (comment) :

LD_PRELOAD=/usr/lib64/libstdc++.so.6 /bin/julia

With the PRELOAD Float16 returns garbage.
Any hint how to use GLMakie without the LD_PRELOAD is appreciated.

@zsoerenm
Copy link
Author

Good news:
I upgraded to Julia v1.8.0beta3 and the error is gone. The LD_PRELOAD is, however, still necessary.
grafik
Thanks for all your help!

@asinghvi17 asinghvi17 added the GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie. label Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie.
Projects
None yet
Development

No branches or pull requests

5 participants