OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
uifont.h
1/*
2===========================================================================
3Copyright (C) 2015 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25class UIRect2D;
26
27typedef enum {
28 FONT_JUSTHORZ_CENTER,
29 FONT_JUSTHORZ_LEFT,
30 FONT_JUSTHORZ_RIGHT
31} fonthorzjustify_t;
32
33typedef enum {
34 FONT_JUSTVERT_TOP,
35 FONT_JUSTVERT_CENTER,
36 FONT_JUSTVERT_BOTTOM
37} fontvertjustify_t;
38
39class UIFont
40{
41protected:
42 unsigned int m_listbase;
43 UColor color;
44 fontheader_t *m_font;
45
46 //
47 // Added in OPM
48 //
49 str name;
50 int refHandle;
51
52public:
53 UIFont();
54 UIFont(const char *fn);
55
56 void Print(float x, float y, const char *text, size_t maxlen = -1, const float *virtualScreen = NULL);
57 void PrintJustified(
58 const UIRect2D& rect, fonthorzjustify_t horz, fontvertjustify_t vert, const char *text, const float *vVirtualScale
59 );
60 void PrintOutlinedJustified(
61 const UIRect2D& rect, fonthorzjustify_t horz, fontvertjustify_t vert, const char* text, const UColor& outlineColor, const float* vVirtualScale
62 );
63 void setColor(UColor col);
64 void setAlpha(float alpha);
65 void setFont(const char *fontname);
66 int getMaxWidthIndex(const char* text, int maxlen);
67 int getWidth(const char *text, int maxlen);
68 int getCharWidth(unsigned short ch);
69 int getHeight(const char *text, int maxlen, const float* virtualScale = NULL);
70 int getHeight(const float* virtualScale = NULL);
71 int CodeSearch(unsigned short uch);
72 bool DBCSIsLeadByte(unsigned short uch);
73 bool DBCSIsMaekin(unsigned short uch);
74 bool DBCSIsAtokin(unsigned short uch);
75 int DBCSGetWordBlockCount(const char* text, int maxlen);
76
77private:
78 void CheckRefreshFont();
79};
80
81int UI_FontStringWidth(fontheader_t *pFont, const char *pszString, int iMaxLen);
Definition ucolor.h:25
Definition uirect2d.h:28
Definition str.h:77