Change the line-up of substitute charaters for full-width spaces (close #260)

This commit is contained in:
1024jp 2014-11-07 16:34:23 +01:00
parent c47b664cd9
commit f7b4dd0b90
3 changed files with 8 additions and 7 deletions

View File

@ -9,6 +9,7 @@ changelog
- “Apache” シンタックス定義の更新
- アウトラインをインデントで階層化
- [beta] 全角空白の不可視文字代替文字を一部変更
- [beta] 書類タイプに public.text を追加
- [rc] ほか、見た目の微調整

View File

@ -221,10 +221,10 @@ static BOOL usesTextFontForInvisibles;
CGContextConcatCTM(context, transform);
// prepare glyphs
CGPathRef spaceGlyphPath = glyphPathWithCharacter([self spaceChar], font);
CGPathRef tabGlyphPath = glyphPathWithCharacter([self tabChar], font);
CGPathRef newLineGlyphPath = glyphPathWithCharacter([self newLineChar], font);
CGPathRef fullWidthSpaceGlyphPath = glyphPathWithCharacter([self fullwidthSpaceChar], font);
CGPathRef spaceGlyphPath = glyphPathWithCharacter([self spaceChar], font, false);
CGPathRef tabGlyphPath = glyphPathWithCharacter([self tabChar], font, false);
CGPathRef newLineGlyphPath = glyphPathWithCharacter([self newLineChar], font, false);
CGPathRef fullWidthSpaceGlyphPath = glyphPathWithCharacter([self fullwidthSpaceChar], font, true);
// store value to avoid accessing properties each time (2014-07 by 1024jp)
BOOL showsSpace = [self showsSpace];
@ -403,7 +403,7 @@ static BOOL usesTextFontForInvisibles;
//------------------------------------------------------
///
CGPathRef glyphPathWithCharacter(unichar character, CTFontRef font)
CGPathRef glyphPathWithCharacter(unichar character, CTFontRef font, bool prefersFullWidth)
//------------------------------------------------------
{
CGFloat fontSize = CTFontGetSize(font);
@ -418,7 +418,7 @@ CGPathRef glyphPathWithCharacter(unichar character, CTFontRef font)
// try fallback fonts in cases where user font doesn't support the input charactor
// - All invisible characters of choices can be covered with the following two fonts.
CGPathRef path = NULL;
NSArray *fallbackFontNames = @[@"LucidaGrande", @"HiraKakuProN-W3"];
NSArray *fallbackFontNames = prefersFullWidth ? @[@"HiraKakuProN-W3", @"LucidaGrande"] : @[@"LucidaGrande", @"HiraKakuProN-W3"];
for (NSString *fontName in fallbackFontNames) {
CTFontRef fallbackFont = CTFontCreateWithName((CFStringRef)fontName, fontSize, 0);

View File

@ -489,7 +489,7 @@ NSUInteger const kSizeOfInvisibleTabCharList = sizeof(kInvisibleTabCharList) /
unichar const kInvisibleNewLineCharList[] = {0x00B6, 0x21A9, 0x21B5, 0x23CE};
NSUInteger const kSizeOfInvisibleNewLineCharList = sizeof(kInvisibleNewLineCharList) / sizeof(unichar);
unichar const kInvisibleFullwidthSpaceCharList[] = {0x25A2, 0x22A0, 0x25B3, 0x2573};
unichar const kInvisibleFullwidthSpaceCharList[] = {0x25A1, 0x22A0, 0x25A0, 0x25B3};
NSUInteger const kSizeOfInvisibleFullwidthSpaceCharList = sizeof(kInvisibleFullwidthSpaceCharList) / sizeof(unichar);