mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Fix another carriage-return-related bug in the Android code.
This commit is contained in:
@@ -126,6 +126,12 @@ void TextDrawerWin32::MeasureStringInternal(std::string_view str, float *w, floa
|
||||
SelectObject(ctx_->hDC, iter->second->hFont);
|
||||
}
|
||||
|
||||
#if 0 && defined(_DEBUG)
|
||||
if (str.find('\r') != std::string_view::npos) {
|
||||
_dbg_assert_msg_(false, "carriage return found in string to measure");
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string toMeasure(str);
|
||||
|
||||
std::vector<std::string_view> lines;
|
||||
@@ -135,7 +141,7 @@ void TextDrawerWin32::MeasureStringInternal(std::string_view str, float *w, floa
|
||||
for (auto &line : lines) {
|
||||
SIZE size;
|
||||
std::wstring wstr = ConvertUTF8ToWString(line);
|
||||
if (wstr.empty()) {
|
||||
if (wstr.empty() && lines.size() > 1) {
|
||||
// Measure empty lines as if it was a space.
|
||||
wstr = L" ";
|
||||
}
|
||||
|
||||
@@ -37,16 +37,11 @@ public class TextRenderer {
|
||||
}
|
||||
|
||||
private static Point measureLine(String string, double textSize) {
|
||||
int w;
|
||||
if (!string.isEmpty()) {
|
||||
textPaint.setTextSize((float) textSize);
|
||||
w = (int) textPaint.measureText(string);
|
||||
// Round width up to even already here to avoid annoyances from odd-width 16-bit textures
|
||||
// which OpenGL does not like - each line must be 4-byte aligned
|
||||
w = (w + 5) & ~1;
|
||||
} else {
|
||||
w = 1;
|
||||
}
|
||||
textPaint.setTextSize((float) textSize);
|
||||
int w = (int) textPaint.measureText(string);
|
||||
// Round width up to even already here to avoid annoyances from odd-width 16-bit textures
|
||||
// which OpenGL does not like - each line must be 4-byte aligned
|
||||
w = (w + 5) & ~1;
|
||||
int h = (int) (textPaint.descent() - textPaint.ascent() + 2.0f);
|
||||
Point p = new Point();
|
||||
p.x = w;
|
||||
@@ -55,7 +50,7 @@ public class TextRenderer {
|
||||
}
|
||||
|
||||
private static Point measure(String string, double textSize) {
|
||||
String [] lines = string.replaceAll("\\r", "").split("\n");
|
||||
String [] lines = string.replaceAll("\r", "").split("\n");
|
||||
Point total = new Point();
|
||||
total.x = 0;
|
||||
for (String line : lines) {
|
||||
|
||||
Reference in New Issue
Block a user