aboutsummaryrefslogtreecommitdiff
path: root/generic/Text.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/Text.c')
-rw-r--r--generic/Text.c72
1 files changed, 69 insertions, 3 deletions
diff --git a/generic/Text.c b/generic/Text.c
index 5bf885f..bc7c843 100644
--- a/generic/Text.c
+++ b/generic/Text.c
@@ -1354,10 +1354,76 @@ Pick(ZnItem item,
*
**********************************************************************************
*/
-static void
-PostScript(ZnItem item,
- ZnBool prepass)
+static int
+PostScript(ZnItem item,
+ ZnBool prepass,
+ ZnBBox *area)
{
+ ZnWInfo *wi = item->wi;
+ TextItem text = (TextItem) item;
+ Tk_FontMetrics fm;
+ TextLineInfo lines, lines_ptr;
+ ZnPoint origin;
+ ZnReal alignment;
+ int i, num_lines;
+ char path[150];
+
+ lines = (TextLineInfo) ZnListArray(text->text_info);
+ num_lines = ZnListSize(text->text_info);
+
+ if (Tk_PostscriptFont(wi->interp, wi->ps_info, text->font) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (Tk_PostscriptColor(wi->interp, wi->ps_info,
+ ZnGetGradientColor(text->color, 0.0, NULL)) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (text->fill_pattern != ZnUnspecifiedImage) {
+ Tcl_AppendResult(wi->interp, "/StippleText {\n ", NULL);
+ Tk_PostscriptStipple(wi->interp, wi->win, wi->ps_info,
+ ZnImagePixmap(text->fill_pattern, wi->win));
+ Tcl_AppendResult(wi->interp, "} bind def\n", NULL);
+ }
+
+ ComputeTransfoAndOrigin(item, &origin);
+
+ sprintf(path, "/InitialTransform load setmatrix\n"
+ "[%.15g %.15g %.15g %.15g %.15g %.15g] concat\n"
+ "1 -1 scale\n",
+ wi->current_transfo->_[0][0], wi->current_transfo->_[0][1],
+ wi->current_transfo->_[1][0], wi->current_transfo->_[1][1],
+ wi->current_transfo->_[2][0], wi->current_transfo->_[2][1]);
+ Tcl_AppendResult(wi->interp, path, NULL);
+
+ sprintf(path, "%.15g %.15g [\n", origin.x, origin.y);
+ Tcl_AppendResult(wi->interp, path, NULL);
+
+ /*
+ * Emit code to draw the lines.
+ */
+ for (i = 0, lines_ptr = lines; i < num_lines; i++, lines_ptr++) {
+ ZnPostscriptString(wi->interp, lines_ptr->start, lines_ptr->num_bytes);
+ }
+
+ switch (text->alignment) {
+ default:
+ case TK_JUSTIFY_LEFT:
+ alignment = 0;
+ break;
+ case TK_JUSTIFY_CENTER:
+ alignment = 0.5;
+ break;
+ case TK_JUSTIFY_RIGHT:
+ alignment = 1;
+ break;
+ }
+ Tk_GetFontMetrics(text->font, &fm);
+ /* DrawText should not mess with anchors, they are already accounted for */
+ sprintf(path, "] %d %g %g %g %s DrawText\n", fm.linespace, 0.0, 0.0,
+ alignment, (text->fill_pattern == ZnUnspecifiedImage) ? "false" : "true");
+ Tcl_AppendResult(wi->interp, path, NULL);
+
+ return TCL_OK;
}