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

SDL2 Error when using pixels.drawText() #153

Closed
JinnRoad opened this issue Nov 8, 2023 · 1 comment
Closed

SDL2 Error when using pixels.drawText() #153

JinnRoad opened this issue Nov 8, 2023 · 1 comment

Comments

@JinnRoad
Copy link

JinnRoad commented Nov 8, 2023

Warning: For others who find this, the solution below mysteriously stopped working. My solution at this link works (for now):
Araq/pixels#2 (comment)

# From book: "Mastering Nim, 2nd Edition" Chapter 3

import pixels

drawText 50, 50, "hello world!", 30, Red

Error

/home/user/.nimble/pkgs2/pixels-0.1.0-d6b41f4a271e9eedfe1e6e8c13d7fb6f010b6c23/pixels.nim(12) drawText
Error: unhandled exception: font could not be created, SDL error Couldn't open /usr/share/fonts/TTF/FiraSans-Regular.ttf [SDLException]
Error: execution of an external program failed: '/home/user/.cache/nim/ch03_text_d/ch03_text_4D8F0A24490781C34D568D66A34AA20B6C408DD8'

Fix

# Ch3 requires a text font.
# Navigate to the directory where you're running your nim code. The below
# command downloads to the current directory a font from nim's SDL2 library,
# renames it to FiraSans-Regular, which is the font SDL2 is looking for.
wget https://github.com/nim-lang/sdl2/blob/master/examples/liberation-sans.ttf -O FiraSans-Regular.ttf

# The font is expected to be in /usr/shared/fonts/TTF, and you can put the font
# there instead, which requires the use of sudo.
@Araq
Copy link
Member

Araq commented Nov 9, 2023

That's a "pixels" library problem, not an SDL problem. Also, it might just be an installation problem.

@Araq Araq closed this as completed Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants