From: David Abrahams <dave@boost-consulting.com>
Subject: Re: Emacs defeats ClearType
Date: Fri, 03 Jun 2005 11:27:08 -0400 [thread overview]
Message-ID: <u3brzihpv.fsf@boost-consulting.com> (raw)
In-Reply-To: 1117787455.42a0153fdf46f@webmail.freedom2surf.net
[-- Attachment #1: Type: text/plain, Size: 1663 bytes --]
jasonr@f2s.com writes:
> Quoting David Abrahams <dave@boost-consulting.com>:
>
>> When ClearType
>> (http://www.microsoft.com/typography/cleartype/tuner/Step1.aspx) is
>> enabled on an NT build of Emacs, it's very common for emacs to "slice
>> off" a few antialiased pixels on either side of a character's vertical
>> member. It happens especially in lines that are being typed. You can
>> see examples in this sentence of characters whose vertical members
>> appear to be thin, red lines (image enclosed).
>
> This happens because Windows tells lies about the width of characters when
> sub-pixel antialiasing is in effect.
>
> You are welcome to investigate a way around this if you want.
Fantastic; it turned out to be easy. I have enclosed a patch that
works for me. The use of those strange #defines
#define W32_spi_getfontsmoothing 0x4A
#define W32_spi_getfontsmoothingtype 0x0200A
#define W32_fe_fontsmoothingcleartype 0x2
is because the use of -D_WIN32_WINNT=0x0400 on the compiler
command-line makes the corresponding MS constants unavailable through
<windows.h>. I wasn't sure what the best way to handle this stuff
might be -- i.e. what's most consistent with regular Emacs coding
practice. I would be happy to change the approach in whatever way is
deemed necessary. I also release all rights to my patch to the FSF.
Incidentally, it seemed to work just fine for me if I remove the
checks for whether cleartype is enabled altogether, and just make the
width adjustments unconditionally. That would eliminate the issue
with those constants described above and probably make a small
difference in speed. Seems like a viable option to me.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: w32term.patch --]
[-- Type: text/x-patch, Size: 1197 bytes --]
--- w32term.c 25 Mar 2005 19:19:53 -0500 1.224
+++ w32term.c 03 Jun 2005 11:21:29 -0400
@@ -903,6 +903,29 @@
int real_width;
GetCharWidth (hdc, *char2b, *char2b, &real_width);
#endif
+
+ BOOL smoothing_enabled;
+ UINT smoothing_type;
+
+ /* Attempt to account for ClearType antialiasing.
+ * GetCharABCWidths fails to report the fractional pixels
+ * used for subpixel antialiasing
+ */
+#define W32_spi_getfontsmoothing 0x4A
+#define W32_spi_getfontsmoothingtype 0x0200A
+#define W32_fe_fontsmoothingcleartype 0x2
+
+ if (SystemParametersInfo(W32_spi_getfontsmoothing, 0, &smoothing_enabled, 0)
+ && smoothing_enabled
+ && SystemParametersInfo(W32_spi_getfontsmoothingtype, 0, &smoothing_type, 0)
+ && smoothing_type == W32_fe_fontsmoothingcleartype
+ )
+ {
+ char_widths.abcA -=1;
+ char_widths.abcB +=2;
+ char_widths.abcC -= 1;
+ }
+
pcm->width = char_widths.abcA + char_widths.abcB + char_widths.abcC;
#if 0
/* As far as I can tell, this is the best way to determine what
[-- Attachment #3: Type: text/plain, Size: 61 bytes --]
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
[-- Attachment #4: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next prev parent reply other threads:[~2005-06-03 15:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-02 12:38 Emacs defeats ClearType David Abrahams
2005-06-03 8:30 ` jasonr
2005-06-03 10:54 ` David Abrahams
2005-06-03 15:22 ` jasonr
2005-06-03 15:27 ` David Abrahams [this message]
2005-06-06 15:47 ` jasonr
2005-06-06 16:46 ` David Abrahams
2005-06-07 1:15 ` Miles Bader
2005-06-07 13:20 ` David Abrahams
2005-06-08 13:45 ` [PING] ClearType Patch David Abrahams
2005-06-08 14:33 ` Eli Zaretskii
2005-06-08 15:46 ` David Abrahams
2005-06-08 16:44 ` Stefan Monnier
2005-06-08 20:01 ` David Abrahams
2005-06-08 18:22 ` Eli Zaretskii
2005-06-08 19:57 ` David Abrahams
2005-06-08 21:29 ` jasonr
2005-06-08 21:23 ` jasonr
2005-06-08 22:17 ` David Abrahams
2005-06-09 8:10 ` jasonr
2005-06-11 13:12 ` Eli Zaretskii
2005-06-11 16:50 ` David Abrahams
2005-06-15 7:15 ` David Abrahams
2005-06-15 9:19 ` David Abrahams
2005-06-18 23:02 ` How is highlighting done in show-paren-mode? David Abrahams
2005-07-14 18:55 ` Who can explain the display architecture? David Abrahams
2005-07-15 9:41 ` Kim F. Storm
2005-06-08 23:34 ` [PING] ClearType Patch Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=u3brzihpv.fsf@boost-consulting.com \
--to=dave@boost-consulting.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).