Commit b876ea91 authored by Kenichi Handa's avatar Kenichi Handa
Browse files

If the font driver doesn't have `shape' function, return Qnil.

parent a1fe5dfa
......@@ -3625,6 +3625,12 @@ FONT-OBJECT. */)
Lisp_Object gstring, n;
int len, i, j;
if (! FONT_OBJECT_P (font_object))
return Qnil;
CHECK_FONT_GET_OBJECT (font_object, font);
if (! font->driver->shape)
return Qnil;
if (NILP (string))
{
validate_region (&from, &to);
......@@ -3641,49 +3647,9 @@ FONT-OBJECT. */)
args_out_of_range_3 (string, from, to);
}
if (! FONT_OBJECT_P (font_object))
return to;
CHECK_FONT_GET_OBJECT (font_object, font);
len = end - start;
gstring = Ffont_make_gstring (font_object, make_number (len));
Ffont_fill_gstring (gstring, font_object, from, to, string);
if (! font->driver->shape)
{
/* Make zero-width glyphs to have one pixel width to make the
display routine not lose the cursor. */
for (i = 0; i < len; i++)
{
Lisp_Object g = LGSTRING_GLYPH (gstring, i);
unsigned code;
struct font_metrics metrics;
if (NILP (g))
break;
code = LGLYPH_CODE (g);
if (font->driver->text_extents (font, &code, 1, &metrics) == 0)
{
Lisp_Object gstr = Ffont_make_gstring (font_object,
make_number (1));
LGSTRING_SET_WIDTH (gstr, 1);
LGSTRING_SET_LBEARING (gstr, metrics.lbearing);
LGSTRING_SET_RBEARING (gstr, metrics.rbearing + 1);
LGSTRING_SET_ASCENT (gstr, metrics.ascent);
LGSTRING_SET_DESCENT (gstr, metrics.descent);
LGLYPH_SET_FROM (g, 0);
LGLYPH_SET_TO (g, 1);
LGSTRING_SET_GLYPH (gstr, 0, g);
from = make_number (start + i);
to = make_number (start + i + 1);
if (NILP (string))
Fcompose_region_internal (from, to, gstr, Qnil);
else
Fcompose_string_internal (string, from, to, gstr, Qnil);
}
}
return make_number (end);
}
/* Try at most three times with larger gstring each time. */
for (i = 0; i < 3; i++)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment