JustAnotherDnDGame 0.1.0
Jeu de rôle tactique au d20, vue de dessus, en C++/Qt
Loading...
Searching...
No Matches
BitmapFont.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Valentin Eloy
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#pragma once
5
6#include <memory>
7#include <string>
8#include <string_view>
9
12
13class QRhiTexture;
14
19
20namespace hmi {
21
22struct RhiContext;
23
25inline const std::string FONTS_SUBDIRECTORY = "Fonts/";
26
40public:
42 static constexpr const char* FONT_ASSET_FILE_NAME = "font.png";
44 static constexpr const char* FONT_METRICS_FILE_NAME = "font.json";
45
50 explicit BitmapFont(const RhiContext& context);
51
53 [[nodiscard]] TextureHandle textureHandle() const {
54 return _texture.get();
55 }
56
58 [[nodiscard]] int textureWidth() const noexcept {
59 return _textureWidth;
60 }
61
63 [[nodiscard]] int textureHeight() const noexcept {
64 return _textureHeight;
65 }
66
68 [[nodiscard]] const FontMetrics& metrics() const noexcept {
69 return _metrics;
70 }
71
73 [[nodiscard]] TextExtent measure(std::string_view text, float scale = 1.0f) const {
74 return measureText(_metrics, text, scale);
75 }
76
77private:
80 bool loadFromAssets(const RhiContext& context);
82 void generateProcedural(const RhiContext& context);
83
87 std::shared_ptr<QRhiTexture> _texture;
88};
89
90} // namespace hmi
Métriques de police bitmap, mesure pure de texte, lecture JSON et repli procédural (LOT-52) — logique...
Ordonnancement de calques unique et explicite du rendu (EX-REN-014).
int textureHeight() const noexcept
Definition BitmapFont.h:63
int _textureWidth
Definition BitmapFont.h:85
const FontMetrics & metrics() const noexcept
Definition BitmapFont.h:68
TextExtent measure(std::string_view text, float scale=1.0f) const
Raccourci pour hmi::measureText(metrics(), text, scale).
Definition BitmapFont.h:73
int _textureHeight
Definition BitmapFont.h:86
static constexpr const char * FONT_METRICS_FILE_NAME
Nom du fichier de métriques attendu dans Assets/Fonts/, à côté de l'atlas.
Definition BitmapFont.h:44
bool loadFromAssets(const RhiContext &context)
Essaie de charger Assets/Fonts/font.png + font.json.
Definition BitmapFont.cpp:29
void generateProcedural(const RhiContext &context)
Génère la police procédurale (hmi::buildProceduralFont) et crée la texture associée.
Definition BitmapFont.cpp:83
std::shared_ptr< QRhiTexture > _texture
Definition BitmapFont.h:87
TextureHandle textureHandle() const
Definition BitmapFont.h:53
FontMetrics _metrics
Definition BitmapFont.h:84
int textureWidth() const noexcept
Definition BitmapFont.h:58
BitmapFont(const RhiContext &context)
Charge la police (fichier, avec repli procédural) et crée la texture GPU associée.
Definition BitmapFont.cpp:20
static constexpr const char * FONT_ASSET_FILE_NAME
Nom du fichier d'atlas de glyphes attendu dans Assets/Fonts/.
Definition BitmapFont.h:42
Definition AudioEngine.cpp:15
TextExtent measureText(const FontMetrics &metrics, std::string_view text, float scale) noexcept
Largeur et hauteur qu'occuperait text avec metrics, à l'échelle scale.
Definition ProceduralFont.cpp:262
const std::string FONTS_SUBDIRECTORY
Sous-dossier des assets de police, relatif au dossier d'assets (LOT-52).
Definition BitmapFont.h:25
void * TextureHandle
Identité opaque d'une texture liée, du point de vue de la composition.
Definition RenderLayer.h:107
Métriques d'une police bitmap : région et avance de chaque point de code couvert.
Definition ProceduralFont.h:43
Le QRhi courant et le lot de téléversements de l'image en cours.
Definition RhiContext.h:34
Dimensions mesurées d'un texte, en pixels (à l'échelle demandée).
Definition ProceduralFont.h:61