aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/Image.c20
-rw-r--r--generic/Text.c4
2 files changed, 24 insertions, 0 deletions
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
/*
**********************************************************************************
diff --git a/generic/Text.c b/generic/Text.c
index c81d1b7..891ab85 100644
--- a/generic/Text.c
+++ b/generic/Text.c
@@ -1557,7 +1557,11 @@ PointToChar(TextItem text,
n = Tk_MeasureChars(text->font, ti->start, (int) ti->num_bytes,
p.x + 2 - (int) ti->origin_x, TK_PARTIAL_OK,
&dummy);
+#ifdef PTK
+ byte_index = (ti->start + n - 1) - text->text;
+#else
byte_index = Tcl_UtfPrev(ti->start + n, ti->start) - text->text;
+#endif
break;
}
}