/* Font backend for the Microsoft Windows API.
- Copyright (C) 2007-2014 Free Software Foundation, Inc.
+ Copyright (C) 2007-2015 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#define JOHAB_CHARSET 130
#endif
-Lisp_Object Qgdi;
-Lisp_Object Quniscribe;
-static Lisp_Object QCformat;
-static Lisp_Object Qmonospace, Qsansserif, Qmono, Qsans, Qsans_serif;
-static Lisp_Object Qserif, Qscript, Qdecorative;
-static Lisp_Object Qraster, Qoutline, Qunknown;
-
-/* antialiasing */
-static Lisp_Object Qstandard, Qsubpixel, Qnatural;
-
-/* languages */
-static Lisp_Object Qzh;
-
-/* scripts */
-static Lisp_Object Qgreek, Qcoptic, Qcyrillic, Qarmenian, Qhebrew;
-static Lisp_Object Qarabic, Qsyriac, Qnko, Qthaana, Qdevanagari, Qbengali;
-static Lisp_Object Qgurmukhi, Qgujarati, Qoriya, Qtamil, Qtelugu;
-static Lisp_Object Qkannada, Qmalayalam, Qsinhala, Qthai, Qlao;
-static Lisp_Object Qtibetan, Qmyanmar, Qgeorgian, Qhangul, Qethiopic;
-static Lisp_Object Qcherokee, Qcanadian_aboriginal, Qogham, Qrunic;
-static Lisp_Object Qkhmer, Qmongolian, Qbraille, Qhan;
-static Lisp_Object Qideographic_description, Qcjk_misc, Qkana, Qbopomofo;
-static Lisp_Object Qkanbun, Qyi, Qbyzantine_musical_symbol;
-static Lisp_Object Qmusical_symbol, Qmathematical, Qcham, Qphonetic;
-/* Not defined in characters.el, but referenced in fontset.el. */
-static Lisp_Object Qbalinese, Qbuginese, Qbuhid, Qcuneiform, Qcypriot;
-static Lisp_Object Qdeseret, Qglagolitic, Qgothic, Qhanunoo, Qkharoshthi;
-static Lisp_Object Qlimbu, Qlinear_b, Qold_italic, Qold_persian, Qosmanya;
-static Lisp_Object Qphags_pa, Qphoenician, Qshavian, Qsyloti_nagri;
-static Lisp_Object Qtagalog, Qtagbanwa, Qtai_le, Qtifinagh, Qugaritic;
-
-/* W32 charsets: for use in Vw32_charset_info_alist. */
-static Lisp_Object Qw32_charset_ansi, Qw32_charset_default;
-static Lisp_Object Qw32_charset_symbol, Qw32_charset_shiftjis;
-static Lisp_Object Qw32_charset_hangeul, Qw32_charset_gb2312;
-static Lisp_Object Qw32_charset_chinesebig5, Qw32_charset_oem;
-static Lisp_Object Qw32_charset_easteurope, Qw32_charset_turkish;
-static Lisp_Object Qw32_charset_baltic, Qw32_charset_russian;
-static Lisp_Object Qw32_charset_arabic, Qw32_charset_greek;
-static Lisp_Object Qw32_charset_hebrew, Qw32_charset_vietnamese;
-static Lisp_Object Qw32_charset_thai, Qw32_charset_johab, Qw32_charset_mac;
-
-/* Font spacing symbols - defined in font.c. */
-extern Lisp_Object Qc, Qp, Qm;
-
static void fill_in_logfont (struct frame *, LOGFONT *, Lisp_Object);
static BYTE w32_antialias_type (Lisp_Object);
static Lisp_Object w32_registry (LONG, DWORD);
/* EnumFontFamiliesEx callbacks. */
-static int CALLBACK add_font_entity_to_list (ENUMLOGFONTEX *,
- NEWTEXTMETRICEX *,
- DWORD, LPARAM);
-static int CALLBACK add_one_font_entity_to_list (ENUMLOGFONTEX *,
- NEWTEXTMETRICEX *,
- DWORD, LPARAM);
-static int CALLBACK add_font_name_to_list (ENUMLOGFONTEX *,
- NEWTEXTMETRICEX *,
- DWORD, LPARAM);
+static int CALLBACK ALIGN_STACK add_font_entity_to_list (ENUMLOGFONTEX *,
+ NEWTEXTMETRICEX *,
+ DWORD, LPARAM);
+static int CALLBACK ALIGN_STACK add_one_font_entity_to_list (ENUMLOGFONTEX *,
+ NEWTEXTMETRICEX *,
+ DWORD, LPARAM);
+static int CALLBACK ALIGN_STACK add_font_name_to_list (ENUMLOGFONTEX *,
+ NEWTEXTMETRICEX *,
+ DWORD, LPARAM);
/* struct passed in as LPARAM arg to EnumFontFamiliesEx, for keeping track
of what we really want. */
intern_font_name (char * string)
{
Lisp_Object str = DECODE_SYSTEM (build_string (string));
- int len = SCHARS (str);
+ ptrdiff_t len = SCHARS (str);
Lisp_Object obarray = check_obarray (Vobarray);
Lisp_Object tem = oblookup (obarray, SDATA (str), len, len);
/* This code is similar to intern function from lread.c. */
- return SYMBOLP (tem) ? tem : Fintern (str, obarray);
+ return SYMBOLP (tem) ? tem : intern_driver (str, obarray, tem);
}
/* w32 implementation of get_cache for font backend.
of METRICS. The glyphs are specified by their glyph codes in
CODE (length NGLYPHS). Apparently metrics can be NULL, in this
case just return the overall width. */
-int
+void
w32font_text_extents (struct font *font, unsigned *code,
int nglyphs, struct font_metrics *metrics)
{
struct w32font_info *w32_font = (struct w32font_info *) font;
- if (metrics)
- {
- memset (metrics, 0, sizeof (struct font_metrics));
- metrics->ascent = font->ascent;
- metrics->descent = font->descent;
+ memset (metrics, 0, sizeof (struct font_metrics));
+ metrics->ascent = font->ascent;
+ metrics->descent = font->descent;
- for (i = 0; i < nglyphs; i++)
- {
- struct w32_metric_cache *char_metric;
- int block = *(code + i) / CACHE_BLOCKSIZE;
- int pos_in_block = *(code + i) % CACHE_BLOCKSIZE;
+ for (i = 0; i < nglyphs; i++)
+ {
+ struct w32_metric_cache *char_metric;
+ int block = *(code + i) / CACHE_BLOCKSIZE;
+ int pos_in_block = *(code + i) % CACHE_BLOCKSIZE;
- if (block >= w32_font->n_cache_blocks)
- {
- if (!w32_font->cached_metrics)
- w32_font->cached_metrics
- = xmalloc ((block + 1)
- * sizeof (struct w32_metric_cache *));
- else
- w32_font->cached_metrics
- = xrealloc (w32_font->cached_metrics,
- (block + 1)
- * sizeof (struct w32_metric_cache *));
- memset (w32_font->cached_metrics + w32_font->n_cache_blocks, 0,
- ((block + 1 - w32_font->n_cache_blocks)
- * sizeof (struct w32_metric_cache *)));
- w32_font->n_cache_blocks = block + 1;
- }
+ if (block >= w32_font->n_cache_blocks)
+ {
+ if (!w32_font->cached_metrics)
+ w32_font->cached_metrics
+ = xmalloc ((block + 1)
+ * sizeof (struct w32_metric_cache *));
+ else
+ w32_font->cached_metrics
+ = xrealloc (w32_font->cached_metrics,
+ (block + 1)
+ * sizeof (struct w32_metric_cache *));
+ memset (w32_font->cached_metrics + w32_font->n_cache_blocks, 0,
+ ((block + 1 - w32_font->n_cache_blocks)
+ * sizeof (struct w32_metric_cache *)));
+ w32_font->n_cache_blocks = block + 1;
+ }
- if (!w32_font->cached_metrics[block])
- {
- w32_font->cached_metrics[block]
- = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
- }
+ if (!w32_font->cached_metrics[block])
+ {
+ w32_font->cached_metrics[block]
+ = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
+ }
- char_metric = w32_font->cached_metrics[block] + pos_in_block;
+ char_metric = w32_font->cached_metrics[block] + pos_in_block;
- if (char_metric->status == W32METRIC_NO_ATTEMPT)
- {
- if (dc == NULL)
- {
- /* TODO: Frames can come and go, and their fonts
- outlive them. So we can't cache the frame in the
- font structure. Use selected_frame until the API
- is updated to pass in a frame. */
- f = XFRAME (selected_frame);
-
- dc = get_frame_dc (f);
- old_font = SelectObject (dc, w32_font->hfont);
- }
- compute_metrics (dc, w32_font, *(code + i), char_metric);
- }
-
- if (char_metric->status == W32METRIC_SUCCESS)
+ if (char_metric->status == W32METRIC_NO_ATTEMPT)
+ {
+ if (dc == NULL)
{
- metrics->lbearing = min (metrics->lbearing,
- metrics->width + char_metric->lbearing);
- metrics->rbearing = max (metrics->rbearing,
- metrics->width + char_metric->rbearing);
- metrics->width += char_metric->width;
+ /* TODO: Frames can come and go, and their fonts
+ outlive them. So we can't cache the frame in the
+ font structure. Use selected_frame until the API
+ is updated to pass in a frame. */
+ f = XFRAME (selected_frame);
+
+ dc = get_frame_dc (f);
+ old_font = SelectObject (dc, w32_font->hfont);
}
- else
- /* If we couldn't get metrics for a char,
- use alternative method. */
- break;
+ compute_metrics (dc, w32_font, *(code + i), char_metric);
}
- /* If we got through everything, return. */
- if (i == nglyphs)
- {
- if (dc != NULL)
- {
- /* Restore state and release DC. */
- SelectObject (dc, old_font);
- release_frame_dc (f, dc);
- }
- return metrics->width;
- }
+ if (char_metric->status == W32METRIC_SUCCESS)
+ {
+ metrics->lbearing = min (metrics->lbearing,
+ metrics->width + char_metric->lbearing);
+ metrics->rbearing = max (metrics->rbearing,
+ metrics->width + char_metric->rbearing);
+ metrics->width += char_metric->width;
+ }
+ else
+ /* If we couldn't get metrics for a char,
+ use alternative method. */
+ break;
+ }
+ /* If we got through everything, return. */
+ if (i == nglyphs)
+ {
+ if (dc != NULL)
+ {
+ /* Restore state and release DC. */
+ SelectObject (dc, old_font);
+ release_frame_dc (f, dc);
+ }
+ return;
}
/* For non-truetype fonts, GetGlyphOutlineW is not supported, so
}
/* Give our best estimate of the metrics, based on what we know. */
- if (metrics)
- {
- metrics->width = total_width - w32_font->metrics.tmOverhang;
- metrics->lbearing = 0;
- metrics->rbearing = total_width;
- }
+ metrics->width = total_width - w32_font->metrics.tmOverhang;
+ metrics->lbearing = 0;
+ metrics->rbearing = total_width;
/* Restore state and release DC. */
SelectObject (dc, old_font);
release_frame_dc (f, dc);
-
- return total_width;
}
/* w32 implementation of draw for font backend.
/* Callback function for EnumFontFamiliesEx.
* Adds the name of a font to a Lisp list (passed in as the lParam arg). */
-static int CALLBACK
+static int CALLBACK ALIGN_STACK
add_font_name_to_list (ENUMLOGFONTEX *logical_font,
NEWTEXTMETRICEX *physical_font,
DWORD font_type, LPARAM list_object)
* and if so, adds it to a list. Both the data we are checking against
* and the list to which the fonts are added are passed in via the
* lparam argument, in the form of a font_callback_data struct. */
-static int CALLBACK
+static int CALLBACK ALIGN_STACK
add_font_entity_to_list (ENUMLOGFONTEX *logical_font,
NEWTEXTMETRICEX *physical_font,
DWORD font_type, LPARAM lParam)
/* Callback function for EnumFontFamiliesEx.
* Terminates the search once we have a match. */
-static int CALLBACK
+static int CALLBACK ALIGN_STACK
add_one_font_entity_to_list (ENUMLOGFONTEX *logical_font,
NEWTEXTMETRICEX *physical_font,
DWORD font_type, LPARAM lParam)