SDLPainter
0.1.0
QPainter benzeri SDL3 + OpenGL/Vulkan 2D çizim kütüphanesi
Toggle main menu visibility
Yüklüyor...
Arıyor...
Eşleşme Yok
font.h
1
#pragma once
2
3
#include "sdl_painter/texture.h"
4
5
#include <cstdint>
6
#include <memory>
7
#include <string>
8
#include <unordered_map>
9
10
namespace
sdl_painter {
11
12
class
IRenderer
;
13
15
struct
Glyph
{
16
Texture
texture;
17
int32_t width{0};
18
int32_t height{0};
19
int32_t advance{0};
20
int32_t bearing_x{0};
21
int32_t bearing_y{0};
22
};
23
25
enum class
Alignment : uint8_t {
26
kLeft,
27
kCenter,
28
kRight,
29
};
30
43
class
Font {
44
public
:
45
Font() =
default
;
46
50
Font
(
const
std::string& file_path, int32_t point_size);
51
52
~Font();
53
54
// Non-copyable, movable
55
Font(
const
Font&) =
delete
;
56
Font& operator=(
const
Font&) =
delete
;
57
Font(Font&& other)
noexcept
;
58
Font& operator=(Font&& other)
noexcept
;
59
61
[[nodiscard]]
bool
IsValid
() const noexcept {
return
mHandle !=
nullptr
; }
62
64
[[nodiscard]] int32_t
PointSize
() const noexcept {
return
mPointSize; }
65
67
[[nodiscard]] int32_t
Ascent
()
const
;
68
70
[[nodiscard]]
void
*
Handle
() const noexcept {
return
mHandle; }
71
77
bool
MeasureText
(
const
std::string& text, int32_t& out_width,
78
int32_t& out_height)
const
;
79
81
const
Glyph
*
GetGlyph
(
IRenderer
& renderer,
char32_t
codepoint)
const
;
82
83
private
:
84
void
* mHandle{
nullptr
};
85
int32_t mPointSize{0};
86
87
// Karakter önbelleği (mutable çünkü mantıksal const'u bozmuyoruz)
88
mutable
std::unordered_map<char32_t, Glyph> mGlyphCache;
89
};
90
91
}
// namespace sdl_painter
sdl_painter::Font::Font
Font(const std::string &file_path, int32_t point_size)
TTF dosyasından font yükle.
sdl_painter::Font::PointSize
int32_t PointSize() const noexcept
Punto boyutunu döndür.
Definition
font.h:64
sdl_painter::Font::GetGlyph
const Glyph * GetGlyph(IRenderer &renderer, char32_t codepoint) const
Karakter için Glyph al; yoksa oluşturur.
sdl_painter::Font::Ascent
int32_t Ascent() const
Font ascent (baseline'dan yukariya olan maksimum piksel) degerini dondur.
sdl_painter::Font::IsValid
bool IsValid() const noexcept
Font başarıyla yüklendi mi?
Definition
font.h:61
sdl_painter::Font::Handle
void * Handle() const noexcept
SDL_ttf font handle'ı döndür (opak pointer).
Definition
font.h:70
sdl_painter::Font::MeasureText
bool MeasureText(const std::string &text, int32_t &out_width, int32_t &out_height) const
Verilen metnin piksel boyutunu ölç.
sdl_painter::IRenderer
Backend-agnostik soyut renderer arayüzü.
Definition
renderer.h:32
sdl_painter::Texture
RAII sarmalayıcı — texture yaşam döngüsünü yönetir.
Definition
texture.h:15
sdl_painter::Glyph
Tek bir karakterin metrikleri ve dokusu.
Definition
font.h:15
include
sdl_painter
font.h
Oluşturan
1.17.0