Changeset - r24210:b9baa2f1bb39
[Not reviewed]
master
0 4 0
Michael Lutz - 4 years ago 2020-05-17 21:31:49
michi@icosahedron.de
Codechange: Consistently use WChar when passing characters around, and also define it as char32_t.
4 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/fontcache.cpp
Show inline comments
 
@@ -105,13 +105,13 @@ SpriteFontCache::~SpriteFontCache()
 
	this->ClearGlyphToSpriteMap();
 
}
 

	
 
SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key)
 
SpriteID SpriteFontCache::GetUnicodeGlyph(WChar key)
 
{
 
	if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) return 0;
 
	return this->glyph_to_spriteid_map[GB(key, 8, 8)][GB(key, 0, 8)];
 
}
 

	
 
void SpriteFontCache::SetUnicodeGlyph(GlyphID key, SpriteID sprite)
 
void SpriteFontCache::SetUnicodeGlyph(WChar key, SpriteID sprite)
 
{
 
	if (this->glyph_to_spriteid_map == nullptr) this->glyph_to_spriteid_map = CallocT<SpriteID*>(256);
 
	if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) this->glyph_to_spriteid_map[GB(key, 8, 8)] = CallocT<SpriteID>(256);
src/gfx_func.h
Show inline comments
 
@@ -112,7 +112,7 @@ int DrawString(int left, int right, int 
 
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
 
int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
 

	
 
void DrawCharCentered(uint32 c, int x, int y, TextColour colour);
 
void DrawCharCentered(WChar c, int x, int y, TextColour colour);
 

	
 
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE);
 
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE);
 
@@ -164,7 +164,7 @@ void SortResolutions();
 
bool ToggleFullScreen(bool fs);
 

	
 
/* gfx.cpp */
 
byte GetCharacterWidth(FontSize size, uint32 key);
 
byte GetCharacterWidth(FontSize size, WChar key);
 
byte GetDigitWidth(FontSize size = FS_NORMAL);
 
void GetBroadestDigit(uint *front, uint *next, FontSize size = FS_NORMAL);
 

	
src/string_type.h
Show inline comments
 
@@ -32,7 +32,7 @@ enum CharSetFilter {
 
};
 

	
 
/** Type for wide characters, i.e. non-UTF8 encoded unicode characters. */
 
typedef uint32 WChar;
 
typedef char32_t WChar;
 

	
 
/* The following are directional formatting codes used to get the LTR and RTL strings right:
 
 * http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */
src/textbuf_type.h
Show inline comments
 
@@ -53,7 +53,7 @@ struct Textbuf {
 
	void DeleteAll();
 
	bool InsertClipboard();
 

	
 
	bool InsertChar(uint32 key);
 
	bool InsertChar(WChar key);
 
	bool InsertString(const char *str, bool marked, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr);
 

	
 
	bool DeleteChar(uint16 keycode);
0 comments (0 inline, 0 general)