(font_range): Don't require a font for a variation
selector. (Ffont_variation_glyphs): New function. (syms_of_font): Defsubr it.
This commit is contained in:
parent
2b33f1efb5
commit
78a2f9cd53
1 changed files with 44 additions and 0 deletions
44
src/font.c
44
src/font.c
|
@ -3811,6 +3811,7 @@ font_range (pos, limit, w, face, string)
|
|||
|
||||
category = CHAR_TABLE_REF (Vunicode_category_table, c);
|
||||
if (! EQ (category, QCf)
|
||||
&& ! CHAR_VARIATION_SELECTOR_P (c)
|
||||
&& font_encode_char (font_object, c) == FONT_INVALID_CODE)
|
||||
{
|
||||
Lisp_Object f = font_for_char (face, c, pos - 1, string);
|
||||
|
@ -3832,6 +3833,7 @@ font_range (pos, limit, w, face, string)
|
|||
FETCH_STRING_CHAR_ADVANCE_NO_CHECK (c, string, i, i_byte);
|
||||
category = CHAR_TABLE_REF (Vunicode_category_table, c);
|
||||
if (! EQ (category, QCf)
|
||||
&& ! CHAR_VARIATION_SELECTOR_P (c)
|
||||
&& font_encode_char (f, c) == FONT_INVALID_CODE)
|
||||
{
|
||||
*limit = pos - 1;
|
||||
|
@ -4407,6 +4409,47 @@ created glyph-string. Otherwise, the value is nil. */)
|
|||
return composition_gstring_put_cache (gstring, XINT (n));
|
||||
}
|
||||
|
||||
DEFUN ("font-variation-glyphs", Ffont_variation_glyphs, Sfont_variation_glyphs,
|
||||
2, 2, 0,
|
||||
doc: /* Return a list of variation glyphs for CHAR in FONT-OBJECT.
|
||||
Each element of the value is a cons (VARIATION-SELECTOR . GLYPH-ID),
|
||||
where
|
||||
VARIATION-SELECTOR is a chracter code of variation selection
|
||||
(#xFE00..#xFE0F or #xE0100..#xE01EF)
|
||||
GLYPH-ID is a glyph code of the corresponding variation glyph. */)
|
||||
(font_object, character)
|
||||
Lisp_Object font_object, character;
|
||||
{
|
||||
unsigned variations[256];
|
||||
struct font *font;
|
||||
int i, n;
|
||||
Lisp_Object val;
|
||||
|
||||
CHECK_FONT_OBJECT (font_object);
|
||||
CHECK_CHARACTER (character);
|
||||
font = XFONT_OBJECT (font_object);
|
||||
if (! font->driver->get_variation_glyphs)
|
||||
return Qnil;
|
||||
n = font->driver->get_variation_glyphs (font, XINT (character), variations);
|
||||
if (! n)
|
||||
return Qnil;
|
||||
val = Qnil;
|
||||
for (i = 0; i < 255; i++)
|
||||
if (variations[i])
|
||||
{
|
||||
Lisp_Object code;
|
||||
int vs = (i < 16 ? 0xFE00 + i : 0xE0100 + (i - 16));
|
||||
|
||||
if (variations[i] > MOST_POSITIVE_FIXNUM)
|
||||
code = Fcons (make_number ((variations[i]) >> 16),
|
||||
make_number ((variations[i]) & 0xFFFF));
|
||||
else
|
||||
code = make_number (variations[i]);
|
||||
val = Fcons (Fcons (make_number (vs), code), val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
DEFUN ("font-drive-otf", Ffont_drive_otf, Sfont_drive_otf, 6, 6, 0,
|
||||
|
@ -5065,6 +5108,7 @@ syms_of_font ()
|
|||
defsubr (&Sfont_xlfd_name);
|
||||
defsubr (&Sclear_font_cache);
|
||||
defsubr (&Sfont_shape_gstring);
|
||||
defsubr (&Sfont_variation_glyphs);
|
||||
#if 0
|
||||
defsubr (&Sfont_drive_otf);
|
||||
defsubr (&Sfont_otf_alternates);
|
||||
|
|
Loading…
Add table
Reference in a new issue