Overview
| Artifact ID: | 45d62fb3766cc3f7c3c824049226d8415ad60b4105f08e43d4354c57ed540278 |
|---|---|
| Ticket: | 8162e9b7a90465f0b2a761c9515dfbc45d4b7e9f |
| Date: | 2024-05-17 19:28:42 |
| User: | nemethi |
| Artifact Attached: | 0f1600bf4845848b23095c8cfd02763f718082ae4927e804a8cc3b8e049a2e90 |
| Filename: | GetTkFontAttributes.c |
| Description: |
Content:
/*
*---------------------------------------------------------------------------
*
* 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;
}
