[tekui-devel] tekui: display_x11: fixed attribute datatypes in hostgetfattrfun...
Timm S. Mueller
tmueller at neoscientists.org
Thu May 15 00:08:23 CEST 2008
details: http://hg.teklib.org/tekui/rev/0782c1240fee
changeset: 488:0782c1240fee
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Sun May 11 14:35:42 2008 +0200
description:
display_x11: fixed attribute datatypes in hostgetfattrfunc(), underline
position calculation corrected, removed floating point arithmetics from
position and thickness calculation; visual_mod: remaining InitRequest is now
freed in vis_exit(); visual_api, visual_lua: added font:getAttrs(); Display:
now bassed on Class instead of Object, Font cache now contains font
attributes, added getFontAttrs() function; Text: optimized pen selection
during drawing
diffs (truncated from 340 to 100 lines):
diff -r f1b07726543b -r 0782c1240fee src/display_x11/display_x11_font.c
--- a/src/display_x11/display_x11_font.c Sun May 11 11:45:16 2008 +0200
+++ b/src/display_x11/display_x11_font.c Sun May 11 14:35:42 2008 +0200
@@ -1465,92 +1465,81 @@ x11_hostgetfattrfunc(struct THook *hook,
return TTRUE;
case TVisual_FontPxSize:
- *((TINT *) item->tti_Value) = fn->pxsize;
+ *((TTAG *) item->tti_Value) = fn->pxsize;
break;
case TVisual_FontItalic:
- *((TINT *) item->tti_Value) = (fn->attr & FNT_ITALIC) ?
+ *((TTAG *) item->tti_Value) = (fn->attr & FNT_ITALIC) ?
TTRUE : TFALSE;
break;
case TVisual_FontBold:
- *((TINT *) item->tti_Value) = (fn->attr & FNT_BOLD) ?
+ *((TTAG *) item->tti_Value) = (fn->attr & FNT_BOLD) ?
TTRUE : TFALSE;
break;
case TVisual_FontAscent:
- *((TINT *) item->tti_Value) = mod->x11_use_xft ?
+ *((TTAG *) item->tti_Value) = mod->x11_use_xft ?
fn->xftfont->ascent : fn->font->ascent;
break;
case TVisual_FontDescent:
- *((TINT *) item->tti_Value) = mod->x11_use_xft ?
+ *((TTAG *) item->tti_Value) = mod->x11_use_xft ?
fn->xftfont->descent : fn->xftfont->descent;
break;
case TVisual_FontHeight:
- *((TINT *) item->tti_Value) = mod->x11_use_xft ?
+ *((TTAG *) item->tti_Value) = mod->x11_use_xft ?
fn->xftfont->ascent + fn->xftfont->descent :
fn->font->ascent + fn->font->descent;
break;
case TVisual_FontUlPosition:
{
+ unsigned long ulp;
if (mod->x11_use_xft)
{
- TFLOAT scale;
- TFLOAT ulp = fn->xftfont->descent / 2;
+ ulp = fn->xftfont->descent / 2;
FT_Face face = (*mod->x11_xftiface.XftLockFace)(fn->xftfont);
-
if (face)
{
if (face->units_per_EM != 0)
{
- scale = (TFLOAT)fn->xftfont->height / face->units_per_EM;
- ulp = (TFLOAT)(face->underline_position) * scale;
- /* FIXME: result is possibly (always?) negative;
- not sure if it can be handled this way */
- ulp = fabs(ulp);
+ ulp = -face->underline_position *
+ fn->xftfont->height / face->units_per_EM;
}
(*mod->x11_xftiface.XftUnlockFace)(fn->xftfont);
}
-
- *((TINT *) item->tti_Value) = (TINT)ulp;
}
else
{
- if (!XGetFontProperty(fn->font, XA_UNDERLINE_POSITION,
- (unsigned long *)item->tti_Value))
- *((TINT *) item->tti_Value) = fn->font->descent / 2;
- }
+ ulp = fn->font->descent / 2;
+ XGetFontProperty(fn->font, XA_UNDERLINE_POSITION, &ulp);
+ }
+ *((TTAG *) item->tti_Value) = (TTAG) ulp;
break;
}
case TVisual_FontUlThickness:
{
+ unsigned long ult = 1;
if (mod->x11_use_xft)
{
- TFLOAT scale;
- TFLOAT ult = 1;
FT_Face face = (*mod->x11_xftiface.XftLockFace)(fn->xftfont);
-
if (face)
{
if (face->units_per_EM != 0)
{
- scale = (TFLOAT)fn->xftfont->height / face->units_per_EM;
- ult = (TFLOAT)(face->underline_thickness) * scale;
+ ult = face->underline_thickness *
+ fn->xftfont->height / face->units_per_EM;
}
(*mod->x11_xftiface.XftUnlockFace)(fn->xftfont);
More information about the tekui-devel
mailing list