Coder Social home page Coder Social logo

createskyblue / easy-u8g2-font-generate-tools Goto Github PK

View Code? Open in Web Editor NEW
33.0 3.0 6.0 7.95 MB

This is an easy to operate u8g2 font generation tool. Users only need to input the text to be converted, select the font file and set the font size. The tool will automatically de duplicate the text, generate the map font mapping file, generate the BDF font library, and finally export the C language code

License: GNU General Public License v3.0

C 72.05% Python 27.95%

easy-u8g2-font-generate-tools's Introduction

Easy U8g2 font generate tools

这是一个易于操作的U8g2字体生成工具,使用者只需要输入需要转换的文本,选择字体文件以及设置字体大小,该工具会自动对文本进行去重、生成map字体映射文件、生成bdf字库并最终导出C语言字库代码

开源协议

main.py适用于GPL3.0协议

实现功能

  • 自定义文本
  • 文本自动去重
  • ASCII字符可选
  • 自定义ttf字体
  • 自定义字体大小
  • 字间距调整

使用方式

python3 main.py

第三方工具使用

名称 来源
bdfconv https://github.com/olikraus/u8g2
otf2bdf http://sofia.nmsu.edu/~mleisher/Software/otf2bdf/
Alibaba-PuHuiTi-Medium https://ics.alibaba.com/project/Hn8mXx

演示图片

shell界面 生成字体 实际lcd演示

easy-u8g2-font-generate-tools's People

Contributors

createskyblue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

easy-u8g2-font-generate-tools's Issues

在使用(包括您的)各种工具时,发现我的UTF8中文和中英文混合字符串出现中间空白

使用的硬件环境:STM32+HAL
使用的U8G2版本:
olikraus/u8g2@3e86287
使用的生成字体(请删除txt后缀):
SarasaMonoSC-Regular.ttf.txt

使用的代码:

    u8g2_DrawUTF8(&u8g2, 0, 30, "距1234567");
    u8g2_DrawUTF8(&u8g2, 0, 62, "倾890.123");

得到的现象:
image

应该得到的现象:
数字和中文应该不间断,但实际中间有空白。

生成的过程1:

PS C:\Users\25351\Desktop\Easy-u8g2-font-generate-tools-master> python .\main.py
 =============U8g2字库生成器 V1.0=============
 Email: [email protected]

[ASK] 请输入需要生成字库的文本(自动去重):012345 6789.AD%+-~:|距倾查护翼短测量校准设置离内温存储角值系统信息亮度日期时间电
[ASK] 生成字库命名 >SarasaMonoSC
[ASK] 输入ttf格式字体路径 >SarasaMonoSC-Regular.ttf
[ASK] 输入生成字库字体DPI >72
[ASK] 输入生成字库字体大小(px) >28
[ASK] 输入生成字库字体间距大小(%) >0
[ASK] 是否过滤ASCII? (Y/n) >n
[ASK] MAP字符映射文件是否包含ASCII? (Y/n) >n
原子字库: {'短', '校', '6', '~', '统', '亮', '日', '-', '时', '存', '5', '+', '值', '8', '2', '查', '内', '倾', '翼', '息', '4', ' ', 'D', ':', '距', '温', '护', '1', '量', '度', '置', '%', '信', '角', '电', '.', '离', '|', '测', '准', '系', '期', '9', '设', '0', '3', '7', '储', '间', 'A'}
转unicode原子字库: ['$20', '$25', '$2B', '$2D', '$2E', '$30', '$31', '$32', '$33', '$34', '$35', '$36', '$37', '$38', '$39', '$3A', '$41', '$44', '$4EAE', '$4FE1', '$503C', '$503E', '$50A8', '$5185', '$51C6', '$5B58', '$5EA6', '$606F', '$62A4', '$65E5', '$65F6', '$671F', '$67E5', '$6821', '$6D4B', '$6E29', '$7535', '$77ED', '$79BB', '$7C', '$7CFB', '$7E', '$7EDF', '$7F6E', '$7FFC', '$89D2', '$8BBE', '$8DDD', '$91CF', '$95F4']
字符map映射表: $20, $25, $2B, $2D, $2E, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $3A, $41, $44, $4EAE, $4FE1, $503C, $503E, $50A8, $5185, $51C6, $5B58, $5EA6, $606F, $62A4, $65E5, $65F6, $671F, $67E5, $6821, $6D4B, $6E29, $7535, $77ED, $79BB, $7C, $7CFB, $7E, $7EDF, $7F6E, $7FFC, $89D2, $8BBE, $8DDD, $91CF, $95F4
> otf2bdf.exe -v -r 72 -p 28.0 -o bdf/SarasaMonoSC-Regular_28.bdf SarasaMonoSC-Regular.ttf
> bdfconv.exe -v -b 0 -f 1 bdf/SarasaMonoSC-Regular_28.bdf -M map/SarasaMonoSC.map -n SarasaMonoSC_28 -o code/SarasaMonoSC_28.c -p 0 -d bdf/SarasaMonoSC-Regular_28.bdf
Parse File bdf/SarasaMonoSC-Regular_28.bdf: 45714 glyph(s) found
Map: map_cmd_list='$20, $25, $2B, $2D, $2E, $30, $31, $32, $33, $34, $35, $36, $37, $38, $39, $3A, $41, $44, $4EAE, $4FE1, $503C, $503E, $50A8, $5185, $51C6, $5B58, $5EA6, $606F, $62A4, $65E5, $65F6, $671F, $67E5, $6821, $6D4B, $6E29, $7535, $77ED, $79BB, $7C, $7CFB, $7E, $7EDF, $7F6E, $7FFC, $89D2, $8BBE, $8DDD, $91CF, $95F4'
Map: exclude=0 from=32/$20 to=32/$20 map=32/$20 (further single glyph logs disabled)
Reduce: Start
Reduce: End
CalculateMaxBBX: x=0, y=-7, w=27, h=32
CalculateMaxBBX: Encodings x=32, y=124, w=32, h=38388
bf_CalculateMinMaxDWidth: dx_min=84, dx_max=84
bf_CalculateMinMaxDWidth: x_min=0, x_max=7
bf_CalculateMinMaxDWidth: Monospaced font.
bf_CalculateMaxBitFieldSize: bbx.x=4, bbx.y=4, bbx.w=5, bbx.h=5, dwidth=8
RLE Compress: best zero bits 4, one bits 4, total bit size 22792
RLE Compress: Font code generation, selected glyphs=50, total glyphs=45714
RLE Compress: ASCII gylphs=20, Unicode glyphs=30
RLE Compress: Glyphs per unicode lookup table entry=100
RLE Compress: Unicode lookup table len=0, written entries=0
RLE Compress: Unicode lookup table first entry: delta=4, encoding=65535
RLE Compress: Unicode lookup table last entry: delta=4353, encoding=0
RLE Compress: 'A' pos = 403, 'a' pos = 0
RLE Compress: Font size 2880
Draw TGA, line height 36
Draw TGA, xmax 1478
bf_WriteU8G2CByFilename: Write file 'code/SarasaMonoSC_28.c'
 [操作完成]

生成的过程2:

[ASK] 请输入需要生成字库的文本(自动去重):距倾查护翼短测量校准设置离内温存储角值系统信息亮度日期时间电
[ASK] 生成字库命名 >SarasaMonoSC3
[ASK] 输入ttf格式字体路径 >SarasaMonoSC-Regular.ttf
[ASK] 输入生成字库字体DPI >96
[ASK] 输入生成字库字体大小(px) >28
[ASK] 输入生成字库字体间距大小(%) >0
[ASK] 是否过滤ASCII? (Y/n) >Y
[ASK] MAP字符映射文件是否包含ASCII? (Y/n) >Y
原子字库: {'置', '查', '信', '内', '值', '间', '存', '准', '离', '量', '护', '距', '温', '倾', '期', '短', '统', '翼', '度', '电', '亮', '息', '系', '日', '测', '角', '储', '校', '时', '设'}
转unicode原子字库: ['$4EAE', '$4FE1', '$503C', '$503E', '$50A8', '$5185', '$51C6', '$5B58', '$5EA6', '$606F', '$62A4', '$65E5', '$65F6', '$671F', '$67E5', '$6821', '$6D4B', '$6E29', '$7535', '$77ED', '$79BB', '$7CFB', '$7EDF', '$7F6E', '$7FFC', '$89D2', '$8BBE', '$8DDD', '$91CF', '$95F4']
字符map映射表: 32-128, $4EAE, $4FE1, $503C, $503E, $50A8, $5185, $51C6, $5B58, $5EA6, $606F, $62A4, $65E5, $65F6, $671F, $67E5, $6821, $6D4B, $6E29, $7535, $77ED, $79BB, $7CFB, $7EDF, $7F6E, $7FFC, $89D2, $8BBE, $8DDD, $91CF, $95F4
> otf2bdf.exe -v -r 96 -p 21.0 -o bdf/SarasaMonoSC-Regular_28.bdf SarasaMonoSC-Regular.ttf
> bdfconv.exe -v -b 0 -f 1 bdf/SarasaMonoSC-Regular_28.bdf -M map/SarasaMonoSC3.map -n SarasaMonoSC3_28 -o code/SarasaMonoSC3_28.c -p 0 -d bdf/SarasaMonoSC-Regular_28.bdf
Parse File bdf/SarasaMonoSC-Regular_28.bdf: 45714 glyph(s) found
Map: map_cmd_list='32-128, $4EAE, $4FE1, $503C, $503E, $50A8, $5185, $51C6, $5B58, $5EA6, $606F, $62A4, $65E5, $65F6, $671F, $67E5, $6821, $6D4B, $6E29, $7535, $77ED, $79BB, $7CFB, $7EDF, $7F6E, $7FFC, $89D2, $8BBE, $8DDD, $91CF, $95F4'
Map: exclude=0 from=32/$20 to=128/$80 map=32/$20
Map: exclude=0 from=20142/$4eae to=20142/$4eae map=20142/$4eae (further single glyph logs disabled)
Reduce: Start
Reduce: End
CalculateMaxBBX: x=0, y=-7, w=27, h=32
CalculateMaxBBX: Encodings x=32, y=124, w=20142, h=38388
bf_CalculateMinMaxDWidth: dx_min=84, dx_max=84
bf_CalculateMinMaxDWidth: x_min=0, x_max=7
bf_CalculateMinMaxDWidth: Monospaced font.
bf_CalculateMaxBitFieldSize: bbx.x=4, bbx.y=5, bbx.w=5, bbx.h=5, dwidth=8
RLE Compress: best zero bits 4, one bits 3, total bit size 38160
RLE Compress: Font code generation, selected glyphs=125, total glyphs=45714
RLE Compress: ASCII gylphs=95, Unicode glyphs=30
RLE Compress: Glyphs per unicode lookup table entry=100
RLE Compress: Unicode lookup table len=0, written entries=0
RLE Compress: Unicode lookup table first entry: delta=4, encoding=65535
RLE Compress: Unicode lookup table last entry: delta=4608, encoding=0
RLE Compress: 'A' pos = 811, 'a' pos = 1694
RLE Compress: Font size 4801
Draw TGA, line height 36
Draw TGA, xmax 1478
bf_WriteU8G2CByFilename: Write file 'code/SarasaMonoSC3_28.c'
 [操作完成]

排除的问题:
在使用u8g2官方内置的字体如u8g2_font_wqy12_t_gb2312a的显示正常
image

可以认定是字符串和u8g2不兼容,但具体是什么导致的,只有三个可能性,1. 文字字体与您U8g2工具不兼容,2. 您U8g2工具和最新版本代码不匹配,3. 文字字体和最新版本代码不匹配。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.