1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-01 01:32:04 +03:00

Merge remote-tracking branch 'origin/develop' into update-neovim

This commit is contained in:
Tae Won Ha 2018-07-20 12:52:42 +02:00
commit b7aff4e0fd
10 changed files with 124 additions and 84 deletions

View File

@ -470,7 +470,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 287; CURRENT_PROJECT_VERSION = 288;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@ -530,7 +530,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 287; CURRENT_PROJECT_VERSION = 288;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -557,7 +557,7 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 287; DYLIB_CURRENT_VERSION = 288;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac"; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;
@ -579,7 +579,7 @@
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 287; DYLIB_CURRENT_VERSION = 288;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac"; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
FRAMEWORK_VERSION = A; FRAMEWORK_VERSION = A;

View File

@ -15,9 +15,9 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>SNAPSHOT-287</string> <string>SNAPSHOT-288</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>287</string> <string>288</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Tae Won Ha. All rights reserved.</string> <string>Copyright © 2017 Tae Won Ha. All rights reserved.</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>

View File

@ -3,12 +3,9 @@
void recurseDraw( void recurseDraw(
const unichar *chars, const unichar *chars,
CGGlyph *glyphs, CGGlyph *glyphs, CGPoint *positions, UniCharCount length,
CGPoint *positions,
UniCharCount length,
CGContextRef context, CGContextRef context,
CTFontRef fontRef, CTFontRef fontRef,
NSMutableArray *fontCache, NSMutableArray *fontCache,
BOOL isComposing,
BOOL useLigatures BOOL useLigatures
); );

View File

@ -9,7 +9,7 @@
*/ */
/** /**
* Extracted from 351faf929e4abe32ea4cc31078d1a625fc86a69f of MacVim, 2018-07-03 * Extracted from snapshot-146 of MacVim
* https://github.com/macvim-dev/macvim * https://github.com/macvim-dev/macvim
* See VIM.LICENSE * See VIM.LICENSE
*/ */
@ -20,9 +20,7 @@
#import "MMCoreTextView.h" #import "MMCoreTextView.h"
// @formatter:off static CTFontRef
static CTFontRef
lookupFont(NSMutableArray *fontCache, const unichar *chars, UniCharCount count, lookupFont(NSMutableArray *fontCache, const unichar *chars, UniCharCount count,
CTFontRef currFontRef) CTFontRef currFontRef)
{ {
@ -58,20 +56,15 @@ lookupFont(NSMutableArray *fontCache, const unichar *chars, UniCharCount count,
attributedStringForString(NSString *string, const CTFontRef font, attributedStringForString(NSString *string, const CTFontRef font,
BOOL useLigatures) BOOL useLigatures)
{ {
NSDictionary *attrs = nil; NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
if (useLigatures) { (id)font, kCTFontAttributeName,
attrs = [NSDictionary dictionaryWithObjectsAndKeys: // 2 - full ligatures including rare
(id)font, kCTFontAttributeName, // 1 - basic ligatures
// 2 - full ligatures including rare // 0 - no ligatures
// 1 - basic ligatures [NSNumber numberWithInteger:(useLigatures ? 1 : 0)],
// 0 - only ligatures essential for proper rendering of text kCTLigatureAttributeName,
// this option seems to render ligatures for some nil
// monospace fonts with ligatures, eg Iosevka, ... ];
[NSNumber numberWithInt:1],
kCTLigatureAttributeName,
nil
];
}
return CFAttributedStringCreate(NULL, (CFStringRef)string, return CFAttributedStringCreate(NULL, (CFStringRef)string,
(CFDictionaryRef)attrs); (CFDictionaryRef)attrs);
@ -79,7 +72,7 @@ attributedStringForString(NSString *string, const CTFontRef font,
static UniCharCount static UniCharCount
fetchGlyphsAndAdvances(const CTLineRef line, CGGlyph *glyphs, CGSize *advances, fetchGlyphsAndAdvances(const CTLineRef line, CGGlyph *glyphs, CGSize *advances,
CGPoint *positions, UniCharCount length) UniCharCount length)
{ {
NSArray *glyphRuns = (NSArray*)CTLineGetGlyphRuns(line); NSArray *glyphRuns = (NSArray*)CTLineGetGlyphRuns(line);
@ -89,23 +82,19 @@ fetchGlyphsAndAdvances(const CTLineRef line, CGGlyph *glyphs, CGSize *advances,
CTRunRef run = (CTRunRef)item; CTRunRef run = (CTRunRef)item;
CFIndex count = CTRunGetGlyphCount(run); CFIndex count = CTRunGetGlyphCount(run);
if (count > 0) { if (count > 0 && count - offset > length)
if (count > length - offset) count = length - offset;
count = length - offset;
CFRange range = CFRangeMake(0, count); CFRange range = CFRangeMake(0, count);
if (glyphs != NULL) if (glyphs != NULL)
CTRunGetGlyphs(run, range, &glyphs[offset]); CTRunGetGlyphs(run, range, &glyphs[offset]);
if (advances != NULL) if (advances != NULL)
CTRunGetAdvances(run, range, &advances[offset]); CTRunGetAdvances(run, range, &advances[offset]);
if (positions != NULL)
CTRunGetPositions(run, range, &positions[offset]);
offset += count; offset += count;
if (offset >= length) if (offset >= length)
break; break;
}
} }
return offset; return offset;
@ -128,28 +117,78 @@ gatherGlyphs(CGGlyph glyphs[], UniCharCount count)
} }
static UniCharCount static UniCharCount
composeGlyphsForChars(const unichar *chars, CGGlyph *glyphs, ligatureGlyphsForChars(const unichar *chars, CGGlyph *glyphs,
CGPoint *positions, UniCharCount length, CTFontRef font, CGPoint *positions, UniCharCount length, CTFontRef font)
BOOL isComposing, BOOL useLigatures)
{ {
// CoreText has no simple wait of retrieving a ligature for a set of
// UniChars. The way proposed on the CoreText ML is to convert the text to
// an attributed string, create a CTLine from it and retrieve the Glyphs
// from the CTRuns in it.
CGGlyph refGlyphs[length];
CGPoint refPositions[length];
memcpy(refGlyphs, glyphs, sizeof(CGGlyph) * length);
memcpy(refPositions, positions, sizeof(CGSize) * length);
memset(glyphs, 0, sizeof(CGGlyph) * length); memset(glyphs, 0, sizeof(CGGlyph) * length);
NSString *plainText = [NSString stringWithCharacters:chars length:length]; NSString *plainText = [NSString stringWithCharacters:chars length:length];
CFAttributedStringRef composedText = attributedStringForString(plainText, CFAttributedStringRef ligatureText = attributedStringForString(plainText,
font, font, YES);
useLigatures);
CTLineRef line = CTLineCreateWithAttributedString(composedText); CTLineRef ligature = CTLineCreateWithAttributedString(ligatureText);
// get the (composing)glyphs and advances for the new text CGSize ligatureRanges[length], regularRanges[length];
UniCharCount offset = fetchGlyphsAndAdvances(line, glyphs, NULL,
isComposing ? positions : NULL,
length);
CFRelease(composedText); // get the (ligature)glyphs and advances for the new text
CFRelease(line); UniCharCount offset = fetchGlyphsAndAdvances(ligature, glyphs,
ligatureRanges, length);
// fetch the advances for the base text
CTFontGetAdvancesForGlyphs(font, kCTFontOrientationDefault, refGlyphs,
regularRanges, length);
// as ligatures composing characters it is required to adjust the CFRelease(ligatureText);
CFRelease(ligature);
// tricky part: compare both advance ranges and chomp positions which are
// covered by a single ligature while keeping glyphs not in the ligature
// font.
#define fequal(a, b) (fabs((a) - (b)) < FLT_EPSILON)
#define fless(a, b)((a) - (b) < FLT_EPSILON) && (fabs((a) - (b)) > FLT_EPSILON)
CFIndex skip = 0;
CFIndex i;
for (i = 0; i < offset && skip + i < length; ++i) {
memcpy(&positions[i], &refPositions[skip + i], sizeof(CGSize));
if (fequal(ligatureRanges[i].width, regularRanges[skip + i].width)) {
// [mostly] same width
continue;
} else if (fless(ligatureRanges[i].width,
regularRanges[skip + i].width)) {
// original is wider than our result - use the original glyph
// FIXME: this is currently the only way to detect emoji (except
// for 'glyph[i] == 5')
glyphs[i] = refGlyphs[skip + i];
continue;
}
// no, that's a ligature
// count how many positions this glyph would take up in the base text
CFIndex j = 0;
float width = ceil(regularRanges[skip + i].width);
while ((int)width < (int)ligatureRanges[i].width
&& skip + i + j < length) {
width += ceil(regularRanges[++j + skip + i].width);
}
skip += j;
}
#undef fless
#undef fequal
// as ligatures combine characters it is required to adjust the
// original length value // original length value
return offset; return offset;
} }
@ -157,12 +196,18 @@ composeGlyphsForChars(const unichar *chars, CGGlyph *glyphs,
void void
recurseDraw(const unichar *chars, CGGlyph *glyphs, CGPoint *positions, recurseDraw(const unichar *chars, CGGlyph *glyphs, CGPoint *positions,
UniCharCount length, CGContextRef context, CTFontRef fontRef, UniCharCount length, CGContextRef context, CTFontRef fontRef,
NSMutableArray *fontCache, BOOL isComposing, BOOL useLigatures) NSMutableArray *fontCache, BOOL useLigatures)
{ {
if (CTFontGetGlyphsForCharacters(fontRef, chars, glyphs, length)) { if (CTFontGetGlyphsForCharacters(fontRef, chars, glyphs, length)) {
// All chars were mapped to glyphs, so draw all at once and return. // All chars were mapped to glyphs, so draw all at once and return.
length = composeGlyphsForChars(chars, glyphs, positions, length, if (useLigatures) {
fontRef, isComposing, useLigatures); length = ligatureGlyphsForChars(chars, glyphs, positions, length,
fontRef);
} else {
// only fixup surrogate pairs if we're not using ligatures
length = gatherGlyphs(glyphs, length);
}
CTFontDrawGlyphs(fontRef, glyphs, positions, length, context); CTFontDrawGlyphs(fontRef, glyphs, positions, length, context);
return; return;
} }
@ -223,7 +268,7 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGPoint *positions,
return; return;
recurseDraw(chars, glyphs, positions, attemptedCount, context, recurseDraw(chars, glyphs, positions, attemptedCount, context,
fallback, fontCache, isComposing, useLigatures); fallback, fontCache, useLigatures);
// If only a portion of the invalid range was rendered above, // If only a portion of the invalid range was rendered above,
// the remaining range needs to be attempted by subsequent // the remaining range needs to be attempted by subsequent
@ -247,6 +292,4 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGPoint *positions,
} }
} }
// @formatter:on
#pragma clang diagnostic pop #pragma clang diagnostic pop

View File

@ -192,7 +192,7 @@ static CGColorRef color_for(NSInteger value) {
const UniChar *bEnd = unichars + unilength; const UniChar *bEnd = unichars + unilength;
UniCharCount choppedLength; UniCharCount choppedLength;
bool wide; bool wide;
bool pWide = false; bool pWide = NO;
while (b < bEnd) { while (b < bEnd) {
wide = CFStringIsSurrogateHighCharacter(*b) || CFStringIsSurrogateLowCharacter(*b); wide = CFStringIsSurrogateHighCharacter(*b) || CFStringIsSurrogateLowCharacter(*b);
@ -200,8 +200,7 @@ static CGColorRef color_for(NSInteger value) {
choppedLength = b - bStart; choppedLength = b - bStart;
// NSString *logged = [NSString stringWithCharacters:bStart length:choppedLength]; // NSString *logged = [NSString stringWithCharacters:bStart length:choppedLength];
// NSLog(@"C(%d,%p..%p)[%@]", pWide, bStart, b, logged); // NSLog(@"C(%d,%p..%p)[%@]", pWide, bStart, b, logged);
// We use isComposing = false to retain the old behavior of Macvim's recurseDraw recurseDraw(bStart, glyphs, p, choppedLength, context, fontWithTraits, _fontLookupCache, _usesLigatures);
recurseDraw(bStart, glyphs, p, choppedLength, context, fontWithTraits, _fontLookupCache, false, _usesLigatures);
UniCharCount step = pWide ? choppedLength / 2 : choppedLength; UniCharCount step = pWide ? choppedLength / 2 : choppedLength;
p += step; p += step;
g += step; g += step;
@ -215,8 +214,7 @@ static CGColorRef color_for(NSInteger value) {
choppedLength = b - bStart; choppedLength = b - bStart;
// NSString *logged = [NSString stringWithCharacters:bStart length:choppedLength]; // NSString *logged = [NSString stringWithCharacters:bStart length:choppedLength];
// NSLog(@"T(%d,%p..%p)[%@]", pWide, bStart, b, logged); // NSLog(@"T(%d,%p..%p)[%@]", pWide, bStart, b, logged);
// We use isComposing = false to retain the old behavior of Macvim's recurseDraw recurseDraw(bStart, glyphs, p, choppedLength, context, fontWithTraits, _fontLookupCache, _usesLigatures);
recurseDraw(bStart, glyphs, p, choppedLength, context, fontWithTraits, _fontLookupCache, false, _usesLigatures);
} }
// NSLog(@"S(-,%p..%p)[%@]", unichars, unichars + unilength, string); // NSLog(@"S(-,%p..%p)[%@]", unichars, unichars + unilength, string);

View File

@ -1234,7 +1234,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 287; CURRENT_PROJECT_VERSION = 288;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
@ -1291,7 +1291,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 287; CURRENT_PROJECT_VERSION = 288;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO; ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;

View File

@ -1224,7 +1224,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>SNAPSHOT-287</string> <string>SNAPSHOT-288</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
@ -1241,7 +1241,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>287</string> <string>288</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string> <string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>BNDL</string> <string>BNDL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>SNAPSHOT-287</string> <string>SNAPSHOT-288</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>287</string> <string>288</string>
</dict> </dict>
</plist> </plist>

View File

@ -7,22 +7,25 @@
<description>Most recent changes with links to updates for VimR.</description> <description>Most recent changes with links to updates for VimR.</description>
<language>en</language> <language>en</language>
<item> <item>
<title>SNAPSHOT-287</title> <title>SNAPSHOT-288</title>
<description><![CDATA[ <description><![CDATA[
<ul> <ul>
<li>GH-659: Bugfix (introduced in a snapshot): Turning off ligatures does not really turn off ligatures.</li> <li>GH-659: Bugfix (introduced in a snapshot): Turning off ligatures does not really turn off ligatures.<ul>
<li>Reverts the update on <code>MMCoreTextView</code>.</li>
</ul>
</li>
</ul> </ul>
]]></description> ]]></description>
<releaseNotesLink> <releaseNotesLink>
https://github.com/qvacua/vimr/releases/tag/snapshot/287 https://github.com/qvacua/vimr/releases/tag/snapshot/288
</releaseNotesLink> </releaseNotesLink>
<pubDate>2018-07-17T21:47:39.216538</pubDate> <pubDate>2018-07-18T17:04:18.666713</pubDate>
<minimumSystemVersion>10.10.0</minimumSystemVersion> <minimumSystemVersion>10.10.0</minimumSystemVersion>
<enclosure url="https://github.com/qvacua/vimr/releases/download/snapshot/287/VimR-SNAPSHOT-287.tar.bz2" <enclosure url="https://github.com/qvacua/vimr/releases/download/snapshot/288/VimR-SNAPSHOT-288.tar.bz2"
sparkle:version="287" sparkle:version="288"
sparkle:shortVersionString="SNAPSHOT-287" sparkle:shortVersionString="SNAPSHOT-288"
sparkle:dsaSignature="MC0CFGi/fu6NGA0bTq01XuJ+GPpxsXMRAhUAsXwgPZMd+W5+SQJi3JjpozhsTGg=" sparkle:dsaSignature="MC0CFQCguDVWFXfF+veCN6Jy3yBHG4mWcAIUfVWgbmGW/18UxNaFRerRjukfsKE="
length="14807057" length="14806420"
type="application/octet-stream"/> type="application/octet-stream"/>
</item> </item>
</channel> </channel>

View File

@ -7,7 +7,6 @@
* Dependencies updates: * Dependencies updates:
- ReactiveX/RxSwift@4.2.0 - ReactiveX/RxSwift@4.2.0
- httpswift/swifter@1.4.2 - httpswift/swifter@1.4.2
- `MMCoreTextView` of MacVim: macvim-dev/macvim@351faf929e4abe32ea4cc31078d1a625fc86a69f
# 0.24.0-282 # 0.24.0-282