summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Rumney <jasonr@gnu.org>2005-07-01 21:28:08 +0000
committerJason Rumney <jasonr@gnu.org>2005-07-01 21:28:08 +0000
commitc2baa2b65bf9492c0a23a31816a561a187039ae9 (patch)
tree901dd874f670b60fd029d38e9af232bf554e4c76 /src
parent64f72ae1be6377a34420542246868fdbdcf57e63 (diff)
downloademacs-c2baa2b65bf9492c0a23a31816a561a187039ae9.tar.gz
emacs-c2baa2b65bf9492c0a23a31816a561a187039ae9.tar.bz2
emacs-c2baa2b65bf9492c0a23a31816a561a187039ae9.zip
* w32term.c (cleartype_active): New flag for enabling sub-pixel
workaround. (w32_initialize): Initialize it. (w32_native_per_char_metric): Allow a couple of extra pixels when Cleartype is active. * w32term.c (w32_initialize): Move check for screen reader here from syms_of_w32term.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/w32term.c49
2 files changed, 55 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3752b58c831..950a0414047 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2005-07-01 Jason Rumney <jasonr@gnu.org>
+
+ * w32term.c (cleartype_active): New flag for enabling sub-pixel
+ workaround.
+ (w32_initialize): Initialize it.
+ (w32_native_per_char_metric): Allow a couple of extra pixels when
+ Cleartype is active.
+
+ * w32term.c (w32_initialize): Move check for screen reader here
+ from syms_of_w32term.
+
2005-06-30 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
* xterm.c (handle_one_xevent): bzero compose_status when nbytes
diff --git a/src/w32term.c b/src/w32term.c
index 1caa1313df4..24c03a001e6 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -138,6 +138,9 @@ int w32_use_visible_system_caret;
for Far East languages. */
int w32_enable_unicode_output;
+/* Flag to enable Cleartype hack for font metrics. */
+static int cleartype_active;
+
DWORD dwWindowsThreadId = 0;
HANDLE hWindowsThread = NULL;
DWORD dwMainThreadId = 0;
@@ -907,6 +910,16 @@ w32_native_per_char_metric (font, char2b, font_type, pcm)
int real_width;
GetCharWidth (hdc, *char2b, *char2b, &real_width);
#endif
+ if (cleartype_active)
+ {
+ /* Cleartype antialiasing causes characters to overhang
+ by a pixel on each side compared with what GetCharABCWidths
+ reports. */
+ char_widths.abcA -= 1;
+ char_widths.abcC -= 1;
+ char_widths.abcB += 2;
+ }
+
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
@@ -6403,6 +6416,12 @@ w32_initialize ()
w32_system_caret_x = 0;
w32_system_caret_y = 0;
+ /* Initialize w32_use_visible_system_caret based on whether a screen
+ reader is in use. */
+ if (!SystemParametersInfo (SPI_GETSCREENREADER, 0,
+ &w32_use_visible_system_caret, 0))
+ w32_use_visible_system_caret = 0;
+
last_tool_bar_item = -1;
any_help_event_p = 0;
@@ -6447,6 +6466,8 @@ w32_initialize ()
/* Dynamically link to optional system components. */
{
HANDLE user_lib = LoadLibrary ("user32.dll");
+ UINT smoothing_type;
+ BOOL smoothing_enabled;
#define LOAD_PROC(fn) pfn##fn = (void *) GetProcAddress (user_lib, #fn)
@@ -6467,6 +6488,28 @@ w32_initialize ()
effectively form the border of the main scroll bar range. */
vertical_scroll_bar_top_border = vertical_scroll_bar_bottom_border
= GetSystemMetrics (SM_CYVSCROLL);
+
+ /* Constants that are not always defined by the system headers
+ since they only exist on certain versions of Windows. */
+#ifndef SPI_GETFONTSMOOTHING
+#define SPI_GETFONTSMOOTHING 0x4A
+#endif
+#ifndef SPI_GETFONTSMOOTHINGTYPE
+#define SPI_GETFONTSMOOTHINGTYPE 0x0200A
+#endif
+#ifndef FE_FONTSMOOTHINGCLEARTYPE
+#define FE_FONTSMOOTHINGCLEARTYPE 0x2
+#endif
+
+ /* Determine if Cleartype is in use. Used to enable a hack in
+ the char metric calculations which adds extra pixels to
+ compensate for the "sub-pixels" that are not counted by the
+ system APIs. */
+ cleartype_active =
+ SystemParametersInfo (SPI_GETFONTSMOOTHING, 0, &smoothing_enabled, 0)
+ && smoothing_enabled
+ && SystemParametersInfo (SPI_GETFONTSMOOTHINGTYPE, 0, &smoothing_type, 0)
+ && smoothing_type == FE_FONTSMOOTHINGCLEARTYPE;
}
}
@@ -6536,11 +6579,7 @@ software is running as it starts up.
When this variable is set, other variables affecting the appearance of
the cursor have no effect. */);
- /* Initialize w32_use_visible_system_caret based on whether a screen
- reader is in use. */
- if (!SystemParametersInfo (SPI_GETSCREENREADER, 0,
- &w32_use_visible_system_caret, 0))
- w32_use_visible_system_caret = 0;
+ w32_use_visible_system_caret = 0;
/* We don't yet support this, but defining this here avoids whining
from cus-start.el and other places, like "M-x set-variable". */