summaryrefslogtreecommitdiff
path: root/src/os/windows/font_win32.cpp
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2021-02-21 17:03:19 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2021-04-07 09:31:47 +0200
commite0561dbded57f195e7842cf69764e3ee2c3a71da (patch)
tree10ae740118601eb102fa73a753bdcdca03607552 /src/os/windows/font_win32.cpp
parent825867f2c50ce508fac442e6113da9cebbfccf75 (diff)
downloadopenttd-e0561dbded57f195e7842cf69764e3ee2c3a71da.tar.xz
Fix #8713: Change OTTD2FS and FS2OTTD to return string objects instead of static buffers
Diffstat (limited to 'src/os/windows/font_win32.cpp')
-rw-r--r--src/os/windows/font_win32.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp
index 9a9dba2f2..1d923ddb2 100644
--- a/src/os/windows/font_win32.cpp
+++ b/src/os/windows/font_win32.cpp
@@ -83,7 +83,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
}
/* Convert font name to file system encoding. */
- wchar_t *font_namep = wcsdup(OTTD2FS(font_name));
+ wchar_t *font_namep = wcsdup(OTTD2FS(font_name).c_str());
for (index = 0;; index++) {
wchar_t *s;
@@ -377,6 +377,7 @@ Win32FontCache::Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels)
{
this->dc = CreateCompatibleDC(nullptr);
this->SetFontSize(fs, pixels);
+ this->fontname = FS2OTTD(this->logfont.lfFaceName);
}
Win32FontCache::~Win32FontCache()
@@ -438,7 +439,7 @@ void Win32FontCache::SetFontSize(FontSize fs, int pixels)
this->glyph_size.cx = otm->otmTextMetrics.tmMaxCharWidth;
this->glyph_size.cy = otm->otmTextMetrics.tmHeight;
- DEBUG(freetype, 2, "Loaded font '%s' with size %d", FS2OTTD((LPTSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)), pixels);
+ DEBUG(freetype, 2, "Loaded font '%s' with size %d", FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)).c_str(), pixels);
}
/**
@@ -541,10 +542,10 @@ void Win32FontCache::ClearFontCache()
/* Convert characters outside of the BMP into surrogate pairs. */
WCHAR chars[2];
if (key >= 0x010000U) {
- chars[0] = (WCHAR)(((key - 0x010000U) >> 10) + 0xD800);
- chars[1] = (WCHAR)(((key - 0x010000U) & 0x3FF) + 0xDC00);
+ chars[0] = (wchar_t)(((key - 0x010000U) >> 10) + 0xD800);
+ chars[1] = (wchar_t)(((key - 0x010000U) & 0x3FF) + 0xDC00);
} else {
- chars[0] = (WCHAR)(key & 0xFFFF);
+ chars[0] = (wchar_t)(key & 0xFFFF);
}
WORD glyphs[2] = { 0, 0 };