SDLPainter
1.2.0
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/export.h"
4
#include "sdl_painter/texture.h"
5
6
#include <cstdint>
7
#include <memory>
8
#include <string>
9
#include <unordered_map>
10
11
namespace
sdl_painter {
12
13
class
IRenderer
;
14
class
GlyphAtlas;
15
23
struct
Glyph
{
25
TextureHandle
texture
{kInvalidTexture};
26
27
// Atlas içindeki normalize doku koordinatları.
28
float
u0{0.0F};
29
float
v0{0.0F};
30
float
u1{0.0F};
31
float
v1{0.0F};
32
33
int32_t width{0};
34
int32_t height{0};
35
int32_t advance{0};
36
int32_t bearing_x{0};
37
int32_t bearing_y{0};
38
40
[[nodiscard]]
bool
IsValid
() const noexcept {
41
return
texture
!= kInvalidTexture;
42
}
43
};
44
46
enum class
Alignment : uint8_t {
47
kLeft,
48
kCenter,
49
kRight,
50
};
51
53
enum class
TextWrap : uint8_t {
57
kNone,
60
kWord,
61
};
62
72
class
SDLPAINTER_API Font {
73
public
:
74
// Govde .cpp'de: sinif dllexport edildiginde derleyici bu ctor'u her
75
// TU'da emit eder ve temizlik yolu icin unique_ptr<GlyphAtlas>'in
76
// yikicisini ornekler — GlyphAtlas burada eksik tip.
77
Font();
78
82
Font
(
const
std::string& file_path, int32_t point_size);
83
84
~Font();
85
86
// Non-copyable, movable
87
Font(
const
Font&) =
delete
;
88
Font& operator=(
const
Font&) =
delete
;
89
Font(Font&& other)
noexcept
;
90
Font& operator=(Font&& other)
noexcept
;
91
93
[[nodiscard]]
bool
IsValid
() const noexcept {
return
mHandle !=
nullptr
; }
94
96
[[nodiscard]] int32_t
PointSize
() const noexcept {
return
mPointSize; }
97
99
[[nodiscard]] int32_t
Ascent
()
const
;
100
106
[[nodiscard]] int32_t
LineHeight
()
const
;
107
109
[[nodiscard]]
void
*
Handle
() const noexcept {
return
mHandle; }
110
116
bool
MeasureText
(
const
std::string& text, int32_t& out_width,
117
int32_t& out_height)
const
;
118
120
const
Glyph
*
GetGlyph
(
IRenderer
& renderer,
char32_t
codepoint)
const
;
121
123
[[nodiscard]] std::size_t
AtlasPageCount
()
const
;
124
125
private
:
126
void
* mHandle{
nullptr
};
127
int32_t mPointSize{0};
128
129
// Karakter önbelleği (mutable çünkü mantıksal const'u bozmuyoruz)
130
mutable
std::unordered_map<char32_t, Glyph> mGlyphCache;
131
134
mutable
std::unique_ptr<GlyphAtlas> mAtlas;
135
};
136
137
}
// namespace sdl_painter
sdl_painter::Font::AtlasPageCount
std::size_t AtlasPageCount() const
Glyph atlasının açtığı sayfa sayısı (teşhis/test).
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:96
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:93
sdl_painter::Font::LineHeight
int32_t LineHeight() const
İki satır arasındaki önerilen dikey mesafe (piksel).
sdl_painter::Font::Handle
void * Handle() const noexcept
SDL_ttf font handle'ı döndür (opak pointer).
Definition
font.h:109
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:64
sdl_painter::Glyph
Tek bir karakterin metrikleri ve atlas içindeki konumu.
Definition
font.h:23
sdl_painter::Glyph::IsValid
bool IsValid() const noexcept
Glyph çizilebilir bir görüntüye sahip mi?
Definition
font.h:40
sdl_painter::Glyph::texture
TextureHandle texture
Glyph'i içeren atlas sayfasının texture'ı (sahiplik atlasta).
Definition
font.h:25
include
sdl_painter
font.h
Oluşturan
1.18.0