Skip to content

Commit

Permalink
修复字体空指针报错
Browse files Browse the repository at this point in the history
  • Loading branch information
Hansin1997 committed Feb 22, 2021
1 parent 820a96a commit 9251adc
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<dependency>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>captcha-core</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion captcha-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>captcha</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>captcha-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.dustlight.captcha.sender;

import cn.dustlight.captcha.core.Code;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

Expand Down Expand Up @@ -107,8 +108,13 @@ public static class DefaultImageHandler implements ImageHandler {

public DefaultImageHandler(String... fontNames) {
this.secureRandom = new SecureRandom();
Collection<String> availableFonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
if (fontNames != null) {
Collection<String> availableFonts = null;
try {
availableFonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
} catch (NullPointerException e) {
LoggerFactory.getLogger(getClass()).error("GraphicsEnvironment Error", e);
}
if (availableFonts != null && fontNames != null) {
for (String fn : fontNames) {
if (fn != null && fn.trim().length() > 0 && availableFonts.contains(fn)) {
this.font = fn;
Expand Down
2 changes: 1 addition & 1 deletion extensions/email-sender/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<dependency>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>email-sender</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion extensions/email-sender/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>captcha</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>email-sender</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extensions/reCAPTCHA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<dependency>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>recaptcha</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion extensions/reCAPTCHA/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>captcha</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>recaptcha</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extensions/redis-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dependency>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>redis-store</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion extensions/redis-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>captcha</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>redis-store</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion extensions/tencent-sms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>tencent-sms</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion extensions/tencent-sms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>captcha</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>tencent-sms</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<packaging>pom</packaging>
<groupId>cn.dustlight.captcha</groupId>
<artifactId>captcha</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
<name>captcha</name>
<description>CAPTCHA service parent project for Spring Boot</description>

Expand Down

0 comments on commit 9251adc

Please sign in to comment.