From: handa Date: Thu, 22 Sep 2005 07:20:15 +0000 (+0000) Subject: (mface__realize): Set rface->average_width. X-Git-Tag: REL-1-3-0~155 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fc8198626f60ef824c103679aa40d3b3a46ef83;p=m17n%2Fm17n-lib.git (mface__realize): Set rface->average_width. (mface__update_frame_face): Set frame->average_width. --- diff --git a/src/face.c b/src/face.c index db7c807..e8cd66a 100644 --- a/src/face.c +++ b/src/face.c @@ -724,6 +724,20 @@ mface__realize (MFrame *frame, MFace **faces, int num, int size, MFont *font) } else rface->space_width = rfont->spec.size / 10; + if (rfont->average_width) + rface->average_width = rfont->average_width; + else + { + work_gstring.glyphs[0].code + = mfont__encode_char (frame, (MFont *) rfont, NULL, 'x'); + if (work_gstring.glyphs[0].code != MCHAR_INVALID_CODE) + { + mfont__get_metric (&work_gstring, 0, 1); + rface->average_width = work_gstring.glyphs[0].width; + } + else + rface->average_width = rface->space_width; + } } else { @@ -857,6 +871,7 @@ mface__update_frame_face (MFrame *frame) frame->rface = NULL; frame->rface = mface__realize (frame, NULL, 0, 0, NULL); frame->space_width = frame->rface->space_width; + frame->average_width = frame->rface->average_width; frame->ascent = frame->rface->ascent; frame->descent = frame->rface->descent; }