aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/PlatWin.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2015-11-20 10:52:27 +1100
committerNeil <nyamatongwe@gmail.com>2015-11-20 10:52:27 +1100
commitad16ecb14a085d950b6a243b02267a0eca50f5c9 (patch)
tree716d509d76ed477dfc12eac8a767507699d93d64 /win32/PlatWin.cxx
parent393a48b469af457392d4120b2d4351c345c4486c (diff)
downloadscintilla-mirror-ad16ecb14a085d950b6a243b02267a0eca50f5c9.tar.gz
Using DirectWrite, for ligatures and other character clusters, display caret and
selections part-way through clusters so that the caret doesn't stick to the end of the cluster making it easier to understand editing actions.
Diffstat (limited to 'win32/PlatWin.cxx')
-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();