OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
gthfont.h
Go to the documentation of this file.
1#pragma once
2
3#include <zenkit/Font.hh>
4
5#include <Tempest/Painter>
6
7class GthFont final {
8 public:
9 GthFont();
10 GthFont(zenkit::Read& data, std::string_view ftex, const Tempest::Color &cl);
11 GthFont(const GthFont&) = default;
12 GthFont(GthFont&&) = default;
13
14 GthFont& operator = (const GthFont&) = default;
16
17 int pixelSize() const;
18 void setScale(float s);
19
20 void drawText(Tempest::Painter& p, int x, int y, int w, int h, std::string_view txt, Tempest::AlignFlag align, int firstLine=0) const;
21 void drawText(Tempest::Painter& p, int x, int y, std::string_view txt) const;
22
23 auto textSize(const std::string_view txt) const -> Tempest::Size;
24 auto textSize(const char* b, const char* e) const -> Tempest::Size;
25 auto textSize(const uint8_t* b, const uint8_t* e) const -> Tempest::Size;
26 auto textSize(int w, std::string_view txt) const -> Tempest::Size;
27 auto lineCount(int w, std::string_view txt) const -> int32_t;
28
29 private:
30 std::shared_ptr<zenkit::Font> pfnt;
31 const Tempest::Texture2d* tex = nullptr;
32 uint32_t fntHeight = 0;
33 float scale = 0;
34 Tempest::Color color;
35
36 const uint8_t* getLine(const uint8_t* txt, int bw, int &width) const;
37 const uint8_t* getWord(const uint8_t* txt, int &width, int &space) const;
38
39 static bool isSpace(uint8_t ch);
40 Tempest::Size processText(Tempest::Painter* p, int x, int y, int w, int h, std::string_view txt, Tempest::AlignFlag align, int firstLine) const;
41 };
42
GthFont(const GthFont &)=default
GthFont()
Definition gthfont.cpp:8
auto lineCount(int w, std::string_view txt) const -> int32_t
Definition gthfont.cpp:184
void drawText(Tempest::Painter &p, int x, int y, int w, int h, std::string_view txt, Tempest::AlignFlag align, int firstLine=0) const
void setScale(float s)
Definition gthfont.cpp:22
GthFont & operator=(const GthFont &)=default
GthFont(zenkit::Read &data, std::string_view ftex, const Tempest::Color &cl)
auto textSize(const std::string_view txt) const -> Tempest::Size
Definition gthfont.cpp:131
int pixelSize() const
Definition gthfont.cpp:18
GthFont(GthFont &&)=default