diff options
author | Neil <nyamatongwe@gmail.com> | 2015-11-20 10:52:27 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2015-11-20 10:52:27 +1100 |
commit | ad16ecb14a085d950b6a243b02267a0eca50f5c9 (patch) | |
tree | 716d509d76ed477dfc12eac8a767507699d93d64 | |
parent | 393a48b469af457392d4120b2d4351c345c4486c (diff) | |
download | scintilla-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.
-rw-r--r-- | doc/ScintillaHistory.html | 5 | ||||
-rw-r--r-- | win32/PlatWin.cxx | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 1c7943845..b7e20b12f 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -513,6 +513,11 @@ <a href="http://sourceforge.net/p/scintilla/bugs/1779/">Bug #1779</a>. </li> <li> + On Windows 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. + </li> + <li> On GTK+ on OS X, fix warning during destruction. <a href="http://sourceforge.net/p/scintilla/bugs/1777/">Bug #1777</a>. </li> 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(); |