1 /******************************************************************************/
2 /* Mednafen - Multi-system Emulator                                           */
3 /******************************************************************************/
4 /* text.h:
5 **  Copyright (C) 2007-2016 Mednafen Team
6 **
7 ** This program is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU General Public License
9 ** as published by the Free Software Foundation; either version 2
10 ** of the License, or (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software Foundation, Inc.,
19 ** 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 */
21 
22 #ifndef __MDFN_VIDEO_TEXT_H
23 #define __MDFN_VIDEO_TEXT_H
24 
25 namespace Mednafen
26 {
27 
28 enum
29 {
30  // If the order of these constants is changed, you must also update the array of FontDescriptor
31  // in text.cpp.
32  MDFN_FONT_5x7,
33  MDFN_FONT_6x9,
34 
35 // MDFN_FONT_6x10,
36 
37  MDFN_FONT_6x12,
38  MDFN_FONT_6x13_12x13,
39  MDFN_FONT_9x18_18x18,
40 
41  #ifdef WANT_INTERNAL_CJK
42  MDFN_FONT_12x13,
43  MDFN_FONT_18x18,
44  #endif
45 
46  _MDFN_FONT_COUNT
47 };
48 
49 uint32 GetFontHeight(const unsigned fontid);
50 
51 uint32 GetTextPixLength(const char* text, uint32 fontid = MDFN_FONT_9x18_18x18);
52 uint32 GetTextPixLength(const char32_t* text, uint32 fontid = MDFN_FONT_9x18_18x18);
53 
54 INLINE uint32 GetTextPixLength(const std::string& text, uint32 fontid = MDFN_FONT_9x18_18x18) { return GetTextPixLength(text.c_str(), fontid); }
55 INLINE uint32 GetTextPixLength(const std::u32string& text, uint32 fontid = MDFN_FONT_9x18_18x18) { return GetTextPixLength(text.c_str(), fontid); }
56 
57 uint32 DrawText(MDFN_Surface* surf, int32 x, int32 y, const char* text, uint32 color, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0);
58 uint32 DrawText(MDFN_Surface* surf, const MDFN_Rect& crect, int32 x, int32 y, const char* text, uint32 color, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0);
59 uint32 DrawTextShadow(MDFN_Surface* surf, int32 x, int32 y, const char* text, uint32 color, uint32 shadcolor, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0);
60 uint32 DrawTextShadow(MDFN_Surface* surf, const MDFN_Rect& crect, int32 x, int32 y, const char* text, uint32 color, uint32 shadcolor, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0);
61 
62 uint32 DrawText(MDFN_Surface* surf, int32 x, int32 y, const char32_t* text, uint32 color, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0);
63 uint32 DrawText(MDFN_Surface* surf, const MDFN_Rect& crect, int32 x, int32 y, const char32_t* text, uint32 color, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0);
64 uint32 DrawTextShadow(MDFN_Surface* surf, int32 x, int32 y, const char32_t* text, uint32 color, uint32 shadcolor, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0);
65 uint32 DrawTextShadow(MDFN_Surface* surf, const MDFN_Rect& crect, int32 x, int32 y, const char32_t* text, uint32 color, uint32 shadcolor, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0);
66 
67 INLINE uint32 DrawText(MDFN_Surface* surf, int32 x, int32 y, const std::string& text, uint32 color, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0) { return DrawText(surf, x, y, text.c_str(), color, fontid, hcenterw); }
68 INLINE uint32 DrawText(MDFN_Surface* surf, const MDFN_Rect& crect, int32 x, int32 y, const std::string& text, uint32 color, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0) { return DrawText(surf, crect, x, y, text.c_str(), color, fontid, hcenterw); }
69 INLINE uint32 DrawTextShadow(MDFN_Surface* surf, int32 x, int32 y, const std::string& text, uint32 color, uint32 shadcolor, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0) { return DrawTextShadow(surf, x, y, text.c_str(), color, shadcolor, fontid, hcenterw); }
70 INLINE uint32 DrawTextShadow(MDFN_Surface* surf, const MDFN_Rect& crect, int32 x, int32 y, const std::string& text, uint32 color, uint32 shadcolor, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0) { return DrawTextShadow(surf, crect, x, y, text.c_str(), color, shadcolor, fontid, hcenterw); }
71 
72 INLINE uint32 DrawText(MDFN_Surface* surf, int32 x, int32 y, const std::u32string& text, uint32 color, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0) { return DrawText(surf, x, y, text.c_str(), color, fontid, hcenterw); }
73 INLINE uint32 DrawText(MDFN_Surface* surf, const MDFN_Rect& crect, int32 x, int32 y, const std::u32string& text, uint32 color, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0) { return DrawText(surf, crect, x, y, text.c_str(), color, fontid, hcenterw); }
74 INLINE uint32 DrawTextShadow(MDFN_Surface* surf, int32 x, int32 y, const std::u32string& text, uint32 color, uint32 shadcolor, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0) { return DrawTextShadow(surf, x, y, text.c_str(), color, shadcolor, fontid, hcenterw); }
75 INLINE uint32 DrawTextShadow(MDFN_Surface* surf, const MDFN_Rect& crect, int32 x, int32 y, const std::u32string& text, uint32 color, uint32 shadcolor, uint32 fontid = MDFN_FONT_9x18_18x18, uint32 hcenterw = 0) { return DrawTextShadow(surf, crect, x, y, text.c_str(), color, shadcolor, fontid, hcenterw); }
76 
77 }
78 #endif
79