Skip to content

Commit 664c20b

Browse files
committed
【更改】半角字符整数缩放二倍显示,全角字符在补全上下空行的情况下以原缩放比例显示
- 将字体高度计算调整为 height * 2 来支持双倍高度渲染 - 修改 PrintCharacters 函数添加 is_fullwidth_cha 参数来区分全角/半角字符处理 - 实现全角字符的一倍打印和上下补全逻辑 - 实现半角字符的去右半边和左右缩放两倍打印逻辑 - 调整 other_characters 文件中的字符映射顺序以优化显示效果 - 更新版本号从 2.4.1 到 3.0.0 表示重大功能更新
1 parent ba40cdb commit 664c20b

10 files changed

Lines changed: 171 additions & 144 deletions

README.en.md

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22

33
> ENGLISH | [简体中文](README.md)
44
5-
## font-cengluan(层峦字体
5+
## font-cengluan(Cengluan TTY Font
66

7-
cengluan is a Chinese TTY font designed for Linux, aiming to provide Chinese display in TTY without installing kernel patches such as [cjktty](https://github.com/zhmars/cjktty-patches) or third-party software like [kmscon](http://www.freedesktop.org/wiki/Software/kmscon), [fbterm](https://salsa.debian.org/debian/fbterm), or [zhcon](https://zhcon.sourceforge.net/).
7+
cengluan is a Chinese TTY font designed for Linux, aiming to provide Chinese display in TTY without installing kernel patches like [cjktty](https://github.com/zhmars/cjktty-patches), nor third-party software such as [kmscon](http://www.freedesktop.org/wiki/Software/kmscon), [fbterm](https://salsa.debian.org/debian/fbterm), or [zhcon](https://zhcon.sourceforge.net/).
88

9-
The inspiration for this project comes from the [syllazh](https://github.com/oldherl/syllazh/) font.
9+
This project is inspired by the [syllazh](https://github.com/oldherl/syllazh/) font.
1010

1111
### Phonetic Characters
1212

13-
When using this font, you may notice that characters with similar pronunciations are displayed as the same character. For example, any of the characters "用永勇拥擁涌湧咏詠蛹雍踊庸踴泳" will be uniformly displayed as "用".
13+
When using this font, you may notice that Chinese characters with similar pronunciations are displayed as the same character. For example: any character from "用永勇拥擁涌湧咏詠蛹雍踊庸踴泳" will be uniformly displayed as "用".
1414

15-
This is because fonts on Linux TTY are generally changed using the `setfont` tool from the kbd package, which supports a maximum of 512 glyphs. However, a single glyph can map to multiple Unicode code points.
16-
Therefore, cengluan maps all characters with the same pronunciation (ignoring tones) to the same glyph, allowing for Chinese character display within the limited number of glyphs.
15+
This is because fonts on Linux TTY are generally changed using the setfont tool from the kbd package, which supports up to 512 glyphs, but a single glyph can be mapped to multiple Unicode code points. Therefore, font-cengluan maps all Chinese characters with the same syllable (ignoring tones) to the same glyph, enabling Chinese display with a limited number of glyphs.
1716

18-
### Terminal User Inerface Display Optimization
17+
### Terminal Graphic Program Display Optimization
1918

20-
This font also optimizes the mapping of commonly used graphical symbols in terminals to make them more suitable for terminal use. Some examples:
19+
This font also optimizes the mapping of commonly used graphic symbols in terminals to make it more suitable for terminal use. Some examples:
2120

2221
- Original symbols:
2322

@@ -38,8 +37,8 @@ This font also optimizes the mapping of commonly used graphical symbols in termi
3837
? ? ?
3938
?????????
4039
```
41-
42-
(Cannot be displayed correctly)
40+
41+
(Cannot be displayed properly)
4342

4443
- After optimization:
4544

@@ -51,33 +50,36 @@ This font also optimizes the mapping of commonly used graphical symbols in termi
5150
L---┴---J
5251
```
5352

54-
Among these, `` is mapped to the letter `r`, `` is mapped to the letter `T`, `` is mapped to the letter `J`, etc.
55-
This type of mapping maximizes the improvement of display quality without occupying more glyphs (:-D).
53+
Here, `` is mapped to the letter `r`, `` to `T`, `` to `J`, etc.
54+
Such mappings maximize display improvement while minimizing the use of additional glyphs (:-D).
5655

57-
![btop with font-cengluan](assets/btop.png)
56+
![font-cengluan performance in btop](assets/btop.png)
5857

5958
### Character Width Display Optimization
6059

61-
In regular text display scenarios:
60+
In conventional text display scenarios:
61+
62+
- **Full-width characters** (such as Chinese characters and symbols in GB2312) have a display width of two units (occupying two character positions) and a height of one character row (occupying one line height);
63+
- **Half-width characters** (such as English letters, Arabic numerals, and ASCII punctuation) have a display width of one unit and the same height of one character row.
64+
65+
That is: Chinese characters and symbols in GB2312 encoding are full-width, while ASCII characters and English symbols (like commas, periods) are typically half-width.
66+
67+
However, PC Screen Font 2 (PSF2) is a fixed-width bitmap font format that does not support characters of different sizes (widths) within a single font. Consequently:
6268

63-
- **Full-width characters** (such as Chinese characters and symbols in GB2312) have a display width of two units (occupying two character positions) and a height of one character line (occupying one line height);
64-
- **Half-width characters** (such as English letters, Arabic numerals, and ASCII punctuation) have a display width of one unit and the same height as one character line.
69+
- If all characters are displayed with a width of one unit: full-width characters only show the left half, with the right half displayed as the [32nd character](#the-32nd-character);
70+
- If all characters are displayed with a width of two units: all half-width characters occupy two columns, but visually they are only one unit wide, resulting in [large gaps between two half-width characters](assets/display_old_old.png).
6571

66-
This means: Chinese characters and symbols in GB2312 encoding are full-width, while ASCII characters and English symbols (such as commas, periods) are typically half-width.
72+
Given the high difficulty of finding or designing "tall and narrow half-width monospaced Chinese fonts" or "adapted full-width English letter fonts", the old solution of font-cengluan mapped all English letters, Arabic numerals, ASCII punctuation, etc., to full-width characters in the UTF-8 high range; the result was [still excessive spacing between half-width characters](assets/display_old.png).
6773

68-
However, PC Screen Font 2 (PSF2) is a fixed-width bitmap font format that does not support characters of different sizes (widths) within a single font.
69-
This leads to:
74+
In the current solution, all half-width characters are scaled by an integer factor of two, while full-width characters are displayed at the original scaling ratio with complementary blank rows above and below.
7075

71-
- If all characters are displayed with a width of one unit: full-width characters only show the left half, with the right half displaying the [thirty-second character](#thirty-second-character);
72-
- If all characters are displayed with a width of two units: all half-width characters occupy two columns, but visually only have a width of one unit, resulting in [large gaps between half-width characters](assets/display_old.png).
76+
![Half-width characters extended, full-width characters complemented](assets/Half-width_characters_extended__full-width_characters_complemented.svg)
7377

74-
Given the high difficulty of finding or designing "tall and narrow half-width monospace Chinese fonts" or "compatible full-width English letter fonts",
75-
font-cengluan maps all English letters, Arabic numerals, ASCII punctuation, and other characters to full-width characters in the UTF-8 high range.
76-
Although each Chinese character is still separated by a [thirty-second character](#thirty-second-character), font-cengluan achieves a relatively balanced visual appearance overall.
78+
Although each full-width character is still separated on the right by a [32nd character](#the-32nd-character), font-cengluan achieves a relatively balanced visual appearance overall.
7779

78-
### Thirty-second Character
80+
### The 32nd Character
7981

80-
The thirty-second character in Linux TTY fonts defaults to `U+20`, which is a space. This character is used to fill positions in the background where no character is present.
82+
In Linux TTY, the 32nd character of the default font is `U+20`, i.e., a space. This character is used to fill positions in the background where no character is present.
8183

8284
## Building the Font
8385

@@ -100,29 +102,29 @@ The thirty-second character in Linux TTY fonts defaults to `U+20`, which is a sp
100102
bash build.bash
101103
```
102104

103-
During the build process, the script will install `psftools`, which is used to generate the font.
105+
During the build process, the script will install `psftools` for font generation.
104106

105107
After building, a PSF2 font file named `cengluan.psfu.gz` will be generated in the `output/` directory.
106108

107109
## Using the Font
108110

109-
> Ensure that the version of the `setfont` command is `2.6rc1` or higher.
110-
> Versions prior to `2.6rc1` do not support fonts larger than 65535 (approximately 64KB).
111-
> After `2.6rc1`, the limit has been relaxed to 4194304 (approximately 4MB).
111+
> Ensure the `setfont` command is version `2.6rc1` or higher.
112+
> Versions before `2.6rc1` do not support fonts larger than 65535 bytes (≈64KB) before compression.
113+
> After `2.6rc1`, this limit was raised to 4194304 bytes (≈4MB).
112114
>
113115
> Run `setfont -V` to check the version.
114116
115-
Place `cengluan.psfu.gz` in the `consolefonts` directory (located at `/usr/share/consolefonts/` on Debian and `/usr/share/kbd/consolefonts/` on Arch Linux), then execute `setfont cengluan` to change the font or `setfont -d cengluan` to switch to a double-sized font.
117+
Place `cengluan.psfu.gz` into the `consolefonts` directory (located at `/usr/share/consolefonts/` in Debian, `/usr/share/kbd/consolefonts/` in Arch Linux). Then run `setfont cengluan` to change the font, or `setfont -d cengluan` to switch to double-sized font.
116118

117119
## License
118120

119-
> Thanks to **[oldherl](https://github.com/oldherl)** for their forward-looking technical exploration project [syllazh](https://github.com/oldherl/syllazh/);
121+
> Thanks to **[oldherl](https://github.com/oldherl)** for the forward-looking technical exploration project [syllazh](https://github.com/oldherl/syllazh/);
120122
>
121-
> Thanks to **[TakWolf](https://github.com/TakWolf)** and their team for providing the [fusion-pixel-font](https://github.com/TakWolf/fusion-pixel-font).
123+
> Thanks to **[TakWolf](https://github.com/TakWolf)** and their team for providing the [fusion-pixel-font](https://github.com/TakWolf/fusion-pixel-font) font.
122124
123-
The script files `build.bash`, `build_font_from_bdf.py`, and all files in the `scripts/` directory in this repository follow the [GNU GENERAL PUBLIC LICENSE Version 3](LICENSE),
124-
`original/references/pinyin_hanzi` in the `original/references/` directory follows the GNU Lesser General Public License (LGPL) 2.1, and other reference files follow the [Unlicense license](original/references/LICENSE),
125-
The font files generated by this project follow the [MIT license](MIT-LICENSE) or [SIL OPEN FONT LICENSE Version 1.1](SIL-LICENSE). For the original font upstream licenses, see the files in [`FONT-LICENSE/`](FONT-LICENSE/).
125+
The script files `build.bash`, `build_font_from_bdf.py`, and all files in `scripts/` in this repository follow the [GNU GENERAL PUBLIC LICENSE Version 3](LICENSE).
126+
`original/references/pinyin_hanzi` in the `original/references/` directory follows the GNU Lesser General Public License (LGPL) 2.1, while other reference files follow the [Unlicense](original/references/LICENSE).
127+
The font files generated by this project follow either the [MIT License](MIT-LICENSE) or the [SIL OPEN FONT LICENSE Version 1.1](SIL-LICENSE). For original font upstream licenses, see the files under [`FONT-LICENSE/`](FONT-LICENSE/).
126128

127129
## Contributing
128130

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ cengluan 是一个为 Linux 设计的中文 TTY 字体,旨在在不安装诸
4040
? ? ?
4141
?????????
4242
```
43-
43+
4444
(无法正常显示)
4545

4646
- 优化后:
@@ -71,15 +71,21 @@ cengluan 是一个为 Linux 设计的中文 TTY 字体,旨在在不安装诸
7171
导致,若:
7272

7373
- 所有字符以宽一个单位显示:全角字符仅显示左半截,右半截显示为字体中的[第三十二个字符](#第三十二个字符)
74-
- 所有字符以宽二个单位显示:所有半角字符占满两行,但视觉宽仅一单位,导致[两个半角字符间有大空隙](assets/display_old.png)
74+
- 所有字符以宽二个单位显示:所有半角字符占满两行,但视觉宽仅一单位,导致[两个半角字符间有大空隙](assets/display_old_old.png)
7575

7676
鉴于寻找和设计“瘦高半角等宽汉字等字体”或“适配的全角英文字母等字体”的高难度。
77-
font-cengluan 将所有英文字母、阿拉伯数字、ASCII 标点符号等字映射为 UTF-8 高位的全角字符。
78-
虽每个汉字间仍被一个[第三十二个字符](#第三十二个字符)隔开,font-cengluan 在总体视觉上达到相对平衡。
77+
旧方案下 font-cengluan 将所有英文字母、阿拉伯数字、ASCII 标点符号等字映射为 UTF-8 高位的全角字符;
78+
结果[半角字符之间的间隔仍过大](assets/display_old.png)
79+
80+
当前方案下,将所有半角字符整数缩放二倍显示,全角字符在补全上下空行的情况下以原缩放比例显示。
81+
82+
![半角放大、全角补全](assets/Half-width_characters_extended__full-width_characters_complemented.svg)
83+
84+
虽每个全角字符右侧仍被一个[第三十二个字符](#第三十二个字符)隔开,font-cengluan 在总体视觉上达到相对平衡。
7985

8086
### 第三十二个字符
8187

82-
Linux TTY 默认第字体的三十二个字符为 `U+20`,既空格。这个字符被用来填充背景中没有字符的位置
88+
Linux TTY 默认第字体的三十二个字符为 `U+20`,既空格。这个位置的字符被用来填充背景中没有字符的位置
8389

8490
## 构建字体
8591

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.1
1+
3.0.0

0 commit comments

Comments
 (0)