Skip to content

Commit

Permalink
AtlasEngine: Fix support for combining diacritics
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed Feb 1, 2022
1 parent 469202f commit d288ff4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/renderer/atlas/AtlasEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,37 @@ void AtlasEngine::_flushBufferLine()
break;
}

if (_api.glyphAdvances.size() < actualGlyphCount)
{
// Grow the buffer by at least 1.5x and at least of `actualGlyphCount` items.
// The 1.5x growth ensures we don't reallocate every time we need 1 more slot.
auto size = _api.glyphAdvances.size();
size = size + (size >> 1);
size = std::max<size_t>(size, actualGlyphCount);
_api.glyphAdvances = Buffer<f32>{ size };
_api.glyphOffsets = Buffer<DWRITE_GLYPH_OFFSET>{ size };
}

THROW_IF_FAILED(_sr.textAnalyzer->GetGlyphPlacements(
/* textString */ _api.bufferLine.data() + a.textPosition,
/* clusterMap */ _api.clusterMap.data(),
/* textProps */ _api.textProps.data(),
/* textLength */ a.textLength,
/* glyphIndices */ _api.glyphIndices.data(),
/* glyphProps */ _api.glyphProps.data(),
/* glyphCount */ actualGlyphCount,
/* fontFace */ mappedFontFace.get(),
/* fontEmSize */ _api.fontMetrics.fontSizeInDIP,
/* isSideways */ false,
/* isRightToLeft */ a.bidiLevel & 1,
/* scriptAnalysis */ &scriptAnalysis,
/* localeName */ nullptr,
/* features */ &features,
/* featureRangeLengths */ &featureRangeLengths,
/* featureRanges */ featureRanges,
/* glyphAdvances */ _api.glyphAdvances.data(),
/* glyphOffsets */ _api.glyphOffsets.data()));

_api.textProps[a.textLength - 1].canBreakShapingAfter = 1;

size_t beg = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/atlas/AtlasEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ namespace Microsoft::Console::Render
Buffer<DWRITE_SHAPING_TEXT_PROPERTIES> textProps;
Buffer<u16> glyphIndices;
Buffer<DWRITE_SHAPING_GLYPH_PROPERTIES> glyphProps;
Buffer<f32> glyphAdvances;
Buffer<DWRITE_GLYPH_OFFSET> glyphOffsets;
std::vector<DWRITE_FONT_FEATURE> fontFeatures; // changes are flagged as ApiInvalidations::Font|Size
std::vector<DWRITE_FONT_AXIS_VALUE> fontAxisValues; // changes are flagged as ApiInvalidations::Font|Size
FontMetrics fontMetrics; // changes are flagged as ApiInvalidations::Font|Size
Expand Down

0 comments on commit d288ff4

Please sign in to comment.