Abstract: LCDs are common devices in embedded systems. How to display Chinese characters and English on an LCD? What are the differences between vector fonts and bitmap fonts? Why are there multiple encodings for the same character? What do GB2312 and GB18030 refer to? Are they related? How do embedded devices support multiple languages? Where can we obtain font libraries? Do we need to pay for them? This article addresses all these questions!
1. How to Display Characters on an LCD
How do we display characters on an LCD? Here we discuss the logical issues, not the LCD controller driver.
First, we need to have a concept of an LCD: an LCD is essentially a matrix made up of dots, just like a single LED.
A monochrome LED can display on and off.
Arranging multiple LEDs in a row can create a running light effect.
Multiple rows of LEDs form a dot matrix.
Multiple dot matrices can create a graphic display.
If a graphic display is made of tri-color LEDs, it can display video animations.


Whether it is a COG LCD
, OLED LCD
, or TFT LCD
, they are all essentially matrices made up of dots, similar to a graphic display made of LEDs.
Of course, the manufacturing processes differ, and the technology for controlling the display content is also different. We will not discuss manufacturing technology here; control technology will be covered in a separate course later.
Clearly, to display characters on a graphic display, we only need to light up the corresponding LED dots. Which LEDs should be lit for different characters?
Let’s think in reverse: how do we save the position information of the Chinese characters displayed on the LED matrix in the code for future use?

This is a 16×16 LED matrix.
The state of each LED is either on or off, so we can use 1 bit to represent its state: 1 for on, 0 for off.
1 byte, which is 8 bits, can represent the state of one row of LEDs.
The first row of the character “德” can be represented as: 0001 0000 0100 0000; which is 0x10, 0x40;
Using this method, we can obtain the complete display information for the character “德”:
-
0001 0000 0100 0000 0x10 0x40
-
0001 0000 0100 0000 0x10 0x40
-
0010 1111 1111 1110 0x2F 0xFE
-
0100 0000 0100 0000 0x40 0x40
-
1001 0111 1111 1100 0x97 0xFC
-
0001 0100 1010 0100 0x14 0xA4
-
0010 0100 1010 0100 0x24 0xA4
-
0110 0111 1111 1100 0x67 0xFC
-
1010 0000 0000 0000 0xA0 0x00
-
0010 1111 1111 1110 0x2F 0xFE
-
0010 0000 0100 0000 0x20 0x40
-
0010 0000 0010 0100 0x20 0x24
-
0010 0101 0010 0010 0x25 0x22
-
0010 0101 0000 1010 0x25 0x05
-
0010 1001 0000 1000 0x29 0x08
-
0010 0000 1111 1000 0x20 0xF8
We can save this in an array as follows:
de_dot[32]={
0x10, 0x40, 0x10, 0x40,0x2f, 0xfe, 0x40, 0x40,
0x97, 0xfc, 0x14, 0xa4,0x24, 0xa4,0x67, 0xfc,
0xa0, 0x00,0x2f, 0xfe,0x20, 0x40,0x20, 0x24,
0x25, 0x22, 0x25, 0x05, 0x29, 0x08, 0x20, 0xf8};
With this array, we can restore it to the LED matrix in the code using a modulus method to display the character “德”.
Those who have played with 7-segment displays should be familiar with this. To display numbers on a 7-segment display, we define the display masks for digits 0-9 in the code (information about which segments are on or off). Displaying Chinese characters on a matrix is just a matter of having more LEDs.
Therefore, to display characters on an LCD, we first need to know how to depict the character information and restore this information to the LCD using the modulus method to depict the character.
2. Dot Matrix Font Library
So what is a dot matrix font library?
The array of depiction information for the character “德” mentioned above is the dot matrix font library.
The effect depicted by this character is known as dot matrix font. The form in which the depiction information is saved is called dot matrix font library.

Dot matrix font libraries come in various forms:
- 1. Directly saving the information in an array in the code. (This is usually done when the displayed content is limited.)
- 2. Depicting the dot matrix information in a bmp image and retrieving information from the image based on an information file (FNT) when needed. (Many games use this type of texture font, also known as bmpfont.)
- 3. Packing a bunch of dot matrix information arrays into a bin file and using algorithms to locate character positions. (When there are many dot matrices, they are integrated according to encoding specifications.)
- 4. Fonts integrated according to computer font specifications. (For example, Windows ttf fonts, bdf fonts.)
3. Modulus Method
The modulus method refers to the way individual bit position information is combined into bytes.
Earlier, when we obtained the position information for the character “德”: we used horizontal modulus with the high bits first. There are many different modulus methods, and common methods are as follows:

Sizes
Chinese characters typically come in these sizes: 12x12, 16x16, 24x24
. On a 128*64 pixel COG screen, 12×12 dot matrix characters can generally display 5 lines.
The dot matrix for ASCII characters usually matches the height of Chinese characters, with the width being half; for example, 12×12 Chinese characters pair with 12×6 ASCII characters, and 16×16 Chinese characters pair with 16×8 ASCII characters.
4. Vector Fonts
Vector fonts: In vector fonts (Vector font), each glyph is described using mathematical curves, containing key points on the glyph boundary, derivative information of the connecting lines, etc. The font rendering engine reads these mathematical vectors and performs certain mathematical operations to render them. The advantage of this type of font is that the actual size of the font can be scaled indefinitely without distortion or color change. Vector fonts mainly include Type1, TrueType, OpenType, etc.
Freetype: The FreeType library is a completely free (open-source), high-quality, and portable font engine that provides a unified interface to access various font format files, including TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF, etc.
- Vector fonts rendered using Freetype ultimately result in bitmaps, after all, an LCD is made up of individual dots.
- Theoretically, vector fonts can be scaled infinitely without distortion.
- However, rendering vector fonts at smaller sizes may lead to severe distortion for certain characters (with many strokes).
5. Character Encoding
Character encoding refers to a mapping rule that allows a character to be mapped to other forms of data for storage and transmission in computers.

ASCII Code
ASCII (American Standard Code for Information Interchange) is a computer coding system based on Latin letters, primarily used to display modern English and other Western European languages. It is the most universal information exchange standard and is equivalent to the international standard ISO/IEC 646. ASCII was first published as a normative standard in 1967, with the last update in 1986, defining a total of 128 characters.
Codepage
Many languages in Europe and America are not defined in ASCII, so various countries (or organizations) use the remaining 127 values of a byte to map the characters they need.
With many countries and definitions, how do we decide which mapping to use?
Systems like IBM and Microsoft introduced the concept of CodePage: each mapping is assigned a number. The code page numbers for these systems are not completely the same. The code defined by IBM is called OEM, while the code defined by Microsoft is called ANSI.

6. Chinese Character Encoding
There are many Chinese characters, and simply using the high 127 values cannot represent them.
Therefore, national standard organizations have defined the “Character Set for Information Exchange in Chinese Encoding” with three versions:
GB2312 Encoding: Released on May 1, 1981, it is the national standard for simplified Chinese character encoding. GB2312 uses double-byte encoding for Chinese characters, including 7445 graphic characters, of which 6763 are Chinese characters.
GBK Encoding: Released in December 1995, it is an expanded national standard for Chinese character encoding based on GB2312, using double-byte encoding. The GBK character set includes 21003 Chinese characters, covering all Chinese characters in the national standard GB13000-1, as well as all characters in the BIG5 encoding.
GB18030 Encoding: Released on March 17, 2000, it is an expanded national standard for Chinese character encoding based on GBK, covering Chinese, Japanese, Korean, and Chinese minority languages, including 27484 Chinese characters. The GB18030 character set uses single-byte, double-byte, and four-byte encoding methods. It is compatible with the GBK and GB2312 character sets.
Chinese character encoding uses a partition concept, as shown in the partition below, where the double-byte area two conforms to the GB2312 standard.

7. How to Obtain Font Libraries
Before discussing how to obtain font libraries, let’s clarify the copyright issue.
- Copyright refers to the font, which is the effect of depicting a character. The formation of a font is usually either a vector font or a dot matrix font library.
- Using tools to convert a vector font library into a dot matrix font library still retains the same font, so the copyright remains with the vector font owner.
Obtaining Vector Fonts
There are many fonts on your computer. The fonts installed on your computer are usually stored in C:\Windows\Fonts
on Windows, and these fonts are typically in ttf format.
These fonts are generally not open-source, meaning they cannot be used commercially for embedded devices. Open-source fonts include: Source Han Sans, which can be used commercially for free.

8. Obtaining Dot Matrix Fonts
We are more concerned with how to obtain dot matrix fonts.
As mentioned earlier, dot matrix fonts exist in many forms, so we have many ways to obtain them.
-
Obtain dot matrix font libraries from old computer Chinese cards. This method is relatively hard to find; some foreign dot matrix font libraries can be found on GitHub, but I haven’t found any for Chinese characters.
-
Obtain Chinese dot matrix fonts from DOS systems. I have used HZ1616 and HZ1212. The copyright of these fonts is not very clear. However, these font libraries are quite old, so they generally conform to the GB2312 standard and do not include rare characters.
-
Find dot matrix fonts in computer fonts. Common computer fonts are in TTF format, which represents that they only have vector fonts. Many computer fonts may include both vector and dot matrix fonts. Dot matrix fonts are usually small-sized fonts. Small-sized fonts rendered with vector fonts may not look good, so certain fonts usually come with small-sized dot matrix fonts.
-
Use modulus tools to extract dot matrix information. If the characters used are few, tools like “zimo3” can be used for extraction.
-
Use dot matrix generation tools for batch generation. For example, the “Font Library Production Software.rar” created by Yimu Yu Software Studio can batch convert vector libraries to dot matrix libraries.
-
Find foreign dot matrices from open-source modules. For example, the tslib touch library contains English dot matrices.
-
Purchase. There is a company called Qualcomm that sells dot matrix font library chips. There is a company called Beijing Zhongyi that has a good set of dot matrix fonts. This set of dot matrix fonts is well-known for its performance, and experienced engineers generally have encountered it; however, most companies may not have obtained authorization. Many other font companies also have dot matrix fonts, such as Founder.
-
Draw each character yourself using editing tools and then convert them into arrays using your brain.
Source | Wujique http://www.wujique.com/
This article is sourced from the internet, and the copyright belongs to the original author. If there are any copyright issues, please contact me for deletion.
End
Recommended Reading:
Collection | Linux Articles SummaryCollection | Programming LifeCollection | C LanguageMy Knowledge CircleFollow the public account and reply “1024” to get the link to the learning materials cloud disk.Thank you for your likes, follows, shares, and views. I will remember every encouragement!
Embedded Linux
Scan the QR code to follow my public account