NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ut_Font.h
1#ifndef NW4R_UT_FONT_H
2#define NW4R_UT_FONT_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/ut/ut_CharStrmReader.h>
6
7#include <revolution/GX.h>
8
9namespace nw4r {
10namespace ut {
11
12enum FontEncoding {
13 FONT_ENCODING_UTF8,
14 FONT_ENCODING_UTF16,
15 FONT_ENCODING_SJIS,
16 FONT_ENCODING_CP1252,
17
18 FONT_ENCODING_MAX
19};
20
21struct CharWidths {
22 s8 left; // at 0x0
23 u8 glyphWidth; // at 0x1
24 s8 charWidth; // at 0x2
25};
26
27struct Glyph {
28 void* pTexture; // at 0x0
29 CharWidths widths; // at 0x4
30 u8 height; // at 0x7
31 GXTexFmt texFormat; // at 0x8
32 u16 texWidth; // at 0xC
33 u16 texHeight; // at 0xE
34 u16 cellX; // at 0x10
35 u16 cellY; // at 0x12
36};
37
38/******************************************************************************
39 *
40 * Font
41 *
42 ******************************************************************************/
43class Font {
44public:
45 enum Type { TYPE_NULL, TYPE_ROM, TYPE_RESOURCE, TYPE_PAIR };
46
47public:
48 Font() : mReadFunc(&CharStrmReader::ReadNextCharCP1252) {}
49 virtual ~Font() {} // at 0x8
50
51 virtual int GetWidth() const = 0; // at 0xC
52 virtual int GetHeight() const = 0; // at 0x10
53
54 virtual int GetAscent() const = 0; // at 0x14
55 virtual int GetDescent() const = 0; // at 0x18
56 virtual int GetBaselinePos() const = 0; // at 0x1C
57
58 virtual int GetCellHeight() const = 0; // at 0x20
59 virtual int GetCellWidth() const = 0; // at 0x24
60 virtual int GetMaxCharWidth() const = 0; // at 0x28
61
62 virtual Type GetType() const = 0; // at 0x2C
63 virtual GXTexFmt GetTextureFormat() const = 0; // at 0x30
64 virtual int GetLineFeed() const = 0; // at 0x34
65
66 virtual CharWidths GetDefaultCharWidths() const = 0; // at 0x38
67 virtual void SetDefaultCharWidths(const CharWidths& rWidths) = 0; // at 0x3C
68
69 virtual bool SetAlternateChar(u16 ch) = 0; // at 0x40
70 virtual void SetLineFeed(int lf) = 0; // at 0x44
71
72 virtual int GetCharWidth(u16 ch) const = 0; // at 0x48
73 virtual CharWidths GetCharWidths(u16 ch) const = 0; // at 0x4C
74 virtual void GetGlyph(Glyph* pGlyph, u16 ch) const = 0; // at 0x50
75 virtual FontEncoding GetEncoding() const = 0; // at 0x54
76
77 void InitReaderFunc(FontEncoding encode);
78
79 CharStrmReader GetCharStrmReader() const {
80 return CharStrmReader(mReadFunc);
81 }
82
83private:
84 CharStrmReader::ReadFunc mReadFunc; // at 0x4
85};
86
87} // namespace ut
88} // namespace nw4r
89
90#endif
Debugging library which includes various utilities used by the rest of nw4r.
Definition ut_list.cpp:4