Commit 57016d37 authored by Jason Rumney's avatar Jason Rumney
Browse files

* w32fns.c (x_to_w32_font, w32_to_x_font, x_to_w32_weight)

(w32_to_x_weight, w32_to_all_x_charsets): Remove obsolete functions.
(w32_to_x_charset, x_to_w32_charset)
(Qw32_charset_ansi, Qw32_charset_symbol, Qw32_charset_default)
(Qw32_charset_shiftjis, Qw32_charset_hangeul, Qw32_charset_johab)
(Qw32_charset_chinesebig5, Qw32_charset_gb2312, Qw32_charset_oem)
(Qw32_charset_easteurope, Qw32_charset_turkish, Qw32_charset_baltic)
(Qw32_charset_russian, Qw32_charset_arabic, Qw32_charset_greek)
(Qw32_charset_hebrew, Qw32_charset_vietnamese, Qw32_charset_thai)
(Qw32_charset_mac, Vw32_charset_info_alist): Move to w32font.c.
(Qw32_charset_unicode): Remove.
(syms_of_w32fns): Update for above changes.

* w32font.c (w32_to_x_charset, x_to_w32_charset)
(Qw32_charset_ansi, Qw32_charset_symbol, Qw32_charset_default)
(Qw32_charset_shiftjis, Qw32_charset_hangeul, Qw32_charset_johab)
(Qw32_charset_chinesebig5, Qw32_charset_gb2312, Qw32_charset_oem)
(Qw32_charset_easteurope, Qw32_charset_turkish, Qw32_charset_baltic)
(Qw32_charset_russian, Qw32_charset_arabic, Qw32_charset_greek)
(Qw32_charset_hebrew, Qw32_charset_vietnamese, Qw32_charset_thai)
(Qw32_charset_mac, Vw32_charset_info_alist): Move from w32fns.c.
(syms_of_w32font): Update for above changes.

* w32-fns.el (top-level): Unconditionally define all charsets.
parent 13ac2398
2008-06-27 Jason Rumney <jasonr@gnu.org>
* w32-fns.el (top-level): Unconditionally define all charsets.
2008-06-27 Alan Mackenzie <acm@muc.de>
* progmodes/cc-mode.el (c-mode-base-map): Don't bind C-M-[ae] to
......
......@@ -376,26 +376,22 @@ bit output with no translation."
(w32-add-charset-info "ms-symbol" 'w32-charset-symbol nil)
(w32-add-charset-info "ms-oem" 'w32-charset-oem 437)
(w32-add-charset-info "ms-oemlatin" 'w32-charset-oem 850)
(if (boundp 'w32-extra-charsets-defined)
(progn
(w32-add-charset-info "iso8859-2" 'w32-charset-easteurope 28592)
(w32-add-charset-info "iso8859-3" 'w32-charset-turkish 28593)
(w32-add-charset-info "iso8859-4" 'w32-charset-baltic 28594)
(w32-add-charset-info "iso8859-6" 'w32-charset-arabic 28596)
(w32-add-charset-info "iso8859-7" 'w32-charset-greek 28597)
(w32-add-charset-info "iso8859-8" 'w32-charset-hebrew 1255)
(w32-add-charset-info "iso8859-9" 'w32-charset-turkish 1254)
(w32-add-charset-info "iso8859-13" 'w32-charset-baltic 1257)
(w32-add-charset-info "koi8-r" 'w32-charset-russian 20866)
(w32-add-charset-info "iso8859-5" 'w32-charset-russian 28595)
(w32-add-charset-info "tis620" 'w32-charset-thai 874)
(w32-add-charset-info "windows-1258" 'w32-charset-vietnamese 1258)
(w32-add-charset-info "ksc5601.1992" 'w32-charset-johab 1361)
(w32-add-charset-info "mac-roman" 'w32-charset-mac 10000)))
(if (boundp 'w32-unicode-charset-defined)
(progn
(w32-add-charset-info "iso10646-1" 'w32-charset-unicode t))
(w32-add-charset-info "iso10646-1" 'w32-charset-default t))
(w32-add-charset-info "iso8859-2" 'w32-charset-easteurope 28592)
(w32-add-charset-info "iso8859-3" 'w32-charset-turkish 28593)
(w32-add-charset-info "iso8859-4" 'w32-charset-baltic 28594)
(w32-add-charset-info "iso8859-6" 'w32-charset-arabic 28596)
(w32-add-charset-info "iso8859-7" 'w32-charset-greek 28597)
(w32-add-charset-info "iso8859-8" 'w32-charset-hebrew 1255)
(w32-add-charset-info "iso8859-9" 'w32-charset-turkish 1254)
(w32-add-charset-info "iso8859-13" 'w32-charset-baltic 1257)
(w32-add-charset-info "koi8-r" 'w32-charset-russian 20866)
(w32-add-charset-info "iso8859-5" 'w32-charset-russian 28595)
(w32-add-charset-info "tis620" 'w32-charset-thai 874)
(w32-add-charset-info "windows-1258" 'w32-charset-vietnamese 1258)
(w32-add-charset-info "ksc5601.1992" 'w32-charset-johab 1361)
(w32-add-charset-info "mac-roman" 'w32-charset-mac 10000)))
(w32-add-charset-info "iso10646-1" 'w32-charset-default t))
;; ;; If unicode windows charset is not defined, use ansi fonts.
;; (w32-add-charset-info "iso10646-1" 'w32-charset-ansi t))
......
2008-06-27 Jason Rumney <jasonr@gnu.org>
* w32fns.c (x_to_w32_font, w32_to_x_font, x_to_w32_weight)
(w32_to_x_weight, w32_to_all_x_charsets): Remove obsolete functions.
(w32_to_x_charset, x_to_w32_charset)
(Qw32_charset_ansi, Qw32_charset_symbol, Qw32_charset_default)
(Qw32_charset_shiftjis, Qw32_charset_hangeul, Qw32_charset_johab)
(Qw32_charset_chinesebig5, Qw32_charset_gb2312, Qw32_charset_oem)
(Qw32_charset_easteurope, Qw32_charset_turkish, Qw32_charset_baltic)
(Qw32_charset_russian, Qw32_charset_arabic, Qw32_charset_greek)
(Qw32_charset_hebrew, Qw32_charset_vietnamese, Qw32_charset_thai)
(Qw32_charset_mac, Vw32_charset_info_alist): Move to w32font.c.
(Qw32_charset_unicode): Remove.
(syms_of_w32fns): Update for above changes.
* w32font.c (w32_to_x_charset, x_to_w32_charset)
(Qw32_charset_ansi, Qw32_charset_symbol, Qw32_charset_default)
(Qw32_charset_shiftjis, Qw32_charset_hangeul, Qw32_charset_johab)
(Qw32_charset_chinesebig5, Qw32_charset_gb2312, Qw32_charset_oem)
(Qw32_charset_easteurope, Qw32_charset_turkish, Qw32_charset_baltic)
(Qw32_charset_russian, Qw32_charset_arabic, Qw32_charset_greek)
(Qw32_charset_hebrew, Qw32_charset_vietnamese, Qw32_charset_thai)
(Qw32_charset_mac, Vw32_charset_info_alist): Move from w32fns.c.
(syms_of_w32font): Update for above changes.
2008-06-27 Dan Nicolaescu <dann@ics.uci.edu>
* s/usg5-4.h: Fix previous change: keep the correct branch of a
......@@ -20,12 +45,12 @@
* w32font.h (FONT_HANDLE, FONT_TEXTMETRIC): New macros.
* w32term.c (x_draw_glyph_string_foreground):
* w32term.c (x_draw_glyph_string_foreground)
(x_draw_composite_glyph_string_foreground): Sync with xterm.c.
Use FONT_HANDLE macro.
(x_draw_glyph_string): Use FONT_TEXTMETRIC macro.
* w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape):
* w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape)
(uniscribe_encode_char): Use FONT_HANDLE macro.
* w32font.c (Fx_select_font): Use FONT_HANDLE macro.
......@@ -65,10 +90,10 @@
(w32font_open_internal): Remove compat code. Set new hfont member.
(Fx_select_font): Use new hfont member.
* w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape):
* w32uniscribe.c (uniscribe_otf_capability, uniscribe_shape)
(uniscribe_encode_char): Use new hfont member.
* w32term.c (x_draw_glyph_string_foreground):
* w32term.c (x_draw_glyph_string_foreground)
(x_draw_composite_glyph_string_foreground): Use new hfont member.
(x_draw_glyph_string): Use metrics in w32font_info.
......
This diff is collapsed.
......@@ -43,6 +43,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define CLEARTYPE_NATURAL_QUALITY 6
#endif
/* VIETNAMESE_CHARSET and JOHAB_CHARSET are not defined in some versions
of MSVC headers. */
#ifndef VIETNAMESE_CHARSET
#define VIETNAMESE_CHARSET 163
#endif
#ifndef JOHAB_CHARSET
#define JOHAB_CHARSET 130
#endif
extern struct font_driver w32font_driver;
Lisp_Object Qgdi;
......@@ -80,6 +89,20 @@ static Lisp_Object Qtagalog, Qtagbanwa, Qtai_le, Qtifinagh, Qugaritic;
/* Only defined here, but useful for distinguishing IPA capable fonts. */
static Lisp_Object Qphonetic;
/* 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;
/* Associative list linking character set strings to Windows codepages. */
static Lisp_Object Vw32_charset_info_alist;
/* Font spacing symbols - defined in font.c. */
extern Lisp_Object Qc, Qp, Qm;
......@@ -129,9 +152,6 @@ struct font_callback_data
style variations if the font name is not specified. */
static void list_all_matching_fonts P_ ((struct font_callback_data *));
/* From old font code in w32fns.c */
char * w32_to_x_charset P_ ((int, char *));
static int
memq_no_quit (elt, list)
......@@ -1425,6 +1445,89 @@ add_one_font_entity_to_list (logical_font, physical_font, font_type, lParam)
return !NILP (match_data->list);
}
/* Old function to convert from x to w32 charset, from w32fns.c. */
static LONG
x_to_w32_charset (lpcs)
char * lpcs;
{
Lisp_Object this_entry, w32_charset;
char *charset;
int len = strlen (lpcs);
/* Support "*-#nnn" format for unknown charsets. */
if (strncmp (lpcs, "*-#", 3) == 0)
return atoi (lpcs + 3);
/* All Windows fonts qualify as unicode. */
if (!strncmp (lpcs, "iso10646", 8))
return DEFAULT_CHARSET;
/* Handle wildcards by ignoring them; eg. treat "big5*-*" as "big5". */
charset = alloca (len + 1);
strcpy (charset, lpcs);
lpcs = strchr (charset, '*');
if (lpcs)
*lpcs = '\0';
/* Look through w32-charset-info-alist for the character set.
Format of each entry is
(CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
*/
this_entry = Fassoc (build_string (charset), Vw32_charset_info_alist);
if (NILP (this_entry))
{
/* At startup, we want iso8859-1 fonts to come up properly. */
if (xstrcasecmp (charset, "iso8859-1") == 0)
return ANSI_CHARSET;
else
return DEFAULT_CHARSET;
}
w32_charset = Fcar (Fcdr (this_entry));
/* Translate Lisp symbol to number. */
if (EQ (w32_charset, Qw32_charset_ansi))
return ANSI_CHARSET;
if (EQ (w32_charset, Qw32_charset_symbol))
return SYMBOL_CHARSET;
if (EQ (w32_charset, Qw32_charset_shiftjis))
return SHIFTJIS_CHARSET;
if (EQ (w32_charset, Qw32_charset_hangeul))
return HANGEUL_CHARSET;
if (EQ (w32_charset, Qw32_charset_chinesebig5))
return CHINESEBIG5_CHARSET;
if (EQ (w32_charset, Qw32_charset_gb2312))
return GB2312_CHARSET;
if (EQ (w32_charset, Qw32_charset_oem))
return OEM_CHARSET;
if (EQ (w32_charset, Qw32_charset_johab))
return JOHAB_CHARSET;
if (EQ (w32_charset, Qw32_charset_easteurope))
return EASTEUROPE_CHARSET;
if (EQ (w32_charset, Qw32_charset_turkish))
return TURKISH_CHARSET;
if (EQ (w32_charset, Qw32_charset_baltic))
return BALTIC_CHARSET;
if (EQ (w32_charset, Qw32_charset_russian))
return RUSSIAN_CHARSET;
if (EQ (w32_charset, Qw32_charset_arabic))
return ARABIC_CHARSET;
if (EQ (w32_charset, Qw32_charset_greek))
return GREEK_CHARSET;
if (EQ (w32_charset, Qw32_charset_hebrew))
return HEBREW_CHARSET;
if (EQ (w32_charset, Qw32_charset_vietnamese))
return VIETNAMESE_CHARSET;
if (EQ (w32_charset, Qw32_charset_thai))
return THAI_CHARSET;
if (EQ (w32_charset, Qw32_charset_mac))
return MAC_CHARSET;
return DEFAULT_CHARSET;
}
/* Convert a Lisp font registry (symbol) to a windows charset. */
static LONG
registry_to_w32_charset (charset)
......@@ -1441,6 +1544,203 @@ registry_to_w32_charset (charset)
return DEFAULT_CHARSET;
}
/* Old function to convert from w32 to x charset, from w32fns.c. */
static char *
w32_to_x_charset (fncharset, matching)
int fncharset;
char *matching;
{
static char buf[32];
Lisp_Object charset_type;
int match_len = 0;
if (matching)
{
/* If fully specified, accept it as it is. Otherwise use a
substring match. */
char *wildcard = strchr (matching, '*');
if (wildcard)
*wildcard = '\0';
else if (strchr (matching, '-'))
return matching;
match_len = strlen (matching);
}
switch (fncharset)
{
case ANSI_CHARSET:
/* Handle startup case of w32-charset-info-alist not
being set up yet. */
if (NILP (Vw32_charset_info_alist))
return "iso8859-1";
charset_type = Qw32_charset_ansi;
break;
case DEFAULT_CHARSET:
charset_type = Qw32_charset_default;
break;
case SYMBOL_CHARSET:
charset_type = Qw32_charset_symbol;
break;
case SHIFTJIS_CHARSET:
charset_type = Qw32_charset_shiftjis;
break;
case HANGEUL_CHARSET:
charset_type = Qw32_charset_hangeul;
break;
case GB2312_CHARSET:
charset_type = Qw32_charset_gb2312;
break;
case CHINESEBIG5_CHARSET:
charset_type = Qw32_charset_chinesebig5;
break;
case OEM_CHARSET:
charset_type = Qw32_charset_oem;
break;
case EASTEUROPE_CHARSET:
charset_type = Qw32_charset_easteurope;
break;
case TURKISH_CHARSET:
charset_type = Qw32_charset_turkish;
break;
case BALTIC_CHARSET:
charset_type = Qw32_charset_baltic;
break;
case RUSSIAN_CHARSET:
charset_type = Qw32_charset_russian;
break;
case ARABIC_CHARSET:
charset_type = Qw32_charset_arabic;
break;
case GREEK_CHARSET:
charset_type = Qw32_charset_greek;
break;
case HEBREW_CHARSET:
charset_type = Qw32_charset_hebrew;
break;
case VIETNAMESE_CHARSET:
charset_type = Qw32_charset_vietnamese;
break;
case THAI_CHARSET:
charset_type = Qw32_charset_thai;
break;
case MAC_CHARSET:
charset_type = Qw32_charset_mac;
break;
case JOHAB_CHARSET:
charset_type = Qw32_charset_johab;
break;
default:
/* Encode numerical value of unknown charset. */
sprintf (buf, "*-#%u", fncharset);
return buf;
}
{
Lisp_Object rest;
char * best_match = NULL;
int matching_found = 0;
/* Look through w32-charset-info-alist for the character set.
Prefer ISO codepages, and prefer lower numbers in the ISO
range. Only return charsets for codepages which are installed.
Format of each entry is
(CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
*/
for (rest = Vw32_charset_info_alist; CONSP (rest); rest = XCDR (rest))
{
char * x_charset;
Lisp_Object w32_charset;
Lisp_Object codepage;
Lisp_Object this_entry = XCAR (rest);
/* Skip invalid entries in alist. */
if (!CONSP (this_entry) || !STRINGP (XCAR (this_entry))
|| !CONSP (XCDR (this_entry))
|| !SYMBOLP (XCAR (XCDR (this_entry))))
continue;
x_charset = SDATA (XCAR (this_entry));
w32_charset = XCAR (XCDR (this_entry));
codepage = XCDR (XCDR (this_entry));
/* 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))))
{
/* If we don't have a match already, then this is the
best. */
if (!best_match)
{
best_match = x_charset;
if (matching && !strnicmp (x_charset, matching, match_len))
matching_found = 1;
}
/* If we already found a match for MATCHING, then
only consider other matches. */
else if (matching_found
&& strnicmp (x_charset, matching, match_len))
continue;
/* If this matches what we want, and the best so far doesn't,
then this is better. */
else if (!matching_found && matching
&& !strnicmp (x_charset, matching, match_len))
{
best_match = x_charset;
matching_found = 1;
}
/* If this is fully specified, and the best so far isn't,
then this is better. */
else if ((!strchr (best_match, '-') && strchr (x_charset, '-'))
/* If this is an ISO codepage, and the best so far isn't,
then this is better, but only if it fully specifies the
encoding. */
|| (strnicmp (best_match, "iso", 3) != 0
&& strnicmp (x_charset, "iso", 3) == 0
&& strchr (x_charset, '-')))
best_match = x_charset;
/* If both are ISO8859 codepages, choose the one with the
lowest number in the encoding field. */
else if (strnicmp (best_match, "iso8859-", 8) == 0
&& strnicmp (x_charset, "iso8859-", 8) == 0)
{
int best_enc = atoi (best_match + 8);
int this_enc = atoi (x_charset + 8);
if (this_enc > 0 && this_enc < best_enc)
best_match = x_charset;
}
}
}
/* If no match, encode the numeric value. */
if (!best_match)
{
sprintf (buf, "*-#%u", fncharset);
return buf;
}
strncpy (buf, best_match, 31);
/* If the charset is not fully specified, put -0 on the end. */
if (!strchr (best_match, '-'))
{
int pos = strlen (best_match);
/* Charset specifiers shouldn't be very long. If it is a made
up one, truncating it should not do any harm since it isn't
recognized anyway. */
if (pos > 29)
pos = 29;
strcpy (buf + pos, "-0");
}
buf[31] = '\0';
return buf;
}
}
static Lisp_Object
w32_registry (w32_charset, font_type)
LONG w32_charset;
......@@ -2218,6 +2518,51 @@ syms_of_w32font ()
DEFSYM (Qtifinagh, "tifinagh");
DEFSYM (Qugaritic, "ugaritic");
/* W32 font encodings. */
DEFVAR_LISP ("w32-charset-info-alist",
&Vw32_charset_info_alist,
doc: /* Alist linking Emacs character sets to Windows fonts and codepages.
Each entry should be of the form:
(CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE))
where CHARSET_NAME is a string used in font names to identify the charset,
WINDOWS_CHARSET is a symbol that can be one of:
w32-charset-ansi, w32-charset-default, w32-charset-symbol,
w32-charset-shiftjis, w32-charset-hangeul, w32-charset-gb2312,
w32-charset-chinesebig5, w32-charset-johab, w32-charset-hebrew,
w32-charset-arabic, w32-charset-greek, w32-charset-turkish,
w32-charset-vietnamese, w32-charset-thai, w32-charset-easteurope,
w32-charset-russian, w32-charset-mac, w32-charset-baltic,
or w32-charset-oem.
CODEPAGE should be an integer specifying the codepage that should be used
to display the character set, t to do no translation and output as Unicode,
or nil to do no translation and output as 8 bit (or multibyte on far-east
versions of Windows) characters. */);
Vw32_charset_info_alist = Qnil;
DEFSYM (Qw32_charset_ansi, "w32-charset-ansi");
DEFSYM (Qw32_charset_symbol, "w32-charset-symbol");
DEFSYM (Qw32_charset_default, "w32-charset-default");
DEFSYM (Qw32_charset_shiftjis, "w32-charset-shiftjis");
DEFSYM (Qw32_charset_hangeul, "w32-charset-hangeul");
DEFSYM (Qw32_charset_chinesebig5, "w32-charset-chinesebig5");
DEFSYM (Qw32_charset_gb2312, "w32-charset-gb2312");
DEFSYM (Qw32_charset_oem, "w32-charset-oem");
DEFSYM (Qw32_charset_johab, "w32-charset-johab");
DEFSYM (Qw32_charset_easteurope, "w32-charset-easteurope");
DEFSYM (Qw32_charset_turkish, "w32-charset-turkish");
DEFSYM (Qw32_charset_baltic, "w32-charset-baltic");
DEFSYM (Qw32_charset_russian, "w32-charset-russian");
DEFSYM (Qw32_charset_arabic, "w32-charset-arabic");
DEFSYM (Qw32_charset_greek, "w32-charset-greek");
DEFSYM (Qw32_charset_hebrew, "w32-charset-hebrew");
DEFSYM (Qw32_charset_vietnamese, "w32-charset-vietnamese");
DEFSYM (Qw32_charset_thai, "w32-charset-thai");
DEFSYM (Qw32_charset_mac, "w32-charset-mac");
defsubr (&Sx_select_font);
w32font_driver.type = Qgdi;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment