aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2006-06-09 02:14:49 +0000
committerKenichi Handa2006-06-09 02:14:49 +0000
commit02dacbbc4f5681826be277dc03fd1e865cf8c04b (patch)
treeab75cbf1355c0de56982268c2f6a3348a987b6cd /src
parent1bb1d99b434ea422c401fa8e71d06a7db065fafb (diff)
downloademacs-02dacbbc4f5681826be277dc03fd1e865cf8c04b.tar.gz
emacs-02dacbbc4f5681826be277dc03fd1e865cf8c04b.zip
(reorder_font_vector): Pay attention to the case that
the 3rd element of font_def is nil. (fontset_font): For the default fontset, append one more fontset elements for a script-based font specification. Don't add script attribute on finding a font. (new_fontset_from_font): Unconditionally set FONTSET_ASCII to the font name. (fontset_ascii_font): If a font can't be opened, return nil.
Diffstat (limited to 'src')
-rw-r--r--src/fontset.c62
1 files changed, 41 insertions, 21 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 6e3e8b69961..7df4b9167ef 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -461,7 +461,10 @@ reorder_font_vector (fontset_element)
461 for (i = 0; i < size; i++) 461 for (i = 0; i < size; i++)
462 { 462 {
463 font_def = AREF (fontset_element, i + 3); 463 font_def = AREF (fontset_element, i + 3);
464 charset_id_table[i] = XINT (AREF (AREF (font_def, 2), 1)); 464 if (! NILP (AREF (font_def, 2)))
465 charset_id_table[i] = XINT (AREF (AREF (font_def, 2), 1));
466 else
467 charset_id_table[i] = -1;
465 } 468 }
466 469
467 /* Then, store FONT-DEFs in NEW_VEC in the correct order. */ 470 /* Then, store FONT-DEFs in NEW_VEC in the correct order. */
@@ -472,6 +475,9 @@ reorder_font_vector (fontset_element)
472 if (charset_id_table[i] == XINT (XCAR (list))) 475 if (charset_id_table[i] == XINT (XCAR (list)))
473 new_vec[idx++] = AREF (fontset_element, i + 3); 476 new_vec[idx++] = AREF (fontset_element, i + 3);
474 } 477 }
478 for (i = 0; i < size; i++)
479 if (charset_id_table[i] < 0)
480 new_vec[idx++] = AREF (fontset_element, i + 3);
475 481
476 /* At last, update FONT-DEFs. */ 482 /* At last, update FONT-DEFs. */
477 for (i = 0; i < size; i++) 483 for (i = 0; i < size; i++)
@@ -562,6 +568,12 @@ fontset_font (fontset, c, face, id)
562 /* Build a vector [ -1 -1 nil NEW-ELT0 NEW-ELT1 NEW-ELT2 ... ], 568 /* Build a vector [ -1 -1 nil NEW-ELT0 NEW-ELT1 NEW-ELT2 ... ],
563 where the first -1 is to force reordering of NEW-ELTn, 569 where the first -1 is to force reordering of NEW-ELTn,
564 NEW-ETLn is [nil nil AREF (elt, n) nil]. */ 570 NEW-ETLn is [nil nil AREF (elt, n) nil]. */
571#ifdef USE_FONT_BACKEND
572 if (enable_font_backend
573 && EQ (base_fontset, Vdefault_fontset))
574 vec = Fmake_vector (make_number (ASIZE (elt) + 4), make_number (-1));
575 else
576#endif /* not USE_FONT_BACKEND */
565 vec = Fmake_vector (make_number (ASIZE (elt) + 3), make_number (-1)); 577 vec = Fmake_vector (make_number (ASIZE (elt) + 3), make_number (-1));
566 ASET (vec, 2, Qnil); 578 ASET (vec, 2, Qnil);
567 for (i = 0; i < ASIZE (elt); i++) 579 for (i = 0; i < ASIZE (elt); i++)
@@ -577,6 +589,25 @@ fontset_font (fontset, c, face, id)
577 ASET (tmp, 2, AREF (elt, i)); 589 ASET (tmp, 2, AREF (elt, i));
578 ASET (vec, 3 + i, tmp); 590 ASET (vec, 3 + i, tmp);
579 } 591 }
592#ifdef USE_FONT_BACKEND
593 if (enable_font_backend
594 && EQ (base_fontset, Vdefault_fontset))
595 {
596 Lisp_Object script, font_spec, tmp;
597
598 script = CHAR_TABLE_REF (Vchar_script_table, c);
599 if (NILP (script))
600 script = intern ("latin");
601 font_spec = Ffont_spec (0, NULL);
602 ASET (font_spec, FONT_REGISTRY_INDEX, Qiso10646_1);
603 ASET (font_spec, FONT_EXTRA_INDEX,
604 Fcons (Fcons (QCscript, script), Qnil));
605 tmp = Fmake_vector (make_number (5), Qnil);
606 ASET (tmp, 3, font_spec);
607 ASET (vec, 3 + i, tmp);
608 }
609#endif /* USE_FONT_BACKEND */
610
580 /* Then store it in the fontset. */ 611 /* Then store it in the fontset. */
581 FONTSET_SET (fontset, range, vec); 612 FONTSET_SET (fontset, range, vec);
582 } 613 }
@@ -637,7 +668,7 @@ fontset_font (fontset, c, face, id)
637 Lisp_Object font_object = AREF (elt, 4); 668 Lisp_Object font_object = AREF (elt, 4);
638 int has_char; 669 int has_char;
639 670
640 if (NILP (font_entity)) 671 if (NILP (font_entity) && ! NILP (AREF (font_def, 0)))
641 { 672 {
642 Lisp_Object tmp = AREF (font_def, 0); 673 Lisp_Object tmp = AREF (font_def, 0);
643 Lisp_Object spec = Ffont_spec (0, NULL); 674 Lisp_Object spec = Ffont_spec (0, NULL);
@@ -652,13 +683,14 @@ fontset_font (fontset, c, face, id)
652 683
653 font_merge_old_spec (Qnil, family, registry, spec); 684 font_merge_old_spec (Qnil, family, registry, spec);
654 } 685 }
655 script = CHAR_TABLE_REF (Vchar_script_table, c);
656 if (! NILP (script))
657 ASET (spec, FONT_EXTRA_INDEX,
658 Fcons (Fcons (QCscript, script), Qnil));
659 font_entity = font_find_for_lface (f, face->lface, spec); 686 font_entity = font_find_for_lface (f, face->lface, spec);
660 ASET (elt, 3, font_entity); 687 ASET (elt, 3, font_entity);
661 } 688 }
689 else if (FONT_SPEC_P (font_entity))
690 {
691 font_entity = font_find_for_lface (f, face->lface, font_entity);
692 ASET (elt, 3, font_entity);
693 }
662 if (NILP (font_entity)) 694 if (NILP (font_entity))
663 { 695 {
664 ASET (elt, 1, make_number (-1)); 696 ASET (elt, 1, make_number (-1));
@@ -1810,22 +1842,8 @@ new_fontset_from_font (f, font_object)
1810 int id = new_fontset_from_font_name (xlfd); 1842 int id = new_fontset_from_font_name (xlfd);
1811 Lisp_Object fontset = FONTSET_FROM_ID (id); 1843 Lisp_Object fontset = FONTSET_FROM_ID (id);
1812 1844
1813 if (STRINGP (FONTSET_ASCII (fontset))) 1845 FONTSET_ASCII (fontset) = build_string (font_get_name (font_object));
1814 FONTSET_ASCII (fontset) = Fcons (FONTSET_ASCII (fontset),
1815 Fcons (font_object, Qnil));
1816 else
1817 {
1818 Lisp_Object val = XCDR (FONTSET_ASCII (fontset));
1819 1846
1820 for (; ! NILP (val); val = XCDR (val))
1821 if (EQ (XCAR (val), font_object))
1822 break;
1823 if (NILP (val))
1824 {
1825 val = FONTSET_ASCII (fontset);
1826 XSETCDR (val, Fcons (font_object, XCDR (val)));
1827 }
1828 }
1829 return id; 1847 return id;
1830} 1848}
1831 1849
@@ -1869,6 +1887,8 @@ fontset_ascii_font (f, id)
1869 font_object = font_open_by_name (f, SDATA (ascii_slot)); 1887 font_object = font_open_by_name (f, SDATA (ascii_slot));
1870 FONTSET_ASCII (fontset) = Fcons (ascii_slot, Fcons (font_object, Qnil)); 1888 FONTSET_ASCII (fontset) = Fcons (ascii_slot, Fcons (font_object, Qnil));
1871 } 1889 }
1890 if (NILP (font_object))
1891 return NULL;
1872 return XSAVE_VALUE (font_object)->pointer; 1892 return XSAVE_VALUE (font_object)->pointer;
1873} 1893}
1874 1894