/* *--------------------------------------------------------------------------- * * GetTkFontAttributes -- * Fill in TkFontAttributes from an XftFont. */ static void GetTkFontAttributes( Tk_Window tkwin, XftFont *ftFont, TkFontAttributes *faPtr) { const char *family = "Unknown"; const char *const *familyPtr = &family; double ptSize, dblPxSize, size; int intPxSize, weight, slant; (void) XftPatternGetString(ftFont->pattern, XFT_FAMILY, 0, familyPtr); if (XftPatternGetDouble(ftFont->pattern, XFT_SIZE, 0, &ptSize) == XftResultMatch) { size = ptSize; } else if (XftPatternGetDouble(ftFont->pattern, XFT_PIXEL_SIZE, 0, &dblPxSize) == XftResultMatch) { size = -dblPxSize; } else if (XftPatternGetInteger(ftFont->pattern, XFT_PIXEL_SIZE, 0, &intPxSize) == XftResultMatch) { size = (double)-intPxSize; } else { size = 12.0; } if (XftPatternGetInteger(ftFont->pattern, XFT_WEIGHT, 0, &weight) != XftResultMatch) { weight = XFT_WEIGHT_MEDIUM; } if (XftPatternGetInteger(ftFont->pattern, XFT_SLANT, 0, &slant) != XftResultMatch) { slant = XFT_SLANT_ROMAN; } #ifdef DEBUG_FONTSEL printf("family %s size %d weight %d slant %d\n", family, (int)size, weight, slant); #endif /* DEBUG_FONTSEL */ faPtr->family = Tk_GetUid(family); faPtr->size = size; faPtr->weight = (weight > XFT_WEIGHT_MEDIUM) ? TK_FW_BOLD : TK_FW_NORMAL; faPtr->slant = (slant > XFT_SLANT_ROMAN) ? TK_FS_ITALIC : TK_FS_ROMAN; faPtr->underline = 0; faPtr->overstrike = 0; }