Skip to content

Commit

Permalink
text兼容width为0的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
qbhy committed May 9, 2019
1 parent ef0dbb4 commit 212223c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/qbhy/poster/drawable/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public void draw(Graphics2D gd, int posterWidth, int posterHeight) throws IOExce

// 如果宽高不合适,先缩放
if (image.getWidth() != width || image.getHeight() != height) {
System.out.println("如果宽高不合适,先缩放");
image = resize(image, width, height);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/qbhy/poster/drawable/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void draw(Graphics2D gd, int posterWidth, int posterHeight) {
gd.setColor(ColorTools.String2Color(color));

// 文本域实际宽度
int textWidth = width + x > posterWidth ? posterWidth - x : width;
int textWidth = width + x > posterWidth ? posterWidth - x : (width == 0 ? posterWidth : width);
// 当前行数
int currentNum = 0;
// 当前行应该取到第几个文字
Expand Down Expand Up @@ -133,7 +133,7 @@ private static int getWordWidth(Font font, String content) {
@Min(value = 8, message = "文本字体大小不能小于8")
private Integer fontSize = 24; // 字体大小
@Min(value = 0, message = "文本区域宽度不能小于0")
private Integer width; // 文本域宽度
private Integer width = 0; // 文本域宽度
@Min(value = 0, message = "文本行高不能小于0")
private Integer lineHeight = 0; // 行高

Expand Down

0 comments on commit 212223c

Please sign in to comment.