Skip to content

Commit 6df9411

Browse files
authored
Merge pull request #343 from mgee/add-thinstrokes-option
Add macthinstrokes option
2 parents 33f0aed + e226fb8 commit 6df9411

18 files changed

Lines changed: 78 additions & 2 deletions

runtime/doc/gui_mac.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ to your .gvimrc file to revert back to the default Vim tab label.
111111
*macvim-options*
112112
These are the non-standard options that MacVim supports:
113113
'antialias' 'blurradius' 'fullscreen'
114-
'fuoptions' 'macligatures' 'macmeta' 'toolbariconsize'
115-
'transparency'
114+
'fuoptions' 'macligatures' 'macmeta' 'macthinstrokes'
115+
'toolbariconsize' 'transparency'
116116

117117
*macvim-commands*
118118
These are the non-standard commands that MacVim supports:

runtime/doc/options.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5043,6 +5043,18 @@ A jump table for the options with a short description can be found at |Q_op|.
50435043
'guifont' supports them. Examples for such fonts are Fira Code or
50445044
Haskelig.
50455045
Note: Currently this option only has an effect if
5046+
'Use Core Text renderer' is enabled in the GUI preferences pane.
5047+
5048+
*'macthinstrokes'* *'nomacthinstrokes'*
5049+
'macthinstrokes' boolean (default off)
5050+
global
5051+
{not in Vi}
5052+
{only available when compiled with GUI enabled on
5053+
Mac OS X}
5054+
This option only has an effect in the GUI version of Vim on Mac OS X
5055+
v10.8 or later. When on, Vim will render the text a little lighter
5056+
which looks nice with a dark colorscheme.
5057+
Note: Currently this option only has an effect if
50465058
'Use Core Text renderer' is enabled in the GUI preferences pane.
50475059

50485060
*'macmeta'* *'mmta'* *'nomacmeta'* *'nommta'*

runtime/doc/quickref.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ Short explanation of each option: *option-list*
785785
'macatsui' Mac GUI: use ATSUI text drawing
786786
'macligatures' display ligatures (MacVim GUI only)
787787
'macmeta' 'mmta' use option as meta key (MacVim GUI only)
788+
'macthinstrokes' render the text lighter by using thin strokes (MacVim GUI only)
788789
'magic' changes special characters in search patterns
789790
'makeef' 'mef' name of the errorfile for ":make"
790791
'makeprg' 'mp' program to use for the ":make" command

runtime/doc/tags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
433433
'macatsui' options.txt /*'macatsui'*
434434
'macligatures' options.txt /*'macligatures'*
435435
'macmeta' options.txt /*'macmeta'*
436+
'macthinstrokes' options.txt /*'macthinstrokes'*
436437
'magic' options.txt /*'magic'*
437438
'makeef' options.txt /*'makeef'*
438439
'makeprg' options.txt /*'makeprg'*
@@ -614,6 +615,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
614615
'nomacatsui' options.txt /*'nomacatsui'*
615616
'nomacligatures' options.txt /*'nomacligatures'*
616617
'nomacmeta' options.txt /*'nomacmeta'*
618+
'nomacthinstrokes' options.txt /*'nomacthinstrokes'*
617619
'nomagic' options.txt /*'nomagic'*
618620
'nomh' options.txt /*'nomh'*
619621
'noml' options.txt /*'noml'*

runtime/optwin.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,8 @@ if has("gui")
665665
call <SID>BinOptionG("macligatures", &macligatures)
666666
call append("$", "macmeta\tuse option as meta key")
667667
call append("$", "\t(local to buffer)")
668+
call append("$", "macthinstrokes\tuse thin strokes")
669+
call <SID>BinOptionG("macthinstrokes", &macthinstrokes)
668670
call <SID>BinOptionL("mmta")
669671
endif
670672
endif

src/MacVim/MMBackend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ extern NSTimeInterval MMBalloonEvalInternalDelay;
135135

136136
- (void)setAntialias:(BOOL)antialias;
137137
- (void)setLigatures:(BOOL)ligatures;
138+
- (void)setThinStrokes:(BOOL)thinStrokes;
138139
- (void)setBlurRadius:(int)radius;
139140

140141
- (void)updateModifiedFlag;

src/MacVim/MMBackend.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,13 @@ - (void)setLigatures:(BOOL)ligatures
11831183
[self queueMessage:msgid data:nil];
11841184
}
11851185

1186+
- (void)setThinStrokes:(BOOL)thinStrokes
1187+
{
1188+
int msgid = thinStrokes ? EnableThinStrokesMsgID : DisableThinStrokesMsgID;
1189+
1190+
[self queueMessage:msgid data:nil];
1191+
}
1192+
11861193
- (void)setBlurRadius:(int)radius
11871194
{
11881195
NSMutableData *data = [NSMutableData data];

src/MacVim/MMCoreTextView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
float fontDescent;
3030
BOOL antialias;
3131
BOOL ligatures;
32+
BOOL thinStrokes;
3233
NSMutableArray *drawData;
3334

3435
MMTextViewHelper *helper;
@@ -77,6 +78,7 @@
7778
- (void)setMouseShape:(int)shape;
7879
- (void)setAntialias:(BOOL)state;
7980
- (void)setLigatures:(BOOL)state;
81+
- (void)setThinStrokes:(BOOL)state;
8082
- (void)setImControl:(BOOL)enable;
8183
- (void)activateIm:(BOOL)enable;
8284
- (void)checkImState;

src/MacVim/MMCoreTextView.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#define kCTFontOrientationDefault kCTFontDefaultOrientation
4949
#endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
5050

51+
extern void CGContextSetFontSmoothingStyle(CGContextRef, int);
52+
extern int CGContextGetFontSmoothingStyle(CGContextRef);
53+
#define fontSmoothingStyleLight (2 << 3)
54+
5155
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
5256
static void
5357
CTFontDrawGlyphs(CTFontRef fontRef, const CGGlyph glyphs[],
@@ -396,6 +400,11 @@ - (void)setLigatures:(BOOL)state
396400
ligatures = state;
397401
}
398402

403+
- (void)setThinStrokes:(BOOL)state
404+
{
405+
thinStrokes = state;
406+
}
407+
399408
- (void)setImControl:(BOOL)enable
400409
{
401410
[helper setImControl:enable];
@@ -1299,6 +1308,13 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
12991308

13001309
CGContextSaveGState(context);
13011310

1311+
int originalFontSmoothingStyle = 0;
1312+
if (thinStrokes) {
1313+
CGContextSetShouldSmoothFonts(context, YES);
1314+
originalFontSmoothingStyle = CGContextGetFontSmoothingStyle(context);
1315+
CGContextSetFontSmoothingStyle(context, fontSmoothingStyleLight);
1316+
}
1317+
13021318
// NOTE! 'cells' is zero if we're drawing a composing character
13031319
CGFloat clipWidth = cells > 0 ? cells*cellSize.width : w;
13041320
CGRect clipRect = { {x, y}, {clipWidth, cellSize.height} };
@@ -1389,6 +1405,8 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
13891405
recurseDraw(chars, glyphs, positions, length, context, fontRef, fontCache, ligatures);
13901406

13911407
CFRelease(fontRef);
1408+
if (thinStrokes)
1409+
CGContextSetFontSmoothingStyle(context, originalFontSmoothingStyle);
13921410
CGContextRestoreGState(context);
13931411
}
13941412

src/MacVim/MMTextView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
int insertionPointFraction;
2222
BOOL antialias;
2323
BOOL ligatures;
24+
BOOL thinStrokes;
2425
NSRect *invertRects;
2526
int numInvertRects;
2627

@@ -34,6 +35,7 @@
3435
- (void)setMouseShape:(int)shape;
3536
- (void)setAntialias:(BOOL)antialias;
3637
- (void)setLigatures:(BOOL)ligatures;
38+
- (void)setThinStrokes:(BOOL)thinStrokes;
3739
- (void)setImControl:(BOOL)enable;
3840
- (void)activateIm:(BOOL)enable;
3941
- (void)checkImState;

0 commit comments

Comments
 (0)