aboutsummaryrefslogtreecommitdiffstats
path: root/src/fontset.c
diff options
context:
space:
mode:
authorJoakim Verona2012-09-03 17:30:17 +0200
committerJoakim Verona2012-09-03 17:30:17 +0200
commit4a37733c693d59a9b83a3fb2d0c7f9461d149f60 (patch)
treea33402e09342f748baebf0e4f5a1e40538e620f4 /src/fontset.c
parent5436d1df5e2ba0b4d4f72b03a1cd09b20403654b (diff)
parentdcde497f27945c3ca4ce8c21f655ef6f627acdd2 (diff)
downloademacs-4a37733c693d59a9b83a3fb2d0c7f9461d149f60.tar.gz
emacs-4a37733c693d59a9b83a3fb2d0c7f9461d149f60.zip
upstream
Diffstat (limited to 'src/fontset.c')
-rw-r--r--src/fontset.c134
1 files changed, 89 insertions, 45 deletions
diff --git a/src/fontset.c b/src/fontset.c
index c39d68a8ecf..01e38fe45e5 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -185,8 +185,7 @@ void (*check_window_system_func) (void);
185 185
186 186
187/* Prototype declarations for static functions. */ 187/* Prototype declarations for static functions. */
188static Lisp_Object fontset_add (Lisp_Object, Lisp_Object, Lisp_Object, 188static void fontset_add (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
189 Lisp_Object);
190static Lisp_Object fontset_find_font (Lisp_Object, int, struct face *, 189static Lisp_Object fontset_find_font (Lisp_Object, int, struct face *,
191 int, int); 190 int, int);
192static void reorder_font_vector (Lisp_Object, struct font *); 191static void reorder_font_vector (Lisp_Object, struct font *);
@@ -213,27 +212,71 @@ fontset_id_valid_p (int id)
213/* Return the fontset with ID. No check of ID's validness. */ 212/* Return the fontset with ID. No check of ID's validness. */
214#define FONTSET_FROM_ID(id) AREF (Vfontset_table, id) 213#define FONTSET_FROM_ID(id) AREF (Vfontset_table, id)
215 214
216/* Macros to access special values of FONTSET. */ 215/* Access special values of FONTSET. */
217#define FONTSET_ID(fontset) XCHAR_TABLE (fontset)->extras[0]
218 216
219/* Macros to access special values of (base) FONTSET. */ 217#define FONTSET_ID(fontset) XCHAR_TABLE (fontset)->extras[0]
220#define FONTSET_NAME(fontset) XCHAR_TABLE (fontset)->extras[1] 218static void
221#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4] 219set_fontset_id (Lisp_Object fontset, Lisp_Object id)
222/* #define FONTSET_SPEC(fontset) XCHAR_TABLE (fontset)->extras[5] */ 220{
221 set_char_table_extras (fontset, 0, id);
222}
223
224/* Access special values of (base) FONTSET. */
225
226#define FONTSET_NAME(fontset) XCHAR_TABLE (fontset)->extras[1]
227static void
228set_fontset_name (Lisp_Object fontset, Lisp_Object name)
229{
230 set_char_table_extras (fontset, 1, name);
231}
232
233#define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->extras[4]
234static void
235set_fontset_ascii (Lisp_Object fontset, Lisp_Object ascii)
236{
237 set_char_table_extras (fontset, 4, ascii);
238}
239
240/* Access special values of (realized) FONTSET. */
241
242#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2]
243static void
244set_fontset_base (Lisp_Object fontset, Lisp_Object base)
245{
246 set_char_table_extras (fontset, 2, base);
247}
248
249#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3]
250static void
251set_fontset_frame (Lisp_Object fontset, Lisp_Object frame)
252{
253 set_char_table_extras (fontset, 3, frame);
254}
223 255
224/* Macros to access special values of (realized) FONTSET. */ 256#define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5]
225#define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->extras[2] 257static void
226#define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[3] 258set_fontset_nofont_face (Lisp_Object fontset, Lisp_Object face)
227/* #define FONTSET_OBJLIST(fontset) XCHAR_TABLE (fontset)->extras[4] */ 259{
228#define FONTSET_NOFONT_FACE(fontset) XCHAR_TABLE (fontset)->extras[5] 260 set_char_table_extras (fontset, 5, face);
229/* #define FONTSET_REPERTORY(fontset) XCHAR_TABLE (fontset)->extras[6] */ 261}
230#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7] 262
263#define FONTSET_DEFAULT(fontset) XCHAR_TABLE (fontset)->extras[7]
264static void
265set_fontset_default (Lisp_Object fontset, Lisp_Object def)
266{
267 set_char_table_extras (fontset, 7, def);
268}
231 269
232/* For both base and realized fontset. */ 270/* For both base and realized fontset. */
233#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[8]
234 271
235#define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset))) 272#define FONTSET_FALLBACK(fontset) XCHAR_TABLE (fontset)->extras[8]
273static void
274set_fontset_fallback (Lisp_Object fontset, Lisp_Object fallback)
275{
276 set_char_table_extras (fontset, 8, fallback);
277}
236 278
279#define BASE_FONTSET_P(fontset) (NILP (FONTSET_BASE (fontset)))
237 280
238/* Macros for FONT-DEF and RFONT-DEF of fontset. */ 281/* Macros for FONT-DEF and RFONT-DEF of fontset. */
239#define FONT_DEF_NEW(font_def, font_spec, encoding, repertory) \ 282#define FONT_DEF_NEW(font_def, font_spec, encoding, repertory) \
@@ -265,7 +308,7 @@ fontset_id_valid_p (int id)
265#define RFONT_DEF_NEW(rfont_def, font_def) \ 308#define RFONT_DEF_NEW(rfont_def, font_def) \
266 do { \ 309 do { \
267 (rfont_def) = Fmake_vector (make_number (4), Qnil); \ 310 (rfont_def) = Fmake_vector (make_number (4), Qnil); \
268 ASET ((rfont_def), 1, (font_def)); \ 311 ASET ((rfont_def), 1, (font_def)); \
269 RFONT_DEF_SET_SCORE ((rfont_def), 0); \ 312 RFONT_DEF_SET_SCORE ((rfont_def), 0); \
270 } while (0) 313 } while (0)
271 314
@@ -307,15 +350,17 @@ fontset_ref (Lisp_Object fontset, int c)
307 replace with ELT, if ADD is `prepend', prepend ELT, otherwise, 350 replace with ELT, if ADD is `prepend', prepend ELT, otherwise,
308 append ELT. */ 351 append ELT. */
309 352
310#define FONTSET_ADD(fontset, range, elt, add) \ 353#define FONTSET_ADD(fontset, range, elt, add) \
311 (NILP (add) \ 354 (NILP (add) \
312 ? (NILP (range) \ 355 ? (NILP (range) \
313 ? (FONTSET_FALLBACK (fontset) = Fmake_vector (make_number (1), (elt))) \ 356 ? (set_fontset_fallback \
314 : Fset_char_table_range ((fontset), (range), \ 357 (fontset, Fmake_vector (make_number (1), (elt)))) \
315 Fmake_vector (make_number (1), (elt)))) \ 358 : ((void) \
359 Fset_char_table_range (fontset, range, \
360 Fmake_vector (make_number (1), elt)))) \
316 : fontset_add ((fontset), (range), (elt), (add))) 361 : fontset_add ((fontset), (range), (elt), (add)))
317 362
318static Lisp_Object 363static void
319fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Object add) 364fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Object add)
320{ 365{
321 Lisp_Object args[2]; 366 Lisp_Object args[2];
@@ -341,10 +386,9 @@ fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Objec
341 else 386 else
342 { 387 {
343 args[idx] = FONTSET_FALLBACK (fontset); 388 args[idx] = FONTSET_FALLBACK (fontset);
344 FONTSET_FALLBACK (fontset) 389 set_fontset_fallback
345 = NILP (args[idx]) ? args[1 - idx] : Fvconcat (2, args); 390 (fontset, NILP (args[idx]) ? args[1 - idx] : Fvconcat (2, args));
346 } 391 }
347 return Qnil;
348} 392}
349 393
350static int 394static int
@@ -485,7 +529,7 @@ fontset_get_font_group (Lisp_Object fontset, int c)
485 if (c >= 0) 529 if (c >= 0)
486 char_table_set_range (fontset, from, to, font_group); 530 char_table_set_range (fontset, from, to, font_group);
487 else 531 else
488 FONTSET_FALLBACK (fontset) = font_group; 532 set_fontset_fallback (fontset, font_group);
489 return font_group; 533 return font_group;
490} 534}
491 535
@@ -720,8 +764,9 @@ fontset_font (Lisp_Object fontset, int c, struct face *face, int id)
720 if (! EQ (base_fontset, Vdefault_fontset)) 764 if (! EQ (base_fontset, Vdefault_fontset))
721 { 765 {
722 if (NILP (FONTSET_DEFAULT (fontset))) 766 if (NILP (FONTSET_DEFAULT (fontset)))
723 FONTSET_DEFAULT (fontset) 767 set_fontset_default
724 = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset); 768 (fontset,
769 make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset));
725 FONT_DEFERRED_LOG ("default fontset: font for", make_number (c), Qnil); 770 FONT_DEFERRED_LOG ("default fontset: font for", make_number (c), Qnil);
726 default_rfont_def 771 default_rfont_def
727 = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0); 772 = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0);
@@ -781,16 +826,14 @@ make_fontset (Lisp_Object frame, Lisp_Object name, Lisp_Object base)
781 826
782 fontset = Fmake_char_table (Qfontset, Qnil); 827 fontset = Fmake_char_table (Qfontset, Qnil);
783 828
784 FONTSET_ID (fontset) = make_number (id); 829 set_fontset_id (fontset, make_number (id));
785 if (NILP (base)) 830 if (NILP (base))
786 { 831 set_fontset_name (fontset, name);
787 FONTSET_NAME (fontset) = name;
788 }
789 else 832 else
790 { 833 {
791 FONTSET_NAME (fontset) = Qnil; 834 set_fontset_name (fontset, Qnil);
792 FONTSET_FRAME (fontset) = frame; 835 set_fontset_frame (fontset, frame);
793 FONTSET_BASE (fontset) = base; 836 set_fontset_base (fontset, base);
794 } 837 }
795 838
796 ASET (Vfontset_table, id, fontset); 839 ASET (Vfontset_table, id, fontset);
@@ -958,7 +1001,7 @@ face_for_char (FRAME_PTR f, struct face *face, int c, int pos, Lisp_Object objec
958 else 1001 else
959 { 1002 {
960 face_id = face_for_font (f, Qnil, face); 1003 face_id = face_for_font (f, Qnil, face);
961 FONTSET_NOFONT_FACE (fontset) = make_number (face_id); 1004 set_fontset_nofont_face (fontset, make_number (face_id));
962 } 1005 }
963 } 1006 }
964 eassert (face_id >= 0); 1007 eassert (face_id >= 0);
@@ -1580,7 +1623,7 @@ appended. By default, FONT-SPEC overrides the previous settings. */)
1580 Lisp_Object tail, fr, alist; 1623 Lisp_Object tail, fr, alist;
1581 int fontset_id = XINT (FONTSET_ID (fontset)); 1624 int fontset_id = XINT (FONTSET_ID (fontset));
1582 1625
1583 FONTSET_ASCII (fontset) = fontname; 1626 set_fontset_ascii (fontset, fontname);
1584 name = FONTSET_NAME (fontset); 1627 name = FONTSET_NAME (fontset);
1585 FOR_EACH_FRAME (tail, fr) 1628 FOR_EACH_FRAME (tail, fr)
1586 { 1629 {
@@ -1658,7 +1701,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); 1701 len = font_unparse_xlfd (font_spec, 0, xlfd, 256);
1659 if (len < 0) 1702 if (len < 0)
1660 error ("Invalid fontset name (perhaps too long): %s", SDATA (name)); 1703 error ("Invalid fontset name (perhaps too long): %s", SDATA (name));
1661 FONTSET_ASCII (fontset) = make_unibyte_string (xlfd, len); 1704 set_fontset_ascii (fontset, make_unibyte_string (xlfd, len));
1662 } 1705 }
1663 else 1706 else
1664 { 1707 {
@@ -1744,7 +1787,7 @@ fontset_from_font (Lisp_Object font_object)
1744 Fset_fontset_font (name, Qnil, font_spec, Qnil, Qnil); 1787 Fset_fontset_font (name, Qnil, font_spec, Qnil, Qnil);
1745 } 1788 }
1746 1789
1747 FONTSET_ASCII (fontset) = font_name; 1790 set_fontset_ascii (fontset, font_name);
1748 1791
1749 return XINT (FONTSET_ID (fontset)); 1792 return XINT (FONTSET_ID (fontset));
1750} 1793}
@@ -2161,9 +2204,10 @@ syms_of_fontset (void)
2161 2204
2162 Vdefault_fontset = Fmake_char_table (Qfontset, Qnil); 2205 Vdefault_fontset = Fmake_char_table (Qfontset, Qnil);
2163 staticpro (&Vdefault_fontset); 2206 staticpro (&Vdefault_fontset);
2164 FONTSET_ID (Vdefault_fontset) = make_number (0); 2207 set_fontset_id (Vdefault_fontset, make_number (0));
2165 FONTSET_NAME (Vdefault_fontset) 2208 set_fontset_name
2166 = build_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"); 2209 (Vdefault_fontset,
2210 build_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"));
2167 ASET (Vfontset_table, 0, Vdefault_fontset); 2211 ASET (Vfontset_table, 0, Vdefault_fontset);
2168 next_fontset_id = 1; 2212 next_fontset_id = 1;
2169 2213