[Pkg-tcltk-commits] r518 - in tk8.5/trunk/debian: . patches

sgolovan-guest at alioth.debian.org sgolovan-guest at alioth.debian.org
Wed Feb 20 19:09:14 UTC 2008


Author: sgolovan-guest
Date: 2008-02-20 19:09:13 +0000 (Wed, 20 Feb 2008)
New Revision: 518

Added:
   tk8.5/trunk/debian/patches/font.diff
Modified:
   tk8.5/trunk/debian/changelog
   tk8.5/trunk/debian/patches/series
Log:
[tk8.5]
  * Added an experimental patch which makes choosing a font for a given
    character more reliable even in case of incorrect fontconfig setup
    (closes: #465462).


Modified: tk8.5/trunk/debian/changelog
===================================================================
--- tk8.5/trunk/debian/changelog	2008-02-11 13:50:46 UTC (rev 517)
+++ tk8.5/trunk/debian/changelog	2008-02-20 19:09:13 UTC (rev 518)
@@ -1,8 +1,10 @@
-tk8.5 (8.5.1-2) UNRELEASED; urgency=low
+tk8.5 (8.5.1-2) unstable; urgency=low
 
-  * NOT RELEASED YET
+  * Added an experimental patch which makes choosing a font for a given
+    character more reliable even in case of incorrect fontconfig setup
+    (closes: #465462).
 
- -- Sergei Golovan <sgolovan at debian.org>  Sat,  9 Feb 2008 01:24:46 +0300
+ -- Sergei Golovan <sgolovan at debian.org>  Wed, 20 Feb 2008 21:56:37 +0300
 
 tk8.5 (8.5.1-1) unstable; urgency=low
 

Added: tk8.5/trunk/debian/patches/font.diff
===================================================================
--- tk8.5/trunk/debian/patches/font.diff	                        (rev 0)
+++ tk8.5/trunk/debian/patches/font.diff	2008-02-20 19:09:13 UTC (rev 518)
@@ -0,0 +1,172 @@
+--- unix/tkUnixRFont.c.orig	2008-02-14 21:38:54.000000000 +0300
++++ unix/tkUnixRFont.c	2008-02-15 22:37:06.000000000 +0300
+@@ -20,6 +20,7 @@
+     XftFont *ftFont;
+     FcPattern *source;
+     FcCharSet *charset;
++    int failed;
+ } UnixFtFace;
+ 
+ typedef struct {
+@@ -60,6 +61,31 @@
+ }
+ 
+ static XftFont *
++GetFontFallback(
++    UnixFtFont *fontPtr)
++{
++    double size;
++    int pxsize;
++    char *type;
++
++    if (XftPatternGetDouble(fontPtr->pattern, XFT_SIZE, 0,
++	    &size) == XftResultMatch) {
++	type = XFT_SIZE;
++    } else if (XftPatternGetInteger(fontPtr->pattern, XFT_PIXEL_SIZE, 0,
++	    &pxsize) == XftResultMatch) {
++	type = XFT_PIXEL_SIZE;
++	size = pxsize;
++    } else {
++	type = XFT_SIZE;
++	size = 12.0;
++    }
++    return XftFontOpen(fontPtr->display, fontPtr->screen,
++	    FC_FAMILY, FcTypeString, "sans",
++	    type, XftTypeDouble, size,
++	    NULL);
++}
++
++static XftFont *
+ GetFont(
+     UnixFtFont *fontPtr,
+     FcChar32 ucs4)
+@@ -69,23 +95,57 @@
+     if (ucs4) {
+ 	for (i = 0; i < fontPtr->nfaces; i++) {
+ 	    FcCharSet *charset = fontPtr->faces[i].charset;
+-	    if (charset && FcCharSetHasChar(charset, ucs4)) {
+-		break;
++	    if (!(charset && FcCharSetHasChar(charset, ucs4))) {
++		continue;
++	    }
++	    if (fontPtr->faces[i].ftFont) {
++		return fontPtr->faces[i].ftFont;
++	    } else {
++		if (!fontPtr->faces[i].failed) {
++		    FcPattern *pat = FcFontRenderPrepare(0, fontPtr->pattern,
++			    fontPtr->faces[i].source);
++
++		    fontPtr->faces[i].ftFont = XftFontOpenPattern(fontPtr->display, pat);
++		}
++		if (fontPtr->faces[i].ftFont) {
++		    return fontPtr->faces[i].ftFont;
++		} else {
++		    fontPtr->faces[i].failed = 1;
++		}
+ 	    }
+ 	}
+-	if (i == fontPtr->nfaces) {
+-	    i = 0;
++    }
++
++    for (i = 0; i < fontPtr->nfaces; i++) {
++	if (fontPtr->faces[i].ftFont) {
++	    return fontPtr->faces[i].ftFont;
++	} else {
++	    if (!fontPtr->faces[i].failed) {
++		FcPattern *pat = FcFontRenderPrepare(0, fontPtr->pattern,
++			fontPtr->faces[i].source);
++
++		fontPtr->faces[i].ftFont = XftFontOpenPattern(fontPtr->display, pat);
++	    }
++	    if (fontPtr->faces[i].ftFont) {
++		return fontPtr->faces[i].ftFont;
++	    } else {
++		fontPtr->faces[i].failed = 1;
++	    }
+ 	}
+-    } else {
+-	i = 0;
+     }
+-    if (!fontPtr->faces[i].ftFont) {
+-	FcPattern *pat = FcFontRenderPrepare(0, fontPtr->pattern,
+-		fontPtr->faces[i].source);
+ 
+-	fontPtr->faces[i].ftFont = XftFontOpenPattern(fontPtr->display, pat);
++    if (fontPtr->faces[fontPtr->nfaces].ftFont) {
++	return fontPtr->faces[fontPtr->nfaces].ftFont;
++    } else {
++	fontPtr->faces[fontPtr->nfaces].ftFont = GetFontFallback(fontPtr);
++	if (fontPtr->faces[fontPtr->nfaces].ftFont) {
++	    return fontPtr->faces[fontPtr->nfaces].ftFont;
++	} else {
++	    Tcl_Panic("Cannot find a usable font. Check your fontconfig settings");
++	    /* Never reached */
++	    return NULL;
++	}
+     }
+-    return fontPtr->faces[i].ftFont;
+ }
+ 
+ /*
+@@ -184,7 +244,7 @@
+     FcCharSet *charset;
+     FcResult result;
+     XftFont *ftFont;
+-    int i;
++    int i, nfont;
+ 
+     if (!fontPtr) {
+ 	fontPtr = (UnixFtFont *) ckalloc(sizeof(UnixFtFont));
+@@ -199,21 +259,22 @@
+ 
+     set = FcFontSort(0, pattern, FcTrue, NULL, &result);
+     if (!set) {
+-	FcPatternDestroy(pattern);
+-	ckfree((char *)fontPtr);
+-	return NULL;
++	nfont = 0;
++    } else {
++	nfont = set->nfont;
+     }
+ 
+     fontPtr->fontset = set;
+     fontPtr->pattern = pattern;
+-    fontPtr->faces = (UnixFtFace *) ckalloc(set->nfont * sizeof(UnixFtFace));
+-    fontPtr->nfaces = set->nfont;
++    /* Extra slot for possible fallback */
++    fontPtr->faces = (UnixFtFace *) ckalloc((nfont + 1) * sizeof(UnixFtFace));
++    fontPtr->nfaces = nfont;
+ 
+     /*
+      * Fill in information about each returned font
+      */
+ 
+-    for (i = 0; i < set->nfont; i++) {
++    for (i = 0; i < nfont; i++) {
+ 	fontPtr->faces[i].ftFont = 0;
+ 	fontPtr->faces[i].source = set->fonts[i];
+ 	if (FcPatternGetCharSet(set->fonts[i], FC_CHARSET, 0,
+@@ -222,7 +283,13 @@
+ 	} else {
+ 	    fontPtr->faces[i].charset = 0;
+ 	}
++	fontPtr->faces[i].failed = 0;
+     }
++    /* Fill in a fallback slot */
++    fontPtr->faces[nfont].ftFont = 0;
++    fontPtr->faces[nfont].source = 0;
++    fontPtr->faces[nfont].charset = 0;
++    fontPtr->faces[nfont].failed = 0;
+ 
+     fontPtr->display = Tk_Display(tkwin);
+     fontPtr->screen = Tk_ScreenNumber(tkwin);
+@@ -253,7 +320,7 @@
+     Tk_ErrorHandler handler = Tk_CreateErrorHandler(display, -1, -1, -1, NULL,
+ 	    (ClientData) NULL);
+ 
+-    for (i = 0; i < fontPtr->nfaces; i++) {
++    for (i = 0; i <= fontPtr->nfaces; i++) {
+ 	if (fontPtr->faces[i].ftFont) {
+ 	    XftFontClose(fontPtr->display, fontPtr->faces[i].ftFont);
+ 	}

Modified: tk8.5/trunk/debian/patches/series
===================================================================
--- tk8.5/trunk/debian/patches/series	2008-02-11 13:50:46 UTC (rev 517)
+++ tk8.5/trunk/debian/patches/series	2008-02-20 19:09:13 UTC (rev 518)
@@ -4,3 +4,4 @@
 rpath.diff
 non-linux.diff
 manpages.diff
+font.diff -p0




More information about the Pkg-tcltk-commits mailing list