-/* Font backend for the Microsoft W32 API.
- Copyright (C) 2007-2011 Free Software Foundation, Inc.
+/* Font backend for the Microsoft Windows API.
+ Copyright (C) 2007-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
#include <windows.h>
+#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <commdlg.h>
-#include <setjmp.h>
#include "lisp.h"
#include "w32term.h"
static Lisp_Object Qraster, Qoutline, Qunknown;
/* antialiasing */
-extern Lisp_Object Qnone; /* reuse from w32fns.c */
static Lisp_Object Qstandard, Qsubpixel, Qnatural;
/* languages */
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, Qsymbol, Qbraille, Qhan;
+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;
s_pfn_Get_Outline_Text_MetricsW = (GetOutlineTextMetricsW_Proc)
GetProcAddress (hm_unicows, "GetOutlineTextMetricsW");
}
- if (s_pfn_Get_Outline_Text_MetricsW == NULL)
- abort (); /* cannot happen */
+ eassert (s_pfn_Get_Outline_Text_MetricsW != NULL);
return s_pfn_Get_Outline_Text_MetricsW (hdc, cbData, lpotmw);
}
s_pfn_Get_Text_MetricsW = (GetTextMetricsW_Proc)
GetProcAddress (hm_unicows, "GetTextMetricsW");
}
- if (s_pfn_Get_Text_MetricsW == NULL)
- abort (); /* cannot happen */
+ eassert (s_pfn_Get_Text_MetricsW != NULL);
return s_pfn_Get_Text_MetricsW (hdc, lptmw);
}
s_pfn_Get_Glyph_OutlineW = (GetGlyphOutlineW_Proc)
GetProcAddress (hm_unicows, "GetGlyphOutlineW");
}
- if (s_pfn_Get_Glyph_OutlineW == NULL)
- abort (); /* cannot happen */
+ eassert (s_pfn_Get_Glyph_OutlineW != NULL);
return s_pfn_Get_Glyph_OutlineW (hdc, uChar, uFormat, lpgm, cbBuffer,
lpvBuffer, lpmat2);
}
Lisp_Object
intern_font_name (char * string)
{
- Lisp_Object obarray, tem, str;
- int len;
-
- str = DECODE_SYSTEM (build_string (string));
- len = SCHARS (str);
-
- /* The following code is copied from the function intern (in lread.c). */
- obarray = Vobarray;
- if (!VECTORP (obarray) || ASIZE (obarray) == 0)
- obarray = check_obarray (obarray);
- tem = oblookup (obarray, SDATA (str), len, len);
- if (SYMBOLP (tem))
- return tem;
- return Fintern (str, obarray);
+ Lisp_Object str = DECODE_SYSTEM (build_string (string));
+ int 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);
}
/* w32 implementation of get_cache for font backend.
Return a glyph code of FONT for character C (Unicode code point).
If FONT doesn't have such a glyph, return FONT_INVALID_CODE.
- For speed, the gdi backend uses unicode (Emacs calls encode_char
+ For speed, the gdi backend uses Unicode (Emacs calls encode_char
far too often for it to be efficient). But we still need to detect
which characters are not supported by the font.
*/
if (!w32_font->cached_metrics[block])
{
w32_font->cached_metrics[block]
- = xmalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
- memset (w32_font->cached_metrics[block], 0,
- CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
+ = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
}
char_metric = w32_font->cached_metrics[block] + pos_in_block;
total_width = size.cx;
}
- /* On 95/98/ME, only some unicode functions are available, so fallback
+ /* On 95/98/ME, only some Unicode functions are available, so fallback
on doing a dummy draw to find the total width. */
if (!total_width)
{
/* w32 implementation of draw for font backend.
Optional.
Draw glyphs between FROM and TO of S->char2b at (X Y) pixel
- position of frame F with S->FACE and S->GC. If WITH_BACKGROUND
- is nonzero, fill the background in advance. It is assured that
- WITH_BACKGROUND is zero when (FROM > 0 || TO < S->nchars).
+ position of frame F with S->FACE and S->GC. If WITH_BACKGROUND,
+ fill the background in advance. It is assured that WITH_BACKGROUND
+ is false when (FROM > 0 || TO < S->nchars).
TODO: Currently this assumes that the colors and fonts are already
set in the DC. This seems to be true now, but maybe only due to
int
w32font_draw (struct glyph_string *s, int from, int to,
- int x, int y, int with_background)
+ int x, int y, bool with_background)
{
UINT options;
HRGN orig_clip = NULL;
Optional.
Get coordinates of the INDEXth anchor point of the glyph whose
code is CODE. Store the coordinates in *X and *Y. Return 0 if
- the operations was successfull. Otherwise return -1.
+ the operations was successful. Otherwise return -1.
static int
w32font_anchor_point (struct font *font, unsigned code,
int index, int *x, int *y);
w32font_otf_drive (struct font *font, Lisp_Object features,
Lisp_Object gstring_in, int from, int to,
Lisp_Object gstring_out, int idx,
- int alternate_subst);
+ bool alternate_subst);
*/
/* Internal implementation of w32font_list.
font->space_width = font->average_width = w32_font->metrics.tmAveCharWidth;
font->vertical_centering = 0;
- font->encoding_type = 0;
font->baseline_offset = 0;
font->relative_compose = 0;
font->default_ascent = w32_font->metrics.tmAscent;
else
ASET (entity, FONT_SIZE_INDEX, make_number (0));
- /* Cache unicode codepoints covered by this font, as there is no other way
+ /* Cache Unicode codepoints covered by this font, as there is no other way
of getting this information easily. */
if (font_type & TRUETYPE_FONTTYPE)
{
currently appear in fontset.el, so it isn't worth
creating a mapping table of codepages/scripts to languages
or opening the font to see if there are any language tags
- in it that the W32 API does not expose. Fontset
+ in it that the Windows API does not expose. Fontset
spec should have a fallback, as some backends do
not recognize language at all. */
return 0;
return 1;
}
+#ifndef WINDOWSNT
+#define _strlwr strlwr
+#endif /* !WINDOWSNT */
static int
check_face_name (LOGFONT *font, char *full_name)
/* Skip non matching fonts. */
/* For uniscribe backend, consider only truetype or opentype fonts
- that have some unicode coverage. */
+ that have some Unicode coverage. */
if (match_data->opentype_only
&& ((!(physical_font->ntmTm.ntmFlags & NTMFLAGS_OPENTYPE)
&& !(font_type & TRUETYPE_FONTTYPE))
Lisp_Object spec_charset = AREF (match_data->orig_font_spec,
FONT_REGISTRY_INDEX);
- /* iso10646-1 fonts must contain unicode mapping tables. */
+ /* iso10646-1 fonts must contain Unicode mapping tables. */
if (EQ (spec_charset, Qiso10646_1))
{
if (!is_unicode)
&& !(physical_font->ntmFontSig.fsUsb[0] & 0x007F001F))
return 1;
}
- /* unicode-sip fonts must contain characters in unicode plane 2.
+ /* unicode-sip fonts must contain characters in Unicode plane 2.
so look for bit 57 (surrogates) in the Unicode subranges, plus
the bits for CJK ranges that include those characters. */
else if (EQ (spec_charset, Qunicode_sip))
ASET (entity, FONT_REGISTRY_INDEX, spec_charset);
}
/* Otherwise if using the uniscribe backend, report ANSI and DEFAULT
- fonts as unicode and skip other charsets. */
+ fonts as Unicode and skip other charsets. */
else if (match_data->opentype_only)
{
if (logical_font->elfLogFont.lfCharSet == ANSI_CHARSET
if (strncmp (lpcs, "*-#", 3) == 0)
return atoi (lpcs + 3);
- /* All Windows fonts qualify as unicode. */
+ /* All Windows fonts qualify as Unicode. */
if (!strncmp (lpcs, "iso10646", 8))
return DEFAULT_CHARSET;
{
char *charset;
- /* If charset is defaulted, charset is unicode or unknown, depending on
+ /* If charset is defaulted, charset is Unicode or unknown, depending on
font type. */
if (w32_charset == DEFAULT_CHARSET)
return font_type == TRUETYPE_FONTTYPE ? Qiso10646_1 : Qunknown;
/* Font families are interned, but allow for strings also in case of
user input. */
else if (SYMBOLP (tmp))
- strncpy (logfont->lfFaceName,
- SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE);
+ {
+ strncpy (logfont->lfFaceName,
+ SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE);
+ logfont->lfFaceName[LF_FACESIZE-1] = '\0';
+ }
}
tmp = AREF (font_spec, FONT_ADSTYLE_INDEX);
{
Lisp_Object key, val;
key = XCAR (tmp), val = XCDR (tmp);
- /* Only use QCscript if charset is not provided, or is unicode
+ /* Only use QCscript if charset is not provided, or is Unicode
and a single script is specified. This is rather crude,
and is only used to narrow down the fonts returned where
there is a definite match. Some scripts, such as latin, han,
DEFSYM (Qrunic, "runic");
DEFSYM (Qkhmer, "khmer");
DEFSYM (Qmongolian, "mongolian");
- DEFSYM (Qsymbol, "symbol");
DEFSYM (Qbraille, "braille");
DEFSYM (Qhan, "han");
DEFSYM (Qideographic_description, "ideographic-description");