You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ab...@apache.org on 2004/06/01 13:41:57 UTC
cvs commit: jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image TextTag.java
abey 2004/06/01 04:41:57
Modified: image/src/org/apache/taglibs/image TextTag.java
Log:
Fixed a bug that used to set font style and size only when the font name is also specified
Revision Changes Path
1.4 +17 -16 jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image/TextTag.java
Index: TextTag.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs-sandbox/image/src/org/apache/taglibs/image/TextTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TextTag.java 3 May 2004 15:47:42 -0000 1.3
+++ TextTag.java 1 Jun 2004 11:41:57 -0000 1.4
@@ -80,15 +80,15 @@
private String text;
- private String font;
+ private String font = "sanserif";
private String color = "0x000000";
private int size = 10;
- private boolean italic;
+ private boolean italic = false;
- private boolean bold;
+ private boolean bold = false;
public int doEndTag() throws JspException {
Tag pTag = getParent();
@@ -97,22 +97,23 @@
"Text must be a nested tag of Image Tag!");
ImageHolder par = (ImageHolder) getParent();
BufferedImage image = par.getImage();
-
- int _x = (int) Util.convertToWhole(x, image.getWidth());
- int _y = (int) Util.convertToWhole(y, image.getHeight());
- Font f = Font.getFont("SansSerif");
- if (font != null) {
- int style = 0;
- style = italic ? style | Font.ITALIC : style;
- style = bold ? style | Font.BOLD : style;
- try {
- f = new Font(font, style, size);
- } catch (RuntimeException e) {
- }
- }
+
if (text == null) {
text = bodyContent.getString();
}
+ int _x = (int) Util.convertToWhole(x, image.getWidth());
+ int _y = (int) Util.convertToWhole(y, image.getHeight());
+ Font f = null;
+ int style = 0;
+ style = italic ? style | Font.ITALIC : style;
+ style = bold ? style | Font.BOLD : style;
+ try {
+ f = new Font(font, style, size);
+ } catch (Exception e) {
+ pageContext.getServletContext().log(e, "Could not create Font!");
+ f = Font.getFont("sanserif");
+ }
+
par.setImage(par.getImaging().textOverlay(image, text, _x, _y, f,
Util.getColor(color)));
return EVAL_PAGE;
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org