Skip to content

Commit

Permalink
Patch 6.2.210 (extra)
Browse files Browse the repository at this point in the history
Problem:    Mac OSX: antialiased fonts are not supported.
Solution:   Add the 'antialias' option to switch on antialiasing on Mac OSX
            10.2 and later. (Peter Cucka)
Files:      runtime/doc/options.txt, src/gui_mac.c, src/option.h, src/option.c
  • Loading branch information
brammool authored and d3zd3z committed Jan 27, 2004
1 parent 62128da commit c233b67
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 24 deletions.
1 change: 1 addition & 0 deletions .cvsignore
@@ -1,2 +1,3 @@
gvimext.dll
.arch-ids
{arch}
26 changes: 19 additions & 7 deletions runtime/doc/options.txt
@@ -1,4 +1,4 @@
*options.txt* For Vim version 6.2. Last change: 2003 Aug 12
*options.txt* For Vim version 6.2. Last change: 2004 Jan 22


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -619,26 +619,38 @@ A jump table for the options with a short description can be found at |Q_op|.
Registered sign, Greek/Cyrillic letters are represented by two octets,
therefore those fonts have "wide" glyphs for them. This is also
true of some line drawing characters used to make tables in text
file. Therefore, when a CJK font is used for GUI vim or
vim is running inside a terminal (emulators) that uses a CJK font
(or vim is run inside an xterm invoked with "-cjkwidth" option.),
file. Therefore, when a CJK font is used for GUI Vim or
Vim is running inside a terminal (emulators) that uses a CJK font
(or Vim is run inside an xterm invoked with "-cjkwidth" option.),
this option should be set to "double" to match the width perceived
by Vim with the width of glyphs in the font. Perhaps it also has
to be set to "double" under CJK Windows 9x/ME or Windows 2k/XP
when the system locale is set to one of CJK locales. See Unicode
Standard Annex #11 (http://www.unicode.org/reports/tr11).

*'autochdir'* *'acd'* *'noatuochdir'* *'noacd'*
*'antialias'* *'anti'* *'noantialias'* *'noanti'*
'antialias' 'anti' boolean (default: off)
global
{not in Vi}
{only available when compiled with GUI enabled
on Mac OS X}
This option only has an effect in the 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).

*'autochdir'* *'acd'* *'noautochdir'* *'noacd'*
'autochdir' 'acd' boolean (default off)
global
{not in Vi}
{only available when compiled with the
|+netbeans_intg| or |+sun_workshop| feature}
When on, vim will change its value for the current working directory
When on, Vim will change its value for the current working directory
whenever you open a file, switch buffers, delete a buffer or
open/close a window. It will change to the directory containing the
file which was opened or selected. This option is provided for
backward compatibility with the vim released with Sun ONE Studio 4
backward compatibility with the Vim released with Sun ONE Studio 4
Enterprise Edition.

*'arabic'* *'arab'* *'noarabic'* *'noarab'*
Expand Down
95 changes: 78 additions & 17 deletions src/gui_mac.c
Expand Up @@ -2794,6 +2794,12 @@ gui_mch_init()
gui.scrollbar_height = gui.scrollbar_width = 15; /* cheat 1 overlap */
gui.border_offset = gui.border_width = 2;

#if defined(FEAT_GUI) && defined(MACOS_X)
/* If Quartz-style text antialiasing is available (see
gui_mch_draw_string() below), enable it for all font sizes. */
vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1");
#endif

/* TODO: Load bitmap if using TOOLBAR */
return OK;
}
Expand Down Expand Up @@ -3265,31 +3271,85 @@ gui_mch_draw_string(row, col, s, len, flags)
int len;
int flags;
{
TextMode (srcCopy);
TextFace (normal);

/* SelectFont(hdc, gui.currFont); */
#if defined(FEAT_GUI) && defined(MACOS_X)
/*
* On OS X, try using Quartz-style text antialiasing.
*/
SInt32 sys_version = 0;

if (flags & DRAW_TRANSP)
Gestalt(gestaltSystemVersion, &sys_version);
if (sys_version >= 0x1020)
{
TextMode (srcOr);
/* Quartz antialiasing is available only in OS 10.2 and later. */
UInt32 qd_flags = (p_antialias ?
kQDUseCGTextRendering | kQDUseCGTextMetrics : 0);
(void)SwapQDTextFlags(qd_flags);
}

MoveTo (TEXT_X(col), TEXT_Y(row));
DrawText ((char *)s, 0, len);
if (sys_version >= 0x1020 && p_antialias)
{
StyleParameter face;

face = normal;
if (flags & DRAW_BOLD)
face |= bold;
if (flags & DRAW_UNDERL)
face |= underline;
TextFace(face);

/* Quartz antialiasing works only in srcOr transfer mode. */
TextMode(srcOr);

if (!(flags & DRAW_TRANSP))
{
/*
* Since we're using srcOr mode, we have to clear the block
* before drawing the text. The following is like calling
* gui_mch_clear_block(row, col, row, col + len - 1),
* but without setting the bg color to gui.back_pixel.
*/
Rect rc;
rc.left = FILL_X(col);
rc.top = FILL_Y(row);
rc.right = FILL_X(col + len) + (col + len == Columns);
rc.bottom = FILL_Y(row + 1);
EraseRect(&rc);
}

MoveTo(TEXT_X(col), TEXT_Y(row));
DrawText((char*)s, 0, len);
}
else
#endif
{
/* Use old-style, non-antialiased QuickDraw text rendering. */
TextMode (srcCopy);
TextFace (normal);

/* SelectFont(hdc, gui.currFont); */

if (flags & DRAW_BOLD)
{
TextMode (srcOr);
MoveTo (TEXT_X(col) + 1, TEXT_Y(row));
if (flags & DRAW_TRANSP)
{
TextMode (srcOr);
}

MoveTo (TEXT_X(col), TEXT_Y(row));
DrawText ((char *)s, 0, len);
}

if (flags & DRAW_UNDERL)
{
MoveTo (FILL_X(col), FILL_Y(row + 1) - 1);
LineTo (FILL_X(col + len) - 1, FILL_Y(row + 1) - 1);

if (flags & DRAW_BOLD)
{
TextMode (srcOr);
MoveTo (TEXT_X(col) + 1, TEXT_Y(row));
DrawText ((char *)s, 0, len);
}

if (flags & DRAW_UNDERL)
{
MoveTo (FILL_X(col), FILL_Y(row + 1) - 1);
LineTo (FILL_X(col + len) - 1, FILL_Y(row + 1) - 1);
}
}
}

Expand Down Expand Up @@ -4045,6 +4105,7 @@ gui_mch_add_menu_item(menu, idx)
int key = 0;
int modifiers = 0;
char_u *p_actext;

p_actext = menu->actext;
key = find_special_key(&p_actext, &modifiers, /*keycode=*/0);
if (*p_actext != 0)
Expand Down Expand Up @@ -5110,7 +5171,7 @@ gui_mch_show_popupmenu(menu)
#if defined(FEAT_CW_EDITOR) || defined(PROTO)
/* TODO: Is it need for MACOS_X? (Dany) */
void
mch_post_buffer_write (buf_T *buf)
mch_post_buffer_write(buf_T *buf)
{
# ifdef USE_SIOUX
printf ("Writing Buf...\n");
Expand Down
9 changes: 9 additions & 0 deletions src/option.c
Expand Up @@ -320,6 +320,15 @@ static struct vimoption
(char_u *)224L,
#endif
(char_u *)0L}},
{"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
#if defined(FEAT_GUI) && defined(MACOS_X)
(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
},
{"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM,
#ifdef FEAT_ARABIC
(char_u *)VAR_WIN, PV_ARAB,
Expand Down
3 changes: 3 additions & 0 deletions src/option.h
Expand Up @@ -290,6 +290,9 @@ 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' */
#endif
EXTERN int p_ar; /* 'autoread' */
EXTERN int p_aw; /* 'autowrite' */
EXTERN int p_awa; /* 'autowriteall' */
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -637,6 +637,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
210,
/**/
209,
/**/
Expand Down

0 comments on commit c233b67

Please sign in to comment.