1921 |
}; |
}; |
1922 |
|
|
1923 |
|
|
1924 |
/* Create an X fontset on frame F with base font name |
/* Create an X fontset on frame F with base font name BASE_FONTNAME. */ |
|
BASE_FONTNAME.. */ |
|
1925 |
|
|
1926 |
static XFontSet |
static XFontSet |
1927 |
xic_create_xfontset (f, base_fontname) |
xic_create_xfontset (f, base_fontname) |
1928 |
struct frame *f; |
struct frame *f; |
1929 |
char *base_fontname; |
char *base_fontname; |
1930 |
{ |
{ |
1931 |
XFontSet xfs; |
XFontSet xfs = NULL; |
1932 |
char **missing_list; |
char **missing_list; |
1933 |
int missing_count; |
int missing_count; |
1934 |
char *def_string; |
char *def_string; |
1935 |
|
Lisp_Object rest, frame; |
1936 |
|
|
1937 |
xfs = XCreateFontSet (FRAME_X_DISPLAY (f), |
/* See if there is another frame already using same fontset. */ |
1938 |
base_fontname, &missing_list, |
FOR_EACH_FRAME (rest, frame) |
1939 |
&missing_count, &def_string); |
{ |
1940 |
|
struct frame *cf = XFRAME (frame); |
1941 |
|
if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf) |
1942 |
|
&& FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f) |
1943 |
|
&& !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname)) |
1944 |
|
{ |
1945 |
|
xfs = FRAME_XIC_FONTSET (cf); |
1946 |
|
break; |
1947 |
|
} |
1948 |
|
} |
1949 |
|
|
1950 |
|
if (!xfs) |
1951 |
|
/* New fontset. */ |
1952 |
|
xfs = XCreateFontSet (FRAME_X_DISPLAY (f), |
1953 |
|
base_fontname, &missing_list, |
1954 |
|
&missing_count, &def_string); |
1955 |
if (missing_list) |
if (missing_list) |
1956 |
XFreeStringList (missing_list); |
XFreeStringList (missing_list); |
1957 |
|
|
1958 |
/* No need to free def_string. */ |
if (FRAME_XIC_BASE_FONTNAME (f)) |
1959 |
|
xfree (FRAME_XIC_BASE_FONTNAME (f)); |
1960 |
|
FRAME_XIC_BASE_FONTNAME (f) = xstrdup (base_fontname); |
1961 |
|
|
1962 |
|
/* No need to free def_string. */ |
1963 |
return xfs; |
return xfs; |
1964 |
} |
} |
1965 |
|
|
1966 |
|
/* Free the X fontset of frame F if it is the last frame using it. */ |
1967 |
|
|
1968 |
|
void |
1969 |
|
xic_free_xfontset (f) |
1970 |
|
struct frame *f; |
1971 |
|
{ |
1972 |
|
Lisp_Object rest, frame; |
1973 |
|
int shared_p = 0; |
1974 |
|
|
1975 |
|
if (!FRAME_XIC_FONTSET (f)) |
1976 |
|
return; |
1977 |
|
|
1978 |
|
/* See if there is another frame sharing the same fontset. */ |
1979 |
|
FOR_EACH_FRAME (rest, frame) |
1980 |
|
{ |
1981 |
|
struct frame *cf = XFRAME (frame); |
1982 |
|
if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf) |
1983 |
|
&& FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f) |
1984 |
|
&& FRAME_XIC_FONTSET (cf) == FRAME_XIC_FONTSET (f)) |
1985 |
|
{ |
1986 |
|
shared_p = 1; |
1987 |
|
break; |
1988 |
|
} |
1989 |
|
} |
1990 |
|
|
1991 |
|
if (!shared_p) |
1992 |
|
/* The fontset is not used anymore. It is safe to free it. */ |
1993 |
|
XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f)); |
1994 |
|
|
1995 |
|
if (FRAME_XIC_BASE_FONTNAME (f)) |
1996 |
|
xfree (FRAME_XIC_BASE_FONTNAME (f)); |
1997 |
|
FRAME_XIC_BASE_FONTNAME (f) = NULL; |
1998 |
|
FRAME_XIC_FONTSET (f) = NULL; |
1999 |
|
} |
2000 |
|
|
2001 |
|
|
2002 |
/* Value is the best input style, given user preferences USER (already |
/* Value is the best input style, given user preferences USER (already |
2003 |
checked to be supported by Emacs), and styles supported by the |
checked to be supported by Emacs), and styles supported by the |
2148 |
return; |
return; |
2149 |
|
|
2150 |
XDestroyIC (FRAME_XIC (f)); |
XDestroyIC (FRAME_XIC (f)); |
2151 |
if (FRAME_XIC_FONTSET (f)) |
xic_free_xfontset (f); |
|
XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f)); |
|
2152 |
|
|
2153 |
FRAME_XIC (f) = NULL; |
FRAME_XIC (f) = NULL; |
|
FRAME_XIC_FONTSET (f) = NULL; |
|
2154 |
} |
} |
2155 |
|
|
2156 |
|
|
2229 |
XVaNestedList attr; |
XVaNestedList attr; |
2230 |
XFontSet xfs; |
XFontSet xfs; |
2231 |
|
|
2232 |
|
xic_free_xfontset (f); |
2233 |
|
|
2234 |
xfs = xic_create_xfontset (f, base_fontname); |
xfs = xic_create_xfontset (f, base_fontname); |
2235 |
|
|
2236 |
attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL); |
attr = XVaCreateNestedList (0, XNFontSet, xfs, NULL); |
2240 |
XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL); |
XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL); |
2241 |
XFree (attr); |
XFree (attr); |
2242 |
|
|
|
if (FRAME_XIC_FONTSET (f)) |
|
|
XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f)); |
|
2243 |
FRAME_XIC_FONTSET (f) = xfs; |
FRAME_XIC_FONTSET (f) = xfs; |
2244 |
} |
} |
2245 |
|
|