Class CaptchaFontUtil
java.lang.Object
cloud.opencode.base.captcha.support.CaptchaFontUtil
Captcha Font Utility - Font handling utilities
验证码字体工具 - 字体处理工具
This class provides font-related utilities for CAPTCHA rendering.
此类提供验证码渲染的字体相关工具。
Features | 主要功能:
- Font style variation - 字体样式变化
- Configurable font size - 可配置字体大小
Usage Examples | 使用示例:
Font font = CaptchaFontUtil.getFont(config);
Font[] fonts = CaptchaFontUtil.getFonts(config, 4);
Security | 安全性:
- Thread-safe: Yes (stateless utility) - 线程安全: 是(无状态工具)
- Null-safe: No (config must not be null) - 空值安全: 否(配置不能为null)
Performance | 性能特性:
- Time complexity: O(1) - bounded by small constant font/color lists - 时间复杂度: O(1),由常量字体/颜色列表限制
- Space complexity: O(1) - stateless utility - 空间复杂度: O(1) 无状态工具类
- Since:
- JDK 25, opencode-base-captcha V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic FontgetChineseFont(float fontSize) Gets a font suitable for Chinese characters.static FontgetFont(CaptchaConfig config) Gets a font based on configuration.static FontGets a font with specified name and size.static ColorgetRandomColor(CaptchaConfig config) Gets a random color from the config colors.static FontgetRandomStyleFont(Font font) Gets a random font style.static FontgetRotatedFont(Font font, double angle) Gets a rotated font.static ColorGenerates a random color.static ColorGenerates a dark random color.static ColorGenerates a light random color.
-
Method Details
-
getFont
Gets a font based on configuration. 根据配置获取字体。- Parameters:
config- the configuration | 配置- Returns:
- the font | 字体
-
getFont
-
getRandomStyleFont
-
getRotatedFont
-
getChineseFont
Gets a font suitable for Chinese characters. 获取适合中文字符的字体。- Parameters:
fontSize- the font size | 字体大小- Returns:
- the font | 字体
-
getRandomColor
Gets a random color from the config colors. 从配置颜色中获取随机颜色。- Parameters:
config- the configuration | 配置- Returns:
- the random color | 随机颜色
-
randomColor
Generates a random color. 生成随机颜色。- Returns:
- the random color | 随机颜色
-
randomLightColor
Generates a light random color. 生成浅随机颜色。- Returns:
- the light color | 浅颜色
-
randomDarkColor
Generates a dark random color. 生成深随机颜色。- Returns:
- the dark color | 深颜色
-