Revert "Fix column count issues with certain ligature." (#4558)

Reopens #696.
Closes #4375.
This reverts commit 027f1228cb.
This commit is contained in:
Dustin L. Howett (MSFT) 2020-02-12 15:54:25 -08:00 committed by GitHub
parent 9385a83811
commit 04955a4395
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -404,30 +404,8 @@ CustomTextLayout::CustomTextLayout(gsl::not_null<IDWriteFactory1*> const factory
// Offsets is how far to move the origin (in pixels) from where it is
auto& offset = _glyphOffsets.at(i);
// Get how many columns we expected the glyph to have and multiply into pixels.
UINT16 columns = 0;
{
// Because of typographic features such as ligatures, it is well possible for a glyph to represent
// multiple code points. Previous calls to IDWriteTextAnalyzer::GetGlyphs stores the mapping
// information between code points and glyphs in _glyphClusters.
// To properly allocate the columns for such glyphs, we need to find all characters that this glyph
// is representing and add column counts for all the characters together.
// Find the range for current glyph run in _glyphClusters.
const auto runStartIterator = _glyphClusters.begin() + run.textStart;
const auto runEndIterator = _glyphClusters.begin() + run.textStart + run.textLength;
// Find the range of characters that the current glyph is representing.
const auto firstIterator = std::find(runStartIterator, runEndIterator, i - run.glyphStart);
const auto lastIterator = std::find(runStartIterator, runEndIterator, i - run.glyphStart + 1);
// Add all allocated column counts together.
for (auto j = firstIterator; j < lastIterator; j++)
{
const auto charIndex = std::distance(_glyphClusters.begin(), j);
columns += _textClusterColumns.at(charIndex);
}
}
// Get how many columns we expected the glyph to have and mutiply into pixels.
const auto columns = _textClusterColumns.at(i);
const auto advanceExpected = static_cast<float>(columns * _width);
// If what we expect is bigger than what we have... pad it out.