Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
rdoeffinger committed May 8, 2020
2 parents 30f8057 + a0d82bc commit 3d41d4c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
6 changes: 5 additions & 1 deletion impl11/ddraw/PrimarySurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,11 @@ void PrimarySurface::RenderText()
continue;
}

std::wstring wtext = string_towstring(xwaText.text);
char t[2];
t[0] = xwaText.textChar;
t[1] = 0;

std::wstring wtext = string_towstring(t);

if (wtext.empty())
{
Expand Down
8 changes: 2 additions & 6 deletions impl11/ddraw/XwaDrawTextHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ void RenderCharHook(short x, short y, unsigned char fw, unsigned char fh, char c
xwaText.positionY = y;
xwaText.color = color;
xwaText.fontSize = fh;

char t[2];
t[0] = c;
t[1] = 0;
xwaText.text = t;
xwaText.textChar = c;

g_xwa_text.push_back(xwaText);
}
Expand Down Expand Up @@ -50,7 +46,7 @@ void ComputeMetricsHook()
std::wstring wtext = string_towstring(t);

ComPtr<IDWriteTextLayout> layout;
dwriteFactory->CreateTextLayout(wtext.c_str(), 1, textFormat, 100, 100, &layout);
dwriteFactory->CreateTextLayout(wtext.c_str(), wtext.length(), textFormat, 100, 100, &layout);

DWRITE_TEXT_METRICS m{};
layout->GetMetrics(&m);
Expand Down
2 changes: 1 addition & 1 deletion impl11/ddraw/XwaDrawTextHook.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct XwaText
int positionY;
unsigned int color;
int fontSize;
std::string text;
char textChar;
};

extern std::vector<XwaText> g_xwa_text;
Expand Down
11 changes: 10 additions & 1 deletion impl11/ddraw/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ std::string wchar_tostring(LPCWSTR text)

std::wstring string_towstring(const std::string& text)
{
return std::wstring(text.begin(), text.end());
std::wstringstream path;
path << text.c_str();
return path.str();
}

std::wstring string_towstring(const char* text)
{
std::wstringstream path;
path << text;
return path.str();
}

#if LOGGER
Expand Down
1 change: 1 addition & 0 deletions impl11/ddraw/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

std::string wchar_tostring(LPCWSTR text);
std::wstring string_towstring(const std::string& text);
std::wstring string_towstring(const char* text);

#if LOGGER

Expand Down

0 comments on commit 3d41d4c

Please sign in to comment.