Exemplo n.º 1
0
Arquivo: xftcore.c Projeto: aosm/X11
void
XftCoreExtentsUtf8 (Display	    *dpy,
		    XFontStruct	    *fs,
		    XftChar8	    *string, 
		    int		    len,
		    XGlyphInfo	    *extents)
{
    int		direction;
    int		ascent, descent;
    XCharStruct overall;
    XChar2b	*xc, xcloc[XFT_CORE_N16LOCAL];
    int		n;

    xc = XftCoreConvertUtf8 (string, len, xcloc, &n);
    XTextExtents16 (fs, xc, n, &direction,
		    &ascent, &descent, &overall);
    if (xc != xcloc)
	free (xc);
    if (overall.lbearing < overall.rbearing)
    {
	extents->x = overall.lbearing;
	extents->width = overall.rbearing - overall.lbearing;
    }
    else
    {
	extents->x = overall.rbearing;
	extents->width = overall.lbearing - overall.rbearing;
    }
    extents->y = -overall.ascent;
    extents->height = overall.ascent + overall.descent;
    extents->xOff = overall.width;
    extents->yOff = 0;
}
Exemplo n.º 2
0
void Font::char_bbox(long c, FontBoundingBox& b) const {
    if (c < 0) {
	b.left_bearing_ = 0;
	b.right_bearing_ = 0;
	b.width_ = 0;
	b.ascent_ = 0;
	b.descent_ = 0;
	b.font_ascent_ = 0;
	b.font_descent_ = 0;
	return;
    }
    FontRep* f = impl_->default_rep();
    float scale = f->scale_;
    XFontStruct* xf = f->font_;
    Display* d = f->display_;
    XCharStruct xc;
    XChar2b xc2b;
    xc2b.byte1 = (unsigned char)((c & 0xff00) >> 8);
    xc2b.byte2 = (unsigned char)(c & 0xff);
    int dir, asc, des;
    XTextExtents16(xf, &xc2b, 1, &dir, &asc, &des, &xc);
    b.left_bearing_ = scale * d->to_coord(-xc.lbearing);
    b.right_bearing_ = scale * d->to_coord(xc.rbearing);
    b.width_ = width(c);
    b.ascent_ = scale * d->to_coord(xc.ascent);
    b.descent_ = scale * d->to_coord(xc.descent);
    b.font_ascent_ = scale * d->to_coord(xf->ascent);
    b.font_descent_ = scale * d->to_coord(xf->descent);
}
Exemplo n.º 3
0
static void X11DRV_TextExtents_normal( fontObject* pfo, XChar2b* pstr, int count,
                                       int* pdir, int* pascent, int* pdescent,
                                       int* pwidth, int max_extent, int* pfit,
                                       int* partial_extents )
{
    XCharStruct info;
    int ascent, descent, width;
    int i, fit;

    width = 0;
    fit = 0;
    *pascent = 0;
    *pdescent = 0;
    wine_tsx11_lock();
    for ( i = 0; i < count; i++ )
    {
	XTextExtents16( pfo->fs, pstr, 1, pdir, &ascent, &descent, &info );
	if ( *pascent < ascent ) *pascent = ascent;
	if ( *pdescent < descent ) *pdescent = descent;
	width += info.width;
	if ( partial_extents ) partial_extents[i] = width;
	if ( width < max_extent ) fit++;

	pstr++;
    }
    wine_tsx11_unlock();
    *pwidth = width;
    if ( pfit ) *pfit = fit;
}
Exemplo n.º 4
0
Arquivo: xftcore.c Projeto: aosm/X11
Bool
XftCoreGlyphExists (Display	    *dpy,
		    XFontStruct	    *fs,
		    XftChar32	    glyph)
{
    int		direction;
    int		ascent, descent;
    XCharStruct overall;
    XChar2b	xc;

    XftCoreConvert32 (&glyph, 1, &xc);
    XTextExtents16 (fs, &xc, 1, &direction,
		    &ascent, &descent, &overall);
    return (overall.lbearing != 0 ||
	    overall.rbearing != 0 ||
	    overall.width != 0 ||
	    overall.ascent != 0 ||
	    overall.descent != 0);
}
Exemplo n.º 5
0
static
void X11DRV_TextExtents_dbcs_2fonts( fontObject* pfo, XChar2b* pstr, int count,
                                     int* pdir, int* pascent, int* pdescent,
                                     int* pwidth, int max_extent, int* pfit,
                                     int* partial_extents )
{
    XCharStruct info;
    int ascent, descent, width;
    int i;
    int fit;
    int curfont;
    fontObject* pfos[X11FONT_REFOBJS_MAX+1];

    pfos[0] = XFONT_GetFontObject( pfo->prefobjs[0] );
    pfos[1] = pfo;
    if ( pfos[0] == NULL ) pfos[0] = pfo;

    width = 0;
    fit = 0;
    *pascent = 0;
    *pdescent = 0;
    wine_tsx11_lock();
    for ( i = 0; i < count; i++ )
    {
	curfont = ( pstr->byte1 != 0 ) ? 1 : 0;
	XTextExtents16( pfos[curfont]->fs, pstr, 1, pdir, &ascent, &descent, &info );
	if ( *pascent < ascent ) *pascent = ascent;
	if ( *pdescent < descent ) *pdescent = descent;
	width += info.width;
	if ( partial_extents ) partial_extents[i] = width;
	if ( width <= max_extent ) fit++;

	pstr ++;
    }
    wine_tsx11_unlock();
    *pwidth = width;
    if ( pfit ) *pfit = fit;
}