diff options
author | joye <joye> | 2014-06-13 21:18:59 (GMT) |
---|---|---|
committer | joye <joye> | 2014-06-13 21:18:59 (GMT) |
commit | d1babaaa20a8c24a55deeb3e551d0dbcbce836d5 (patch) | |
tree | c301486f5008d667bf0279c419a6d8bb4191cd66 /src | |
parent | 69f046a58e124ca00486f54f6c725f0738efabb1 (diff) | |
download | blt-d1babaaa20a8c24a55deeb3e551d0dbcbce836d5.zip blt-d1babaaa20a8c24a55deeb3e551d0dbcbce836d5.tar.gz blt-d1babaaa20a8c24a55deeb3e551d0dbcbce836d5.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrPSOutput.C | 48 | ||||
-rw-r--r-- | src/bltGrText.C | 30 |
2 files changed, 55 insertions, 23 deletions
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C index 84df667..acf1ea6 100644 --- a/src/bltGrPSOutput.C +++ b/src/bltGrPSOutput.C @@ -829,11 +829,8 @@ void PostScript::prolog() "/cstringshow {\n" " {\n" " dup type /stringtype eq\n" -" gsave\n" -" 1 -1 scale\n" " { show } { glyphshow }\n" " ifelse\n" -" grestore\n" " } forall\n" "} bind def\n" "\n" @@ -874,25 +871,64 @@ void PostScript::prolog() " % angle for rotating, and x and y for positioning are still on the\n" " % stack.\n" " translate\n" -" neg rotate\n" +"%% rotate\n" " lineLength xoffset mul\n" " strings length 1 sub spacing mul height add yoffset mul translate\n" +" % center, rotate, -center\n" +" lineLength 2 div baseline 2 div translate\n" +" neg rotate\n" +" lineLength -2 div baseline -2 div translate\n" " % Now use the baseline and justification information to translate\n" " % so that the origin is at the baseline and positioning point for\n" " % the first line of text.\n" -" justify lineLength mul baseline neg translate\n" +" justify lineLength mul baseline translate\n" +"%% justify lineLength mul baseline neg translate\n" " % Iterate over each of the lines to output it. For each line,\n" " % compute its width again so it can be properly justified, then\n" " % display it.\n" " strings {\n" " dup cstringwidth pop\n" -" justify neg mul height 2 div moveto\n" +" justify neg mul 0 moveto\n" +" gsave\n" +" 1 -1 scale\n" " cstringshow\n" +" grestore\n" " 0 spacing translate\n" +"%% 0 spacing neg translate\n" " } forall\n" " grestore\n" "} bind def \n" "\n" +"/EndText {\n" +" %Stack :\n" +" grestore\n" +"} def\n" +"\n" +"/BeginText {\n" +" %Stack : w h theta centerX centerY\n" +" gsave\n" +" % Translate the origin to the center of bounding box and rotate\n" +" translate neg rotate\n" +" % Translate back to the origin of the text region\n" +" -0.5 mul exch -0.5 mul exch translate\n" +"} def\n" +"\n" +"/DrawAdjText {\n" +" %Stack : str strWidth x y\n" +" moveto % Go to the text position\n" +" exch dup dup 4 2 roll\n" +" % Adjust character widths to get desired overall string width\n" +" % adjust X = (desired width - real width)/#chars\n" +" stringwidth pop sub exch\n" +" length div\n" +" 0 3 -1 roll\n" +" % Flip back the scale so that the string is not drawn in reverse\n" +" gsave\n" +" 1 -1 scale\n" +" ashow\n" +" grestore\n" +"} def\n" +"\n" "/DrawBitmap {\n" " % Stack: ?bgColorProc? boolean centerX centerY width height theta imageStr\n" " gsave\n" diff --git a/src/bltGrText.C b/src/bltGrText.C index 10e0cdc..5b610a2 100644 --- a/src/bltGrText.C +++ b/src/bltGrText.C @@ -141,9 +141,17 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y) Tk_TextLayout layout = Tk_ComputeTextLayout(ops->font, text, -1, -1, ops->justify, 0, &w1, &h1); + Tk_FontMetrics fm; + Tk_GetFontMetrics(ops->font, &fm); + + psPtr->setFont(ops->font); + psPtr->setForeground(ops->color); + +#if 1 int xx =0; int yy =0; switch (ops->anchor) { + /* case TK_ANCHOR_NW: xx = 0; yy = 2; break; case TK_ANCHOR_N: xx = 1; yy = 2; break; case TK_ANCHOR_NE: xx = 2; yy = 2; break; @@ -153,7 +161,7 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y) case TK_ANCHOR_SW: xx = 0; yy = 0; break; case TK_ANCHOR_W: xx = 0; yy = 1; break; case TK_ANCHOR_CENTER: xx = 1; yy = 1; break; - /* + */ case TK_ANCHOR_NW: xx = 0; yy = 0; break; case TK_ANCHOR_N: xx = 1; yy = 0; break; case TK_ANCHOR_NE: xx = 2; yy = 0; break; @@ -163,7 +171,6 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y) case TK_ANCHOR_SW: xx = 0; yy = 2; break; case TK_ANCHOR_W: xx = 0; yy = 1; break; case TK_ANCHOR_CENTER: xx = 1; yy = 1; break; - */ } const char* justify =NULL; @@ -173,14 +180,8 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y) case TK_JUSTIFY_RIGHT: justify = "1"; break; } - cerr << text << ' ' << '(' << x << ',' << y << ')' << ' ' - << '(' << xx << ',' << yy << ')' << ' ' << justify << endl; - - Tk_FontMetrics fm; - Tk_GetFontMetrics(ops->font, &fm); - - psPtr->setFont(ops->font); - psPtr->setForeground(ops->color); + // cerr << text << ' ' << ops->angle << ' ' << '(' << x << ',' << y << ')' + // << ' ' << '(' << xx << ',' << yy << ')' << ' ' << justify << endl; psPtr->format("%g %d %d [\n", ops->angle, x, y); Tcl_ResetResult(graphPtr_->interp_); @@ -188,7 +189,8 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y) psPtr->append(Tcl_GetStringResult(graphPtr_->interp_)); Tcl_ResetResult(graphPtr_->interp_); psPtr->format("] %d %g %g %s DrawText\n", - fm.linespace, xx/-2.0, yy/2.0, justify); + fm.linespace, xx/-2.0, yy/-2.0, justify); +#endif #if 0 double w2, h2; @@ -198,12 +200,6 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y) rr.x += w2*.5; rr.y += h2*.5; - Tk_FontMetrics fm; - Tk_GetFontMetrics(ops->font, &fm); - - psPtr->setFont(ops->font); - psPtr->setForeground(ops->color); - int width = Tk_TextWidth(ops->font, text, strlen(text)); psPtr->format("%d %d %g %g %g BeginText\n", w1, h1, ops->angle, rr.x, rr.y); psPtr->format("(%s) %d %g %g DrawAdjText\n",text, width, 0. , h1*.5); |