CN101114443A - Indentation method of dot-matrix characters in two-dimensional graphics engine and Chinese processing method - Google Patents
Indentation method of dot-matrix characters in two-dimensional graphics engine and Chinese processing method Download PDFInfo
- Publication number
- CN101114443A CN101114443A CNA200610089009XA CN200610089009A CN101114443A CN 101114443 A CN101114443 A CN 101114443A CN A200610089009X A CNA200610089009X A CN A200610089009XA CN 200610089009 A CN200610089009 A CN 200610089009A CN 101114443 A CN101114443 A CN 101114443A
- Authority
- CN
- China
- Prior art keywords
- characters
- character
- dot matrix
- chinese
- graphics engine
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 239000011159 matrix material Substances 0.000 title claims abstract description 70
- 238000007373 indentation Methods 0.000 title claims abstract description 36
- 238000000034 method Methods 0.000 title claims abstract description 35
- 238000003672 processing method Methods 0.000 title claims abstract description 9
- 239000000872 buffer Substances 0.000 claims description 9
- 230000000694 effects Effects 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 3
- 241000234435 Lilium Species 0.000 description 2
- 238000009825 accumulation Methods 0.000 description 1
- 230000001186 cumulative effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
Images
Landscapes
- Controls And Circuits For Display Device (AREA)
Abstract
本发明公开了一种二维图形引擎中的点阵字符的缩进方法以及使用该算法完成的中文处理方法,包括:读取字符数据;打开点阵字库文件备用;对字符数据中的加密字符进行处理;利用点阵字符的缩进方法计算每个字符的实际长度,然后累加得到所有读入字符的总长度;处理字符的高度以及行间距;将字符总长度与屏幕宽度进行比较,对超出屏幕的字符作省略处理或是作换行处理,并记录所能显示的字符的总长度;对二维图形引擎的各种通道属性和缓存器进行设置;对中文显示中的居中、左对齐和右对齐的位置进行处理和计算;利用点阵字符的缩进方法对字符进行裁减;将裁减后的字符送入二维图形通道中等待显示输出。
The invention discloses an indentation method of a dot matrix character in a two-dimensional graphics engine and a Chinese processing method completed by using the algorithm, including: reading character data; opening a dot matrix font library file for backup; and encrypting characters in the character data Processing; use the indentation method of dot matrix characters to calculate the actual length of each character, and then accumulate the total length of all read characters; process the height of characters and line spacing; compare the total length of characters with the width of the screen, Characters on the screen are omitted or line-wrapped, and the total length of characters that can be displayed is recorded; various channel attributes and registers of the two-dimensional graphics engine are set; centering, left alignment and right alignment in Chinese display The aligned position is processed and calculated; the characters are trimmed using the indentation method of the dot matrix characters; the trimmed characters are sent to the two-dimensional graphics channel to wait for display output.
Description
技术领域technical field
本发明涉及使用2维图形引擎支持点阵字库的技术。特别涉及点阵字符的缩进算法。The invention relates to the technology of using a 2-dimensional graphics engine to support dot matrix fonts. In particular, the indentation algorithm for dot matrix characters is involved.
背景技术Background technique
目前越来越多的嵌入式产品使用二维图形引擎来支持图文的电视OSD层显示。这就使得支持中文的显示技术成为必需。然而由于2D图形引擎的局限性,其不能够支持矢量字库,因此只能选择使用点阵字库作为支持中文所需的字库。At present, more and more embedded products use two-dimensional graphics engine to support the TV OSD layer display of graphics and text. This makes display technology that supports Chinese necessary. However, due to the limitations of the 2D graphics engine, it cannot support vector fonts, so it can only choose to use dot matrix fonts as the fonts required to support Chinese.
在点阵字符库中,包含了ASCII码和汉字以及其他符号,每个字符都用一个0、1位图来表示。其中如果某一位为1,则表示此字符在该位上是需要被填充的,因此该位的颜色应置为字符颜色。如果此位为0,则表示此位是不需要被填充的,对应于此位的颜色应置为背景颜色。在实际应用中,可以通过Windows中使用的矢量ASCII码和汉字转换为点阵字字库,因而可以有多种字体(如宋体、楷体、黑体、幼园等),每种字体又有多种大小型号,这样可以根据实际需求来选择所需的字体和字符型号。The dot matrix character library contains ASCII codes, Chinese characters and other symbols, and each character is represented by a 0, 1 bitmap. Among them, if a certain bit is 1, it means that this character needs to be filled in this bit, so the color of this bit should be set as the character color. If this bit is 0, it means that this bit does not need to be filled, and the color corresponding to this bit should be set as the background color. In practical applications, vector ASCII codes and Chinese characters used in Windows can be converted into dot matrix fonts, so there can be multiple fonts (such as Song, Kai, Hei, Kindergarten, etc.), and each font has multiple sizes. Model, so that the required font and character model can be selected according to actual needs.
在西文环境下显示汉字的方法是调用中文汉字库进行汉字显示。国标码汉字的内码是从AO-FF,第一字节称为区,第二字节称为位,可用汉字只有96区*96位个。字符集中的ASCII码是1个Byte,其16进制最大的为FFH,即255个西文字符,这就是常见的字符,如“+”、“^”等,另外还包括图形字符等。中文字符由两个字节组成,早期国家定义是1个Word(2个Byte)代表一个汉字。国家标准规定:汉字库分94个区,每个区有94个汉字(以位作区别),每个汉字在汉字库中有确定的区和位编号,这就是汉字的区位码。每个汉字在库中是以点阵字模形式存储的,一般采用16×16点阵(32字节)、24×24点阵(72字节),每个点用一个二进制位(0或1)表示,对应在屏幕上显示出来就是相应的汉字。The method of displaying Chinese characters in the Western language environment is to call the Chinese character library to display Chinese characters. The internal code of the Chinese characters in the national standard code is from AO-FF, the first byte is called the area, and the second byte is called the bit. There are only 96 areas*96 bits of available Chinese characters. The ASCII code in the character set is 1 Byte, and the largest hexadecimal is FFH, that is, 255 Western characters, which are common characters, such as "+", "^", etc., and also include graphic characters. Chinese characters are composed of two bytes. The definition of early countries is that 1 Word (2 Byte) represents a Chinese character. The national standard stipulates: the Chinese character library is divided into 94 districts, and each district has 94 Chinese characters (distinguished by bits), and each Chinese character has a definite district and bit number in the Chinese character library, which is the location code of the Chinese character. Each Chinese character is stored in the form of dot matrix fonts in the library, generally using 16×16 dot matrix (32 bytes), 24×24 dot matrix (72 bytes), each point uses a binary bit (0 or 1 ) represents that corresponding Chinese characters are displayed on the screen.
由于在中文环境下,输入的是汉字的内码,因此必须将之转换成区位码,算出偏移量,从字库中找到对应的汉字,将其字模显示即可。Because in the Chinese environment, the input is the internal code of the Chinese character, so it must be converted into the area code, the offset is calculated, the corresponding Chinese character is found from the font library, and the font is displayed.
然而,使用点阵字符也有其存在的缺点。其主要的缺点就是对于一个无法填满24点阵的字符来说(这里以24点阵字库为例说明),在24*24的显示空间中将会有很大部分时被空着的。这就造成了某些字符显示出来后的效果极其松散。如果碰到连续的ASCII字符,则点阵字库显示出来的效果是无法让人接受的。如,对于一个英文的词汇“lily”来说,由于使用24点阵字库,显示出来的效果则变成了“lily”。因此点阵字库显示技术还有待改进。However, using dot-matrix characters has its drawbacks. Its main shortcoming is exactly that for a character that cannot fill the 24-dot matrix (here, take the 24-dot matrix font library as an example), there will be a large part of it empty in the display space of 24*24. This results in an extremely loose effect after certain characters are displayed. If you encounter continuous ASCII characters, the effect displayed by the dot matrix font is unacceptable. For example, for an English word "lily", since the 24-dot matrix font is used, the displayed effect becomes "lily". Therefore, the dot matrix font display technology still needs to be improved.
发明内容Contents of the invention
本发明的目的在于克服点阵字库由于受固定点阵所限,在多ASCII字符连续显示时所出现的字符松散的问题,从而提供一种能够有效地对点阵字符进行缩进处理的方法。The purpose of the present invention is to overcome the problem of loose characters when multiple ASCII characters are continuously displayed due to the limitation of fixed dot matrix in the dot matrix font library, thereby providing a method capable of effectively indenting dot matrix characters.
为了实现上述目的,本发明提供了一种二维图形引擎中的点阵字符的缩进方法,包括以下步骤:In order to achieve the above object, the invention provides a method for indenting dot matrix characters in a two-dimensional graphics engine, comprising the following steps:
a)、从读入的一段字符中取出一个字符,判断当前字符是否超出了本段字符的总字节长度,若没有超过,则执行下一步,否则,中断执行,跳出循环;以字节个数进行循环计算;a), Take out a character from a segment of characters read in, judge whether the current character exceeds the total byte length of the character in this segment, if not, execute the next step, otherwise, interrupt the execution and jump out of the loop; in bytes The number is cyclically calculated;
b)、辨别当前字符为中文字符还是英文字符或符号,若为中文字符,执行下一步,若为英文字符或符号,执行步骤d);b), distinguish whether the current character is a Chinese character or an English character or a symbol, if it is a Chinese character, perform the next step, if it is an English character or a symbol, perform step d);
c)、将中文字符由16进制内码转化为区位码,然后执行步骤e);c), the Chinese character is converted into the location code by the hexadecimal internal code, and then executes step e);
d)、将英文字符或符号由16进制内码转化为区位码,然后执行步骤e);d), English characters or symbols are converted into area codes from hexadecimal internal codes, and then step e) is performed;
e)、通过区位码对所述步骤2)中所打开的点阵字库文件进行定位检索,读出字符的点阵字符的字模,并存入一个二维数组中;E), carry out positioning retrieval to the opened dot matrix font file in described step 2) by location code, read the font of the dot matrix character of character, and deposit in a two-dimensional array;
f)、对二维数组的每个值分别作“与”运算,得到并记录点阵字符中最左边的点和最右边的点的位置,将最右边的点的位置与最左边的点的位置相减,即可得到一个字符的实际长度,并对于左右两侧的空白部分进行剪裁;f), perform "AND" operation on each value of the two-dimensional array, obtain and record the positions of the leftmost point and the rightmost point in the dot matrix character, and combine the position of the rightmost point with the position of the leftmost point Positions are subtracted to get the actual length of a character, and the blank parts on the left and right sides are trimmed;
g)、返回到步骤a)。g), return to step a).
一种应用所述的二维图形引擎中的点阵字符的缩进方法的中文处理方法,包括:A Chinese processing method using the indentation method of dot matrix characters in the described two-dimensional graphics engine, comprising:
1)、从二维图形引擎的接收数据缓存中读取字符数据,并设置标记以识别是否需要继续读取;1), read the character data from the receiving data cache of the two-dimensional graphics engine, and set a flag to identify whether to continue reading;
2)、打开点阵字库文件备用;2), open the dot matrix font file for backup;
3)、对字符数据中的加密字符进行处理;3), process the encrypted characters in the character data;
4)、利用点阵字符的缩进方法计算读入的每个字符的实际长度,然后累加各个字符的实际长度得到所有读入字符的总长度;4), use the indentation method of dot matrix characters to calculate the actual length of each character read in, and then add up the actual length of each character to obtain the total length of all characters read in;
5)、处理字符的高度以及行间距,把字符的高度与行间距相加得到字符的纵向位置;5), process the height of the character and the line spacing, add the height of the character and the line spacing to obtain the longitudinal position of the character;
6)、将步骤4)中得到的字符总长度与屏幕宽度进行比较,若字符的总宽度超过屏幕的宽度,则对超出屏幕的字符作省略处理或是作换行处理,并记录所能显示的字符的总长度;6), compare the total length of the characters obtained in step 4) with the screen width, if the total width of the characters exceeds the width of the screen, then omit or wrap the characters beyond the screen, and record what can be displayed total length of characters;
7)、对二维图形引擎的各种通道属性和缓存器进行设置;7), setting various channel attributes and registers of the two-dimensional graphics engine;
8)、利用步骤4)所得出的缩进处理后读入字符的总宽度对中文显示中的居中、左对齐和右对齐的位置进行处理和计算;8), use the total width of the read-in characters after the indentation processing obtained in step 4) to process and calculate the centered, left-aligned and right-aligned positions in the Chinese display;
9)、利用点阵字符的缩进方法对步骤6)中得到的所能显示字符进行裁减;9), utilize the indentation method of dot-matrix characters to cut the displayable characters obtained in step 6);
10)、将裁减后的字符送入二维图形通道中等待显示输出。10). Send the trimmed characters into the two-dimensional graphics channel and wait for display output.
上述技术方案中,在所述的步骤1)中,所述的从二维图形引擎的接收数据缓存中读取字符数据时,一次读取的字符数据在256个字节之内。In the above technical solution, in step 1), when the character data is read from the received data cache of the two-dimensional graphics engine, the character data read at one time is within 256 bytes.
上述技术方案中,所述点阵字库文件中的点阵字符包括16×16点阵字库、20×20点阵字库、24×24点阵字库、32×32点阵字库。In the above technical solution, the dot matrix characters in the dot matrix font file include a 16×16 dot matrix font, a 20×20 dot matrix font, a 24×24 dot matrix font, and a 32×32 dot matrix font.
上述技术方案中,在所述的步骤7)中,对二维图形引擎的各种通道属性和缓存器进行设置时,分别设置二维图形引擎的三个输入通道和一个输出通道,以及输入、输出通道所使用的缓存器。In the above-mentioned technical scheme, in described step 7), when setting various channel properties and registers of the two-dimensional graphics engine, three input channels and one output channel of the two-dimensional graphics engine are respectively set, and input, The buffer used by the output channel.
本发明的优点在于:The advantages of the present invention are:
通过二维图形引擎中的点阵字符的缩进算法对点阵字符进行缩进,使得点阵字库中的字符能够很好的结合在一起,缩减了字符的间距,使之看其来更加美观。并且利用点阵字符的缩进算法对二维图形引擎中的中文处理做了有效的修正,使之能够很好的结合点阵字符的缩进算法来处理各种要求。Indent the dot matrix characters through the indentation algorithm of dot matrix characters in the two-dimensional graphics engine, so that the characters in the dot matrix font library can be well combined, reducing the distance between characters and making them look more beautiful . In addition, the indentation algorithm of dot matrix characters is used to effectively modify the Chinese processing in the two-dimensional graphics engine, so that it can be well combined with the indentation algorithm of dot matrix characters to deal with various requirements.
附图说明Description of drawings
图1为点阵字符缩进方法的流程图;Fig. 1 is the flowchart of dot matrix character indentation method;
图2为本发明的一种二维图形引擎中的中文处理方法的流程图;Fig. 2 is the flowchart of the Chinese processing method in a kind of two-dimensional graphics engine of the present invention;
图3为24点阵字符点的排列顺序;Fig. 3 is the arrangement sequence of 24 dot matrix character points;
图4为通过缩进方法处理后的字符显示效果与没处理前的字符对比图。Fig. 4 is a comparison diagram of the character display effect after being processed by the indentation method and the character before processing.
具体实施方式Detailed ways
下面结合附图和具体实施方式对本发明的嵌入式系统点阵字符的缩进方法进行说明。The method for indenting embedded system dot matrix characters of the present invention will be described below in conjunction with the accompanying drawings and specific embodiments.
在本实施例中,假设字库中采用24×24点阵,如图1、图2所示,点阵字符在嵌入式系统中的处理过程、缩进方法和显示流程如下。In this embodiment, it is assumed that a 24×24 dot matrix is used in the font library, as shown in FIG. 1 and FIG. 2 , the processing, indentation method and display flow of dot matrix characters in the embedded system are as follows.
步骤1、从接收数据缓存中读取字符数据,字符数据必须在256个字节之内,并设置标记以识别是否需要继续读取;Step 1. Read the character data from the received data buffer, the character data must be within 256 bytes, and set a flag to identify whether to continue reading;
步骤2、打开点阵字库文件,准备调用;Step 2. Open the dot matrix font file and prepare to call it;
步骤3、根据字符的属性处理加密字符,所述的加密字符包括密码、用户名等需要特殊处理的字符。Step 3. Process the encrypted characters according to the attributes of the characters, and the encrypted characters include characters requiring special processing such as passwords and user names.
步骤4、利用缩进算法分别精确计算读入的每个字符实际长度后,经过累加得到所有读入字符的总长度。在本步骤中,对字符的总长度进行计算是指对整行字符的缩进总宽度进行计算,其目的是为了在处理超长字符时便于对屏幕的宽度和字符总宽度进行比较。由于字符在屏幕上显示前,需要做缩进处理,避免现有技术中常见的字符间距过于松散的缺陷,因此,缩进后的字符的宽度不再全为24位,会因每个字符宽度的不同而确定。在计算时,也就不能再笼统地认为一行字符的总宽度如公式(1)所示,等于该行文字的个数乘以24,而是如公式(2)所示,应该为每个字符的宽度的累加和。Step 4. After accurately calculating the actual length of each character read in by using the indentation algorithm, the total length of all characters read in is obtained through accumulation. In this step, calculating the total length of the characters refers to calculating the total width of the indentation of the entire line of characters, the purpose of which is to facilitate the comparison between the width of the screen and the total width of characters when processing super-long characters. Before the characters are displayed on the screen, they need to be indented to avoid the defect that the character spacing is too loose in the prior art. Therefore, the width of the indented characters is no longer all 24 bits, and the width of each character will vary depending on the width of each character. determined by the difference. When calculating, it can no longer be generally considered that the total width of a line of characters, as shown in formula (1), is equal to the number of characters in the line multiplied by 24, but as shown in formula (2), it should be each character The cumulative sum of the widths.
字符总宽度=24*字符个数(1)Total character width = 24*number of characters(1)
字符总宽度=单个字符缩进后的宽度累加(2)The total width of characters = the accumulated width of a single character after indentation (2)
24点阵字符的打点规律如图3所示:从图中可以看出24点阵的字符由24行,每行24位组成。每一个点都是组成文字的点,如果该文字在该点为“1”说明该点是应该被显示出来的,否则该点不显示。The dot rule of 24-dot matrix characters is shown in Figure 3: From the figure, it can be seen that the characters of 24-dot matrix are composed of 24 lines, and each line is composed of 24 bits. Each point is the point that makes up the text. If the text is "1" at this point, it means that the point should be displayed, otherwise the point will not be displayed.
使用位运算对每一行24个点中为“1”的点的起始位置bejin_pos和终止位置end_pos进行记录后,比对每一行记录下来的起始值bejin_pos和终止值end_pos,选择其中最小的起始值bejin_pos和最大的终止值end_pos来定位该字符在24*24点阵中的位置。一旦文字被定位,就可以文字对左边和右边空白的部分进行裁减,而每个经过裁减的文字的实际宽度如公式3所示:Use bit operations to record the start position bejin_pos and end position end_pos of the 24 points in each line that are "1", compare the start value bejin_pos and end value end_pos recorded in each line, and select the smallest start value The initial value bejin_pos and the maximum end value end_pos are used to locate the position of the character in the 24*24 dot matrix. Once the text is positioned, the text can be trimmed to the left and right margins, and the actual width of each trimmed text is shown in Formula 3:
每个经过裁减的文字的实际宽度=终止值end_pos-起始值bejin_pos(3)The actual width of each trimmed text = end value end_pos - start value bejin_pos(3)
求得每个字符缩进后的宽度后,根据公式(2)即可求得字符的总长度。After obtaining the indented width of each character, the total length of the characters can be obtained according to formula (2).
步骤5、处理字符的高度以及行间距,把字符的高度以及行间距累加便可得到需要显示在屏幕上的字符的纵向位置。Step 5, process the height of the characters and the line spacing, and accumulate the height of the characters and the line spacing to obtain the vertical position of the characters to be displayed on the screen.
步骤6、将步骤4中利用缩进算法计算得到的字符总宽度与屏幕宽度进行比较,若字符的总宽度超过屏幕的宽度,则对超出屏幕的字符作省略处理或是作换行处理。如果需要对字符作省略处理,则还要逐一确定字符的宽度,随时准备丢弃超出屏幕的字符。Step 6. Comparing the total width of the characters calculated by the indentation algorithm in step 4 with the screen width, if the total width of the characters exceeds the width of the screen, the characters beyond the screen are omitted or line-wrapped. If the characters need to be omitted, the width of the characters should be determined one by one, and the characters beyond the screen should be discarded at any time.
步骤7、对二维图形引擎的各种通道属性和缓存器(BUFFER)进行设置;其中,分别设置了2D图形引擎的三个输入通道和一个输出通道,以及输入、输出通道所使用的缓存器。Step 7, setting various channel attributes and buffers (BUFFER) of the two-dimensional graphics engine; wherein, three input channels and one output channel of the 2D graphics engine, and buffers used by the input and output channels are set respectively .
步骤8、利用步骤4的所得出的缩进处理后读入该段字符的总宽度对中文显示中的居中、左对齐和右对齐的位置进行处理和精确计算。Step 8. Use the total width of the characters read in after the indentation processing obtained in step 4 to process and accurately calculate the positions of centering, left alignment and right alignment in Chinese display.
步骤9、取一个字符,判断当前字符是否超出了步骤1中所读入字符的长度,若没有超过,则执行下一步,否则,中断执行,跳出循环。Step 9, take a character, judge whether the current character exceeds the length of the character read in step 1, if not, execute the next step, otherwise, interrupt the execution and jump out of the loop.
字符是以16进制内码的形式读入的,Length是读入的字符所占的字节数。一个中文字符需占用两个字节,一个英文或符号占用一个字节。如果是中文,while循环每循环一次m自加二,如果是英文或符号则while循环每循环一次m自加一。m是一个累加器,控制当前while循环处理到了哪个字节上,即如果是中文则当前处理本次读入所有字节中的第m和m+1字节,如果是英文或符号则处理本次读入所有字节的中的第m字节Characters are read in in the form of hexadecimal internal codes, and Length is the number of bytes occupied by the read characters. A Chinese character takes up two bytes, and an English or symbol takes up one byte. If it is Chinese, m will be incremented by two each time the while loop is cycled. If it is English or symbols, m will be incremented by one each time the while loop is cycled. m is an accumulator, which controls which byte is processed by the current while loop, that is, if it is Chinese, it currently processes the mth and m+1 bytes of all bytes read this time, and if it is English or symbols, it processes this Read the mth byte of all bytes
步骤10、辨别当前字符为中文字符还是英文字符或符号,若为中文字符,执行下一步,若为英文或符号,执行步骤12;在ASCII码中,中文字符占两个字节,而英文或符号只占一个字节,如果不经处理直接把内码数据送入读取字库文件的函数中去,就会出现错误,导致读出的是乱码或从字库中检索出的字符不正确,因此需要对中文和英文及符号进行辨别,并分别处理。Step 10, distinguish whether the current character is a Chinese character or an English character or a symbol, if it is a Chinese character, perform the next step, if it is an English or a symbol, perform step 12; in the ASCII code, the Chinese character occupies two bytes, while the English or The symbol only occupies one byte. If the internal code data is directly sent to the function of reading the font file without processing, an error will occur, resulting in garbled characters or incorrect characters retrieved from the font. Therefore It is necessary to distinguish between Chinese and English and symbols, and deal with them separately.
步骤11、将中文字符由16进制内码转化为区位码,然后执行步骤13;其中中文的区码等于第m字节数据(text[m])再减去0xa0,而位码则是第m+1个字节的数据(text[m+1])再减去0xa0。即中文区码=text[m]-0xa0、中文位码=text[m+1]-0xa1。Step 11, convert the Chinese characters from the hexadecimal internal code into the area code, and then perform step 13; wherein the Chinese area code is equal to the mth byte data (text[m]) minus 0xa0, and the bit code is the first m+1 bytes of data (text[m+1]) minus 0xa0. That is, Chinese area code=text[m]-0xa0, Chinese bit code=text[m+1]-0xa1.
步骤12、将英文字符或符号由16进制内码转化为区位码,然后执行步骤13;英文或符号有着固定区码,他们的区码都是0xa3,而位码则是第m字节的内容转换成16进制后的数据(text[m])加上0x80后再减去0xa0。Step 12, convert the English characters or symbols from the hexadecimal internal code to the area code, and then perform step 13; English or symbols have a fixed area code, their area code is 0xa3, and the bit code is the mth byte After the content is converted into hexadecimal data (text[m]), add 0x80 and then subtract 0xa0.
步骤13、通过区位码对字库文件进行定位检索;通过上述步骤得到字符的区位码后计算出该字符在字库中的偏移量。偏移量=((区码-1)×94+(位码-1))×72,其中94表示有94个区,72表示一个字符使用72字节来标记,这里的标记是0、1的打点标记。其相当于一行有24个点(24个点占三个字节,每个字节8位即8个点),一共有24行。因此需要24×3个字节来表示一个24点阵的字符。算出偏移量后根据偏移量再字库中读出该字符的72个字节。Step 13, perform location search on the font file through the location code; calculate the offset of the character in the font library after the location code of the character is obtained through the above steps. Offset=((area code-1)×94+(bit code-1))×72, wherein 94 means that there are 94 areas, and 72 means that a character is marked with 72 bytes, and the marks here are 0, 1 dotted mark. It is equivalent to 24 points in one line (24 points occupy three bytes, each byte is 8 bits, that is, 8 points), and there are 24 lines in total. Therefore, 24×3 bytes are required to represent a 24-dot matrix character. After calculating the offset, read the 72 bytes of the character in the font according to the offset.
步骤14、利用缩进算法中的思想对当前字符进行缩进计算,确定下一个字符的起始位置。Step 14, use the idea in the indentation algorithm to calculate the indentation of the current character, and determine the starting position of the next character.
步骤15、将当前字符送入二维图形通道中等待显示输出,然后取下一个字符转到步骤9。Step 15. Send the current character into the two-dimensional graphics channel and wait for display output, then take the next character and go to step 9.
上述步骤4采用的缩进算法对读入字符的总长度进行了精确的缩进计算以为居中、左对齐、右对齐的显示提供精确的长度计算数据。The indentation algorithm adopted in the above step 4 performs precise indentation calculation on the total length of the read characters to provide accurate length calculation data for centered, left-aligned, and right-aligned displays.
上述步骤9到步骤14采用了缩进算法的处理思想,每处理一个字符就要从字库中读取该字符的0、1分布情况,即72个字节的0、1分布。之后按照缩进算法的处理方法对该字符进行缩进,并得到下一字符的起始地址。The above steps 9 to 14 adopt the processing idea of the indentation algorithm, and each time a character is processed, the distribution of 0 and 1 of the character must be read from the font library, that is, the distribution of 0 and 1 of 72 bytes. Then indent the character according to the processing method of the indentation algorithm, and obtain the starting address of the next character.
上述步骤15把经过缩进处理的字模,最后送入2D图形引擎的输出缓存通道中等待显示。对于字符的显示一般使用字符0位使用背景色或作透明显示,而1位使用不同于背景色的颜色显示。In the above step 15, the indented characters are finally sent to the output buffer channel of the 2D graphics engine for display. For the display of characters, the character 0 is generally used for background color or transparent display, and the 1 bit is displayed with a color different from the background color.
如图1所示,上述步骤所述字符的缩进计算具体实现步骤如下:As shown in Figure 1, the specific implementation steps of the indentation calculation of the characters described in the above steps are as follows:
步骤300:对读入的一段字符以字节个数进行循环计算。由于读入的字符都以字节的形式读到BUFFER中。因此根据字节的个数来循环,直到所有字节完全完毕后退出该循环。Step 300: cyclically calculate the number of bytes for a segment of characters read in. Because the characters read in are all read into BUFFER in the form of bytes. Therefore, it loops according to the number of bytes until all bytes are completely completed and exits the loop.
步骤301:根据中文字符与英文和符号的区别,分别进行处理。由于读入时每个字符是以内码的形式读入的,中文内码占两个字节,而英文或符号占一个字节。如果不经处理直接把内码送入,就会出现错误,导致读出的是乱码,或是字符不正确。Step 301: According to the difference between Chinese characters and English symbols, process them respectively. Since each character is read in in the form of an internal code when reading in, the Chinese internal code occupies two bytes, while the English or symbol occupies one byte. If the internal code is sent directly without processing, an error will occur, resulting in garbled codes or incorrect characters.
中文字符区码=第m个字节的内码-0xa0Chinese character area code = internal code of the mth byte -0xa0
中文字符位码=第m+1个字符的内码-0xa0Chinese character bit code=inner code-0xa0 of the m+1th character
英文或符号的区码=0xa3The area code of English or symbols = 0xa3
英文或符号的位码=第m个字节的内码+0x80-0xa0Bit code of English or symbol=inner code of the mth byte+0x80-0xa0
步骤302:通过区位码对字库文件进行定位检索。字库文件的定位检索依靠字符区位码算出的字库中该字符的偏移量。Step 302: Perform a location search on the font file through the location code. The location retrieval of the font file depends on the offset of the character in the font calculated by the character location code.
偏移量=((区码-1)×94+(位码-1))×72Offset = ((area code-1)×94+(bit code-1))×72
步骤303:根据偏移量从字库中读取点阵字符的字模放入大小为72个字节Buffer中(一个24点阵的中文是由24×24个点组成的,每8个点是一个字节,这样一行有3个字节,一共24行,一次对于0、1的字库文件,其使用24×3个字节来表示一个字符),如果此位为1,则表示此字符该位是需要被填充的,因此该位的颜色应置为字符颜色。如果此位为0,则表示此位是不需要被填充的,对应于此位的颜色应置为背景颜色。Step 303: read the dot matrix characters from the font library according to the offset and put them into a 72-byte Buffer (a 24-dot matrix Chinese is composed of 24×24 dots, and every 8 dots are one Byte, such a line has 3 bytes, a total of 24 lines, once for the font file of 0 and 1, it uses 24×3 bytes to represent a character), if this bit is 1, it means this character bit It needs to be filled, so the color of this bit should be set to the character color. If this bit is 0, it means that this bit does not need to be filled, and the color corresponding to this bit should be set as the background color.
步骤304:对二维数组的每个值分别作“与”运算,得到并记录该24点阵字符中最左边的点和最右边的点的位置,对于那些左右两侧的空白部分则可以进行剪裁。Step 304: Perform an "AND" operation on each value of the two-dimensional array to obtain and record the positions of the leftmost point and the rightmost point in the 24-dot matrix character. For those blank parts on the left and right sides, you can perform tailoring.
步骤305:对该段字符的每个字符进行逐一裁减并累加其宽度后,可以得到该段字符的实际宽度。Step 305: After cutting each character of the character segment one by one and accumulating its width, the actual width of the character character segment can be obtained.
以字符“i”为例,对本发明的方法进行说明。图4所示的是未使用缩进算法前的显示与使用缩进算法后的显示情况。可以看出处理前三个字符“i”的显示分布不是分散的,而处理后三个“i”的分布有了明显的改善,对字符“i”的左侧和右侧进行了明显的裁减。The method of the present invention is described by taking the character "i" as an example. Figure 4 shows the display before the indentation algorithm is used and the display after the indentation algorithm is used. It can be seen that the display distribution of the first three "i" characters is not scattered, but the distribution of the three "i" after processing has been significantly improved, and the left and right sides of the character "i" have been significantly cut .
对三个字符“i”的处理首先根据点阵字符缩进算法从字库中读取相应的字模,并通过对字模中0位和1位的运算,得到起始值bejin_pos(起始值bejin_pos=8),和终止值end_pos(终止值end_pos=14)。i的实际宽度为终止值end_pos减去起始值bejin_pos(终止值end_pos一起始值bejin_pos=6)。三个字符i的总宽度是6×3=18。这里忽略如居中、超出屏幕字符等处理要求。假设三个字符只要求左对齐,则第一个i的在屏幕上的起始位置=屏幕边缘宽度X1+0,根据起始位置和0位与1位的排列顺序,对0位使用背景色显示,对1位使用不同于背景色的颜色显示。第二个i的在屏幕上的起始位置=屏幕边缘宽度+6(第一个i的实际宽度)+字符间距(自行设定,一般为0),显示方法与第一个字符i相同,只是起始位置不同。第三个i的在屏幕上的起始位置=屏幕边缘宽度+12(两个i的实际宽度)+字符间距(自行设定,一般为0),显示方法与第一个字符i相同,只是起始位置不同。The processing of the three characters "i" first reads the corresponding font from the font library according to the dot matrix character indentation algorithm, and obtains the initial value bejin_pos (initial value bejin_pos= 8), and end value end_pos (end value end_pos=14). The actual width of i is the end value end_pos minus the start value bejin_pos (end value end_pos−start value bejin_pos=6). The total width of the three characters i is 6×3=18. Processing requirements such as centering and off-screen characters are ignored here. Assuming that the three characters only require left alignment, the starting position of the first i on the screen = screen edge width X1+0, according to the starting position and the arrangement order of 0 and 1, use the background color for 0 Display is displayed in a color different from the background color for 1 digit. The starting position of the second i on the screen = screen edge width + 6 (the actual width of the first i) + character spacing (set by yourself, generally 0), the display method is the same as the first character i, Only the starting position is different. The starting position of the third i on the screen = screen edge width + 12 (the actual width of the two i) + character spacing (set by yourself, generally 0), the display method is the same as the first character i, only The starting position is different.
通过以上的处理就可以简单的显示经过二位图形引擎的点阵字符缩进算法处理过的三个字符i了。Through the above processing, the three characters i processed by the dot matrix character indentation algorithm of the two-bit graphics engine can be simply displayed.
Claims (5)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB200610089009XA CN100498927C (en) | 2006-07-28 | 2006-07-28 | Dot-character retracting method in two-dimension pattern engines and Chinese processing method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB200610089009XA CN100498927C (en) | 2006-07-28 | 2006-07-28 | Dot-character retracting method in two-dimension pattern engines and Chinese processing method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101114443A true CN101114443A (en) | 2008-01-30 |
CN100498927C CN100498927C (en) | 2009-06-10 |
Family
ID=39022752
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB200610089009XA Expired - Fee Related CN100498927C (en) | 2006-07-28 | 2006-07-28 | Dot-character retracting method in two-dimension pattern engines and Chinese processing method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100498927C (en) |
Cited By (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101763845A (en) * | 2008-12-26 | 2010-06-30 | 上海闻泰电子科技有限公司 | Method for calculating the display width of characters in a dot matrix character library |
CN101599264B (en) * | 2009-07-15 | 2011-10-12 | 青岛海信移动通信技术股份有限公司 | Method and relevant device for displaying characters on mobile terminal |
CN102761418A (en) * | 2012-07-16 | 2012-10-31 | 重庆电子工程职业学院 | Character compression encrypting method |
CN103186507A (en) * | 2011-12-31 | 2013-07-03 | 北京大唐高鸿软件技术有限公司 | Dot matrix font library processing method |
CN102117266B (en) * | 2009-12-31 | 2013-07-10 | 北京谊安医疗系统股份有限公司 | Method and device for processing character pitch |
CN104834701A (en) * | 2015-04-28 | 2015-08-12 | 成都品果科技有限公司 | IOS-system-based intelligent search result displaying method |
CN104932846A (en) * | 2015-06-08 | 2015-09-23 | 中国人民解放军海军航空工程学院 | Russian character printout method of test equipment |
CN108242211A (en) * | 2016-12-26 | 2018-07-03 | 航天信息股份有限公司 | Processing method, device and the board units of dot character |
CN108804066A (en) * | 2018-06-11 | 2018-11-13 | 深圳市琥蜂科技有限公司 | The display methods and computer readable storage medium of screen display character |
CN110106684A (en) * | 2019-05-23 | 2019-08-09 | 卓力电器集团有限公司 | A kind of electric iron intelligence control system |
CN112115708A (en) * | 2020-08-31 | 2020-12-22 | 深圳市镜玩科技有限公司 | Adaptive label display method, related device, equipment and medium |
CN112242118A (en) * | 2019-07-16 | 2021-01-19 | 西安诺瓦星云科技股份有限公司 | Information scrolling display method, device and system |
CN114492304A (en) * | 2022-01-28 | 2022-05-13 | 海宁奕斯伟集成电路设计有限公司 | Font processing circuit, font processing system, font processing method and storage medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3317852B2 (en) * | 1996-07-30 | 2002-08-26 | シャープ株式会社 | Character generator |
JPH11149284A (en) * | 1997-11-18 | 1999-06-02 | Sharp Corp | Character pattern generating device and medium storing control program for character pattern generating device |
JP3552105B2 (en) * | 2000-05-26 | 2004-08-11 | シャープ株式会社 | Graphic display device, character display device, display method, recording medium, and program |
JP2004085607A (en) * | 2002-08-22 | 2004-03-18 | Seiko Epson Corp | Image display device, image display method, and image display program |
JP4662412B2 (en) * | 2003-05-15 | 2011-03-30 | シャープ株式会社 | Character graphic display device, character graphic display method, program, and recording medium |
-
2006
- 2006-07-28 CN CNB200610089009XA patent/CN100498927C/en not_active Expired - Fee Related
Cited By (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101763845A (en) * | 2008-12-26 | 2010-06-30 | 上海闻泰电子科技有限公司 | Method for calculating the display width of characters in a dot matrix character library |
CN101599264B (en) * | 2009-07-15 | 2011-10-12 | 青岛海信移动通信技术股份有限公司 | Method and relevant device for displaying characters on mobile terminal |
CN102117266B (en) * | 2009-12-31 | 2013-07-10 | 北京谊安医疗系统股份有限公司 | Method and device for processing character pitch |
CN103186507A (en) * | 2011-12-31 | 2013-07-03 | 北京大唐高鸿软件技术有限公司 | Dot matrix font library processing method |
CN102761418A (en) * | 2012-07-16 | 2012-10-31 | 重庆电子工程职业学院 | Character compression encrypting method |
CN102761418B (en) * | 2012-07-16 | 2015-04-22 | 重庆电子工程职业学院 | Character compression encrypting method |
CN104834701A (en) * | 2015-04-28 | 2015-08-12 | 成都品果科技有限公司 | IOS-system-based intelligent search result displaying method |
CN104834701B (en) * | 2015-04-28 | 2019-03-26 | 成都品果科技有限公司 | Intelligent search result presentation method based on IOS system |
CN104932846B (en) * | 2015-06-08 | 2018-03-09 | 中国人民解放军91872部队 | A kind of Russian character print output intent of test equipment |
CN104932846A (en) * | 2015-06-08 | 2015-09-23 | 中国人民解放军海军航空工程学院 | Russian character printout method of test equipment |
CN108242211A (en) * | 2016-12-26 | 2018-07-03 | 航天信息股份有限公司 | Processing method, device and the board units of dot character |
CN108804066A (en) * | 2018-06-11 | 2018-11-13 | 深圳市琥蜂科技有限公司 | The display methods and computer readable storage medium of screen display character |
CN110106684A (en) * | 2019-05-23 | 2019-08-09 | 卓力电器集团有限公司 | A kind of electric iron intelligence control system |
CN112242118A (en) * | 2019-07-16 | 2021-01-19 | 西安诺瓦星云科技股份有限公司 | Information scrolling display method, device and system |
CN112242118B (en) * | 2019-07-16 | 2021-11-16 | 西安诺瓦星云科技股份有限公司 | Information scrolling display method, device and system |
CN112115708A (en) * | 2020-08-31 | 2020-12-22 | 深圳市镜玩科技有限公司 | Adaptive label display method, related device, equipment and medium |
CN114492304A (en) * | 2022-01-28 | 2022-05-13 | 海宁奕斯伟集成电路设计有限公司 | Font processing circuit, font processing system, font processing method and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN100498927C (en) | 2009-06-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101114443A (en) | Indentation method of dot-matrix characters in two-dimensional graphics engine and Chinese processing method | |
US8201088B2 (en) | Method and apparatus for associating with an electronic document a font subset containing select character forms which are different depending on location | |
AU2003200547B2 (en) | Method for selecting a font | |
CN108292297B (en) | Label usage for selectively retaining chart elements during visualization optimization | |
CN101963954A (en) | Method and device for displaying words | |
US20250013815A1 (en) | Electronic text generation method and apparatus, device, and medium | |
CN104050158B (en) | Automatic quotation extraction method and device with semantic integrity kept | |
KR20150099936A (en) | Method and apparatus for applying an alternate font for maintaining document layout | |
CN109933751B (en) | Image-text drawing method and device, computer-readable storage medium and computer equipment | |
CN104516868B (en) | The streaming restoring method and system in a kind of space of a whole page space | |
US7444591B1 (en) | Methods involving text attribute recognition | |
US4717911A (en) | Technique for chaining lines of a document together to facilitate editing or proofreading | |
US11030388B2 (en) | Live text glyph modifications | |
CN110968988A (en) | Display processing method and device, electronic equipment and readable storage medium | |
EP1959352A2 (en) | System and method of report representation | |
CN102768655B (en) | JAVA-based display method of Mongolian | |
US20130227444A1 (en) | Method and Device for Improving Page Rendering Speed of Browser | |
CN113436298A (en) | Method, device and related components for automatically generating Chinese character stroke order animation | |
CN104503954A (en) | Text combination display method and text combination display system | |
CN112052647B (en) | Document editing method and device, electronic equipment and readable storage medium | |
KR101204615B1 (en) | Method for creating individual font and mobile device using thereof | |
JP2005070939A (en) | Character string processor, character string processing method, program, and recording medium | |
CN100349203C (en) | Co-screen displaying device supporting scale chracter shape and method thereof | |
JP5645481B2 (en) | Apparatus, method, and program | |
CN112765506A (en) | Page text content display method, device, equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C17 | Cessation of patent right | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20090610 Termination date: 20110728 |