aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Antipov2012-08-21 08:46:05 +0400
committerDmitry Antipov2012-08-21 08:46:05 +0400
commit6d470bddb081435461b67f039b5c9960e23bea8e (patch)
tree0c47d0a899dff887c55637aac9f17ab6245de1b8
parentc68cd5d433e1bbb4478dca51ef5c7ec53259e77e (diff)
downloademacs-6d470bddb081435461b67f039b5c9960e23bea8e.tar.gz
emacs-6d470bddb081435461b67f039b5c9960e23bea8e.zip
Setter macros for fontsets.
* fontset.c (SET_FONTSET_ID, SET_FONTSET_NAME, SET_FONTSET_ASCII) (SET_FONTSET_BASE, SET_FONTSET_FRAME, SET_FONTSET_NOFONT_FACE) (SET_FONTSET_DEFAULT, SET_FONTSET_FALLBACK): New macros. Adjust users.
-rw-r--r--src/ChangeLog8
-rw-r--r--src/fontset.c97
2 files changed, 67 insertions, 38 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 22383088763..5a7c6923029 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12012-08-21 Dmitry Antipov <dmantipov@yandex.ru>
2
3 Setter macros for fontsets.
4 * fontset.c (SET_FONTSET_ID, SET_FONTSET_NAME, SET_FONTSET_ASCII)
5 (SET_FONTSET_BASE, SET_FONTSET_FRAME, SET_FONTSET_NOFONT_FACE)
6 (SET_FONTSET_DEFAULT, SET_FONTSET_FALLBACK): New macros.
7 Adjust users.
8
12012-08-20 Glenn Morris <rgm@gnu.org> 92012-08-20 Glenn Morris <rgm@gnu.org>
2 10
3 * Makefile.in (emacs$(EXEEXT), bootstrap-emacs$(EXEEXT)): 11 * Makefile.in (emacs$(EXEEXT), bootstrap-emacs$(EXEEXT)):
diff --git a/src/fontset.c b/src/fontset.c
index c39d68a8ecf..f9b6e8139ef 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -214,26 +214,46 @@ fontset_id_valid_p (int id)
214#define FONTSET_FROM_ID(id) AREF (Vfontset_table, id) 214#define FONTSET_FROM_ID(id) AREF (Vfontset_table, id)
215 215
216/* Macros to access special values of FONTSET. */ 216/* Macros to access special values of FONTSET. */
217#define FONTSET_ID(fontset) XCHAR_TABLE (fontset)->extras[0] 217
218#define FONTSET_ID(fontset) XCHAR_TABLE (fontset)->extras[0]
219#define SET_FONTSET_ID(fontset, id) \
220 set_char_table_extras ((fontset), 0, (id))
218 221
219/* Macros to access special values of (base) FONTSET. */ 222/* Macros to access special values of (base) FONTSET. */
220#define FONTSET_NAME(fontset) XCHAR_TABLE (fontset)->extras[1] 223
221#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4] 224#define FONTSET_NAME(fontset) XCHAR_TABLE (fontset)->extras[1]
222/* #define FONTSET_SPEC(fontset) XCHAR_TABLE (fontset)->extras[5] */ 225#define SET_FONTSET_NAME(fontset, name) \
226 set_char_table_extras ((fontset), 1, (name))
227
228#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4]
229#define SET_FONTSET_ASCII(fontset, ascii) \
230 set_char_table_extras ((fontset), 4, (ascii))
223 231
224/* Macros to access special values of (realized) FONTSET. */ 232/* Macros to access special values of (realized) FONTSET. */
225#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2] 233
226#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3] 234#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2]
227/* #define FONTSET_OBJLIST(fontset) XCHAR_TABLE (fontset)->extras[4] */ 235#define SET_FONTSET_BASE(fontset, base) \
228#define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5] 236 set_char_table_extras ((fontset), 2, (base))
229/* #define FONTSET_REPERTORY(fontset) XCHAR_TABLE (fontset)->extras[6] */ 237
230#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7] 238#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3]
239#define SET_FONTSET_FRAME(fontset, frame) \
240 set_char_table_extras ((fontset), 3, (frame))
241
242#define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5]
243#define SET_FONTSET_NOFONT_FACE(fontset, face) \
244 set_char_table_extras ((fontset), 5, (face))
245
246#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7]
247#define SET_FONTSET_DEFAULT(fontset, def) \
248 set_char_table_extras ((fontset), 7, (def))
231 249
232/* For both base and realized fontset. */ 250/* For both base and realized fontset. */
233#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[8]
234 251
235#define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset))) 252#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[8]
253#define SET_FONTSET_FALLBACK(fontset, fallback) \
254 set_char_table_extras ((fontset), 8, (fallback))
236 255
256#define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset)))
237 257
238/* Macros for FONT-DEF and RFONT-DEF of fontset. */ 258/* Macros for FONT-DEF and RFONT-DEF of fontset. */
239#define FONT_DEF_NEW(font_def, font_spec, encoding, repertory) \ 259#define FONT_DEF_NEW(font_def, font_spec, encoding, repertory) \
@@ -265,7 +285,7 @@ fontset_id_valid_p (int id)
265#define RFONT_DEF_NEW(rfont_def, font_def) \ 285#define RFONT_DEF_NEW(rfont_def, font_def) \
266 do { \ 286 do { \
267 (rfont_def) = Fmake_vector (make_number (4), Qnil); \ 287 (rfont_def) = Fmake_vector (make_number (4), Qnil); \
268 ASET ((rfont_def), 1, (font_def)); \ 288 ASET ((rfont_def), 1, (font_def)); \
269 RFONT_DEF_SET_SCORE ((rfont_def), 0); \ 289 RFONT_DEF_SET_SCORE ((rfont_def), 0); \
270 } while (0) 290 } while (0)
271 291
@@ -307,12 +327,13 @@ fontset_ref (Lisp_Object fontset, int c)
307 replace with ELT, if ADD is `prepend', prepend ELT, otherwise, 327 replace with ELT, if ADD is `prepend', prepend ELT, otherwise,
308 append ELT. */ 328 append ELT. */
309 329
310#define FONTSET_ADD(fontset, range, elt, add) \ 330#define FONTSET_ADD(fontset, range, elt, add) \
311 (NILP (add) \ 331 (NILP (add) \
312 ? (NILP (range) \ 332 ? (NILP (range) \
313 ? (FONTSET_FALLBACK (fontset) = Fmake_vector (make_number (1), (elt))) \ 333 ? (SET_FONTSET_FALLBACK \
314 : Fset_char_table_range ((fontset), (range), \ 334 (fontset, Fmake_vector (make_number (1), (elt)))) \
315 Fmake_vector (make_number (1), (elt)))) \ 335 : Fset_char_table_range ((fontset), (range), \
336 Fmake_vector (make_number (1), (elt)))) \
316 : fontset_add ((fontset), (range), (elt), (add))) 337 : fontset_add ((fontset), (range), (elt), (add)))
317 338
318static Lisp_Object 339static Lisp_Object
@@ -341,8 +362,8 @@ fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Objec
341 else 362 else
342 { 363 {
343 args[idx] = FONTSET_FALLBACK (fontset); 364 args[idx] = FONTSET_FALLBACK (fontset);
344 FONTSET_FALLBACK (fontset) 365 SET_FONTSET_FALLBACK
345 = NILP (args[idx]) ? args[1 - idx] : Fvconcat (2, args); 366 (fontset, NILP (args[idx]) ? args[1 - idx] : Fvconcat (2, args));
346 } 367 }
347 return Qnil; 368 return Qnil;
348} 369}
@@ -485,7 +506,7 @@ fontset_get_font_group (Lisp_Object fontset, int c)
485 if (c >= 0) 506 if (c >= 0)
486 char_table_set_range (fontset, from, to, font_group); 507 char_table_set_range (fontset, from, to, font_group);
487 else 508 else
488 FONTSET_FALLBACK (fontset) = font_group; 509 SET_FONTSET_FALLBACK (fontset, font_group);
489 return font_group; 510 return font_group;
490} 511}
491 512
@@ -720,8 +741,9 @@ fontset_font (Lisp_Object fontset, int c, struct face *face, int id)
720 if (! EQ (base_fontset, Vdefault_fontset)) 741 if (! EQ (base_fontset, Vdefault_fontset))
721 { 742 {
722 if (NILP (FONTSET_DEFAULT (fontset))) 743 if (NILP (FONTSET_DEFAULT (fontset)))
723 FONTSET_DEFAULT (fontset) 744 SET_FONTSET_DEFAULT
724 = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset); 745 (fontset,
746 make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset));
725 FONT_DEFERRED_LOG ("default fontset: font for", make_number (c), Qnil); 747 FONT_DEFERRED_LOG ("default fontset: font for", make_number (c), Qnil);
726 default_rfont_def 748 default_rfont_def
727 = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0); 749 = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0);
@@ -781,16 +803,14 @@ make_fontset (Lisp_Object frame, Lisp_Object name, Lisp_Object base)
781 803
782 fontset = Fmake_char_table (Qfontset, Qnil); 804 fontset = Fmake_char_table (Qfontset, Qnil);
783 805
784 FONTSET_ID (fontset) = make_number (id); 806 SET_FONTSET_ID (fontset, make_number (id));
785 if (NILP (base)) 807 if (NILP (base))
786 { 808 SET_FONTSET_NAME (fontset, name);
787 FONTSET_NAME (fontset) = name;
788 }
789 else 809 else
790 { 810 {
791 FONTSET_NAME (fontset) = Qnil; 811 SET_FONTSET_NAME (fontset, Qnil);
792 FONTSET_FRAME (fontset) = frame; 812 SET_FONTSET_FRAME (fontset, frame);
793 FONTSET_BASE (fontset) = base; 813 SET_FONTSET_BASE (fontset, base);
794 } 814 }
795 815
796 ASET (Vfontset_table, id, fontset); 816 ASET (Vfontset_table, id, fontset);
@@ -958,7 +978,7 @@ face_for_char (FRAME_PTR f, struct face *face, int c, int pos, Lisp_Object objec
958 else 978 else
959 { 979 {
960 face_id = face_for_font (f, Qnil, face); 980 face_id = face_for_font (f, Qnil, face);
961 FONTSET_NOFONT_FACE (fontset) = make_number (face_id); 981 SET_FONTSET_NOFONT_FACE (fontset, make_number (face_id));
962 } 982 }
963 } 983 }
964 eassert (face_id >= 0); 984 eassert (face_id >= 0);
@@ -1580,7 +1600,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1580 Lisp_Object tail, fr, alist; 1600 Lisp_Object tail, fr, alist;
1581 int fontset_id = XINT (FONTSET_ID (fontset)); 1601 int fontset_id = XINT (FONTSET_ID (fontset));
1582 1602
1583 FONTSET_ASCII (fontset) = fontname; 1603 SET_FONTSET_ASCII (fontset, fontname);
1584 name = FONTSET_NAME (fontset); 1604 name = FONTSET_NAME (fontset);
1585 FOR_EACH_FRAME (tail, fr) 1605 FOR_EACH_FRAME (tail, fr)
1586 { 1606 {
@@ -1658,7 +1678,7 @@ FONT-SPEC is a vector, a cons, or a string. See the documentation of
1658 len = font_unparse_xlfd (font_spec, 0, xlfd, 256); 1678 len = font_unparse_xlfd (font_spec, 0, xlfd, 256);
1659 if (len < 0) 1679 if (len < 0)
1660 error ("Invalid fontset name (perhaps too long): %s", SDATA (name)); 1680 error ("Invalid fontset name (perhaps too long): %s", SDATA (name));
1661 FONTSET_ASCII (fontset) = make_unibyte_string (xlfd, len); 1681 SET_FONTSET_ASCII (fontset, make_unibyte_string (xlfd, len));
1662 } 1682 }
1663 else 1683 else
1664 { 1684 {
@@ -1744,7 +1764,7 @@ fontset_from_font (Lisp_Object font_object)
1744 Fset_fontset_font (name, Qnil, font_spec, Qnil, Qnil); 1764 Fset_fontset_font (name, Qnil, font_spec, Qnil, Qnil);
1745 } 1765 }
1746 1766
1747 FONTSET_ASCII (fontset) = font_name; 1767 SET_FONTSET_ASCII (fontset, font_name);
1748 1768
1749 return XINT (FONTSET_ID (fontset)); 1769 return XINT (FONTSET_ID (fontset));
1750} 1770}
@@ -2161,9 +2181,10 @@ syms_of_fontset (void)
2161 2181
2162 Vdefault_fontset = Fmake_char_table (Qfontset, Qnil); 2182 Vdefault_fontset = Fmake_char_table (Qfontset, Qnil);
2163 staticpro (&Vdefault_fontset); 2183 staticpro (&Vdefault_fontset);
2164 FONTSET_ID (Vdefault_fontset) = make_number (0); 2184 SET_FONTSET_ID (Vdefault_fontset, make_number (0));
2165 FONTSET_NAME (Vdefault_fontset) 2185 SET_FONTSET_NAME
2166 = build_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"); 2186 (Vdefault_fontset,
2187 build_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"));
2167 ASET (Vfontset_table, 0, Vdefault_fontset); 2188 ASET (Vfontset_table, 0, Vdefault_fontset);
2168 next_fontset_id = 1; 2189 next_fontset_id = 1;
2169 2190