X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a0b5606ec769968b10c765f8ff50f312d691ef62..09af58633c2a83b61dee86bcf3794122b101671a:/src/fontset.c diff --git a/src/fontset.c b/src/fontset.c index 0bf716bf1b..b9f6de33eb 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -39,17 +39,10 @@ along with GNU Emacs. If not, see . */ #include "intervals.h" #include "fontset.h" #include "window.h" -#ifdef HAVE_X_WINDOWS -#include "xterm.h" -#endif -#ifdef HAVE_NTGUI -#include "w32term.h" -#endif -#ifdef HAVE_NS -#include "nsterm.h" -#endif +#ifdef HAVE_WINDOW_SYSTEM +#include TERM_HEADER +#endif /* HAVE_WINDOW_SYSTEM */ #include "termhooks.h" - #include "font.h" /* FONTSET @@ -906,45 +899,36 @@ free_face_fontset (struct frame *f, struct face *face) face->fontset = -1; } - -#if 0 -/* Return true if FACE is suitable for displaying character C. - Called from the macro FACE_SUITABLE_FOR_CHAR_P - when C is not an ASCII character. */ - -bool -face_suitable_for_char_p (struct face *face, int c) -{ - Lisp_Object fontset, rfont_def; - - fontset = FONTSET_FROM_ID (face->fontset); - rfont_def = fontset_font (fontset, c, NULL, -1); - return (VECTORP (rfont_def) - && INTEGERP (RFONT_DEF_FACE (rfont_def)) - && face->id == XINT (RFONT_DEF_FACE (rfont_def))); -} -#endif - - -/* Return ID of face suitable for displaying character C on frame F. - FACE must be realized for ASCII characters in advance. Called from - the macro FACE_FOR_CHAR. */ +/* Return ID of face suitable for displaying character C at buffer position + POS on frame F. FACE must be realized for ASCII characters in advance. + Called from the macro FACE_FOR_CHAR. */ int -face_for_char (struct frame *f, struct face *face, int c, int pos, Lisp_Object object) +face_for_char (struct frame *f, struct face *face, int c, + ptrdiff_t pos, Lisp_Object object) { Lisp_Object fontset, rfont_def, charset; int face_id; int id; - /* If face->fontset is negative (that happens when no font is found - for face), just return face->ascii_face because we can't do - anything. Perhaps, we should fix the callers to assure - that face->fontset is always valid. */ - if (ASCII_CHAR_P (c) || face->fontset < 0) + eassert (fontset_id_valid_p (face->fontset)); + + if (ASCII_CHAR_P (c) || CHAR_BYTE8_P (c)) return face->ascii_face->id; - eassert (fontset_id_valid_p (face->fontset)); +#ifdef HAVE_NS + if (face->font) + { + /* Fonts often have characters in other scripts, like symbol, even if they + don't match script: symbol. So check if the character is present + in the current face first. Only enable for NS for now, but should + perhaps be general? */ + Lisp_Object font_object; + XSETFONT (font_object, face->font); + if (font_has_char (f, font_object, c)) return face->id; + } +#endif + fontset = FONTSET_FROM_ID (face->fontset); eassert (!BASE_FONTSET_P (fontset)); @@ -999,7 +983,7 @@ face_for_char (struct frame *f, struct face *face, int c, int pos, Lisp_Object o Lisp_Object -font_for_char (struct face *face, int c, int pos, Lisp_Object object) +font_for_char (struct face *face, int c, ptrdiff_t pos, Lisp_Object object) { Lisp_Object fontset, rfont_def, charset; int id; @@ -1869,7 +1853,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, return Qnil; w = XWINDOW (window); f = XFRAME (w->frame); - face_id = face_at_buffer_position (w, pos, -1, -1, &dummy, + face_id = face_at_buffer_position (w, pos, &dummy, pos + 100, 0, -1); } if (! CHAR_VALID_P (c))