From eec7910d545a1885d3b9a3303c8523b854ea5f6f Mon Sep 17 00:00:00 2001 From: ichizok Date: Mon, 25 Jun 2018 19:18:56 +0900 Subject: [PATCH] Fix fetchGlyphsAndAdvances() in CoreText renderer --- src/MacVim/MMCoreTextView.m | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index a85a043a32..fa4156574b 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -1203,21 +1203,23 @@ fetchGlyphsAndAdvances(const CTLineRef line, CGGlyph *glyphs, CGSize *advances, CTRunRef run = (CTRunRef)item; CFIndex count = CTRunGetGlyphCount(run); - if (count > 0 && count - offset > length) - count = length - offset; + if (count > 0) { + if (count > length - offset) + count = length - offset; - CFRange range = CFRangeMake(0, count); + CFRange range = CFRangeMake(0, count); - if (glyphs != NULL) - CTRunGetGlyphs(run, range, &glyphs[offset]); - if (advances != NULL) - CTRunGetAdvances(run, range, &advances[offset]); - if (positions != NULL) - CTRunGetPositions(run, range, &positions[offset]); + if (glyphs != NULL) + CTRunGetGlyphs(run, range, &glyphs[offset]); + if (advances != NULL) + CTRunGetAdvances(run, range, &advances[offset]); + if (positions != NULL) + CTRunGetPositions(run, range, &positions[offset]); - offset += count; - if (offset >= length) - break; + offset += count; + if (offset >= length) + break; + } } return offset;