/* Special categories */
static MSymbol McatCc, McatCf;
+static MSymbol Mdepth;
+
\f
/* Glyph-string composer. */
levels[size] = 0;
idx[size] = GLYPH_INDEX (g);
logical[size++] = g++->c;
- while (g->type != GLYPH_ANCHOR
- && (g[-1].pos == g->pos || g->combining_code))
+ while (g->type != GLYPH_ANCHOR && g->combining_code)
g++;
}
{
int j = indices[i];
int k = idx[j];
- int pos = glyphs[k].pos;
glyphs[k].bidi_level = levels[j];
#ifdef HAVE_FRIBIDI
#endif /* not HAVE_FRIBIDI */
*(MGLYPH (gidx)) = glyphs[k];
for (gidx++, k++;
- (k < gstring->used - 1
- && (glyphs[k].pos == pos || glyphs[k].combining_code));
+ k < gstring->used - 1 && glyphs[k].combining_code;
gidx++, k++)
{
glyphs[k].bidi_level = levels[j];
MRealizedFace *rface = default_rface;
int non_ascii_found;
int size = gstring->control.fixed_width;
- int ignore_formatting_char = gstring->control.ignore_formatting_char;
int i, limit;
+ int last;
MLIST_RESET (gstring);
gstring->from = from;
APPEND_GLYPH (gstring, g_tmp);
stop = face_change = charset_change = language_change = pos = from;
- g = gstring->glyphs + gstring->used;
+ last = 0;
non_ascii_found = 0;
while (1)
{
else
{
g_tmp.category = mchar_get_prop (c, Mcategory);
- if (ignore_formatting_char && g_tmp.category == McatCf)
- g_tmp.type = GLYPH_SPACE, this_script = Mnil;
- else
- {
- g_tmp.type = GLYPH_CHAR;
- this_script = (MSymbol) mchar_get_prop (c, Mscript);
- if (this_script == Minherited)
- this_script = script;
- }
+ g_tmp.type = GLYPH_CHAR;
+ this_script = (MSymbol) mchar_get_prop (c, Mscript);
+ if (this_script == Minherited)
+ this_script = script;
}
- if (pos == stop || script != this_script || g->type != g_tmp.type)
+ if (pos == stop || script != this_script
+ || MGLYPH (last)->type != g_tmp.type)
{
+ g = MGLYPH (last);
if (non_ascii_found && g->type == GLYPH_CHAR)
while (g < gstring->glyphs + gstring->used)
g = mface__for_chars (script, language, charset,
g, gstring->glyphs + gstring->used, size);
- g = gstring->glyphs + gstring->used;
+ last = gstring->used;
non_ascii_found = 0;
script = this_script;
if (pos == to)
language, charset, size)
: default_rface);
}
- stop = language_change;
+ stop = to;
+ if (stop > language_change)
+ stop = language_change;
if (stop > charset_change)
stop = charset_change;
if (face_change < stop)
non_ascii_found = 1;
else if (g_tmp.type == GLYPH_CHAR && (c <= 32 || c == 127))
{
- g_tmp.c = '^';
+ g_tmp.code = '^';
APPEND_GLYPH (gstring, g_tmp);
if (c < ' ')
- g_tmp.c += 0x40;
+ g_tmp.code = g_tmp.c + 0x40;
else
- g_tmp.c = '?';
+ g_tmp.code = '?';
}
APPEND_GLYPH (gstring, g_tmp);
if (c == '\n'
if (this->type == GLYPH_CHAR && this->rface->rfont)
{
int start = i++;
- MGlyph *tmp = gstring->glyphs + i;
if (this->rface->rfont->layouter != Mnil)
{
- while ((tmp->type == GLYPH_CHAR || tmp->type == GLYPH_SPACE)
- && tmp->rface->rfont == this->rface->rfont
- && tmp->code != MCHAR_INVALID_CODE)
- i++, tmp++;
- i = mfont__flt_run (gstring, start, i,
- this->rface->rfont->layouter,
- this->rface->ascii_rface);
+ MGlyph *prev;
+ unsigned code;
+
+ for (prev = MGLYPH (start - 1);
+ (prev->type == GLYPH_CHAR
+ && prev->category == McatCf
+ && (code = mfont__encode_char (this->rface->rfont, prev->c)
+ != MCHAR_INVALID_CODE));
+ start--, prev--)
+ prev->code = code;
+
+ for (g++;
+ (g->type == GLYPH_CHAR
+ && (g->rface->rfont == this->rface->rfont
+ || (g->category == McatCf
+ && ((code = mfont__encode_char (this->rface->rfont,
+ g->c))
+ != MCHAR_INVALID_CODE))));
+ i++, g++)
+ if (g->rface->rfont != this->rface->rfont)
+ g->code = code;
+ i = mfont__flt_run (gstring, start, i, this->rface);
}
else
{
g_physical_descent = gstring->physical_descent;
g_width = g_lbearing = g_rbearing = 0;
+ mfont__get_metric (gstring, from, to);
+
while (g < last_g)
{
MGlyph *base = g++;
int size = rfont->font.property[MFONT_SIZE];
int width, lbearing, rbearing;
- mfont__get_metric (rfont, base);
if (g == last_g || ! g->combining_code)
{
/* No combining. */
else if (end < g->to)
end = g->to;
- mfont__get_metric (rfont, g);
g->xoff = left + (width * base_x - g->width * add_x) / 2 + off_x;
if (g->xoff < left)
left = g->xoff;
base->ascent = - top;
base->descent = bottom;
+ base->lbearing = lbearing;
+ base->rbearing = rbearing;
if (left < - base->width)
{
base->xoff = - base->width - left;
int width;
MFaceBoxProp *box;
int box_line_height = 0;
+ int ignore_formatting_char = control->ignore_formatting_char;
gstring->ascent = gstring->descent = 0;
gstring->physical_ascent = gstring->physical_descent = 0;
}
}
+ if (g->category == McatCf && ignore_formatting_char)
+ g->type = GLYPH_SPACE;
+
if (g->type == GLYPH_CHAR)
{
MRealizedFace *rface = g->rface;
if (! rfont != ! g->rface->rfont
|| box != g->rface->box
|| ((fromg->code == MCHAR_INVALID_CODE)
- != (g->code == MCHAR_INVALID_CODE)))
+ != (g->code == MCHAR_INVALID_CODE))
+ || (g->category == McatCf && ignore_formatting_char))
break;
if (rfont && fromg->code != MCHAR_INVALID_CODE)
{
rect.x += rect.width;
if (rect.x < x + width)
{
- while (g != gend && x + width - gend[-1].width >= rect.x)
+ while (g != gend
+ && (x + width - gend[-1].width + gend[-1].lbearing >= rect.x))
{
width -= (--gend)->width;
while (! gend->enabled && g != gend)
static MGlyphString scratch_gstring;
static MGlyphString *
-alloc_gstring (MText *mt, int pos, MDrawControl *control, int line, int y)
+alloc_gstring (MFrame *frame, MText *mt, int pos, MDrawControl *control,
+ int line, int y)
{
MGlyphString *gstring;
(*control->format) (line, y, &(gstring->indent), &(gstring->width_limit));
else
gstring->width_limit = control->max_line_width;
+ gstring->anti_alias = control->anti_alias;
+ if (gstring->anti_alias
+ && (unsigned) mwin__device_get_prop (frame->device, Mdepth) < 8)
+ gstring->anti_alias = 0;
return gstring;
}
beg = pos;
end = to;
}
- gstring = alloc_gstring (mt, beg, control, line, y);
+ gstring = alloc_gstring (frame, mt, beg, control, line, y);
compose_glyph_string (frame, mt, beg, end, gstring);
layout_glyph_string (frame, gstring);
end = gstring->to;
while (gst->to < end)
{
line++, y += gst->height;
- gst->next = alloc_gstring (mt, gst->from, control, line, y);
+ gst->next = alloc_gstring (frame, mt, gst->from, control,
+ line, y);
gst->next->top = gstring;
compose_glyph_string (frame, mt, gst->to, end, gst->next);
gst = gst->next;
else if (off_y < 0)
sprintf (work + 2, "%d", off_y);
else if (off_x == 0)
- sprintf (work + 2, "-");
+ sprintf (work + 2, ".");
p = work + strlen (work);
if (off_x > 0)
sprintf (p, ">%d", off_x);
McatCc = msymbol ("Cc");
McatCf = msymbol ("Cf");
+ Mdepth = msymbol ("depth");
MbidiR = msymbol ("R");
MbidiAL = msymbol ("AL");