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 | 28c1e186b953ae0c8fe7681c7d7ae8950efb266f (patch) | |
tree | 87f2c618c45ba4a80bb051e614a5ee416eddd51b | |
parent | 1f9bc0d42bc53fd04cc848da1da52635dcf7a2c0 (diff) | |
download | scintilla-mirror-28c1e186b953ae0c8fe7681c7d7ae8950efb266f.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(); |