mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Support 'antialias' with ATSUI renderer
This commit adds support for the 'antialias' option with the ATSUI renderer (the NSTextView renderer still uses System Preferences). The docs on 'antialias' have been updated. Some changes to the code used by Carbon Vim is affected by this commit. A feature flag FEAT_ANTIALIAS was added to support easy disabling of 'antialias' support. (Patch by Jjgod Jiang with some modifications by Bjorn Winckler.)
This commit is contained in:
committed by
Bjorn Winckler
parent
26349fc938
commit
4868c3cb85
@@ -1,4 +1,4 @@
|
||||
*gui_mac.txt* For Vim version 7.1. Last change: 2008 Feb 05
|
||||
*gui_mac.txt* For Vim version 7.1. Last change: 2008 Mar 16
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bjorn Winckler
|
||||
@@ -220,6 +220,7 @@ as general information regarding Mac OS X user defaults.
|
||||
Here is a list of relevant dictionary entries:
|
||||
|
||||
KEY VALUE ~
|
||||
MMAtsuiRenderer enable ATSUI renderer [bool]
|
||||
MMCellWidthMultiplier width of a normal glyph in em units [float]
|
||||
MMLoginShellArgument login shell parameter [string]
|
||||
MMLoginShellCommand which shell to use to launch Vim [string]
|
||||
|
||||
+15
-9
@@ -666,17 +666,23 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
Standard Annex #11 (http://www.unicode.org/reports/tr11).
|
||||
|
||||
*'antialias'* *'anti'* *'noantialias'* *'noanti'*
|
||||
'antialias' 'anti' boolean (default: off)
|
||||
'antialias' 'anti' boolean (default off, on for MacVim)
|
||||
global
|
||||
{not in Vi}
|
||||
{only available when compiled with Carbon GUI enabled
|
||||
on Mac OS X}
|
||||
This option only has an effect in the Carbon GUI version of Vim on Mac
|
||||
OS X v10.2 or later. When on, Vim will use smooth ("antialiased")
|
||||
fonts, which can be easier to read at certain sizes on certain
|
||||
displays. Setting this option can sometimes cause problems if
|
||||
'guifont' is set to its default (empty string).
|
||||
Note: Antialiasing is handled automatically on MacVim.
|
||||
{only available when compiled with GUI enabled on
|
||||
Mac OS X}
|
||||
This option only has an effect in the Carbon GUI version of Vim on Mac
|
||||
OS X v10.2 or later, and in MacVim when the ATSUI renderer is used.
|
||||
When on, Vim will use smooth ("antialiased") fonts, which can be
|
||||
easier to read at certain sizes on certain displays.
|
||||
|
||||
Setting this option in the Carbon version can sometimes cause problems
|
||||
if 'guifont' is set to its default (empty string).
|
||||
|
||||
The default renderer in MacVim uses the System Preferences to control
|
||||
antialiasing of text; this option is ignored. The ATSUI renderer on
|
||||
the other hand does use this option (and ignores the System
|
||||
Preferences setting).
|
||||
|
||||
*'autochdir'* *'acd'* *'noautochdir'* *'noacd'*
|
||||
'autochdir' 'acd' boolean (default off)
|
||||
|
||||
@@ -30,6 +30,7 @@ enum { MMMaxCellsPerChar = 2 };
|
||||
NSImage *contentImage;
|
||||
NSSize imageSize;
|
||||
ATSUStyle atsuStyles[MMMaxCellsPerChar];
|
||||
BOOL antialias;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame;
|
||||
@@ -57,6 +58,8 @@ enum { MMMaxCellsPerChar = 2 };
|
||||
- (void)setShouldDrawInsertionPoint:(BOOL)on;
|
||||
- (void)setPreEditRow:(int)row column:(int)col;
|
||||
- (void)hideMarkedTextField;
|
||||
- (void)setMouseShape:(int)shape;
|
||||
- (void)setAntialias:(BOOL)state;
|
||||
|
||||
//
|
||||
// NSTextView methods
|
||||
|
||||
@@ -108,6 +108,10 @@ enum {
|
||||
imageSize = NSZeroSize;
|
||||
insetSize = NSZeroSize;
|
||||
|
||||
// NOTE: If the default changes to 'NO' then the intialization of
|
||||
// p_antialias in option.c must change as well.
|
||||
antialias = YES;
|
||||
|
||||
[self initAtsuStyles];
|
||||
}
|
||||
|
||||
@@ -258,6 +262,15 @@ enum {
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setMouseShape:(int)shape
|
||||
{
|
||||
}
|
||||
|
||||
- (void)setAntialias:(BOOL)state
|
||||
{
|
||||
antialias = state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -918,6 +931,9 @@ enum {
|
||||
[contentImage unlockFocus];
|
||||
}
|
||||
|
||||
#define atsu_style_set_bool(s, t, b) \
|
||||
ATSUSetAttributes(s, 1, &t, &(sizeof(Boolean)), &&b);
|
||||
|
||||
- (void)drawString:(UniChar *)string length:(UniCharCount)length
|
||||
atRow:(int)row column:(int)col cells:(int)cells
|
||||
withFlags:(int)flags foregroundColor:(NSColor *)fg
|
||||
@@ -929,6 +945,26 @@ enum {
|
||||
ATSUStyle style = (flags & DRAW_WIDE) ? atsuStyles[1] : atsuStyles[0];
|
||||
ATSUTextLayout layout;
|
||||
|
||||
// Font selection and rendering options for ATSUI
|
||||
ATSUAttributeTag attribTags[3] = { kATSUQDBoldfaceTag,
|
||||
kATSUQDItalicTag,
|
||||
kATSUStyleRenderingOptionsTag };
|
||||
ByteCount attribSizes[] = { sizeof(Boolean),
|
||||
sizeof(Boolean),
|
||||
sizeof(UInt32) };
|
||||
Boolean useBold, useItalic;
|
||||
UInt32 useAntialias;
|
||||
ATSUAttributeValuePtr attribValues[3] = { &useBold, &useItalic,
|
||||
&useAntialias };
|
||||
|
||||
useBold = (flags & DRAW_BOLD) ? true : false;
|
||||
useItalic = (flags & DRAW_ITALIC) ? true : false;
|
||||
useAntialias = antialias ? kATSStyleApplyAntiAliasing
|
||||
: kATSStyleNoAntiAliasing;
|
||||
|
||||
ATSUSetAttributes(style, sizeof(attribValues) / sizeof(attribValues[0]),
|
||||
attribTags, attribSizes, attribValues);
|
||||
|
||||
// NSLog(@"drawString: %d", length);
|
||||
|
||||
ATSUCreateTextLayout(&layout);
|
||||
|
||||
@@ -115,6 +115,8 @@
|
||||
- (void)enterFullscreen;
|
||||
- (void)leaveFullscreen;
|
||||
|
||||
- (void)setAntialias:(BOOL)antialias;
|
||||
|
||||
- (void)updateModifiedFlag;
|
||||
|
||||
- (void)registerServerWithName:(NSString *)name;
|
||||
|
||||
@@ -1065,6 +1065,13 @@ static NSString *MMSymlinkWarningString =
|
||||
[self queueMessage:LeaveFullscreenMsgID data:nil];
|
||||
}
|
||||
|
||||
- (void)setAntialias:(BOOL)antialias
|
||||
{
|
||||
int msgid = antialias ? EnableAntialiasMsgID : DisableAntialiasMsgID;
|
||||
|
||||
[self queueMessage:msgid data:nil];
|
||||
}
|
||||
|
||||
- (void)updateModifiedFlag
|
||||
{
|
||||
// Notify MacVim if _any_ buffer has changed from unmodified to modified or
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
- (void)hideMarkedTextField;
|
||||
- (void)performBatchDrawWithData:(NSData *)data;
|
||||
- (void)setMouseShape:(int)shape;
|
||||
- (void)setAntialias:(BOOL)antialias;
|
||||
|
||||
//
|
||||
// MMTextStorage methods
|
||||
|
||||
@@ -334,6 +334,12 @@ enum {
|
||||
[self setCursor];
|
||||
}
|
||||
|
||||
- (void)setAntialias:(BOOL)antialias
|
||||
{
|
||||
// Antialiasing is handled by the System Preferences and there seems to be
|
||||
// no way to control antialiasing with NSTextView.
|
||||
}
|
||||
|
||||
- (NSFont *)font
|
||||
{
|
||||
return [(MMTextStorage*)[self textStorage] font];
|
||||
|
||||
@@ -889,6 +889,10 @@ static NSTimeInterval MMResendInterval = 0.5;
|
||||
const int *dim = (const int*)[data bytes];
|
||||
[[[windowController vimView] textView] setPreEditRow:dim[0]
|
||||
column:dim[1]];
|
||||
} else if (EnableAntialiasMsgID == msgid) {
|
||||
[[[windowController vimView] textView] setAntialias:YES];
|
||||
} else if (DisableAntialiasMsgID == msgid) {
|
||||
[[[windowController vimView] textView] setAntialias:NO];
|
||||
} else {
|
||||
NSLog(@"WARNING: Unknown message received (msgid=%d)", msgid);
|
||||
}
|
||||
|
||||
@@ -160,6 +160,8 @@ enum {
|
||||
ODBEditMsgID,
|
||||
XcodeModMsgID,
|
||||
LiveResizeMsgID,
|
||||
EnableAntialiasMsgID,
|
||||
DisableAntialiasMsgID,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ char *MessageStrings[] =
|
||||
"ODBEditMsgID",
|
||||
"XcodeModMsgID",
|
||||
"LiveResizeMsgID",
|
||||
"EnableAntialiasMsgID",
|
||||
"DisableAntialiasMsgID",
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1542,6 +1542,13 @@ gui_macvim_add_to_find_pboard(char_u *pat)
|
||||
[pb setString:s forType:NSStringPboardType];
|
||||
}
|
||||
|
||||
void
|
||||
gui_macvim_set_antialias(int antialias)
|
||||
{
|
||||
[[MMBackend sharedInstance] setAntialias:antialias];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1296,3 +1296,10 @@
|
||||
#ifdef FEAT_GUI_MACVIM
|
||||
#define FEAT_GUI_SCROLL_WHEEL_FORCE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Support for enabling/disabling antialiased text.
|
||||
*/
|
||||
#if defined(FEAT_GUI) && defined(MACOS_X)
|
||||
#define FEAT_ANTIALIAS
|
||||
#endif
|
||||
|
||||
+13
-4
@@ -478,14 +478,16 @@ static struct vimoption
|
||||
#endif
|
||||
(char_u *)0L}},
|
||||
{"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
|
||||
#if defined(FEAT_GUI) && defined(MACOS_X)
|
||||
#ifdef FEAT_ANTIALIAS
|
||||
(char_u *)&p_antialias, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)FALSE}
|
||||
#else
|
||||
(char_u *)NULL, PV_NONE,
|
||||
{(char_u *)FALSE, (char_u *)FALSE}
|
||||
#endif
|
||||
},
|
||||
#if FEAT_GUI_MACVIM
|
||||
{(char_u *)TRUE, (char_u *)0L}},
|
||||
#else
|
||||
{(char_u *)FALSE, (char_u *)0L}},
|
||||
#endif
|
||||
{"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM,
|
||||
#ifdef FEAT_ARABIC
|
||||
(char_u *)VAR_WIN, PV_ARAB,
|
||||
@@ -7308,6 +7310,13 @@ set_bool_option(opt_idx, varp, value, opt_flags)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_ANTIALIAS) && defined(FEAT_GUI_MACVIM)
|
||||
else if ((int *)varp == &p_antialias && gui.in_use)
|
||||
{
|
||||
gui_macvim_set_antialias(p_antialias);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* when 'textauto' is set or reset also change 'fileformats' */
|
||||
else if ((int *)varp == &p_ta)
|
||||
set_string_option_direct((char_u *)"ffs", -1,
|
||||
|
||||
+2
-2
@@ -309,8 +309,8 @@ EXTERN int p_acd; /* 'autochdir' */
|
||||
#ifdef FEAT_MBYTE
|
||||
EXTERN char_u *p_ambw; /* 'ambiwidth' */
|
||||
#endif
|
||||
#if defined(FEAT_GUI) && defined(MACOS_X)
|
||||
EXTERN int *p_antialias; /* 'antialias' */
|
||||
#ifdef FEAT_ANTIALIAS
|
||||
EXTERN int p_antialias; /* 'antialias' */
|
||||
#endif
|
||||
EXTERN int p_ar; /* 'autoread' */
|
||||
EXTERN int p_aw; /* 'autowrite' */
|
||||
|
||||
@@ -195,6 +195,7 @@ void gui_mch_leave_fullscreen(void);
|
||||
|
||||
void gui_macvim_update_modified_flag();
|
||||
void gui_macvim_add_to_find_pboard(char_u *pat);
|
||||
void gui_macvim_set_antialias(int antialias);
|
||||
|
||||
OSErr odb_buffer_close(buf_T *buf);
|
||||
OSErr odb_post_buffer_write(buf_T *buf);
|
||||
|
||||
Reference in New Issue
Block a user