aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/PlatWin.cxx7
1 files changed, 3 insertions, 4 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 79fccc22f..bf4f0503b 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -1614,17 +1614,16 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *
HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, 10000.0, 1000.0, &pTextLayout);
if (!SUCCEEDED(hr))
return;
- // For now, assuming WCHAR == cluster
if (!SUCCEEDED(pTextLayout->GetClusterMetrics(clusterMetrics, clusters, &count)))
return;
+ // 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++) {
- position += clusterMetrics[ci].width;
for (size_t inCluster=0; inCluster<clusterMetrics[ci].length; inCluster++) {
- //poses.buffer[ti++] = int(position + 0.5);
- poses.buffer[ti++] = position;
+ 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));
pTextLayout->Release();