Questions tagged [sdl-ttf]

This is a sample library which allows you to use TrueType fonts in your SDL applications. It comes with an example program "showfont" which displays an example string for a given TrueType font file.

208 questions
1
vote
1 answer

Rubygame::TTF - The difference between a string's width and the width of all it's characters

I'm trying to use Rubygame to determine each of a string's character widths as a percentage of the string's total width... require "rubygems" require "rubygame" include Rubygame TTF.setup $font = TTF.new "/Library/Fonts/Times New Roman.ttf",…
1
vote
2 answers

SDL C++ ttf linker errors

I'm using CodeBlocks and trying to link SDL_ttf when compiling my program. I have followed thus instructions: Add "-lSDL_ttf" in the linker command line Put SDL_ttf.dll in library directory Put SDL_ttf.h in include file directory And I have this…
user969416
1
vote
1 answer

SDL2 TTF Text Not Rendering As Expected

I've been working on a program that utilizes SDL2, and I've been trying to get text on the screen using an SDL_Surface converted to a SDL_Texture then rendering with SDL_RenderCopy(). It shows only a black screen (as expected) however the red "Hello…
1
vote
1 answer

problems with keeping content displayed with SDL in C

I try to make a game interface using SDL in C language, where the user needs to click on start after the text is displayed so that it takes him to the menu. But when the text and the button is displayed, they disapear leaving the image blank without…
hoover
  • 9
  • 3
1
vote
0 answers

i can't show text on the window using SDL2 TTF library

I make a SDL_ttf test code: #include #include #include #include "SDLwindow.h" #include #include "GraphLib.h" #undef main using namespace std; int main() { bool running = 1; …
Nico Cano
  • 37
  • 3
1
vote
0 answers

How to include ft2build.h in SDL2 CMake project

I want to compile a CMake project using SDL2 and SDL_ttf library. I copied "SDL_ttf.c" & "SDL_ttf.h" into my src folder. (EDIT: removed it, see comments) I also added this to my CMakeLists.txt: include_directories(${SDL2_TTF_INCLUDE_DIR}) freetype2…
Seim2k20
  • 31
  • 5
1
vote
0 answers

How to make a textbox (SDL2)

i would like to know how to create a textbox with SDL2, in C. I can't figure something out. I've looked for gui libs for SDL2, but they are all written in C++. I've thought of using things like gtk, but have no idea about how it will interact with…
dMight
  • 19
  • 4
1
vote
0 answers

SDL_TTF and runtime missing entry point ScriptFreeCache with GDI32.dll (Windows 7 - SDL - SDL_TTF - Mingw64 - Codeblocks)

I'm trying to understand Simple DirectMedia Layer (SDL) for my own projects and I've encountered an issue I'm not able to solve. The issue arises with Windows 7, but not with Windows 10 (both 64bit machines). The project compiles fine on both OS…
Nem
  • 41
  • 3
1
vote
1 answer

Valgrind thinks my std::ranges of raw pointers are leaking, even after they've been copied to unique pointers

I'm trying to load all true-type fonts in a directory using C++20 ranges and functional-style programming. However, since fonts are a resource, I'm allocating memory within the ranges interface. I think this is why valgrind thinks I have a leak. I…
Josie Thompson
  • 5,608
  • 1
  • 13
  • 24
1
vote
0 answers

How can I get a list of TTF fonts for use with SDL TTF?

How can I get a list of TTF fonts (ideally in a cross platform way) for use with SDL and the SDL TTF library? An initial idea of how the problem might be approached: Here is how I imagine one might go about solving this question: I assume that there…
FreelanceConsultant
  • 13,167
  • 27
  • 115
  • 225
1
vote
1 answer

My SDL_ttf rendered text ends up streched. How do I avoid that?

Here is a minimal example of how I render my SDL text: #include void runttf() { constexpr auto SCREEN_WIDTH{300}; constexpr auto SCREEN_HEIGHT{300}; constexpr auto font_path =…
Johannes
  • 6,490
  • 10
  • 59
  • 108
1
vote
0 answers

Opening file in C++ on Unix: can we avoid case sensitivity?

I am opening a file in a C++ program in Manjaro: TTF_Font* result = TTF_OpenFont(filename, point); (It's using SDL2_TTF, so I don't have direct access to the function that does the opening, but bear with me.) The font package (Microsoft Core Fonts…
Topological Sort
  • 2,733
  • 2
  • 27
  • 54
1
vote
0 answers

Cannot create SDL2_ttf library correctly using local SDL2 repository using cmake

I am making a project that has a deps folder with all its dependencies, currently it includes a git clone of SDL2 and SDL2_ttf. I'd like to get this project to work without having to install SDL2 or SDL2_ttf separately using home brew for example.…
luis
  • 2,067
  • 2
  • 13
  • 21
1
vote
0 answers

How to render text in monospace SDL2 TTF

I'm trying to draw/highlight text in SDL2, there is the simple SDL_Surface *surf = TTF_RenderText_Blended(font, text, size); and then SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, surface);, and then query the texture, and then draw…
404 TNF
  • 19
  • 6
1
vote
1 answer

How to have public class member that can be accessed but not changed by other classes C++

This probably has been asked before, but I can't find something on it other than the general private/public/const solutions. Basically, I need to load fonts into an array when an instance of my class text is created. The text class is in my text.h…