From 81984ff8d6b54b07cf1653b70780b664c528708d Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 13 Feb 2004 13:41:07 +0000 Subject: Protected UTF8 patch for correct compilation under Perl/Tk 800 --- generic/Image.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'generic/Image.c') diff --git a/generic/Image.c b/generic/Image.c index 1796089..ff5174f 100644 --- a/generic/Image.c +++ b/generic/Image.c @@ -1193,10 +1193,16 @@ placeGlyph(FontInfoPtr font, } } +#ifdef PTK +FontInfoPtr +SuckGlyphsFromServer(ZnWInfo *wi, + Tk_Font font) +#else FontInfoPtr SuckGlyphsFromServer(ZnWInfo *wi, Tk_Font font, Tcl_Encoding enc) +#endif { Pixmap offscreen = 0; XImage *image = NULL; @@ -1238,9 +1244,11 @@ SuckGlyphsFromServer(ZnWInfo *wi, width = 0; for (i = 0; i < myfontinfo->num_glyphs; i++) { *str_from = i + myfontinfo->min_char; +#ifndef PTK Tcl_ExternalToUtf(wi->interp, enc, str_from, 1, TCL_ENCODING_START|TCL_ENCODING_END, NULL, str_utf, 8, NULL, &written, NULL); +#endif Tk_MeasureChars(font, str_utf, 1, 0, TK_AT_LEAST_ONE, &length); width = MAX(width, length); } @@ -1277,9 +1285,11 @@ SuckGlyphsFromServer(ZnWInfo *wi, numToGrab = 0; for (i = 0; i < myfontinfo->num_glyphs; i++) { *str_from = i + myfontinfo->min_char; +#ifndef PTK Tcl_ExternalToUtf(wi->interp, enc, str_from, 1, TCL_ENCODING_START|TCL_ENCODING_END, NULL, str_utf, 8, NULL, &written, NULL); +#endif Tk_MeasureChars(font, str_utf, written, 0, TK_AT_LEAST_ONE, &charWidth); myfontinfo->glyph[i].width = charWidth; @@ -1463,7 +1473,11 @@ ZnGetTexFont(ZnWInfo *wi, /*printf("Chargement de la texture pour la fonte %s\n", ZnNameOfTexFont(tfi));*/ +#ifdef PTK + fontinfo = SuckGlyphsFromServer(wi, txf->tkfont); +#else fontinfo = SuckGlyphsFromServer(wi, txf->tkfont, txf->enc); +#endif if (fontinfo == NULL) { goto error; } @@ -1687,7 +1701,9 @@ ZnGetTexFont(ZnWInfo *wi, ZnFree(txf->teximage); txf->teximage = NULL; } +#ifndef PTK Tcl_FreeEncoding(txf->enc); +#endif Tk_FreeFont(txf->tkfont); ZnFree(txf); ZnWarning("Cannot load font texture for font "); @@ -1851,7 +1867,9 @@ ZnFreeTexFont(ZnTexFontInfo tfi) ZnFree(txf->tgvi); ZnFree(txf->lut); ZnFree(txf->teximage); +#ifndef PTK Tcl_FreeEncoding(txf->enc); +#endif Tcl_DeleteHashEntry(txf->hash); ZnFree(txf); } @@ -1887,11 +1905,13 @@ ZnCharInTexFont(ZnTexFontInfo tfi, * ********************************************************************************** */ +#ifndef PTK Tcl_Encoding ZnTexFontEncoding(ZnTexFontInfo tfi) { return ((TexFontInfo *) tfi)->txf->enc; } +#endif /* ********************************************************************************** -- cgit v1.1