One more minor cleanup of font subsystem.
* font.h (struct font_driver): Convert text_extents to return void because returned value is never actually used. * macfont.c (macfont_text_extents): * w32font.c (w32font_text_extents): * xftfont.c (xftfont_text_extents): Adjust to return void and assume that 'metrics' argument is always non-NULL. * ftfont.c (ftfont_text_extents): * xfont.c (xfont_text_extents): Likewise. Avoid redundant memset.
This commit is contained in:
parent
90c5c87753
commit
8661ebaa6c
10 changed files with 166 additions and 194 deletions
|
@ -1,3 +1,15 @@
|
|||
2014-08-25 Dmitry Antipov <dmantipov@yandex.ru>
|
||||
|
||||
One more minor cleanup of font subsystem.
|
||||
* font.h (struct font_driver): Convert text_extents to
|
||||
return void because returned value is never actually used.
|
||||
* macfont.c (macfont_text_extents):
|
||||
* w32font.c (w32font_text_extents):
|
||||
* xftfont.c (xftfont_text_extents): Adjust to return void
|
||||
and assume that 'metrics' argument is always non-NULL.
|
||||
* ftfont.c (ftfont_text_extents):
|
||||
* xfont.c (xfont_text_extents): Likewise. Avoid redundant memset.
|
||||
|
||||
2014-08-25 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Minor cleanups of str_collate fix (Bug#18051).
|
||||
|
|
|
@ -570,9 +570,9 @@ struct font_driver
|
|||
/* Compute the total metrics of the NGLYPHS glyphs specified by
|
||||
the font FONT and the sequence of glyph codes CODE, and store the
|
||||
result in METRICS. */
|
||||
int (*text_extents) (struct font *font,
|
||||
unsigned *code, int nglyphs,
|
||||
struct font_metrics *metrics);
|
||||
void (*text_extents) (struct font *font,
|
||||
unsigned *code, int nglyphs,
|
||||
struct font_metrics *metrics);
|
||||
|
||||
#ifdef HAVE_WINDOW_SYSTEM
|
||||
|
||||
|
|
58
src/ftfont.c
58
src/ftfont.c
|
@ -499,8 +499,8 @@ static Lisp_Object ftfont_open (struct frame *, Lisp_Object, int);
|
|||
static void ftfont_close (struct font *);
|
||||
static int ftfont_has_char (Lisp_Object, int);
|
||||
static unsigned ftfont_encode_char (struct font *, int);
|
||||
static int ftfont_text_extents (struct font *, unsigned *, int,
|
||||
struct font_metrics *);
|
||||
static void ftfont_text_extents (struct font *, unsigned *, int,
|
||||
struct font_metrics *);
|
||||
static int ftfont_get_bitmap (struct font *, unsigned,
|
||||
struct font_bitmap *, int);
|
||||
static int ftfont_anchor_point (struct font *, unsigned, int,
|
||||
|
@ -1371,19 +1371,18 @@ ftfont_encode_char (struct font *font, int c)
|
|||
return (code > 0 ? code : FONT_INVALID_CODE);
|
||||
}
|
||||
|
||||
static int
|
||||
ftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics)
|
||||
static void
|
||||
ftfont_text_extents (struct font *font, unsigned int *code,
|
||||
int nglyphs, struct font_metrics *metrics)
|
||||
{
|
||||
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
|
||||
FT_Face ft_face = ftfont_info->ft_size->face;
|
||||
int width = 0;
|
||||
int i;
|
||||
int i, width = 0;
|
||||
bool first;
|
||||
|
||||
if (ftfont_info->ft_size != ft_face->size)
|
||||
FT_Activate_Size (ftfont_info->ft_size);
|
||||
if (metrics)
|
||||
memset (metrics, 0, sizeof (struct font_metrics));
|
||||
|
||||
for (i = 0, first = 1; i < nglyphs; i++)
|
||||
{
|
||||
if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0)
|
||||
|
@ -1392,39 +1391,28 @@ ftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct
|
|||
|
||||
if (first)
|
||||
{
|
||||
if (metrics)
|
||||
{
|
||||
metrics->lbearing = m->horiBearingX >> 6;
|
||||
metrics->rbearing = (m->horiBearingX + m->width) >> 6;
|
||||
metrics->ascent = m->horiBearingY >> 6;
|
||||
metrics->descent = (m->height - m->horiBearingY) >> 6;
|
||||
}
|
||||
metrics->lbearing = m->horiBearingX >> 6;
|
||||
metrics->rbearing = (m->horiBearingX + m->width) >> 6;
|
||||
metrics->ascent = m->horiBearingY >> 6;
|
||||
metrics->descent = (m->height - m->horiBearingY) >> 6;
|
||||
first = 0;
|
||||
}
|
||||
if (metrics)
|
||||
{
|
||||
if (metrics->lbearing > width + (m->horiBearingX >> 6))
|
||||
metrics->lbearing = width + (m->horiBearingX >> 6);
|
||||
if (metrics->rbearing
|
||||
< width + ((m->horiBearingX + m->width) >> 6))
|
||||
metrics->rbearing
|
||||
= width + ((m->horiBearingX + m->width) >> 6);
|
||||
if (metrics->ascent < (m->horiBearingY >> 6))
|
||||
metrics->ascent = m->horiBearingY >> 6;
|
||||
if (metrics->descent > ((m->height - m->horiBearingY) >> 6))
|
||||
metrics->descent = (m->height - m->horiBearingY) >> 6;
|
||||
}
|
||||
if (metrics->lbearing > width + (m->horiBearingX >> 6))
|
||||
metrics->lbearing = width + (m->horiBearingX >> 6);
|
||||
if (metrics->rbearing
|
||||
< width + ((m->horiBearingX + m->width) >> 6))
|
||||
metrics->rbearing
|
||||
= width + ((m->horiBearingX + m->width) >> 6);
|
||||
if (metrics->ascent < (m->horiBearingY >> 6))
|
||||
metrics->ascent = m->horiBearingY >> 6;
|
||||
if (metrics->descent > ((m->height - m->horiBearingY) >> 6))
|
||||
metrics->descent = (m->height - m->horiBearingY) >> 6;
|
||||
width += m->horiAdvance >> 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
width += font->space_width;
|
||||
}
|
||||
width += font->space_width;
|
||||
}
|
||||
if (metrics)
|
||||
metrics->width = width;
|
||||
|
||||
return width;
|
||||
metrics->width = width;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -1553,8 +1553,8 @@ static CGGlyph macfont_get_glyph_for_cid (struct font *font,
|
|||
static void macfont_close (struct font *);
|
||||
static int macfont_has_char (Lisp_Object, int);
|
||||
static unsigned macfont_encode_char (struct font *, int);
|
||||
static int macfont_text_extents (struct font *, unsigned int *, int,
|
||||
struct font_metrics *);
|
||||
static void macfont_text_extents (struct font *, unsigned int *, int,
|
||||
struct font_metrics *);
|
||||
static int macfont_draw (struct glyph_string *, int, int, int, int, bool);
|
||||
static Lisp_Object macfont_shape (Lisp_Object);
|
||||
static int macfont_variation_glyphs (struct font *, int c,
|
||||
|
@ -2653,9 +2653,9 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
|||
return glyph != kCGFontIndexInvalid ? glyph : FONT_INVALID_CODE;
|
||||
}
|
||||
|
||||
static int
|
||||
macfont_text_extents (struct font *font, unsigned int *code, int nglyphs,
|
||||
struct font_metrics *metrics)
|
||||
static void
|
||||
macfont_text_extents (struct font *font, unsigned int *code,
|
||||
int nglyphs, struct font_metrics *metrics)
|
||||
{
|
||||
int width, i;
|
||||
|
||||
|
@ -2664,28 +2664,21 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
|
|||
for (i = 1; i < nglyphs; i++)
|
||||
{
|
||||
struct font_metrics m;
|
||||
int w = macfont_glyph_extents (font, code[i], metrics ? &m : NULL,
|
||||
NULL, 0);
|
||||
int w = macfont_glyph_extents (font, code[i], &m, NULL, 0);
|
||||
|
||||
if (metrics)
|
||||
{
|
||||
if (width + m.lbearing < metrics->lbearing)
|
||||
metrics->lbearing = width + m.lbearing;
|
||||
if (width + m.rbearing > metrics->rbearing)
|
||||
metrics->rbearing = width + m.rbearing;
|
||||
if (m.ascent > metrics->ascent)
|
||||
metrics->ascent = m.ascent;
|
||||
if (m.descent > metrics->descent)
|
||||
metrics->descent = m.descent;
|
||||
}
|
||||
if (width + m.lbearing < metrics->lbearing)
|
||||
metrics->lbearing = width + m.lbearing;
|
||||
if (width + m.rbearing > metrics->rbearing)
|
||||
metrics->rbearing = width + m.rbearing;
|
||||
if (m.ascent > metrics->ascent)
|
||||
metrics->ascent = m.ascent;
|
||||
if (m.descent > metrics->descent)
|
||||
metrics->descent = m.descent;
|
||||
width += w;
|
||||
}
|
||||
unblock_input ();
|
||||
|
||||
if (metrics)
|
||||
metrics->width = width;
|
||||
|
||||
return width;
|
||||
metrics->width = width;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
14
src/nsfont.m
14
src/nsfont.m
|
@ -627,8 +627,8 @@ static Lisp_Object nsfont_open (struct frame *f, Lisp_Object font_entity,
|
|||
static void nsfont_close (struct font *font);
|
||||
static int nsfont_has_char (Lisp_Object entity, int c);
|
||||
static unsigned int nsfont_encode_char (struct font *font, int c);
|
||||
static int nsfont_text_extents (struct font *font, unsigned int *code,
|
||||
int nglyphs, struct font_metrics *metrics);
|
||||
static void nsfont_text_extents (struct font *font, unsigned int *code,
|
||||
int nglyphs, struct font_metrics *metrics);
|
||||
static int nsfont_draw (struct glyph_string *s, int from, int to, int x, int y,
|
||||
bool with_background);
|
||||
|
||||
|
@ -988,9 +988,9 @@ when setting family in ns_spec_to_descriptor(). */
|
|||
/* Perform the size computation of glyphs of FONT and fill in members
|
||||
of METRICS. The glyphs are specified by their glyph codes in
|
||||
CODE (length NGLYPHS). */
|
||||
static int
|
||||
nsfont_text_extents (struct font *font, unsigned int *code, int nglyphs,
|
||||
struct font_metrics *metrics)
|
||||
static void
|
||||
nsfont_text_extents (struct font *font, unsigned int *code,
|
||||
int nglyphs, struct font_metrics *metrics)
|
||||
{
|
||||
struct nsfont_info *font_info = (struct nsfont_info *)font;
|
||||
struct font_metrics *pcm;
|
||||
|
@ -1000,7 +1000,7 @@ when setting family in ns_spec_to_descriptor(). */
|
|||
|
||||
memset (metrics, 0, sizeof (struct font_metrics));
|
||||
|
||||
for (i =0; i<nglyphs; i++)
|
||||
for (i = 0; i < nglyphs; i++)
|
||||
{
|
||||
/* get metrics for this glyph, filling cache if need be */
|
||||
/* TODO: get metrics for whole string from an NSLayoutManager
|
||||
|
@ -1024,8 +1024,6 @@ when setting family in ns_spec_to_descriptor(). */
|
|||
}
|
||||
|
||||
metrics->width = totalWidth;
|
||||
|
||||
return totalWidth; /* not specified in doc, but xfont.c does it */
|
||||
}
|
||||
|
||||
|
||||
|
|
155
src/w32font.c
155
src/w32font.c
|
@ -473,7 +473,7 @@ w32font_encode_char (struct font *font, int c)
|
|||
of METRICS. The glyphs are specified by their glyph codes in
|
||||
CODE (length NGLYPHS). Apparently metrics can be NULL, in this
|
||||
case just return the overall width. */
|
||||
int
|
||||
void
|
||||
w32font_text_extents (struct font *font, unsigned *code,
|
||||
int nglyphs, struct font_metrics *metrics)
|
||||
{
|
||||
|
@ -487,84 +487,80 @@ w32font_text_extents (struct font *font, unsigned *code,
|
|||
|
||||
struct w32font_info *w32_font = (struct w32font_info *) font;
|
||||
|
||||
if (metrics)
|
||||
memset (metrics, 0, sizeof (struct font_metrics));
|
||||
metrics->ascent = font->ascent;
|
||||
metrics->descent = font->descent;
|
||||
|
||||
for (i = 0; i < nglyphs; i++)
|
||||
{
|
||||
memset (metrics, 0, sizeof (struct font_metrics));
|
||||
metrics->ascent = font->ascent;
|
||||
metrics->descent = font->descent;
|
||||
struct w32_metric_cache *char_metric;
|
||||
int block = *(code + i) / CACHE_BLOCKSIZE;
|
||||
int pos_in_block = *(code + i) % CACHE_BLOCKSIZE;
|
||||
|
||||
for (i = 0; i < nglyphs; i++)
|
||||
{
|
||||
struct w32_metric_cache *char_metric;
|
||||
int block = *(code + i) / CACHE_BLOCKSIZE;
|
||||
int pos_in_block = *(code + i) % CACHE_BLOCKSIZE;
|
||||
|
||||
if (block >= w32_font->n_cache_blocks)
|
||||
{
|
||||
if (!w32_font->cached_metrics)
|
||||
w32_font->cached_metrics
|
||||
= xmalloc ((block + 1)
|
||||
* sizeof (struct w32_metric_cache *));
|
||||
else
|
||||
w32_font->cached_metrics
|
||||
= xrealloc (w32_font->cached_metrics,
|
||||
(block + 1)
|
||||
* sizeof (struct w32_metric_cache *));
|
||||
memset (w32_font->cached_metrics + w32_font->n_cache_blocks, 0,
|
||||
((block + 1 - w32_font->n_cache_blocks)
|
||||
* sizeof (struct w32_metric_cache *)));
|
||||
w32_font->n_cache_blocks = block + 1;
|
||||
}
|
||||
|
||||
if (!w32_font->cached_metrics[block])
|
||||
{
|
||||
w32_font->cached_metrics[block]
|
||||
= xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
|
||||
}
|
||||
|
||||
char_metric = w32_font->cached_metrics[block] + pos_in_block;
|
||||
|
||||
if (char_metric->status == W32METRIC_NO_ATTEMPT)
|
||||
{
|
||||
if (dc == NULL)
|
||||
{
|
||||
/* TODO: Frames can come and go, and their fonts
|
||||
outlive them. So we can't cache the frame in the
|
||||
font structure. Use selected_frame until the API
|
||||
is updated to pass in a frame. */
|
||||
f = XFRAME (selected_frame);
|
||||
|
||||
dc = get_frame_dc (f);
|
||||
old_font = SelectObject (dc, w32_font->hfont);
|
||||
}
|
||||
compute_metrics (dc, w32_font, *(code + i), char_metric);
|
||||
}
|
||||
|
||||
if (char_metric->status == W32METRIC_SUCCESS)
|
||||
{
|
||||
metrics->lbearing = min (metrics->lbearing,
|
||||
metrics->width + char_metric->lbearing);
|
||||
metrics->rbearing = max (metrics->rbearing,
|
||||
metrics->width + char_metric->rbearing);
|
||||
metrics->width += char_metric->width;
|
||||
}
|
||||
if (block >= w32_font->n_cache_blocks)
|
||||
{
|
||||
if (!w32_font->cached_metrics)
|
||||
w32_font->cached_metrics
|
||||
= xmalloc ((block + 1)
|
||||
* sizeof (struct w32_metric_cache *));
|
||||
else
|
||||
/* If we couldn't get metrics for a char,
|
||||
use alternative method. */
|
||||
break;
|
||||
w32_font->cached_metrics
|
||||
= xrealloc (w32_font->cached_metrics,
|
||||
(block + 1)
|
||||
* sizeof (struct w32_metric_cache *));
|
||||
memset (w32_font->cached_metrics + w32_font->n_cache_blocks, 0,
|
||||
((block + 1 - w32_font->n_cache_blocks)
|
||||
* sizeof (struct w32_metric_cache *)));
|
||||
w32_font->n_cache_blocks = block + 1;
|
||||
}
|
||||
/* If we got through everything, return. */
|
||||
if (i == nglyphs)
|
||||
{
|
||||
if (dc != NULL)
|
||||
{
|
||||
/* Restore state and release DC. */
|
||||
SelectObject (dc, old_font);
|
||||
release_frame_dc (f, dc);
|
||||
}
|
||||
|
||||
return metrics->width;
|
||||
}
|
||||
if (!w32_font->cached_metrics[block])
|
||||
{
|
||||
w32_font->cached_metrics[block]
|
||||
= xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
|
||||
}
|
||||
|
||||
char_metric = w32_font->cached_metrics[block] + pos_in_block;
|
||||
|
||||
if (char_metric->status == W32METRIC_NO_ATTEMPT)
|
||||
{
|
||||
if (dc == NULL)
|
||||
{
|
||||
/* TODO: Frames can come and go, and their fonts
|
||||
outlive them. So we can't cache the frame in the
|
||||
font structure. Use selected_frame until the API
|
||||
is updated to pass in a frame. */
|
||||
f = XFRAME (selected_frame);
|
||||
|
||||
dc = get_frame_dc (f);
|
||||
old_font = SelectObject (dc, w32_font->hfont);
|
||||
}
|
||||
compute_metrics (dc, w32_font, *(code + i), char_metric);
|
||||
}
|
||||
|
||||
if (char_metric->status == W32METRIC_SUCCESS)
|
||||
{
|
||||
metrics->lbearing = min (metrics->lbearing,
|
||||
metrics->width + char_metric->lbearing);
|
||||
metrics->rbearing = max (metrics->rbearing,
|
||||
metrics->width + char_metric->rbearing);
|
||||
metrics->width += char_metric->width;
|
||||
}
|
||||
else
|
||||
/* If we couldn't get metrics for a char,
|
||||
use alternative method. */
|
||||
break;
|
||||
}
|
||||
/* If we got through everything, return. */
|
||||
if (i == nglyphs)
|
||||
{
|
||||
if (dc != NULL)
|
||||
{
|
||||
/* Restore state and release DC. */
|
||||
SelectObject (dc, old_font);
|
||||
release_frame_dc (f, dc);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* For non-truetype fonts, GetGlyphOutlineW is not supported, so
|
||||
|
@ -620,18 +616,13 @@ w32font_text_extents (struct font *font, unsigned *code,
|
|||
}
|
||||
|
||||
/* Give our best estimate of the metrics, based on what we know. */
|
||||
if (metrics)
|
||||
{
|
||||
metrics->width = total_width - w32_font->metrics.tmOverhang;
|
||||
metrics->lbearing = 0;
|
||||
metrics->rbearing = total_width;
|
||||
}
|
||||
metrics->width = total_width - w32_font->metrics.tmOverhang;
|
||||
metrics->lbearing = 0;
|
||||
metrics->rbearing = total_width;
|
||||
|
||||
/* Restore state and release DC. */
|
||||
SelectObject (dc, old_font);
|
||||
release_frame_dc (f, dc);
|
||||
|
||||
return total_width;
|
||||
}
|
||||
|
||||
/* w32 implementation of draw for font backend.
|
||||
|
|
|
@ -74,8 +74,8 @@ int w32font_open_internal (struct frame *f, Lisp_Object font_entity,
|
|||
int pixel_size, Lisp_Object font_object);
|
||||
void w32font_close (struct font *font);
|
||||
int w32font_has_char (Lisp_Object entity, int c);
|
||||
int w32font_text_extents (struct font *font, unsigned *code, int nglyphs,
|
||||
struct font_metrics *metrics);
|
||||
void w32font_text_extents (struct font *font, unsigned *code, int nglyphs,
|
||||
struct font_metrics *metrics);
|
||||
int w32font_draw (struct glyph_string *s, int from, int to,
|
||||
int x, int y, bool with_background);
|
||||
|
||||
|
|
|
@ -591,8 +591,8 @@ uniscribe_encode_char (struct font *font, int c)
|
|||
Lisp_Object uniscribe_get_cache (Lisp_Object frame);
|
||||
void uniscribe_free_entity (Lisp_Object font_entity);
|
||||
int uniscribe_has_char (Lisp_Object entity, int c);
|
||||
int uniscribe_text_extents (struct font *font, unsigned *code,
|
||||
int nglyphs, struct font_metrics *metrics);
|
||||
void uniscribe_text_extents (struct font *font, unsigned *code,
|
||||
int nglyphs, struct font_metrics *metrics);
|
||||
int uniscribe_draw (struct glyph_string *s, int from, int to,
|
||||
int x, int y, int with_background);
|
||||
|
||||
|
|
50
src/xfont.c
50
src/xfont.c
|
@ -124,8 +124,8 @@ static void xfont_close (struct font *);
|
|||
static void xfont_prepare_face (struct frame *, struct face *);
|
||||
static int xfont_has_char (Lisp_Object, int);
|
||||
static unsigned xfont_encode_char (struct font *, int);
|
||||
static int xfont_text_extents (struct font *, unsigned *, int,
|
||||
struct font_metrics *);
|
||||
static void xfont_text_extents (struct font *, unsigned *, int,
|
||||
struct font_metrics *);
|
||||
static int xfont_draw (struct glyph_string *, int, int, int, int, bool);
|
||||
static int xfont_check (struct frame *, struct font *);
|
||||
|
||||
|
@ -975,15 +975,14 @@ xfont_encode_char (struct font *font, int c)
|
|||
return (xfont_get_pcm (xfont, &char2b) ? code : FONT_INVALID_CODE);
|
||||
}
|
||||
|
||||
static int
|
||||
xfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics)
|
||||
static void
|
||||
xfont_text_extents (struct font *font, unsigned int *code,
|
||||
int nglyphs, struct font_metrics *metrics)
|
||||
{
|
||||
XFontStruct *xfont = ((struct xfont_info *) font)->xfont;
|
||||
int width = 0;
|
||||
int i, first;
|
||||
int i, width = 0;
|
||||
bool first;
|
||||
|
||||
if (metrics)
|
||||
memset (metrics, 0, sizeof (struct font_metrics));
|
||||
for (i = 0, first = 1; i < nglyphs; i++)
|
||||
{
|
||||
XChar2b char2b;
|
||||
|
@ -997,34 +996,27 @@ xfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct f
|
|||
continue;
|
||||
if (first)
|
||||
{
|
||||
if (metrics)
|
||||
{
|
||||
metrics->lbearing = pcm->lbearing;
|
||||
metrics->rbearing = pcm->rbearing;
|
||||
metrics->ascent = pcm->ascent;
|
||||
metrics->descent = pcm->descent;
|
||||
}
|
||||
metrics->lbearing = pcm->lbearing;
|
||||
metrics->rbearing = pcm->rbearing;
|
||||
metrics->ascent = pcm->ascent;
|
||||
metrics->descent = pcm->descent;
|
||||
first = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (metrics)
|
||||
{
|
||||
if (metrics->lbearing > width + pcm->lbearing)
|
||||
metrics->lbearing = width + pcm->lbearing;
|
||||
if (metrics->rbearing < width + pcm->rbearing)
|
||||
metrics->rbearing = width + pcm->rbearing;
|
||||
if (metrics->ascent < pcm->ascent)
|
||||
metrics->ascent = pcm->ascent;
|
||||
if (metrics->descent < pcm->descent)
|
||||
metrics->descent = pcm->descent;
|
||||
}
|
||||
if (metrics->lbearing > width + pcm->lbearing)
|
||||
metrics->lbearing = width + pcm->lbearing;
|
||||
if (metrics->rbearing < width + pcm->rbearing)
|
||||
metrics->rbearing = width + pcm->rbearing;
|
||||
if (metrics->ascent < pcm->ascent)
|
||||
metrics->ascent = pcm->ascent;
|
||||
if (metrics->descent < pcm->descent)
|
||||
metrics->descent = pcm->descent;
|
||||
}
|
||||
width += pcm->width;
|
||||
}
|
||||
if (metrics)
|
||||
metrics->width = width;
|
||||
return width;
|
||||
|
||||
metrics->width = width;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -557,8 +557,9 @@ xftfont_encode_char (struct font *font, int c)
|
|||
return (code ? code : FONT_INVALID_CODE);
|
||||
}
|
||||
|
||||
static int
|
||||
xftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics)
|
||||
static void
|
||||
xftfont_text_extents (struct font *font, unsigned int *code,
|
||||
int nglyphs, struct font_metrics *metrics)
|
||||
{
|
||||
struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
|
||||
XGlyphInfo extents;
|
||||
|
@ -567,15 +568,12 @@ xftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct
|
|||
XftGlyphExtents (xftfont_info->display, xftfont_info->xftfont, code, nglyphs,
|
||||
&extents);
|
||||
unblock_input ();
|
||||
if (metrics)
|
||||
{
|
||||
metrics->lbearing = - extents.x;
|
||||
metrics->rbearing = - extents.x + extents.width;
|
||||
metrics->width = extents.xOff;
|
||||
metrics->ascent = extents.y;
|
||||
metrics->descent = extents.height - extents.y;
|
||||
}
|
||||
return extents.xOff;
|
||||
|
||||
metrics->lbearing = - extents.x;
|
||||
metrics->rbearing = - extents.x + extents.width;
|
||||
metrics->width = extents.xOff;
|
||||
metrics->ascent = extents.y;
|
||||
metrics->descent = extents.height - extents.y;
|
||||
}
|
||||
|
||||
static XftDraw *
|
||||
|
|
Loading…
Add table
Reference in a new issue