基于注意力机制与三元组损失的少样本字体生成方法
Few-Shot Font Generation Method Based on Attention Mechanism and Triplet Loss
摘要: 针对跨语言少样本字体生成任务中风格特征表达不足和字形结构迁移不够精准的问题,本文提出一种融合注意力机制与三元组损失约束的少样本字体生成方法。该方法在对风格字体图像进行特征提取的基础上,引入上下文增强注意力机制,通过结合卷积操作与上下文感知特征变换模块,实现对字体笔画细粒度局部特征与整体结构信息的联合建模。随后,解码器对融合特征进行重建,生成目标字体图像。此外,本文引入三元组损失函数,从内容一致性与风格判别性两个维度对生成结果进行约束,以进一步增强字形结构一致性和风格表达能力。实验结果表明,该方法在少样本及跨语言字体生成任务中能够有效提升字体的结构保真度和风格迁移质量。
Abstract: To address the problems of insufficient style feature representation and inaccurate glyph structure transfer in cross-lingual few-shot font generation tasks, this paper proposes a few-shot font generation method that integrates an attention mechanism with triplet loss constraints. Based on feature extraction from style font images, a context-enhanced attention mechanism is introduced, which combines convolutional operations with a context-aware feature transformation module to jointly model fine-grained local stroke features and global structural information of glyphs. Subsequently, the decoder reconstructs the fused features to generate target font images. In addition, a triplet loss function is incorporated to constrain the generated results from both content consistency and style discriminability perspectives, thereby enhancing glyph structural consistency and style expression capability. Experimental results demonstrate that the proposed method effectively improves structural fidelity and style transfer quality in few-shot and cross-lingual font generation tasks.
文章引用:闫肖月, 牟大中. 基于注意力机制与三元组损失的少样本字体生成方法[J]. 计算机科学与应用, 2026, 16(2): 29-39. https://doi.org/10.12677/csa.2026.162036

参考文献

[1] 李少波, 张泠泠. 传统、技术、市场——当代汉字字体艺术的创新路径[J]. 美术观察, 2024(2): 23-25.
[2] 杨艳芳. 重建数字字体设计的秩序[J]. 南京艺术学院学报(美术与设计版), 2025(1): 171-175.
[3] 吕文锐, 普园媛, 赵征鹏, 等. 基于字形约束和注意力的艺术字体风格迁移[J]. 计算机工程, 2024, 50(12): 306-317.
[4] Lian, Z., Zhao, B., Chen, X. and Xiao, J. (2018) EasyFont: A Style Learning-Based System to Easily Build Your Large-Scale Handwriting Fonts. ACM Transactions on Graphics, 38, 1-18. [Google Scholar] [CrossRef
[5] Li, Y., Lin, G., He, M., Yuan, D. and Liao, K. (2023) Layer Similarity Guiding Few-Shot Chinese Style Transfer. The Visual Computer, 40, 2265-2278. [Google Scholar] [CrossRef
[6] 马启星, 李成城, 邬友, 等. 粉笔字字体的多风格生成与迁移方法研究[J/OL]. 计算机工程与应用: 1-11.
https://link.cnki.net/urlid/11.2127.TP.20251023.1840.011, 2025-10-24.
[7] Dai, J. (2024) Chinese Calligraphy Style Transfer with Generative Adversarial Network. Proceedings of the 2024 International Conference on Advanced Robotics, Automation Engineering and Machine Learning, Hangzhou, 28-30 June 2024, 104-108. [Google Scholar] [CrossRef
[8] Zhang, W., Sun, Z. and Wu, X. (2024) An End-to-End Generation Model for Chinese Calligraphy Characters Based on Dense Blocks and Capsule Network. Electronics, 13, Article No. 2983. [Google Scholar] [CrossRef
[9] Liu, Y., Khalid, F.b., Wang, C., Mustaffa, M.R.b. and Azman, A.b. (2024) An End-to-End Chinese Font Generation Network with Stroke Semantics and Deformable Attention Skip-Connection. Expert Systems with Applications, 237, Article ID: 121407. [Google Scholar] [CrossRef
[10] 刘宇, 丁阳, Fatimah Binti Khalid, 等. 联合内容和风格表示的无监督字体生成网络[J]. 计算机辅助设计与图形学学报, 2025, 37(5): 865-876.
[11] 赵宏, 黄金海, 常兆斌. 对比学习和多尺度特征提取改进手写字体生成[J/OL]. 华中科技大学学报(自然科学版): 1-10. 2024-10-29. [Google Scholar] [CrossRef
[12] 张嘉, 王志星. 基于风格迁移与骨架化的书法字库自动化生成方法[J]. 电脑知识与技术, 2024, 20(28): 30-33.
[13] 周雅琴, 车大爽. 基于知识图谱的生成式字体设计研究可视化分析[J]. 包装工程, 2024, 45(S1): 8-21.
[14] Li, C., Taniguchi, Y., Lu, M. and Konomi, S. (2021) Few-Shot Font Style Transfer between Different Languages. 2021 IEEE Winter Conference on Applications of Computer Vision (WACV), Waikoloa, 3-8 January 2021, 433-442. [Google Scholar] [CrossRef
[15] Zhang, Y., Man, J. and Sun, P. (2022) MF-Net: A Novel Few-Shot Stylized Multilingual Font Generation Method. Proceedings of the 30th ACM International Conference on Multimedia, Lisboa, 10-14 October 2022, 2088-2096. [Google Scholar] [CrossRef
[16] Qiu, Y., Chu, K., Zhang, J. and Feng, C. (2024) Ma-Font: Few-Shot Font Generation by Multi-Adaptation Method. IEEE Access, 12, 60765-60781. [Google Scholar] [CrossRef
[17] Zhao, H., Ji, T., Rosin, P.L., Lai, Y., Meng, W. and Wang, Y. (2024) Cross-Lingual Font Style Transfer with Full-Domain Convolutional Attention. Pattern Recognition, 155, Article ID: 110709. [Google Scholar] [CrossRef
[18] Pan, W., Zhu, A., Zhou, X., Iwana, B.K. and Li, S. (2023) Few Shot Font Generation via Transferring Similarity Guided Global Style and Quantization Local Style. 2023 IEEE/CVF International Conference on Computer Vision (ICCV), Paris, 1-6 October 2023, 19506-19516. [Google Scholar] [CrossRef
[19] Chen, W., Liu, C. and Ji, Y. (2022) Chinese Character Style Transfer Model Based on Convolutional Neural Network. In: Pimenidis, E., et al., Eds., Artificial Neural Networks and Machine LearningICANN 2022, Springer, 558-569. [Google Scholar] [CrossRef
[20] Yao, M., Zhang, Y., Lin, X., Li, X. and Zuo, W. (2024) VQ-Font: Few-Shot Font Generation with Structure-Aware Enhancement and Quantization. Proceedings of the AAAI Conference on Artificial Intelligence, 38, 16407-16415. [Google Scholar] [CrossRef
[21] Wang, Y., Xiong, K., Yuan, Y. and Zeng, J. (2025) EdgeFont: Enhancing Style and Content Representations in Few-Shot Font Generation with Multi-Scale Edge Self-Supervision. Expert Systems with Applications, 262, Article ID: 125547. [Google Scholar] [CrossRef
[22] Zhang, Y., Zhang, Y. and Cai, W. (2018) Separating Style and Content for Generalized Style Transfer. 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Salt Lake City, 18-23 June 2018, 8447-8455. [Google Scholar] [CrossRef