diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/Font.h | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/Font.h')
| -rw-r--r-- | Minecraft.Client/Font.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Minecraft.Client/Font.h b/Minecraft.Client/Font.h new file mode 100644 index 00000000..b6ad555d --- /dev/null +++ b/Minecraft.Client/Font.h @@ -0,0 +1,83 @@ +#pragma once +class IntBuffer; +class Options; +class Textures; + +class Font +{ +private: + int *charWidths; +public: + int fontTexture; + Random *random; + +private: + int colors[32]; // RGB colors for formatting + + Textures *textures; + + float xPos; + float yPos; + + bool enforceUnicodeSheet; // use unicode sheet for ascii + bool bidirectional; // use bidi to flip strings + + int m_cols; // Number of columns in font sheet + int m_rows; // Number of rows in font sheet + int m_charWidth; // Maximum character width + int m_charHeight; // Maximum character height + TEXTURE_NAME m_textureName; // Texture + std::map<int, int> m_charMap; + +public: + Font(Options *options, const wstring& name, Textures* textures, bool enforceUnicode, TEXTURE_NAME textureName, int cols, int rows, int charWidth, int charHeight, unsigned short charMap[] = NULL); +#ifndef _XBOX + // 4J Stu - This dtor clashes with one in xui! We never delete these anyway so take it out for now. Can go back when we have got rid of XUI + ~Font(); +#endif + void renderFakeCB(IntBuffer *cb); // 4J added + +private: + void renderCharacter(wchar_t c); // 4J added + +public: + void drawShadow(const wstring& str, int x, int y, int color); + void drawShadowWordWrap(const wstring &str, int x, int y, int w, int color, int h); // 4J Added h param + void draw(const wstring &str, int x, int y, int color); + /** + * Reorders the string according to bidirectional levels. A bit expensive at + * the moment. + * + * @param str + * @return + */ +private: + wstring reorderBidi(const wstring &str); + + void draw(const wstring &str, bool dropShadow); + void draw(const wstring& str, int x, int y, int color, bool dropShadow); + int MapCharacter(wchar_t c); // 4J added + bool CharacterExists(wchar_t c); // 4J added + +public: + int width(const wstring& str); + wstring sanitize(const wstring& str); + void drawWordWrap(const wstring &string, int x, int y, int w, int col, int h); // 4J Added h param + +private: + void drawWordWrapInternal(const wstring &string, int x, int y, int w, int col, int h); // 4J Added h param + +public: + void drawWordWrap(const wstring &string, int x, int y, int w, int col, bool darken, int h); // 4J Added h param + +private: + void drawWordWrapInternal(const wstring& string, int x, int y, int w, int col, bool darken, int h); // 4J Added h param + +public: + int wordWrapHeight(const wstring& string, int w); + void setEnforceUnicodeSheet(bool enforceUnicodeSheet); + void setBidirectional(bool bidirectional); + + // 4J-PB - check for invalid player name - Japanese local name + bool AllCharactersValid(const wstring &str); +}; |
