summaryrefslogtreecommitdiff
path: root/src/w32font.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32font.c')
-rw-r--r--src/w32font.c84
1 files changed, 54 insertions, 30 deletions
diff --git a/src/w32font.c b/src/w32font.c
index 0570d2acba3..47a33aec35f 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -29,9 +29,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "coding.h" /* for ENCODE_SYSTEM, DECODE_SYSTEM */
#include "w32font.h"
#ifdef WINDOWSNT
+#include "w32common.h"
#include "w32.h"
#endif
+#include "pdumper.h"
+
/* Cleartype available on Windows XP, cleartype_natural from XP SP1.
The latter does not try to fit cleartype smoothed fonts into the
same bounding box as the non-antialiased version of the font.
@@ -153,7 +156,7 @@ get_outline_metrics_w(HDC hdc, UINT cbData, LPOUTLINETEXTMETRICW lpotmw)
hm_unicows = w32_load_unicows_or_gdi32 ();
if (hm_unicows)
s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc)
- GetProcAddress (hm_unicows, "GetOutlineTextMetricsW");
+ get_proc_addr (hm_unicows, "GetOutlineTextMetricsW");
}
eassert (s_pfn_Get_Outline_Text_MetricsW != NULL);
return s_pfn_Get_Outline_Text_MetricsW (hdc, cbData, lpotmw);
@@ -170,7 +173,7 @@ get_text_metrics_w(HDC hdc, LPTEXTMETRICW lptmw)
hm_unicows = w32_load_unicows_or_gdi32 ();
if (hm_unicows)
s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc)
- GetProcAddress (hm_unicows, "GetTextMetricsW");
+ get_proc_addr (hm_unicows, "GetTextMetricsW");
}
eassert (s_pfn_Get_Text_MetricsW != NULL);
return s_pfn_Get_Text_MetricsW (hdc, lptmw);
@@ -188,7 +191,7 @@ get_glyph_outline_w (HDC hdc, UINT uChar, UINT uFormat, LPGLYPHMETRICS lpgm,
hm_unicows = w32_load_unicows_or_gdi32 ();
if (hm_unicows)
s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc)
- GetProcAddress (hm_unicows, "GetGlyphOutlineW");
+ get_proc_addr (hm_unicows, "GetGlyphOutlineW");
}
eassert (s_pfn_Get_Glyph_OutlineW != NULL);
return s_pfn_Get_Glyph_OutlineW (hdc, uChar, uFormat, lpgm, cbBuffer,
@@ -206,7 +209,7 @@ get_char_width_32_w (HDC hdc, UINT uFirstChar, UINT uLastChar, LPINT lpBuffer)
hm_unicows = w32_load_unicows_or_gdi32 ();
if (hm_unicows)
s_pfn_Get_Char_Width_32W = (GetCharWidth32W_Proc)
- GetProcAddress (hm_unicows, "GetCharWidth32W");
+ get_proc_addr (hm_unicows, "GetCharWidth32W");
}
eassert (s_pfn_Get_Char_Width_32W != NULL);
return s_pfn_Get_Char_Width_32W (hdc, uFirstChar, uLastChar, lpBuffer);
@@ -430,7 +433,7 @@ w32font_encode_char (struct font *font, int c)
CODE (length NGLYPHS). Apparently metrics can be NULL, in this
case just return the overall width. */
void
-w32font_text_extents (struct font *font, unsigned *code,
+w32font_text_extents (struct font *font, const unsigned *code,
int nglyphs, struct font_metrics *metrics)
{
int i;
@@ -675,7 +678,7 @@ w32font_draw (struct glyph_string *s, int from, int to,
characters, because drawing background with font dimensions
in those cases makes the display illegible. There's only one
more call to the draw method with with_background set to
- true, and that's in x_draw_glyph_string_foreground, when
+ true, and that's in w32_draw_glyph_string_foreground, when
drawing the cursor, where we have no such heuristics
available. FIXME. */
if (s->first_glyph->type == GLYPHLESS_GLYPH
@@ -701,11 +704,23 @@ w32font_draw (struct glyph_string *s, int from, int to,
int i;
for (i = 0; i < len; i++)
- ExtTextOutW (s->hdc, x + i, y, options, NULL,
- s->char2b + from + i, 1, NULL);
+ {
+ WCHAR c = s->char2b[from + i] & 0xFFFF;
+ ExtTextOutW (s->hdc, x + i, y, options, NULL, &c, 1, NULL);
+ }
}
else
- ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, len, NULL);
+ {
+ /* The number of glyphs in a glyph_string cannot be larger than
+ the maximum value of the 'used' member of a glyph_row, so we
+ are OK using alloca here. */
+ eassert (len <= SHRT_MAX);
+ WCHAR *chars = alloca (len * sizeof (WCHAR));
+ int j;
+ for (j = 0; j < len; j++)
+ chars[j] = s->char2b[from + j] & 0xFFFF;
+ ExtTextOutW (s->hdc, x, y, options, NULL, chars, len, NULL);
+ }
/* Restore clip region. */
if (s->num_clips > 0)
@@ -718,7 +733,7 @@ w32font_draw (struct glyph_string *s, int from, int to,
}
/* w32 implementation of free_entity for font backend.
- Optional (if FONT_EXTRA_INDEX is not Lisp_Save_Value).
+ Optional.
Free FONT_EXTRA_INDEX field of FONT_ENTITY.
static void
w32font_free_entity (Lisp_Object entity);
@@ -920,7 +935,7 @@ w32font_open_internal (struct frame *f, Lisp_Object font_entity,
if (!EQ (val, Qraster))
logfont.lfOutPrecision = OUT_TT_PRECIS;
- size = XINT (AREF (font_entity, FONT_SIZE_INDEX));
+ size = XFIXNUM (AREF (font_entity, FONT_SIZE_INDEX));
if (!size)
size = pixel_size;
@@ -1096,9 +1111,9 @@ w32_enumfont_pattern_entity (Lisp_Object frame,
ASET (entity, FONT_ADSTYLE_INDEX, tem);
if (physical_font->ntmTm.tmPitchAndFamily & 0x01)
- ASET (entity, FONT_SPACING_INDEX, make_number (FONT_SPACING_PROPORTIONAL));
+ ASET (entity, FONT_SPACING_INDEX, make_fixnum (FONT_SPACING_PROPORTIONAL));
else
- ASET (entity, FONT_SPACING_INDEX, make_number (FONT_SPACING_CHARCELL));
+ ASET (entity, FONT_SPACING_INDEX, make_fixnum (FONT_SPACING_CHARCELL));
if (requested_font->lfQuality != DEFAULT_QUALITY)
{
@@ -1109,19 +1124,19 @@ w32_enumfont_pattern_entity (Lisp_Object frame,
intern_font_name (lf->lfFaceName));
FONT_SET_STYLE (entity, FONT_WEIGHT_INDEX,
- make_number (w32_decode_weight (lf->lfWeight)));
+ make_fixnum (w32_decode_weight (lf->lfWeight)));
FONT_SET_STYLE (entity, FONT_SLANT_INDEX,
- make_number (lf->lfItalic ? 200 : 100));
+ make_fixnum (lf->lfItalic ? 200 : 100));
/* TODO: PANOSE struct has this info, but need to call GetOutlineTextMetrics
to get it. */
- FONT_SET_STYLE (entity, FONT_WIDTH_INDEX, make_number (100));
+ FONT_SET_STYLE (entity, FONT_WIDTH_INDEX, make_fixnum (100));
if (font_type & RASTER_FONTTYPE)
ASET (entity, FONT_SIZE_INDEX,
- make_number (physical_font->ntmTm.tmHeight
+ make_fixnum (physical_font->ntmTm.tmHeight
+ physical_font->ntmTm.tmExternalLeading));
else
- ASET (entity, FONT_SIZE_INDEX, make_number (0));
+ ASET (entity, FONT_SIZE_INDEX, make_fixnum (0));
/* Cache Unicode codepoints covered by this font, as there is no other way
of getting this information easily. */
@@ -1229,9 +1244,9 @@ font_matches_spec (DWORD type, NEWTEXTMETRICEX *font,
/* Check spacing */
val = AREF (spec, FONT_SPACING_INDEX);
- if (INTEGERP (val))
+ if (FIXNUMP (val))
{
- int spacing = XINT (val);
+ int spacing = XFIXNUM (val);
int proportional = (spacing < FONT_SPACING_MONO);
if ((proportional && !(font->ntmTm.tmPitchAndFamily & 0x01))
@@ -1822,8 +1837,8 @@ w32_to_x_charset (int fncharset, char *matching)
/* Look for Same charset and a valid codepage (or non-int
which means ignore). */
if (EQ (w32_charset, charset_type)
- && (!INTEGERP (codepage) || XINT (codepage) == CP_DEFAULT
- || IsValidCodePage (XINT (codepage))))
+ && (!FIXNUMP (codepage) || XFIXNUM (codepage) == CP_DEFAULT
+ || IsValidCodePage (XFIXNUM (codepage))))
{
/* If we don't have a match already, then this is the
best. */
@@ -1955,9 +1970,9 @@ fill_in_logfont (struct frame *f, LOGFONT *logfont, Lisp_Object font_spec)
int dpi = FRAME_RES_Y (f);
tmp = AREF (font_spec, FONT_DPI_INDEX);
- if (INTEGERP (tmp))
+ if (FIXNUMP (tmp))
{
- dpi = XINT (tmp);
+ dpi = XFIXNUM (tmp);
}
else if (FLOATP (tmp))
{
@@ -1966,8 +1981,8 @@ fill_in_logfont (struct frame *f, LOGFONT *logfont, Lisp_Object font_spec)
/* Height */
tmp = AREF (font_spec, FONT_SIZE_INDEX);
- if (INTEGERP (tmp))
- logfont->lfHeight = -1 * XINT (tmp);
+ if (FIXNUMP (tmp))
+ logfont->lfHeight = -1 * XFIXNUM (tmp);
else if (FLOATP (tmp))
logfont->lfHeight = (int) (-1.0 * dpi * XFLOAT_DATA (tmp) / 72.27 + 0.5);
@@ -1977,12 +1992,12 @@ fill_in_logfont (struct frame *f, LOGFONT *logfont, Lisp_Object font_spec)
/* Weight */
tmp = AREF (font_spec, FONT_WEIGHT_INDEX);
- if (INTEGERP (tmp))
+ if (FIXNUMP (tmp))
logfont->lfWeight = w32_encode_weight (FONT_WEIGHT_NUMERIC (font_spec));
/* Italic */
tmp = AREF (font_spec, FONT_SLANT_INDEX);
- if (INTEGERP (tmp))
+ if (FIXNUMP (tmp))
{
int slant = FONT_SLANT_NUMERIC (font_spec);
logfont->lfItalic = slant > 150 ? 1 : 0;
@@ -2036,9 +2051,9 @@ fill_in_logfont (struct frame *f, LOGFONT *logfont, Lisp_Object font_spec)
/* Set pitch based on the spacing property. */
tmp = AREF (font_spec, FONT_SPACING_INDEX);
- if (INTEGERP (tmp))
+ if (FIXNUMP (tmp))
{
- int spacing = XINT (tmp);
+ int spacing = XFIXNUM (tmp);
if (spacing < FONT_SPACING_MONO)
logfont->lfPitchAndFamily
= (logfont->lfPitchAndFamily & 0xF0) | VARIABLE_PITCH;
@@ -2623,6 +2638,9 @@ struct font_driver w32font_driver =
/* Initialize state that does not change between invocations. This is only
called when Emacs is dumped. */
+
+static void syms_of_w32font_for_pdumper (void);
+
void
syms_of_w32font (void)
{
@@ -2802,6 +2820,12 @@ versions of Windows) characters. */);
defsubr (&Sx_select_font);
+ pdumper_do_now_and_after_load (syms_of_w32font_for_pdumper);
+}
+
+static void
+syms_of_w32font_for_pdumper (void)
+{
register_font_driver (&w32font_driver, NULL);
}