forked from old/legacy-imlib2
parent
de446b41a3
commit
7be07a6635
80
src/font.c
80
src/font.c
|
@ -996,13 +996,19 @@ __imlib_render_str(ImlibImage *im, ImlibFont *f, int drx, int dry, const char *t
|
||||||
fn = (ImlibTtfFont *)f;
|
fn = (ImlibTtfFont *)f;
|
||||||
break;
|
break;
|
||||||
case IMLIB_FONT_TYPE_X:
|
case IMLIB_FONT_TYPE_X:
|
||||||
*retw = *reth = *nextx = *nexty = 0;
|
if (retw) *retw = 0;
|
||||||
|
if (reth) *reth = 0;
|
||||||
|
if (nextx) *nextx = 0;
|
||||||
|
if (nexty) *nexty = 0;
|
||||||
return;
|
return;
|
||||||
case IMLIB_FONT_TYPE_TTF_X:
|
case IMLIB_FONT_TYPE_TTF_X:
|
||||||
fn = (ImlibTtfFont *)f->xf.ttffont;
|
fn = (ImlibTtfFont *)f->xf.ttffont;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*retw = *reth = *nextx = *nexty = 0;
|
if (retw) *retw = 0;
|
||||||
|
if (reth) *reth = 0;
|
||||||
|
if (nextx) *nextx = 0;
|
||||||
|
if (nexty) *nexty = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,12 +1038,9 @@ __imlib_render_str(ImlibImage *im, ImlibFont *f, int drx, int dry, const char *t
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
if (retw)
|
if (retw) *retw = tw;
|
||||||
*retw = tw;
|
if (reth) *reth = th;
|
||||||
if (reth)
|
if (nexty) *nexty = fn->ascent + fn->descent;
|
||||||
*reth = th;
|
|
||||||
if (nexty)
|
|
||||||
*nexty = fn->ascent + fn->descent;
|
|
||||||
if (nextx)
|
if (nextx)
|
||||||
{
|
{
|
||||||
#ifdef TTF_FONT_CACHE
|
#ifdef TTF_FONT_CACHE
|
||||||
|
@ -1054,12 +1057,9 @@ __imlib_render_str(ImlibImage *im, ImlibFont *f, int drx, int dry, const char *t
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
tw = h; th = w;
|
tw = h; th = w;
|
||||||
if (retw)
|
if (retw) *retw = tw;
|
||||||
*retw = tw;
|
if (reth) *reth = th;
|
||||||
if (reth)
|
if (nextx) *nextx = fn->ascent + fn->descent;
|
||||||
*reth = th;
|
|
||||||
if (nextx)
|
|
||||||
*nextx = fn->ascent + fn->descent;
|
|
||||||
if (nexty)
|
if (nexty)
|
||||||
{
|
{
|
||||||
#ifdef TTF_FONT_CACHE
|
#ifdef TTF_FONT_CACHE
|
||||||
|
@ -1105,12 +1105,9 @@ __imlib_render_str(ImlibImage *im, ImlibFont *f, int drx, int dry, const char *t
|
||||||
if (yt > y2) y2 = yt;
|
if (yt > y2) y2 = yt;
|
||||||
th = (int)(y2 - y1);
|
th = (int)(y2 - y1);
|
||||||
}
|
}
|
||||||
if (retw)
|
if (retw) *retw = tw;
|
||||||
*retw = tw;
|
if (reth) *reth = th;
|
||||||
if (reth)
|
if (nexty) *nexty = fn->ascent + fn->descent;
|
||||||
*reth = th;
|
|
||||||
if (nexty)
|
|
||||||
*nexty = fn->ascent + fn->descent;
|
|
||||||
if (nextx)
|
if (nextx)
|
||||||
{
|
{
|
||||||
#ifdef TTF_FONT_CACHE
|
#ifdef TTF_FONT_CACHE
|
||||||
|
@ -1343,6 +1340,7 @@ __imlib_xfd_draw_str(Display *display, Drawable drawable, Visual *v, int depth,
|
||||||
ImlibImagePixmap *ip;
|
ImlibImagePixmap *ip;
|
||||||
XRectangle i_ret, l_ret;
|
XRectangle i_ret, l_ret;
|
||||||
int x1, y1, lbearing;
|
int x1, y1, lbearing;
|
||||||
|
int _retw, _reth, _nextx, _nexty;
|
||||||
#ifndef XMB_FONT_CACHE
|
#ifndef XMB_FONT_CACHE
|
||||||
Pixmap p, m;
|
Pixmap p, m;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
|
@ -1354,25 +1352,17 @@ __imlib_xfd_draw_str(Display *display, Drawable drawable, Visual *v, int depth,
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
if (retw)
|
_retw = l_ret.width;
|
||||||
*retw = l_ret.width;
|
_reth = l_ret.height;
|
||||||
if (reth)
|
_nextx = i_ret.width;
|
||||||
*reth = l_ret.height;
|
_nexty = i_ret.height;
|
||||||
if (nextx)
|
|
||||||
*nextx = i_ret.width;
|
|
||||||
if (nexty)
|
|
||||||
*nexty = i_ret.height;
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
if (retw)
|
_retw = l_ret.height;
|
||||||
*retw = l_ret.height;
|
_reth = l_ret.width;
|
||||||
if (reth)
|
_nextx = i_ret.height;
|
||||||
*reth = l_ret.width;
|
_nexty = i_ret.width;
|
||||||
if (nextx)
|
|
||||||
*nextx = i_ret.height;
|
|
||||||
if (nexty)
|
|
||||||
*nexty = i_ret.width;
|
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
|
@ -1406,23 +1396,23 @@ __imlib_xfd_draw_str(Display *display, Drawable drawable, Visual *v, int depth,
|
||||||
if (yt < y1) y1 = yt;
|
if (yt < y1) y1 = yt;
|
||||||
if (yt > y2) y2 = yt;
|
if (yt > y2) y2 = yt;
|
||||||
th = (int)(y2 - y1);
|
th = (int)(y2 - y1);
|
||||||
if (retw)
|
_retw = tw;
|
||||||
*retw = tw;
|
_reth = th;
|
||||||
if (reth)
|
_nextx = i_ret.width;
|
||||||
*reth = th;
|
_nexty = i_ret.height;
|
||||||
if (nextx)
|
|
||||||
*nextx = i_ret.width;
|
|
||||||
if (nexty)
|
|
||||||
*nexty = i_ret.height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (retw) *retw = _retw;
|
||||||
|
if (reth) *reth = _reth;
|
||||||
|
if (nextx) *nextx = _nextx;
|
||||||
|
if (nexty) *nexty = _nexty;
|
||||||
|
|
||||||
/* if we draw outside the image from here - give up */
|
/* if we draw outside the image from here - give up */
|
||||||
if ((x > im->w) || (y > im->h))
|
if ((x > im->w) || (y > im->h))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* if the text is completely outside the image - give up */
|
/* if the text is completely outside the image - give up */
|
||||||
if (((x + *retw) <= 0) || ((y + *reth) <= 0))
|
if (((x + _retw) <= 0) || ((y + _reth) <= 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
im2 = __imlib_CreateImage(MAX(i_ret.width, l_ret.width),
|
im2 = __imlib_CreateImage(MAX(i_ret.width, l_ret.width),
|
||||||
|
|
Loading…
Reference in New Issue