diff options
author | lecoanet | 2004-02-13 10:33:21 +0000 |
---|---|---|
committer | lecoanet | 2004-02-13 10:33:21 +0000 |
commit | ae01bf90ceea33c114d2eaff4beaed7a53987ee5 (patch) | |
tree | 3bdf62733a596752a322484ceacad394941272c7 | |
parent | 39dfb0c71bd5a12799a51557fb675f8ce03b9c25 (diff) | |
download | tkzinc-ae01bf90ceea33c114d2eaff4beaed7a53987ee5.zip tkzinc-ae01bf90ceea33c114d2eaff4beaed7a53987ee5.tar.gz tkzinc-ae01bf90ceea33c114d2eaff4beaed7a53987ee5.tar.bz2 tkzinc-ae01bf90ceea33c114d2eaff4beaed7a53987ee5.tar.xz |
* (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.
-rw-r--r-- | generic/Text.c | 33 |
1 files changed, 23 insertions, 10 deletions
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; } } |