82 |
#include "window.h" |
#include "window.h" |
83 |
#include "intervals.h" |
#include "intervals.h" |
84 |
#include "composite.h" |
#include "composite.h" |
85 |
|
#include "character.h" |
86 |
#include "coding.h" |
#include "coding.h" |
87 |
|
#include "ccl.h" |
88 |
|
|
89 |
/* Set of macros that handle mapping of Mac modifier keys to emacs. */ |
/* Set of macros that handle mapping of Mac modifier keys to emacs. */ |
90 |
#define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \ |
#define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \ |
1529 |
/* Function prototypes of this page. */ |
/* Function prototypes of this page. */ |
1530 |
|
|
1531 |
static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *)); |
static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *)); |
1532 |
static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, int *)); |
static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, |
1533 |
|
struct charset *, int *)); |
1534 |
|
|
1535 |
|
|
1536 |
/* Return a pointer to per-char metric information in FONT of a |
/* Return a pointer to per-char metric information in FONT of a |
1633 |
the two-byte form of C. Encoding is returned in *CHAR2B. */ |
the two-byte form of C. Encoding is returned in *CHAR2B. */ |
1634 |
|
|
1635 |
static int |
static int |
1636 |
mac_encode_char (c, char2b, font_info, two_byte_p) |
mac_encode_char (c, char2b, font_info, charset, two_byte_p) |
1637 |
int c; |
int c; |
1638 |
XChar2b *char2b; |
XChar2b *char2b; |
1639 |
struct font_info *font_info; |
struct font_info *font_info; |
1640 |
|
struct charset *charset; |
1641 |
int *two_byte_p; |
int *two_byte_p; |
1642 |
{ |
{ |
|
int charset = CHAR_CHARSET (c); |
|
1643 |
XFontStruct *font = font_info->font; |
XFontStruct *font = font_info->font; |
1644 |
|
|
1645 |
/* FONT_INFO may define a scheme by which to encode byte1 and byte2. |
/* FONT_INFO may define a scheme by which to encode byte1 and byte2. |
1652 |
|
|
1653 |
if (CHARSET_DIMENSION (charset) == 1) |
if (CHARSET_DIMENSION (charset) == 1) |
1654 |
{ |
{ |
1655 |
ccl->reg[0] = charset; |
ccl->reg[0] = CHARSET_ID (charset); |
1656 |
ccl->reg[1] = char2b->byte2; |
ccl->reg[1] = XCHAR2B_BYTE2 (char2b); |
1657 |
|
ccl->reg[2] = -1; |
1658 |
} |
} |
1659 |
else |
else |
1660 |
{ |
{ |
1661 |
ccl->reg[0] = charset; |
ccl->reg[0] = CHARSET_ID (charset); |
1662 |
ccl->reg[1] = char2b->byte1; |
ccl->reg[1] = XCHAR2B_BYTE1 (char2b); |
1663 |
ccl->reg[2] = char2b->byte2; |
ccl->reg[2] = XCHAR2B_BYTE2 (char2b); |
1664 |
} |
} |
1665 |
|
|
1666 |
ccl_driver (ccl, NULL, NULL, 0, 0, NULL); |
ccl_driver (ccl, NULL, NULL, 0, 0, NULL); |
1668 |
/* We assume that MSBs are appropriately set/reset by CCL |
/* We assume that MSBs are appropriately set/reset by CCL |
1669 |
program. */ |
program. */ |
1670 |
if (font->max_byte1 == 0) /* 1-byte font */ |
if (font->max_byte1 == 0) /* 1-byte font */ |
1671 |
char2b->byte1 = 0, char2b->byte2 = ccl->reg[1]; |
STORE_XCHAR2B (char2b, 0, ccl->reg[1]); |
1672 |
else |
else |
1673 |
char2b->byte1 = ccl->reg[1], char2b->byte2 = ccl->reg[2]; |
STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]); |
1674 |
} |
} |
1675 |
else if (font_info->encoding[charset]) |
else if (font_info->encoding_type) |
1676 |
{ |
{ |
1677 |
/* Fixed encoding scheme. See fontset.h for the meaning of the |
/* Fixed encoding scheme. See fontset.h for the meaning of the |
1678 |
encoding numbers. */ |
encoding numbers. */ |
1679 |
int enc = font_info->encoding[charset]; |
unsigned char enc = font_info->encoding_type; |
1680 |
|
|
1681 |
if ((enc == 1 || enc == 2) |
if ((enc == 1 || enc == 2) |
1682 |
&& CHARSET_DIMENSION (charset) == 2) |
&& CHARSET_DIMENSION (charset) == 2) |
1685 |
if (enc == 1 || enc == 3) |
if (enc == 1 || enc == 3) |
1686 |
char2b->byte2 |= 0x80; |
char2b->byte2 |= 0x80; |
1687 |
|
|
1688 |
|
/* |
1689 |
if (enc == 4) |
if (enc == 4) |
1690 |
{ |
{ |
1691 |
int sjis1, sjis2; |
int sjis1, sjis2; |
1694 |
char2b->byte1 = sjis1; |
char2b->byte1 = sjis1; |
1695 |
char2b->byte2 = sjis2; |
char2b->byte2 = sjis2; |
1696 |
} |
} |
1697 |
|
*/ |
1698 |
} |
} |
1699 |
|
|
1700 |
if (two_byte_p) |
if (two_byte_p) |
4949 |
register char *fontname; |
register char *fontname; |
4950 |
{ |
{ |
4951 |
struct font_info *fontp |
struct font_info *fontp |
4952 |
= FS_LOAD_FONT (f, 0, fontname, -1); |
= FS_LOAD_FONT (f, fontname); |
4953 |
|
|
4954 |
if (!fontp) |
if (!fontp) |
4955 |
return Qnil; |
return Qnil; |
4956 |
|
|
4957 |
|
if (FRAME_FONT (f) == (XFontStruct *) (fontp->font)) |
4958 |
|
/* This font is already set in frame F. There's nothing more to |
4959 |
|
do. */ |
4960 |
|
return build_string (fontp->full_name); |
4961 |
|
|
4962 |
FRAME_FONT (f) = (XFontStruct *) (fontp->font); |
FRAME_FONT (f) = (XFontStruct *) (fontp->font); |
4963 |
FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset; |
FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset; |
4964 |
FRAME_FONTSET (f) = -1; |
FRAME_FONTSET (f) = -1; |
5006 |
Lisp_Object |
Lisp_Object |
5007 |
x_new_fontset (f, fontsetname) |
x_new_fontset (f, fontsetname) |
5008 |
struct frame *f; |
struct frame *f; |
5009 |
char *fontsetname; |
Lisp_Object fontsetname; |
5010 |
{ |
{ |
5011 |
int fontset = fs_query_fontset (build_string (fontsetname), 0); |
int fontset = fs_query_fontset (fontsetname, 0); |
5012 |
Lisp_Object result; |
Lisp_Object result; |
5013 |
|
|
5014 |
if (fontset < 0) |
if (fontset > 0 && FRAME_FONTSET(f) == fontset) |
|
return Qnil; |
|
|
|
|
|
if (FRAME_FONTSET (f) == fontset) |
|
5015 |
/* This fontset is already set in frame F. There's nothing more |
/* This fontset is already set in frame F. There's nothing more |
5016 |
to do. */ |
to do. */ |
5017 |
return fontset_name (fontset); |
return fontset_name (fontset); |
5018 |
|
else if (fontset == 0) |
5019 |
|
/* The default fontset can't be the default font. */ |
5020 |
|
return Qt; |
5021 |
|
|
5022 |
result = x_new_font (f, (SDATA (fontset_ascii (fontset)))); |
if (fontset > 0) |
5023 |
|
result = x_new_font (f, (SDATA (fontset_ascii (fontset)))); |
5024 |
|
else |
5025 |
|
result = x_new_font (f, SDATA (fontsetname)); |
5026 |
|
|
5027 |
if (!STRINGP (result)) |
if (!STRINGP (result)) |
5028 |
/* Can't load ASCII font. */ |
/* Can't load ASCII font. */ |
5029 |
return Qnil; |
return Qnil; |
5030 |
|
|
5031 |
|
if (fontset < 0) |
5032 |
|
fontset = new_fontset_from_font_name (result); |
5033 |
|
|
5034 |
/* Since x_new_font doesn't update any fontset information, do it now. */ |
/* Since x_new_font doesn't update any fontset information, do it now. */ |
5035 |
FRAME_FONTSET(f) = fontset; |
FRAME_FONTSET(f) = fontset; |
5036 |
|
|
5037 |
return build_string (fontsetname); |
return fontset_name (fontset); |
5038 |
} |
} |
5039 |
|
|
5040 |
|
|
5873 |
return; |
return; |
5874 |
} |
} |
5875 |
|
|
5876 |
|
#if 0 |
5877 |
|
/* MAC_TODO: Fix encoding system... */ |
5878 |
setup_coding_system (coding_system, &coding); |
setup_coding_system (coding_system, &coding); |
5879 |
coding.src_multibyte = 0; |
coding.src_multibyte = 0; |
5880 |
coding.dst_multibyte = 1; |
coding.dst_multibyte = 1; |
5881 |
coding.mode |= CODING_MODE_LAST_BLOCK; |
coding.mode |= CODING_MODE_LAST_BLOCK; |
5882 |
coding.composing = COMPOSITION_DISABLED; |
coding.dst_bytes = MAX_MULTsize; |
5883 |
buf = (char *) alloca (size); |
coding.destination = (char *) alloca (size); |
5884 |
|
coding_decode_c_string(&coding, name, strlen(name), qNil); |
5885 |
|
|
5886 |
decode_coding (&coding, name, buf, strlen (name), size - 1); |
decode_coding (&coding, name, buf, strlen (name), size - 1); |
5887 |
bcopy (buf, name, coding.produced); |
bcopy (buf, name, coding.produced); |
5888 |
name[coding.produced] = '\0'; |
name[coding.produced] = '\0'; |
5889 |
|
#endif |
5890 |
} |
} |
5891 |
|
|
5892 |
|
|
5978 |
else |
else |
5979 |
sprintf (mf, "%s-%s-%s", foundry, family, cs); |
sprintf (mf, "%s-%s-%s", foundry, family, cs); |
5980 |
|
|
5981 |
|
#if 0 |
5982 |
|
/* MAC_TODO: Fix coding system to use objects */ |
5983 |
if (!NILP (coding_system)) |
if (!NILP (coding_system)) |
5984 |
{ |
{ |
5985 |
setup_coding_system (coding_system, &coding); |
setup_coding_system (coding_system, &coding); |
5989 |
encode_coding (&coding, family, mf, strlen (family), sizeof (Str32) - 1); |
encode_coding (&coding, family, mf, strlen (family), sizeof (Str32) - 1); |
5990 |
mf[coding.produced] = '\0'; |
mf[coding.produced] = '\0'; |
5991 |
} |
} |
5992 |
|
#endif |
5993 |
} |
} |
5994 |
|
|
5995 |
|
|
6765 |
fontp->height = max_height; |
fontp->height = max_height; |
6766 |
} |
} |
6767 |
|
|
6768 |
|
#if 0 /* MAC_TODO: fill these out with more reasonably values */ |
6769 |
|
|
6770 |
|
/* MAC_TODO: The script encoding is irrelevant in unicode? */ |
6771 |
/* The slot `encoding' specifies how to map a character |
/* The slot `encoding' specifies how to map a character |
6772 |
code-points (0x20..0x7F or 0x2020..0x7F7F) of each charset to |
code-points (0x20..0x7F or 0x2020..0x7F7F) of each charset to |
6773 |
the font code-points (0:0x20..0x7F, 1:0xA0..0xFF), or |
the font code-points (0:0x20..0x7F, 1:0xA0..0xFF), or |
6804 |
: 1))); /* 0xA0A0..0xFFFF */ |
: 1))); /* 0xA0A0..0xFFFF */ |
6805 |
} |
} |
6806 |
|
|
|
#if 0 /* MAC_TODO: fill these out with more reasonably values */ |
|
6807 |
fontp->baseline_offset |
fontp->baseline_offset |
6808 |
= (XGetFontProperty (font, dpyinfo->Xatom_MULE_BASELINE_OFFSET, &value) |
= (XGetFontProperty (font, dpyinfo->Xatom_MULE_BASELINE_OFFSET, &value) |
6809 |
? (long) value : 0); |
? (long) value : 0); |