From ae01bf90ceea33c114d2eaff4beaed7a53987ee5 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 13 Feb 2004 10:33:21 +0000 Subject: * (Render): Rendering of UTF8 strings is now (hopefully) correct in GL. * (PointToChar): Fixed a bug related to UTF char offset versus byte offset. * (ComputeTransfoAndOrigin): Rounded the origin on the integer lattice to get rid of display uglyness on GL. --- generic/Text.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'generic/Text.c') diff --git a/generic/Text.c b/generic/Text.c index 7a2b1f8..c81d1b7 100644 --- a/generic/Text.c +++ b/generic/Text.c @@ -413,7 +413,8 @@ ComputeTransfoAndOrigin(ZnItem item, ZnTransformPoint(&inv, origin, origin); ZnAnchor2Origin(origin, (ZnReal) text->max_width, (ZnReal) text->height, text->anchor, origin); - + origin->x = ZnNearestInt(origin->x); + origin->y = ZnNearestInt(origin->y); /* * The relevant transform in case of an attachment is the item * transform alone. This is case of local coordinate space where @@ -425,6 +426,9 @@ ComputeTransfoAndOrigin(ZnItem item, else { ZnAnchor2Origin(&text->pos, (ZnReal) text->max_width, (ZnReal) text->height, text->anchor, origin); + origin->x = ZnNearestInt(origin->x); + origin->y = ZnNearestInt(origin->y); + return item->wi->current_transfo; } } @@ -680,6 +684,7 @@ ComputeCoordinates(ZnItem item, text->poly[2].x = text->poly[3].x; text->poly[2].y = text->poly[0].y; ZnTransformPoints(transfo, text->poly, text->poly, 4); + /* * Add to the bounding box. */ @@ -1101,6 +1106,9 @@ Render(ZnItem item) int underline_thickness, underline_pos=0, overstrike_pos=0; int sel_first_line=-1, sel_last_line=-1, cursor_line=-1; int sel_start_offset=0, sel_stop_offset=0, cursor_offset=0; +#ifndef PTK + Tcl_Encoding enc; +#endif if (!text->text_info) { return; @@ -1111,6 +1119,9 @@ Render(ZnItem item) return; } } +#ifndef PTK + enc = ZnTexFontEncoding(text->tfi); +#endif #ifdef GL_LIST if (!item->gl_list) { @@ -1264,14 +1275,16 @@ Render(ZnItem item) */ { char *buf; - int written; + int result, written; buf = ZnMalloc(lines_ptr->num_bytes+1); - Tcl_UtfToExternal(wi->interp, NULL, - lines_ptr->start, lines_ptr->num_bytes, - TCL_ENCODING_START|TCL_ENCODING_END, - NULL, buf, lines_ptr->num_bytes+1, NULL, - &written, NULL); + if ((result = Tcl_UtfToExternal(wi->interp, enc, + lines_ptr->start, lines_ptr->num_bytes, + TCL_ENCODING_START|TCL_ENCODING_END, + NULL, buf, lines_ptr->num_bytes+1, NULL, + &written, NULL)) != TCL_OK) { + printf("Failed to convert the string: %d\n", result); + } ZnRenderString(text->tfi, buf, written); ZnFree(buf); } @@ -1381,8 +1394,8 @@ Pick(ZnItem item, ********************************************************************************** */ static void -PostScript(ZnItem item __unused, - ZnPostScriptInfo ps_info __unused) +PostScript(ZnItem item __unused, + ZnBool prepass __unused) { } @@ -1544,7 +1557,7 @@ 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); - byte_index = (ti->start + n - 1) - text->text; + byte_index = Tcl_UtfPrev(ti->start + n, ti->start) - text->text; break; } } -- cgit v1.1