aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2007-12-14 11:16:47 +0000
committerKenichi Handa2007-12-14 11:16:47 +0000
commite3ee03407f1d5f644087077f7f139fe9653c2af2 (patch)
tree2aba3af6495c7da3e7d41272c652b7c8588f8846 /src
parentce021083cdd62fd15e44b38a28dac560679c070c (diff)
downloademacs-e3ee03407f1d5f644087077f7f139fe9653c2af2.tar.gz
emacs-e3ee03407f1d5f644087077f7f139fe9653c2af2.zip
(font_at): Handle the case that the arg C is negative.
Handle the unibyte case. (Ffont_at): Call font_at with the arg C -1.
Diffstat (limited to 'src')
-rw-r--r--src/font.c70
1 files changed, 50 insertions, 20 deletions
diff --git a/src/font.c b/src/font.c
index 7390a978162..f11ef974ccd 100644
--- a/src/font.c
+++ b/src/font.c
@@ -2854,36 +2854,73 @@ font_get_frame_data (f, driver)
2854 2854
2855 2855
2856/* Return the font used to draw character C by FACE at buffer position 2856/* Return the font used to draw character C by FACE at buffer position
2857 POS in window W. If OBJECT is non-nil, it is a string containing C 2857 POS in window W. If STRING is non-nil, it is a string containing C
2858 at index POS. */ 2858 at index POS. If C is negative, get C from the current buffer or
2859 STRING. */
2859 2860
2860Lisp_Object 2861Lisp_Object
2861font_at (c, pos, face, w, object) 2862font_at (c, pos, face, w, string)
2862 int c; 2863 int c;
2863 EMACS_INT pos; 2864 EMACS_INT pos;
2864 struct face *face; 2865 struct face *face;
2865 struct window *w; 2866 struct window *w;
2866 Lisp_Object object; 2867 Lisp_Object string;
2867{ 2868{
2868 FRAME_PTR f; 2869 FRAME_PTR f;
2869 int face_id; 2870 int multibyte;
2870 int dummy; 2871
2872 if (c < 0)
2873 {
2874 if (NILP (string))
2875 {
2876 multibyte = ! NILP (current_buffer->enable_multibyte_characters);
2877 if (multibyte)
2878 {
2879 EMACS_INT pos_byte = CHAR_TO_BYTE (pos);
2880
2881 c = FETCH_CHAR (pos_byte);
2882 }
2883 else
2884 c = FETCH_BYTE (pos);
2885 }
2886 else
2887 {
2888 unsigned char *str;
2889
2890 multibyte = STRING_MULTIBYTE (string);
2891 if (multibyte)
2892 {
2893 EMACS_INT pos_byte = string_char_to_byte (string, pos);
2894
2895 str = SDATA (string) + pos_byte;
2896 c = STRING_CHAR (str, 0);
2897 }
2898 else
2899 c = SDATA (string)[pos];
2900 }
2901 }
2871 2902
2872 f = XFRAME (w->frame); 2903 f = XFRAME (w->frame);
2873 if (! FRAME_WINDOW_P (f)) 2904 if (! FRAME_WINDOW_P (f))
2874 return Qnil; 2905 return Qnil;
2875 if (! face) 2906 if (! face)
2876 { 2907 {
2877 if (STRINGP (object)) 2908 int face_id;
2878 face_id = face_at_string_position (w, object, pos, 0, -1, -1, &dummy, 2909 int endptr;
2910
2911 if (STRINGP (string))
2912 face_id = face_at_string_position (w, string, pos, 0, -1, -1, &endptr,
2879 DEFAULT_FACE_ID, 0); 2913 DEFAULT_FACE_ID, 0);
2880 else 2914 else
2881 face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, 2915 face_id = face_at_buffer_position (w, pos, -1, -1, &endptr,
2882 pos + 100, 0); 2916 pos + 100, 0);
2883 face = FACE_FROM_ID (f, face_id); 2917 face = FACE_FROM_ID (f, face_id);
2884 } 2918 }
2885 face_id = FACE_FOR_CHAR (f, face, c, pos, object); 2919 if (multibyte)
2886 face = FACE_FROM_ID (f, face_id); 2920 {
2921 int face_id = FACE_FOR_CHAR (f, face, c, pos, string);
2922 face = FACE_FROM_ID (f, face_id);
2923 }
2887 if (! face->font_info) 2924 if (! face->font_info)
2888 return Qnil; 2925 return Qnil;
2889 return font_find_object ((struct font *) face->font_info); 2926 return font_find_object ((struct font *) face->font_info);
@@ -3759,8 +3796,7 @@ the current buffer. It defaults to the currently selected window. */)
3759 Lisp_Object position, window, string; 3796 Lisp_Object position, window, string;
3760{ 3797{
3761 struct window *w; 3798 struct window *w;
3762 EMACS_INT pos, pos_byte; 3799 EMACS_INT pos;
3763 int c;
3764 3800
3765 if (NILP (string)) 3801 if (NILP (string))
3766 { 3802 {
@@ -3768,8 +3804,6 @@ the current buffer. It defaults to the currently selected window. */)
3768 pos = XINT (position); 3804 pos = XINT (position);
3769 if (pos < BEGV || pos >= ZV) 3805 if (pos < BEGV || pos >= ZV)
3770 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV)); 3806 args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
3771 pos_byte = CHAR_TO_BYTE (pos);
3772 c = FETCH_CHAR (pos_byte);
3773 } 3807 }
3774 else 3808 else
3775 { 3809 {
@@ -3781,17 +3815,13 @@ the current buffer. It defaults to the currently selected window. */)
3781 pos = XINT (position); 3815 pos = XINT (position);
3782 if (pos < 0 || pos >= SCHARS (string)) 3816 if (pos < 0 || pos >= SCHARS (string))
3783 args_out_of_range (string, position); 3817 args_out_of_range (string, position);
3784 pos_byte = string_char_to_byte (string, pos);
3785 str = SDATA (string) + pos_byte;
3786 len = SBYTES (string) - pos_byte;
3787 c = STRING_CHAR (str, eln);
3788 } 3818 }
3789 if (NILP (window)) 3819 if (NILP (window))
3790 window = selected_window; 3820 window = selected_window;
3791 CHECK_LIVE_WINDOW (window); 3821 CHECK_LIVE_WINDOW (window);
3792 w = XWINDOW (selected_window); 3822 w = XWINDOW (selected_window);
3793 3823
3794 return font_at (c, pos, NULL, w, Qnil); 3824 return font_at (-1, pos, NULL, w, Qnil);
3795} 3825}
3796 3826
3797#if 0 3827#if 0