Reconstruct readable C++ and organize cohesive source subsystems
Administrative source import: native x86 compilation passed for 423 authored units. Source placement and submission states are migrated separately; this commit does not imply peer acceptance.
Previous head: 35d2a8cb36
Payload SHA256: 592f016d2730c5593bb653aa054c1e5f76a6df72c8f5a09e66f74876e2e33dee
This commit is contained in:
parent
35d2a8cb36
commit
a47d20f8be
890 changed files with 11796 additions and 16664 deletions
|
|
@ -1,38 +0,0 @@
|
|||
#include "Render/TextContext.h"
|
||||
#include "UI/TextFitting.h"
|
||||
|
||||
#include <atlconv.h>
|
||||
#include <atlexcept.h>
|
||||
#include <windows.h>
|
||||
|
||||
// OFFSET: 0x00A837D0
|
||||
// FUNCTION: fn_17007
|
||||
std::string FitText(CDC& surface, FontCache& fonts, const TextLocale& locale, std::string text, int width) {
|
||||
TextContext context(surface, fonts, locale);
|
||||
context.SetFont(0, 12, 0, 0);
|
||||
int extent = text.empty() ? 0 : context.Measure(text.c_str(), static_cast<int>(text.size())).cx;
|
||||
context.Measure("...", 3);
|
||||
ATL::CA2WEX<128> wide(text.c_str(), CP_THREAD_ACP);
|
||||
std::wstring remaining(wide);
|
||||
|
||||
while (extent > width) {
|
||||
if (remaining.size() <= 1) {
|
||||
ATL::CW2AEX<128> converted(remaining.c_str(), CP_THREAD_ACP);
|
||||
return std::string(converted) + "...";
|
||||
}
|
||||
|
||||
std::size_t length = remaining.size() - 1;
|
||||
// Original checks the low bytes of adjacent UTF-16 units, not surrogates.
|
||||
if ((remaining[remaining.size() - 2] & 0x80) != 0 && (remaining[remaining.size() - 1] & 0x80) != 0) {
|
||||
--length;
|
||||
}
|
||||
|
||||
remaining.resize(length);
|
||||
ATL::CW2AEX<128> converted(remaining.c_str(), CP_THREAD_ACP);
|
||||
text = converted;
|
||||
text += "...";
|
||||
extent = context.Measure(text.c_str(), static_cast<int>(text.size())).cx;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue