diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 116 |
2 files changed, 97 insertions, 33 deletions
@@ -1,13 +1,19 @@ -2003-06-01 Joe English <jenglish@users.sourceforge.net> +2003-06-09 Joe English <jenglish@users.sourceforge.net> + * unix/tkUnixRFont.c: fix for [Bug#751553] "Xft: + [font configure] does not update in-use fonts". + Fixed TkpGetSubFonts() to return information about + all subfonts, not just the first one. + +2003-06-01 Joe English <jenglish@users.sourceforge.net> * unix/configure.in: BUGFIX, --enable-xft test was broken. * unix/configure: regen -2003-05-31 Joe English <jenglish@users.sourceforge.net> +2003-05-31 Joe English <jenglish@users.sourceforge.net> * unix/tkUnixRFont.c (InitFont): Fill in TkFontAttributes from pattern returned from GetFont (actual font) instead of the query pattern (requested font). -2003-05-31 Joe English <jenglish@users.sourceforge.net> +2003-05-31 Joe English <jenglish@users.sourceforge.net> * unix/tkUnixRFont.c: New file * unix/tkUnixDefault.h: Use different default fonts if HAVE_XFT * unix/Makefile.in: @@ -23,7 +29,7 @@ * tests/menu.test: fixed complex bug in menu clone cleanup [Bug#465324] and removed 'knownBug' from a test. -2003-05-29 Joe English <jenglish@users.sourceforge.net> +2003-05-29 Joe English <jenglish@users.sourceforge.net> * doc/text.n: Fixed markup errors. 2003-05-28 Miguel Bañón <bagnonm@users.sourceforge.net> diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 9fff6c7..56fb0b1 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixRFont.c,v 1.3 2003/05/31 23:00:36 jenglish Exp $ + * RCS: @(#) $Id: tkUnixRFont.c,v 1.4 2003/06/09 20:39:48 jenglish Exp $ */ #include "tkUnixInt.h" @@ -72,10 +72,24 @@ GetFont (UnixFtFont *fontPtr, FcChar32 ucs4) return fontPtr->faces[i].ftFont; } +/* + *--------------------------------------------------------------------------- + * + * InitFont -- + * + * Initializes the fields of a UnixFtFont structure. + * If fontPtr is NULL, also allocates a new UnixFtFont. + * + * Results: + * On error, frees fontPtr and returns NULL, otherwise + * returns fontPtr. + * + *--------------------------------------------------------------------------- + */ + static UnixFtFont * -InitFont (Tk_Window tkwin, FcPattern *pattern) +InitFont (Tk_Window tkwin, FcPattern *pattern, UnixFtFont *fontPtr) { - UnixFtFont *fontPtr; TkFontAttributes *faPtr; TkFontMetrics *fmPtr; char *family; @@ -88,7 +102,8 @@ InitFont (Tk_Window tkwin, FcPattern *pattern) int i; XftFont *ftFont; - fontPtr = (UnixFtFont *) ckalloc (sizeof (UnixFtFont)); + if (!fontPtr) + fontPtr = (UnixFtFont *) ckalloc (sizeof (UnixFtFont)); if (!fontPtr) return NULL; @@ -249,7 +264,7 @@ TkpGetNativeFont(tkwin, name) * work on XLFD names under Unix. */ - fontPtr = InitFont (tkwin, pattern); + fontPtr = InitFont(tkwin, pattern, NULL); if (!fontPtr) return NULL; return &fontPtr->font; @@ -308,7 +323,11 @@ TkpGetFontFromAttributes(tkFontPtr, tkwin, faPtr) } XftPatternAddInteger (pattern, XFT_SLANT, slant); - fontPtr = InitFont (tkwin, pattern); + fontPtr = (UnixFtFont *) tkFontPtr; + if (fontPtr != NULL) { + FiniFont(fontPtr); + } + fontPtr = InitFont(tkwin, pattern, fontPtr); if (!fontPtr) return NULL; return &fontPtr->font; @@ -324,6 +343,21 @@ TkpDeleteFont(tkFontPtr) /* XXX tkUnixFont.c doesn't free tkFontPtr... */ } +/* + *--------------------------------------------------------------------------- + * + * TkpGetFontFamilies -- + * + * Return information about the font families that are available + * on the display of the given window. + * + * Results: + * Modifies interp's result object to hold a list of all the available + * font families. + * + *--------------------------------------------------------------------------- + */ + void TkpGetFontFamilies(interp, tkwin) Tcl_Interp *interp; /* Interp to hold result. */ @@ -334,7 +368,7 @@ TkpGetFontFamilies(interp, tkwin) int i; char *family; - resultPtr = Tcl_GetObjResult(interp); + resultPtr = Tcl_NewListObj(0, NULL); list = XftListFonts (Tk_Display (tkwin), Tk_ScreenNumber (tkwin), @@ -350,41 +384,65 @@ TkpGetFontFamilies(interp, tkwin) } } XftFontSetDestroy (list); + + Tcl_SetObjResult(interp, resultPtr); } +/* + *------------------------------------------------------------------------- + * + * TkpGetSubFonts -- + * Called by [testfont subfonts] in the Tk testing package. + * + * Results: + * Sets interp's result to a list of the faces used by tkfont + * + *------------------------------------------------------------------------- + */ + void TkpGetSubFonts(interp, tkfont) Tcl_Interp *interp; Tk_Font tkfont; { Tcl_Obj *objv[3]; - Tcl_Obj *resultPtr, *listPtr; + Tcl_Obj *listPtr, *resultPtr; UnixFtFont *fontPtr = (UnixFtFont *) tkfont; + FcPattern *pattern; char *family, *foundry, *encoding; - XftFont *ftFont = GetFont (fontPtr, 0); - - resultPtr = Tcl_GetObjResult(interp); - if (XftPatternGetString (ftFont->pattern, XFT_FAMILY, - 0, &family) != XftResultMatch) - { - family = "Unknown"; - } - if (XftPatternGetString (ftFont->pattern, XFT_FOUNDRY, - 0, &foundry) != XftResultMatch) - { - foundry = "Unknown"; - } - if (XftPatternGetString (ftFont->pattern, XFT_ENCODING, - 0, &encoding)) + int i; + + resultPtr = Tcl_NewListObj(0, NULL); + + for (i = 0; i < fontPtr->nfaces ; ++i) { - encoding = "Unknown"; + pattern = /* fontPtr->faces[i].source; */ + FcFontRenderPrepare(0, fontPtr->pattern, fontPtr->faces[i].source); + + if (XftPatternGetString(pattern, XFT_FAMILY, + 0, &family) != XftResultMatch) + { + family = "Unknown"; + } + if (XftPatternGetString(pattern, XFT_FOUNDRY, + 0, &foundry) != XftResultMatch) + { + foundry = "Unknown"; + } + if (XftPatternGetString(pattern, XFT_ENCODING, + 0, &encoding) != XftResultMatch) + { + encoding = "Unknown"; + } + objv[0] = Tcl_NewStringObj(family, -1); + objv[1] = Tcl_NewStringObj(foundry, -1); + objv[2] = Tcl_NewStringObj(encoding, -1); + listPtr = Tcl_NewListObj(3, objv); + Tcl_ListObjAppendElement (NULL, resultPtr, listPtr); } - objv[0] = Tcl_NewStringObj(family, -1); - objv[1] = Tcl_NewStringObj(foundry, -1); - objv[2] = Tcl_NewStringObj(encoding, -1); - listPtr = Tcl_NewListObj (3, objv); - Tcl_ListObjAppendElement (NULL, resultPtr, listPtr); + Tcl_SetObjResult(interp, resultPtr); } + int Tk_MeasureChars(tkfont, source, numBytes, maxLength, flags, lengthPtr) Tk_Font tkfont; /* Font in which characters will be drawn. */ |