Sistema de texto: - Reemplazado dbgtxt.cpp (bitmap 8x8) por TextRenderer (SDL_TTF) - Creado source/text/ con TextRenderer class - Añadidas fuentes TrueType en data/fonts/ - Implementados dos TextRenderer (display + debug) con escalado dinámico - Constantes configurables: TEXT_FONT_PATH, TEXT_BASE_SIZE, TEXT_ANTIALIASING Correcciones de centrado: - Reemplazado text.length() * 8 por text_renderer_.getTextWidth() en ~25 lugares - Texto de tecla F ahora se centra correctamente - Texto de modo (Demo/Logo/Lite) fijo en tercera fila del HUD debug - Implementado espaciado dinámico con getTextHeight() Conversión a mixed case: - ~26 textos de display cambiados de ALL CAPS a mixed case - 15 nombres de temas en theme_manager.cpp convertidos a mixed case - Ejemplos: "FPS" → "fps", "MODO FISICA" → "Modo Física", "DEMO MODE ON" → "Modo Demo: On" - Temas: "SUNSET" → "Sunset", "OCEANO" → "Océano", etc. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
37 lines
1002 B
C++
37 lines
1002 B
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3_ttf/SDL_ttf.h>
|
|
#include <string>
|
|
|
|
class TextRenderer {
|
|
public:
|
|
TextRenderer();
|
|
~TextRenderer();
|
|
|
|
// Inicializa el renderizador de texto con una fuente
|
|
bool init(SDL_Renderer* renderer, const char* font_path, int font_size, bool use_antialiasing = true);
|
|
|
|
// Libera recursos
|
|
void cleanup();
|
|
|
|
// Renderiza texto en la posición especificada con color RGB
|
|
void print(int x, int y, const char* text, uint8_t r, uint8_t g, uint8_t b);
|
|
void print(int x, int y, const std::string& text, uint8_t r, uint8_t g, uint8_t b);
|
|
|
|
// Obtiene el ancho de un texto renderizado
|
|
int getTextWidth(const char* text);
|
|
|
|
// Obtiene la altura de la fuente
|
|
int getTextHeight();
|
|
|
|
// Verifica si está inicializado correctamente
|
|
bool isInitialized() const { return font_ != nullptr && renderer_ != nullptr; }
|
|
|
|
private:
|
|
SDL_Renderer* renderer_;
|
|
TTF_Font* font_;
|
|
int font_size_;
|
|
bool use_antialiasing_;
|
|
};
|