diff options
| author | Kenichi Handa | 2006-06-16 12:19:38 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2006-06-16 12:19:38 +0000 |
| commit | f4d3bea3873d677e1fd9817a4e7d0fcbb42d6fdc (patch) | |
| tree | 843b40b81166d988eb9a56992e4eb94321736912 /src | |
| parent | 25c252565874a9578b4d143d79bc3ec63321ef8a (diff) | |
| download | emacs-f4d3bea3873d677e1fd9817a4e7d0fcbb42d6fdc.tar.gz emacs-f4d3bea3873d677e1fd9817a4e7d0fcbb42d6fdc.zip | |
(check_lface_attrs) [USE_FONT_BACKEND]: Accept font
object in attrs[LFACE_FONT_INDEX].
(set_lface_from_font_name): Cancel all changes for font-backend.
(set_lface_from_font_and_fontset) [USE_FONT_BACKEND]: New
function.
(Finternal_set_lisp_face_attribute): Accept a font object in
QCfont attribute.
(set_font_frame_param): Likewise.
(realize_default_face): Call set_lface_from_font_and_fontset.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfaces.c | 266 |
1 files changed, 156 insertions, 110 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index cf3e444ef60..efdb7b0a660 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -543,6 +543,8 @@ static int merge_face_ref P_ ((struct frame *, Lisp_Object, Lisp_Object *, | |||
| 543 | int, struct named_merge_point *)); | 543 | int, struct named_merge_point *)); |
| 544 | static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object, | 544 | static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object, |
| 545 | Lisp_Object, int, int)); | 545 | Lisp_Object, int, int)); |
| 546 | static void set_lface_from_font_and_fontset P_ ((struct frame *, Lisp_Object, | ||
| 547 | Lisp_Object, int, int)); | ||
| 546 | static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); | 548 | static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); |
| 547 | static struct face *make_realized_face P_ ((Lisp_Object *)); | 549 | static struct face *make_realized_face P_ ((Lisp_Object *)); |
| 548 | static char *best_matching_font P_ ((struct frame *, Lisp_Object *, | 550 | static char *best_matching_font P_ ((struct frame *, Lisp_Object *, |
| @@ -3294,6 +3296,9 @@ check_lface_attrs (attrs) | |||
| 3294 | xassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX]) | 3296 | xassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX]) |
| 3295 | || IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX]) | 3297 | || IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX]) |
| 3296 | || NILP (attrs[LFACE_FONT_INDEX]) | 3298 | || NILP (attrs[LFACE_FONT_INDEX]) |
| 3299 | #ifdef USE_FONT_BACKEND | ||
| 3300 | || FONT_OBJECT_P (attrs[LFACE_FONT_INDEX]) | ||
| 3301 | #endif /* USE_FONT_BACKEND */ | ||
| 3297 | || STRINGP (attrs[LFACE_FONT_INDEX])); | 3302 | || STRINGP (attrs[LFACE_FONT_INDEX])); |
| 3298 | xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX]) | 3303 | xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX]) |
| 3299 | || STRINGP (attrs[LFACE_FONTSET_INDEX])); | 3304 | || STRINGP (attrs[LFACE_FONTSET_INDEX])); |
| @@ -3533,109 +3538,6 @@ set_lface_from_font_name (f, lface, fontname, force_p, may_fail_p) | |||
| 3533 | /* If FONTNAME is actually a fontset name, get ASCII font name of it. */ | 3538 | /* If FONTNAME is actually a fontset name, get ASCII font name of it. */ |
| 3534 | fontset = fs_query_fontset (fontname, 0); | 3539 | fontset = fs_query_fontset (fontname, 0); |
| 3535 | 3540 | ||
| 3536 | #ifdef USE_FONT_BACKEND | ||
| 3537 | if (enable_font_backend) | ||
| 3538 | { | ||
| 3539 | Lisp_Object entity; | ||
| 3540 | struct font *font = NULL; | ||
| 3541 | |||
| 3542 | if (fontset > 0) | ||
| 3543 | font = fontset_ascii_font (f, fontset); | ||
| 3544 | else if (fontset == 0) | ||
| 3545 | { | ||
| 3546 | if (may_fail_p) | ||
| 3547 | return 0; | ||
| 3548 | abort (); | ||
| 3549 | } | ||
| 3550 | else | ||
| 3551 | { | ||
| 3552 | Lisp_Object font_object = font_open_by_name (f, SDATA (fontname)); | ||
| 3553 | |||
| 3554 | if (! NILP (font_object)) | ||
| 3555 | { | ||
| 3556 | font = XSAVE_VALUE (font_object)->pointer; | ||
| 3557 | fontset = new_fontset_from_font (f, font_object); | ||
| 3558 | } | ||
| 3559 | } | ||
| 3560 | |||
| 3561 | if (! font) | ||
| 3562 | { | ||
| 3563 | if (may_fail_p) | ||
| 3564 | return 0; | ||
| 3565 | abort (); | ||
| 3566 | } | ||
| 3567 | |||
| 3568 | entity = font->entity; | ||
| 3569 | |||
| 3570 | /* Set attributes only if unspecified, otherwise face defaults for | ||
| 3571 | new frames would never take effect. If we couldn't get a font | ||
| 3572 | name conforming to XLFD, set normal values. */ | ||
| 3573 | |||
| 3574 | if (force_p || UNSPECIFIEDP (LFACE_FAMILY (lface))) | ||
| 3575 | { | ||
| 3576 | Lisp_Object foundry = AREF (entity, FONT_FOUNDRY_INDEX); | ||
| 3577 | Lisp_Object family = AREF (entity, FONT_FAMILY_INDEX); | ||
| 3578 | Lisp_Object val; | ||
| 3579 | |||
| 3580 | if (! NILP (foundry)) | ||
| 3581 | { | ||
| 3582 | if (! NILP (family)) | ||
| 3583 | val = concat3 (SYMBOL_NAME (foundry), build_string ("-"), | ||
| 3584 | SYMBOL_NAME (family)); | ||
| 3585 | else | ||
| 3586 | val = concat2 (SYMBOL_NAME (foundry), build_string ("-*")); | ||
| 3587 | } | ||
| 3588 | else | ||
| 3589 | { | ||
| 3590 | if (! NILP (family)) | ||
| 3591 | val = SYMBOL_NAME (family); | ||
| 3592 | else | ||
| 3593 | val = build_string ("*"); | ||
| 3594 | } | ||
| 3595 | LFACE_FAMILY (lface) = val; | ||
| 3596 | } | ||
| 3597 | |||
| 3598 | if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface))) | ||
| 3599 | { | ||
| 3600 | int pt = pixel_point_size (f, font->pixel_size * 10); | ||
| 3601 | |||
| 3602 | xassert (pt > 0); | ||
| 3603 | LFACE_HEIGHT (lface) = make_number (pt); | ||
| 3604 | } | ||
| 3605 | |||
| 3606 | if (force_p || UNSPECIFIEDP (LFACE_AVGWIDTH (lface))) | ||
| 3607 | LFACE_AVGWIDTH (lface) = make_number (0); | ||
| 3608 | |||
| 3609 | if (force_p || UNSPECIFIEDP (LFACE_WEIGHT (lface))) | ||
| 3610 | { | ||
| 3611 | Lisp_Object weight = font_symbolic_weight (entity); | ||
| 3612 | Lisp_Object symbol = face_symbolic_weight (weight); | ||
| 3613 | |||
| 3614 | LFACE_WEIGHT (lface) = NILP (symbol) ? weight : symbol; | ||
| 3615 | } | ||
| 3616 | if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface))) | ||
| 3617 | { | ||
| 3618 | Lisp_Object slant = font_symbolic_slant (entity); | ||
| 3619 | Lisp_Object symbol = face_symbolic_slant (slant); | ||
| 3620 | |||
| 3621 | LFACE_SLANT (lface) = NILP (symbol) ? slant : symbol; | ||
| 3622 | } | ||
| 3623 | if (force_p || UNSPECIFIEDP (LFACE_SWIDTH (lface))) | ||
| 3624 | { | ||
| 3625 | Lisp_Object width = font_symbolic_width (entity); | ||
| 3626 | Lisp_Object symbol = face_symbolic_swidth (width); | ||
| 3627 | |||
| 3628 | LFACE_SWIDTH (lface) = NILP (symbol) ? width : symbol; | ||
| 3629 | } | ||
| 3630 | |||
| 3631 | if (font->font.full_name) | ||
| 3632 | LFACE_FONT (lface) = build_string (font->font.full_name); | ||
| 3633 | else | ||
| 3634 | LFACE_FONT (lface) = Qnil; | ||
| 3635 | LFACE_FONTSET (lface) = fontset_name (fontset); | ||
| 3636 | return 1; | ||
| 3637 | } | ||
| 3638 | #endif /* USE_FONT_BACKEND */ | ||
| 3639 | if (fontset > 0) | 3541 | if (fontset > 0) |
| 3640 | font_name = SDATA (fontset_ascii (fontset)); | 3542 | font_name = SDATA (fontset_ascii (fontset)); |
| 3641 | else if (fontset == 0) | 3543 | else if (fontset == 0) |
| @@ -3728,6 +3630,88 @@ set_lface_from_font_name (f, lface, fontname, force_p, may_fail_p) | |||
| 3728 | return 1; | 3630 | return 1; |
| 3729 | } | 3631 | } |
| 3730 | 3632 | ||
| 3633 | #ifdef USE_FONT_BACKEND | ||
| 3634 | /* Set font-related attributes of Lisp face LFACE from FONT-OBJECT and | ||
| 3635 | FONTSET. If FORCE_P is zero, set only unspecified attributes of | ||
| 3636 | LFACE. The exceptions are `font' and `fontset' attributes. They | ||
| 3637 | are set regardless of FORCE_P. */ | ||
| 3638 | |||
| 3639 | static void | ||
| 3640 | set_lface_from_font_and_fontset (f, lface, font_object, fontset, force_p) | ||
| 3641 | struct frame *f; | ||
| 3642 | Lisp_Object lface, font_object; | ||
| 3643 | int fontset; | ||
| 3644 | int force_p; | ||
| 3645 | { | ||
| 3646 | struct font *font = XSAVE_VALUE (font_object)->pointer; | ||
| 3647 | Lisp_Object entity = font->entity; | ||
| 3648 | Lisp_Object val; | ||
| 3649 | |||
| 3650 | /* Set attributes only if unspecified, otherwise face defaults for | ||
| 3651 | new frames would never take effect. If the font doesn't have a | ||
| 3652 | specific property, set a normal value for that. */ | ||
| 3653 | |||
| 3654 | if (force_p || UNSPECIFIEDP (LFACE_FAMILY (lface))) | ||
| 3655 | { | ||
| 3656 | Lisp_Object foundry = AREF (entity, FONT_FOUNDRY_INDEX); | ||
| 3657 | Lisp_Object family = AREF (entity, FONT_FAMILY_INDEX); | ||
| 3658 | |||
| 3659 | if (! NILP (foundry)) | ||
| 3660 | { | ||
| 3661 | if (! NILP (family)) | ||
| 3662 | val = concat3 (SYMBOL_NAME (foundry), build_string ("-"), | ||
| 3663 | SYMBOL_NAME (family)); | ||
| 3664 | else | ||
| 3665 | val = concat2 (SYMBOL_NAME (foundry), build_string ("-*")); | ||
| 3666 | } | ||
| 3667 | else | ||
| 3668 | { | ||
| 3669 | if (! NILP (family)) | ||
| 3670 | val = SYMBOL_NAME (family); | ||
| 3671 | else | ||
| 3672 | val = build_string ("*"); | ||
| 3673 | } | ||
| 3674 | LFACE_FAMILY (lface) = val; | ||
| 3675 | } | ||
| 3676 | |||
| 3677 | if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface))) | ||
| 3678 | { | ||
| 3679 | int pt = pixel_point_size (f, font->pixel_size * 10); | ||
| 3680 | |||
| 3681 | xassert (pt > 0); | ||
| 3682 | LFACE_HEIGHT (lface) = make_number (pt); | ||
| 3683 | } | ||
| 3684 | |||
| 3685 | if (force_p || UNSPECIFIEDP (LFACE_AVGWIDTH (lface))) | ||
| 3686 | LFACE_AVGWIDTH (lface) = make_number (font->font.average_width); | ||
| 3687 | |||
| 3688 | if (force_p || UNSPECIFIEDP (LFACE_WEIGHT (lface))) | ||
| 3689 | { | ||
| 3690 | Lisp_Object weight = font_symbolic_weight (entity); | ||
| 3691 | |||
| 3692 | val = NILP (weight) ? Qnormal : face_symbolic_weight (weight); | ||
| 3693 | LFACE_WEIGHT (lface) = ! NILP (val) ? val : weight; | ||
| 3694 | } | ||
| 3695 | if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface))) | ||
| 3696 | { | ||
| 3697 | Lisp_Object slant = font_symbolic_slant (entity); | ||
| 3698 | |||
| 3699 | val = NILP (slant) ? Qnormal : face_symbolic_slant (slant); | ||
| 3700 | LFACE_SLANT (lface) = ! NILP (val) ? val : slant; | ||
| 3701 | } | ||
| 3702 | if (force_p || UNSPECIFIEDP (LFACE_SWIDTH (lface))) | ||
| 3703 | { | ||
| 3704 | Lisp_Object width = font_symbolic_width (entity); | ||
| 3705 | |||
| 3706 | val = NILP (width) ? Qnormal : face_symbolic_swidth (width); | ||
| 3707 | LFACE_SWIDTH (lface) = ! NILP (val) ? val : width; | ||
| 3708 | } | ||
| 3709 | |||
| 3710 | LFACE_FONT (lface) = font_object; | ||
| 3711 | LFACE_FONTSET (lface) = fontset_name (fontset); | ||
| 3712 | } | ||
| 3713 | #endif /* USE_FONT_BACKEND */ | ||
| 3714 | |||
| 3731 | #endif /* HAVE_WINDOW_SYSTEM */ | 3715 | #endif /* HAVE_WINDOW_SYSTEM */ |
| 3732 | 3716 | ||
| 3733 | 3717 | ||
| @@ -4565,6 +4549,48 @@ FRAME 0 means change the face on all frames, and change the default | |||
| 4565 | else | 4549 | else |
| 4566 | f = check_x_frame (frame); | 4550 | f = check_x_frame (frame); |
| 4567 | 4551 | ||
| 4552 | #ifdef USE_FONT_BACKEND | ||
| 4553 | if (enable_font_backend | ||
| 4554 | && !UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)) | ||
| 4555 | { | ||
| 4556 | int fontset; | ||
| 4557 | |||
| 4558 | if (EQ (attr, QCfontset)) | ||
| 4559 | { | ||
| 4560 | Lisp_Object fontset_name = Fquery_fontset (value, Qnil); | ||
| 4561 | |||
| 4562 | if (NILP (fontset_name)) | ||
| 4563 | signal_error ("Invalid fontset name", value); | ||
| 4564 | LFACE_FONTSET (lface) = value; | ||
| 4565 | } | ||
| 4566 | else | ||
| 4567 | { | ||
| 4568 | Lisp_Object font_object; | ||
| 4569 | |||
| 4570 | if (FONT_OBJECT_P (value)) | ||
| 4571 | { | ||
| 4572 | font_object = value; | ||
| 4573 | fontset = FRAME_FONTSET (f); | ||
| 4574 | } | ||
| 4575 | else | ||
| 4576 | { | ||
| 4577 | CHECK_STRING (value); | ||
| 4578 | |||
| 4579 | fontset = fs_query_fontset (value, 0); | ||
| 4580 | if (fontset >= 0) | ||
| 4581 | value = fontset_ascii (fontset); | ||
| 4582 | else | ||
| 4583 | fontset = FRAME_FONTSET (f); | ||
| 4584 | font_object = font_open_by_name (f, SDATA (value)); | ||
| 4585 | if (NILP (font_object)) | ||
| 4586 | signal_error ("Invalid font", value); | ||
| 4587 | } | ||
| 4588 | set_lface_from_font_and_fontset (f, lface, font_object, | ||
| 4589 | fontset, 1); | ||
| 4590 | } | ||
| 4591 | } | ||
| 4592 | else | ||
| 4593 | #endif /* USE_FONT_BACKEND */ | ||
| 4568 | if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)) | 4594 | if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)) |
| 4569 | { | 4595 | { |
| 4570 | CHECK_STRING (value); | 4596 | CHECK_STRING (value); |
| @@ -4764,13 +4790,18 @@ set_font_frame_param (frame, lface) | |||
| 4764 | #ifdef USE_FONT_BACKEND | 4790 | #ifdef USE_FONT_BACKEND |
| 4765 | else if (enable_font_backend) | 4791 | else if (enable_font_backend) |
| 4766 | { | 4792 | { |
| 4767 | Lisp_Object entity = font_find_for_lface (f, &AREF (lface, 0), Qnil); | 4793 | /* We set FONT_NAME to a font-object. */ |
| 4768 | 4794 | if (FONT_OBJECT_P (LFACE_FONT (lface))) | |
| 4769 | if (NILP (entity)) | 4795 | font_name = LFACE_FONT (lface); |
| 4770 | error ("No font matches the specified attribute"); | 4796 | else |
| 4771 | font_name = font_open_for_lface (f, &AREF (lface, 0), entity); | 4797 | { |
| 4772 | if (NILP (font_name)) | 4798 | font_name = font_find_for_lface (f, &AREF (lface, 0), Qnil); |
| 4773 | error ("No font matches the specified attribute"); | 4799 | if (NILP (font_name)) |
| 4800 | error ("No font matches the specified attribute"); | ||
| 4801 | font_name = font_open_for_lface (f, &AREF (lface, 0), font_name); | ||
| 4802 | if (NILP (font_name)) | ||
| 4803 | error ("No font matches the specified attribute"); | ||
| 4804 | } | ||
| 4774 | } | 4805 | } |
| 4775 | #endif | 4806 | #endif |
| 4776 | else | 4807 | else |
| @@ -7412,12 +7443,27 @@ realize_default_face (f) | |||
| 7412 | #ifdef HAVE_WINDOW_SYSTEM | 7443 | #ifdef HAVE_WINDOW_SYSTEM |
| 7413 | if (FRAME_WINDOW_P (f)) | 7444 | if (FRAME_WINDOW_P (f)) |
| 7414 | { | 7445 | { |
| 7446 | #ifdef USE_FONT_BACKEND | ||
| 7447 | if (enable_font_backend) | ||
| 7448 | { | ||
| 7449 | frame_font = font_find_object (FRAME_FONT_OBJECT (f)); | ||
| 7450 | xassert (FONT_OBJECT_P (frame_font)); | ||
| 7451 | set_lface_from_font_and_fontset (f, lface, frame_font, | ||
| 7452 | FRAME_FONTSET (f), | ||
| 7453 | f->default_face_done_p); | ||
| 7454 | } | ||
| 7455 | else | ||
| 7456 | { | ||
| 7457 | #endif /* USE_FONT_BACKEND */ | ||
| 7415 | /* Set frame_font to the value of the `font' frame parameter. */ | 7458 | /* Set frame_font to the value of the `font' frame parameter. */ |
| 7416 | frame_font = Fassq (Qfont, f->param_alist); | 7459 | frame_font = Fassq (Qfont, f->param_alist); |
| 7417 | xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font))); | 7460 | xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font))); |
| 7418 | frame_font = XCDR (frame_font); | 7461 | frame_font = XCDR (frame_font); |
| 7419 | set_lface_from_font_name (f, lface, frame_font, | 7462 | set_lface_from_font_name (f, lface, frame_font, |
| 7420 | f->default_face_done_p, 1); | 7463 | f->default_face_done_p, 1); |
| 7464 | #ifdef USE_FONT_BACKEND | ||
| 7465 | } | ||
| 7466 | #endif /* USE_FONT_BACKEND */ | ||
| 7421 | f->default_face_done_p = 1; | 7467 | f->default_face_done_p = 1; |
| 7422 | } | 7468 | } |
| 7423 | #endif /* HAVE_WINDOW_SYSTEM */ | 7469 | #endif /* HAVE_WINDOW_SYSTEM */ |