| 1922 | | mw32_strict_logical_font_loader(MW32FontRequest *pfr, |
|---|
| 1923 | | struct frame *f, |
|---|
| 1924 | | struct face *face, |
|---|
| 1925 | | int c) |
|---|
| 1926 | | { |
|---|
| 1927 | | MW32LogicalFont *plf; |
|---|
| 1928 | | Lisp_Object *attrs; |
|---|
| 1929 | | Lisp_Object alist, specs, tem, spec, logfont, option; |
|---|
| 1930 | | |
|---|
| 1931 | | if (face) |
|---|
| 1932 | | attrs = face->lface; |
|---|
| | 1921 | mw32_load_strict_spec (Lisp_Object val, |
|---|
| | 1922 | MW32FontRequest *pfr, |
|---|
| | 1923 | struct frame *f, |
|---|
| | 1924 | int c) |
|---|
| | 1925 | { |
|---|
| | 1926 | Lisp_Object logfont, option; |
|---|
| | 1927 | |
|---|
| | 1928 | if (!CONSP (val)) return NULL; |
|---|
| | 1929 | |
|---|
| | 1930 | logfont = XCAR (val); |
|---|
| | 1931 | val = XCDR (val); |
|---|
| | 1932 | |
|---|
| | 1933 | if (CONSP (val) && CONSP (XCAR (val))) |
|---|
| | 1934 | option = XCAR (val); |
|---|
| 1934 | | attrs = face_unspecified_attrs; |
|---|
| 1935 | | |
|---|
| 1936 | | alist = AREF(Vmw32_font_request_table, pfr->idx); |
|---|
| 1937 | | specs = assq_no_quit(Qstrict_spec, alist); |
|---|
| 1938 | | for (;CONSP (specs);specs = XCDR (specs)) |
|---|
| 1939 | | { |
|---|
| 1940 | | tem = XCAR (specs); |
|---|
| 1941 | | if (!CONSP (tem)) continue; |
|---|
| 1942 | | spec = XCAR (tem); |
|---|
| 1943 | | if (!VECTORP (spec)) continue; |
|---|
| 1944 | | tem = XCDR (tem); |
|---|
| 1945 | | if (!CONSP (tem)) continue; |
|---|
| 1946 | | logfont = XCAR (tem); |
|---|
| 1947 | | tem = XCDR (tem); |
|---|
| 1948 | | |
|---|
| 1949 | | if (CONSP (tem) && CONSP (XCAR (tem))) |
|---|
| 1950 | | option = XCAR (tem); |
|---|
| 1951 | | else option = Qnil; |
|---|
| 1952 | | |
|---|
| 1953 | | if (!mw32_fr_spec_match_p (spec, attrs, c)) continue; |
|---|
| 1954 | | plf = mw32_load_lf_from_lisp_object(f, pfr, logfont, option, c); |
|---|
| 1955 | | if (plf) return plf; |
|---|
| 1956 | | } |
|---|
| 1957 | | |
|---|
| 1958 | | return NULL; |
|---|
| | 1936 | option = Qnil; |
|---|
| | 1937 | |
|---|
| | 1938 | return mw32_load_lf_from_lisp_object(f, pfr, logfont, option, c); |
|---|
| | 1939 | } |
|---|
| | 1940 | |
|---|
| | 1941 | /* val is (<func>) */ |
|---|
| | 1942 | static MW32LogicalFont* |
|---|
| | 1943 | mw32_load_function_spec (Lisp_Object val, |
|---|
| | 1944 | MW32FontRequest *pfr, |
|---|
| | 1945 | struct frame *f, |
|---|
| | 1946 | int c, |
|---|
| | 1947 | Lisp_Object face_attrs) |
|---|
| | 1948 | { |
|---|
| | 1949 | Lisp_Object func, result, logfont, option; |
|---|
| | 1950 | Lisp_Object args[4]; |
|---|
| | 1951 | |
|---|
| | 1952 | if (!CONSP (val)) return NULL; |
|---|
| | 1953 | |
|---|
| | 1954 | func = XCAR (val); |
|---|
| | 1955 | if (!FUNCTIONP (func)) return NULL; |
|---|
| | 1956 | val = XCDR (val); |
|---|
| | 1957 | |
|---|
| | 1958 | args[0] = func; |
|---|
| | 1959 | args[1] = make_number(c); |
|---|
| | 1960 | args[2] = face_attrs; |
|---|
| | 1961 | XSETFRAME (args[3], f); |
|---|
| | 1962 | |
|---|
| | 1963 | result = safe_call (4, args); |
|---|
| | 1964 | if (!CONSP(result)) return NULL; |
|---|
| | 1965 | |
|---|
| | 1966 | option = Qnil; |
|---|
| | 1967 | logfont = CAR (result); |
|---|
| | 1968 | if (!CONSP (logfont)) |
|---|
| | 1969 | { |
|---|
| | 1970 | logfont = result; |
|---|
| | 1971 | if (CONSP (val)) option = XCAR(val); |
|---|
| | 1972 | } |
|---|
| | 1973 | else |
|---|
| | 1974 | { |
|---|
| | 1975 | option = CAR (CDR (result)); |
|---|
| | 1976 | } |
|---|
| | 1977 | if ((!NILP (option)) && (!CONSP (option))) return NULL; |
|---|
| | 1978 | |
|---|
| | 1979 | return mw32_load_lf_from_lisp_object (f, pfr, logfont, option, c); |
|---|
| 1994 | | func = assq_no_quit(Qfunction, alist); |
|---|
| 1995 | | if (!CONSP(func)) return NULL; |
|---|
| 1996 | | func = CDR (func); |
|---|
| 1997 | | if (!FUNCTIONP(func)) return NULL; |
|---|
| 1998 | | face_attrs = mw32_convert_face_attrs(attrs); |
|---|
| 1999 | | |
|---|
| 2000 | | /* (lambda (char face-attrs frame)) */ |
|---|
| 2001 | | args[0] = func; |
|---|
| 2002 | | args[1] = make_number(c); |
|---|
| 2003 | | args[2] = face_attrs; |
|---|
| 2004 | | XSETFRAME(frame, f); |
|---|
| 2005 | | args[3] = frame; |
|---|
| 2006 | | |
|---|
| 2007 | | result = safe_call (4, args); |
|---|
| 2008 | | if (!CONSP(result)) return NULL; |
|---|
| 2009 | | option = Qnil; |
|---|
| 2010 | | logfont = CAR (result); |
|---|
| 2011 | | if (!CONSP(logfont)) logfont = result; |
|---|
| 2012 | | else option = CAR (CDR (result)); |
|---|
| 2013 | | if ((!NILP (option)) && (!CONSP (option))) return NULL; |
|---|
| 2014 | | |
|---|
| 2015 | | plf = mw32_load_lf_from_lisp_object(f, pfr, logfont, option, c); |
|---|
| 2016 | | |
|---|
| | 2022 | specs = assq_no_quit(Qspec, alist); |
|---|
| | 2023 | if (!CONSP (specs)) return NULL; |
|---|
| | 2024 | specs = XCDR (specs); |
|---|
| | 2025 | GCPRO2 (specs, face_attrs); |
|---|
| | 2026 | |
|---|
| | 2027 | plf = NULL; |
|---|
| | 2028 | for (; CONSP (specs); specs = XCDR (specs)) |
|---|
| | 2029 | { |
|---|
| | 2030 | tem = XCAR (specs); |
|---|
| | 2031 | if (!CONSP (tem)) continue; |
|---|
| | 2032 | spec = XCAR (tem); |
|---|
| | 2033 | if (!VECTORP (spec)) continue; |
|---|
| | 2034 | if (!mw32_fr_spec_match_p (spec, attrs, c)) continue; |
|---|
| | 2035 | |
|---|
| | 2036 | tem = XCDR (tem); |
|---|
| | 2037 | if (!CONSP (tem)) continue; |
|---|
| | 2038 | type = XCAR (tem); |
|---|
| | 2039 | tem = XCDR (tem); |
|---|
| | 2040 | |
|---|
| | 2041 | if (EQ (type, Qstrict)) |
|---|
| | 2042 | plf = mw32_load_strict_spec(tem, pfr, f, c); |
|---|
| | 2043 | else if (EQ (type, Qfunction)) |
|---|
| | 2044 | plf = mw32_load_function_spec(tem, pfr, f, c, face_attrs); |
|---|
| | 2045 | |
|---|
| | 2046 | if (plf) break; |
|---|
| | 2047 | } |
|---|
| | 2048 | |
|---|
| | 2049 | UNGCPRO; |
|---|
| | 2217 | mw32_check_font_option (Lisp_Object option) |
|---|
| | 2218 | { |
|---|
| | 2219 | Lisp_Object encoding, relative_compose, default_ascent; |
|---|
| | 2220 | Lisp_Object centering, spacing; |
|---|
| | 2221 | |
|---|
| | 2222 | encoding = mw32_get_font_request_parameter (Qencoding, option); |
|---|
| | 2223 | if (!NILP (encoding) && (!mw32_valid_encoding_p (encoding))) |
|---|
| | 2224 | Fsignal (Qerror, Fcons (build_string ("Invalid encoding"), |
|---|
| | 2225 | Fcons (encoding, Qnil))); |
|---|
| | 2226 | |
|---|
| | 2227 | relative_compose = mw32_get_font_request_parameter (Qrelative_compose, |
|---|
| | 2228 | option); |
|---|
| | 2229 | if (!NILP (relative_compose)) CHECK_NUMBER (relative_compose, 0); |
|---|
| | 2230 | |
|---|
| | 2231 | default_ascent = mw32_get_font_request_parameter (Qdefault_ascent, |
|---|
| | 2232 | option); |
|---|
| | 2233 | if (!NILP (default_ascent)) CHECK_NUMBER (default_ascent, 1); |
|---|
| | 2234 | |
|---|
| | 2235 | spacing = mw32_get_font_request_parameter (Qspacing, option); |
|---|
| | 2236 | if (!NILP (spacing)) CHECK_NUMBER (spacing, 2); |
|---|
| | 2237 | |
|---|
| | 2238 | centering = mw32_get_font_request_parameter (Qcentering, option); |
|---|
| | 2239 | /* needless to check centering */ |
|---|
| | 2240 | } |
|---|
| | 2241 | |
|---|
| | 2242 | static void |
|---|
| 2186 | | Lisp_Object width, height, base, overhang, encoding; |
|---|
| 2187 | | Lisp_Object relative_compose, default_ascent, encoder; |
|---|
| 2188 | | Lisp_Object spacing, dim, centering; |
|---|
| 2189 | | Lisp_Object fr, spec, logfont, option, tem; |
|---|
| 2190 | | |
|---|
| 2191 | | |
|---|
| 2192 | | /* check strict-spec */ |
|---|
| 2193 | | fr = assq_no_quit (Qstrict_spec, alist); |
|---|
| | 2245 | Lisp_Object fr, spec, type, logfont, func, tem; |
|---|
| | 2246 | |
|---|
| | 2247 | /* check spec */ |
|---|
| | 2248 | fr = assq_no_quit (Qspec, alist); |
|---|
| 2216 | | if (!CONSP (tem)) |
|---|
| 2217 | | continue; |
|---|
| 2218 | | option = XCAR (tem); |
|---|
| 2219 | | |
|---|
| 2220 | | encoding = mw32_get_font_request_parameter (Qencoding, option); |
|---|
| 2221 | | if (!NILP (encoding) && (!mw32_valid_encoding_p (encoding))) |
|---|
| 2222 | | Fsignal (Qerror, Fcons (build_string ("Invalid encoding"), |
|---|
| 2223 | | Fcons (encoding, Qnil))); |
|---|
| 2224 | | |
|---|
| 2225 | | relative_compose = mw32_get_font_request_parameter (Qrelative_compose, |
|---|
| 2226 | | option); |
|---|
| 2227 | | if (!NILP (relative_compose)) CHECK_NUMBER (relative_compose, 0); |
|---|
| 2228 | | |
|---|
| 2229 | | default_ascent = mw32_get_font_request_parameter (Qdefault_ascent, |
|---|
| 2230 | | option); |
|---|
| 2231 | | if (!NILP (default_ascent)) CHECK_NUMBER (default_ascent, 1); |
|---|
| 2232 | | |
|---|
| 2233 | | spacing = mw32_get_font_request_parameter (Qspacing, option); |
|---|
| 2234 | | if (!NILP (spacing)) CHECK_NUMBER (spacing, 2); |
|---|
| 2235 | | |
|---|
| 2236 | | centering = mw32_get_font_request_parameter (Qcentering, option); |
|---|
| 2237 | | /* needless to check centering */ |
|---|
| 2238 | | } |
|---|
| 2239 | | |
|---|
| 2240 | | /* check function */ |
|---|
| 2241 | | fr = assq_no_quit (Qfunction, alist); |
|---|
| 2242 | | if (CONSP (fr)) |
|---|
| 2243 | | { |
|---|
| 2244 | | Lisp_Object func = CDR (fr); |
|---|
| 2245 | | if (!FUNCTIONP (func)) |
|---|
| 2246 | | Fsignal (Qerror, Fcons (build_string ("Invalid function"), |
|---|
| 2247 | | Fcons (func, Qnil))); |
|---|
| | 2270 | if (EQ (type, Qstrict)) |
|---|
| | 2271 | { |
|---|
| | 2272 | if (!CONSP (tem)) |
|---|
| | 2273 | Fsignal (Qerror, Fcons (build_string ("Invalid font strict spec value"), |
|---|
| | 2274 | Fcons (tem, Qnil))); |
|---|
| | 2275 | logfont = XCAR (tem); |
|---|
| | 2276 | if (!check_lisp_object_logfont (logfont, 1)) |
|---|
| | 2277 | { |
|---|
| | 2278 | Fsignal (Qerror, Fcons (build_string ("Invalid logfont"), |
|---|
| | 2279 | Fcons (logfont, Qnil))); |
|---|
| | 2280 | } |
|---|
| | 2281 | tem = XCDR (tem); |
|---|
| | 2282 | if (CONSP (tem)) |
|---|
| | 2283 | mw32_check_font_option (XCAR (tem)); |
|---|
| | 2284 | } |
|---|
| | 2285 | else if (EQ (type, Qfunction)) |
|---|
| | 2286 | { |
|---|
| | 2287 | if (!CONSP (tem)) |
|---|
| | 2288 | Fsignal (Qerror, Fcons (build_string ("Invalid font function spec value"), |
|---|
| | 2289 | Fcons (tem, Qnil))); |
|---|
| | 2290 | func = XCAR (tem); |
|---|
| | 2291 | if (!FUNCTIONP (tem)) |
|---|
| | 2292 | Fsignal (Qerror, Fcons (build_string ("Invalid function"), |
|---|
| | 2293 | Fcons (func, Qnil))); |
|---|
| | 2294 | tem = XCDR (tem); |
|---|
| | 2295 | if (CONSP (tem)) |
|---|
| | 2296 | mw32_check_font_option (XCAR (tem)); |
|---|
| | 2297 | } |
|---|
| | 2298 | else |
|---|
| | 2299 | { |
|---|
| | 2300 | Fsignal (Qerror, Fcons (build_string ("Invalid font spec type"), |
|---|
| | 2301 | Fcons (type, Qnil))); |
|---|
| | 2302 | } |
|---|