aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-03-22 17:07:07 +1100
committerNeil <nyamatongwe@gmail.com>2021-03-22 17:07:07 +1100
commitc6abfabd40bdec8adca1b6f534e56a5602ecb993 (patch)
tree4ed7d27379c2beccb683444bb6d3bfc9b636b4a7
parent92c9516b7b6e63f1bc15758232beb87d118570c3 (diff)
downloadscintilla-mirror-c6abfabd40bdec8adca1b6f534e56a5602ecb993.tar.gz
Minimize differences between SurfaceD2D::MeasureWidthsUTF8 and MeasureWidths.
-rw-r--r--win32/PlatWin.cxx12
1 files changed, 6 insertions, 6 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 034b526af..239dd3a2d 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -2483,7 +2483,7 @@ void SurfaceD2D::MeasureWidthsUTF8(const Font *font_, std::string_view text, XYP
// Create a layout
IDWriteTextLayout *pTextLayout = nullptr;
const HRESULT hrCreate = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, 10000.0, 1000.0, &pTextLayout);
- if (!SUCCEEDED(hrCreate)) {
+ if (!SUCCEEDED(hrCreate) || !pTextLayout) {
return;
}
constexpr int clusters = stackBufferLength;
@@ -2496,14 +2496,14 @@ void SurfaceD2D::MeasureWidthsUTF8(const Font *font_, std::string_view text, XYP
}
// A cluster may be more than one WCHAR, such as for "ffi" which is a ligature in the Candara font
FLOAT position = 0.0f;
- size_t ti = 0;
- for (size_t ci = 0; ci < count; ci++) {
- for (size_t inCluster = 0; inCluster < clusterMetrics[ci].length; inCluster++) {
+ int ti = 0;
+ for (unsigned int ci = 0; ci < count; ci++) {
+ for (unsigned int inCluster = 0; inCluster < clusterMetrics[ci].length; inCluster++) {
poses.buffer[ti++] = position + clusterMetrics[ci].width * (inCluster + 1) / clusterMetrics[ci].length;
}
position += clusterMetrics[ci].width;
}
- PLATFORM_ASSERT(ti == static_cast<size_t>(tbuf.tlen));
+ PLATFORM_ASSERT(ti == tbuf.tlen);
// Map the widths given for UTF-16 characters back onto the UTF-8 input string
int ui = 0;
size_t i = 0;
@@ -2513,7 +2513,7 @@ void SurfaceD2D::MeasureWidthsUTF8(const Font *font_, std::string_view text, XYP
if (byteCount == 4) { // Non-BMP
ui++;
}
- for (unsigned int bytePos = 0; (bytePos < byteCount) && (i < text.length()); bytePos++) {
+ for (unsigned int bytePos=0; (bytePos<byteCount) && (i<text.length()); bytePos++) {
positions[i++] = poses.buffer[ui];
}
ui++;