/* Composite sequence support.
Copyright (C) 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008 Free Software Foundation, Inc.
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H14PRO021
Copyright (C) 2003, 2006
else
{
CHECK_STRING (string);
- if (! STRING_MULTIBYTE (current_buffer->enable_multibyte_characters))
+ if (! STRING_MULTIBYTE (string))
error ("Attempt to shape unibyte text");
- CHECK_NATNUM (start);
+ /* FROM and TO are checked by the caller. */
from = XINT (start);
- CHECK_NATNUM (end);
to = XINT (end);
if (from < 0 || from > to || to > SCHARS (string))
args_out_of_range_3 (string, start, end);
else
FETCH_CHAR_ADVANCE (c, charpos, bytepos);
if (c == '\n')
- break;
+ {
+ cmp_it->ch = -2;
+ break;
+ }
val = CHAR_TABLE_REF (Vcomposition_function_table, c);
if (! NILP (val))
{
}
}
cmp_it->stop_pos = charpos;
- cmp_it->ch = -2;
}
/* Check if the character at CHARPOS (and BYTEPOS) is composed
- (possibly with the following charaters) on window W. ENDPOS limits
+ (possibly with the following characters) on window W. ENDPOS limits
characters to be composed. FACE, in non-NULL, is a base face of
the character. If STRING is not nil, it is a string containing the
character to check, and CHARPOS and BYTEPOS are indices in the
DEFUN ("composition-get-gstring", Fcomposition_get_gstring,
Scomposition_get_gstring, 4, 4, 0,
doc: /* Return a glyph-string for characters between FROM and TO.
-If the glhph string is for graphic display, FONT-OBJECT must be
+If the glyph string is for graphic display, FONT-OBJECT must be
a font-object to use for those characters.
Otherwise (for terminal display), FONT-OBJECT must be nil.
If the optional 4th argument STRING is not nil, it is a string
containing the target characters between indices FROM and TO.
-A glhph-string is a vector containing information about how to display
-specific character sequence. The format is:
+A glyph-string is a vector containing information about how to display
+a specific character sequence. The format is:
[HEADER ID GLYPH ...]
HEADER is a vector of this form:
ID is an identification number of the glyph-string. It may be nil if
not yet shaped.
-GLYPH is a vector whose elements has this form:
+GLYPH is a vector whose elements have this form:
[ FROM-IDX TO-IDX C CODE WIDTH LBEARING RBEARING ASCENT DESCENT
[ [X-OFF Y-OFF WADJUST] | nil] ]
where
C is the character of the glyph.
CODE is the glyph-code of C in FONT-OBJECT.
WIDTH thru DESCENT are the metrics (in pixels) of the glyph.
- X-OFF and Y-OFF are offests to the base position for the glyph.
+ X-OFF and Y-OFF are offsets to the base position for the glyph.
WADJUST is the adjustment to the normal width of the glyph.
-If GLYPH is nil, the remaining elements of the glhph-string vector
-must be ignore. */)
+If GLYPH is nil, the remaining elements of the glyph-string vector
+should be ignored. */)
(from, to, font_object, string)
Lisp_Object font_object, from, to, string;
{
Lisp_Object gstring, header;
+ EMACS_INT frompos, topos;
+ CHECK_NATNUM (from);
+ CHECK_NATNUM (to);
if (! NILP (font_object))
CHECK_FONT_OBJECT (font_object);
header = fill_gstring_header (Qnil, from, to, font_object, string);
gstring = gstring_lookup_cache (header);
if (! NILP (gstring))
return gstring;
- if (LGSTRING_GLYPH_LEN (gstring_work) < to - from)
- gstring_work = Fmake_vector (make_number (to - from + 2), Qnil);
+
+ frompos = XINT (from);
+ topos = XINT (to);
+ if (LGSTRING_GLYPH_LEN (gstring_work) < topos - frompos)
+ gstring_work = Fmake_vector (make_number (topos - frompos + 2), Qnil);
LGSTRING_SET_HEADER (gstring_work, header);
LGSTRING_SET_ID (gstring_work, Qnil);
fill_gstring_body (gstring_work);
Compose text in the region between START and END.
Optional 3rd and 4th arguments are COMPONENTS and MODIFICATION-FUNC
-for the composition. See `compose-region' for more detail. */)
+for the composition. See `compose-region' for more details. */)
(start, end, components, modification_func)
Lisp_Object start, end, components, modification_func;
{
Compose text between indices START and END of STRING.
Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC
-for the composition. See `compose-string' for more detail. */)
+for the composition. See `compose-string' for more details. */)
(string, start, end, components, modification_func)
Lisp_Object string, start, end, components, modification_func;
{
doc: /* Internal use only.
Return information about composition at or nearest to position POS.
-See `find-composition' for more detail. */)
+See `find-composition' for more details. */)
(pos, limit, string, detail_p)
Lisp_Object pos, limit, string, detail_p;
{
DEFVAR_LISP ("compose-chars-after-function", &Vcompose_chars_after_function,
doc: /* Function to adjust composition of buffer text.
-The function is called with three arguments FROM, TO, and OBJECT.
-FROM and TO specify the range of text of which composition should be
+This function is called with three arguments: FROM, TO, and OBJECT.
+FROM and TO specify the range of text whose composition should be
adjusted. OBJECT, if non-nil, is a string that contains the text.
This function is called after a text with `composition' property is
DEFVAR_LISP ("auto-composition-function", &Vauto_composition_function,
doc: /* Function to call to compose characters automatically.
-The function is called from the display routine with four arguments,
+This function is called from the display routine with four arguments:
FROM, TO, WINDOW, and STRING.
If STRING is nil, the function must compose characters in the region
Vauto_composition_function = Qnil;
DEFVAR_LISP ("composition-function-table", &Vcomposition_function_table,
- doc: /* Char-able of functions for automatic character composition.
+ doc: /* Char-table of functions for automatic character composition.
For each character that has to be composed automatically with
preceding and/or following characters, this char-table contains
a function to call to compose that character.
The element at index C in the table, if non-nil, is a list of
this form: ([PATTERN PREV-CHARS FUNC] ...)
-PATTERN is a regular expression with which C and the surrounding
+PATTERN is a regular expression which C and the surrounding
characters must match.
PREV-CHARS is a number of characters before C to check the
-matching with PATTERN. If it is 0, PATTERN must match with C and
-the following characters. If it is 1, PATTERN must match with a
+matching with PATTERN. If it is 0, PATTERN must match C and
+the following characters. If it is 1, PATTERN must match a
character before C and the following characters.
If PREV-CHARS is 0, PATTERN can be nil, which means that the
single character C should be composed.
FUNC is a function to return a glyph-string representing a
-composition of the characters matching with PATTERN. It is
+composition of the characters that match PATTERN. It is
called with one argument GSTRING.
GSTRING is a template of a glyph-string to return. It is already
filled with a proper header for the characters to compose, and
glyphs corresponding to those characters one by one. The
-function must return a new glyph-string of the same header as
+function must return a new glyph-string with the same header as
GSTRING, or modify GSTRING itself and return it.
See also the documentation of `auto-composition-mode'. */);