Menu English Ukrainian russian Home

Free technical library for hobbyists and professionals Free technical library


ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING
Free library / Schemes of radio-electronic and electrical devices

New features of the bitmap font editor for LCDs. Encyclopedia of radio electronics and electrical engineering

Free technical library

Encyclopedia of radio electronics and electrical engineering / Radio amateur designer

Comments on the article Comments on the article

A characteristic feature of the new versions of the font editor published in [L] offered to the attention of readers is the presence in them of a character recognition module, which significantly facilitates and speeds up the process of analyzing and loading into the editor fonts previously created using other means. In addition, they provide the user with more advanced mechanisms for creating and editing fonts.

Creating a new font (character generator) for an LCD “from scratch” is, in principle, a simple task, but very painstaking. It is much easier to “adjust” a font found in one of the available sources, most often on the Internet, to your requirements. Based on these considerations, the author believes that radio amateurs most often use a font editor (hereinafter referred to as the editor) precisely to correct “alien” fonts. However, if the parameters of the source font are unknown, the process of loading it into the editor is quite complicated. The desire to eliminate these difficulties was the impetus for the development of updated versions of the editor. I bring to the attention of readers two of its new versions: the basic one (CG-Edit 2.50) and one of its modifications (CG-Edit 2.52).

Compared to the version described in [L], the editor version 2.50 unifies the procedure for loading a font file. Previously, the procedures for loading “your own” and “foreign” (created in other editors) files were different. “Own” files were loaded without specifying the parameters of the font they contained, since this information was contained in the file name.

For “foreign” files, such an operation required manual input of format parameters, scan type and image type (positive or negative). Of course, if font creators somehow included parameter information in the file, it would be easier to enter such files into the editor. But, unfortunately, in practice this is extremely rare.

Usually, to obtain this information, you need to analyze the contents of the font file, which is far from easy, or act by trial and error, repeatedly loading an unfamiliar font and trying out all possible combinations of its parameters in the expectation of seeing in the editing window not a chaotic set of dots, but meaningful outlines of characters. However, simply going through numerous options is too tedious.

In the new version of the editor, the recognition module automatically determines the necessary parameters of the font located in the downloaded file, after which it is downloaded and displayed. The operating principle of this module is as follows. It unfolds the bytes from the file one by one in matrices, the sizes of which correspond to typical formats for representing characters (from 6x8 to 24x24 pixels) on the LCD screen. Then the module compares these matrices with sample matrices in which sample symbols are expanded. At the same time, he goes through all possible options. The result of the comparison is the correlation coefficient (from 0 to 1) of the images in the working and reference matrices.

It is clear that the image of a character in the matrix will be as close as possible to its standard outline if the parameters of its scan in the matrix coincide with the parameters of the analyzed font. As a result of executing cycles for all possible parameters, a three-dimensional array of correlation coefficients is formed. Analysis of this array makes it possible to determine the parameter values ​​that most reliably correspond to the analyzed font.

In addition to defining three font parameters absolutely necessary for the editor to work (character format, scan type and image type), the editor distinguishes four zones in the code table: 20H-2FH (basic mathematical signs and punctuation marks), 30H-39H (decimal digits), 41H -7EH (Latin letters), C0H-FFH (Cyrillic letters). It gives the user an estimate of the presence of recognized characters in each of these zones.

But the module does not analyze all zone symbols. This would significantly increase the duration of its operation and the volume of the editor program. In each zone, it processes only the first four characters, applying the following criteria for its presence:

- any two out of four characters are recognized with a correlation coefficient of at least 0,85 each;
- any three out of four characters are recognized with a correlation coefficient of at least 0,7 each;
- the product of the correlation coefficients of all four symbols is at least 0,179 (which corresponds to an average correlation coefficient of 0,65).

A font is considered recognized if at least one of the above zones is found in the file.

During its operation, the module identifies and correctly loads incomplete fonts with Cyrillic font. A full font differs from an incomplete font in that it contains as many bytes as are required to describe the 224 displayed characters of the WIN-1251 code table (control characters located in the 0-1FH area are not taken into account). For example, in an 8x8 font, each character is described by eight bytes, therefore the size of its image is 8x224 = 1792 bytes. In this font, the characters are placed in the order corresponding to the code table: the first character is always a space, the next is an exclamation point, and so on. It is not at all necessary that all symbols be described correctly. There may also be empty areas in the font. A full font containing images of all characters in the code table ensures the operation of indicators that do not have a built-in character generator.

However, the use of a full font is not always justified. For example, some LCD controllers (for example, T6963C) have a built-in character generator that contains only the first half of the code table (character code range 20Н-7ЭН) and does not contain Cyrillic characters and other alphabets except Latin. To fully work with indicators built using such controllers, it is necessary to load into the character generator RAM, if available, images of the missing symbols with codes 0С0Н-0FFН. Of course, you can perform such a download from a full font, but approximately three-quarters of its volume will not be used and will uselessly take up space in the device’s memory, sometimes quite a lot. For example, the volume of a full font with a 16x24 px matrix is ​​over 10 KB, and keeping an extra 6...7 KB in the microcontroller memory is an unaffordable luxury.

In such cases, incomplete fonts are used, which contain symbol images not of the entire code table, but only of some of its parts. The volume of such a font is smaller than a full font, and the placement of characters in it may not correspond to that accepted in the code table. In practice, most often there are incomplete fonts containing only the Cyrillic alphabet. They are used to “Russify” indicators whose character generators do not have a built-in Cyrillic alphabet. There are incomplete fonts containing only numeric characters, and on foreign sites there are many incomplete fonts with characters from a wide variety of alphabets.

As is known from [L], during operation the editor creates a font image in RAM, always complete, the arrangement of characters in which corresponds to their order in the WIN-1251 code table. Since the location of characters with codes 20H-7FH in the font is always the same, this part is loaded into the image without any conversion.

The situation is exactly the same with incomplete digital font. However, displaying numbers requires the presence in the font of not only the symbols of numbers 0-9 with codes 30H-39H, but also a number of additional characters (space, comma, period, and so on). Therefore, usually a digital font contains characters with codes 20H-3FH, arranged in accordance with the code table. The editor loads these two types of partial fonts into the image from its beginning.

The situation is different with an incomplete font containing only the Cyrillic alphabet. The first character in it is not a space (20H), but a Cyrillic letter A (0С0H). This situation is recognized. The incomplete Cyrillic font will be loaded into the image, starting from the position reserved for the character with code 0C0H. Firstly, this corresponds to the logic of placing characters in the code table and makes it easier to navigate through the characters during editing, and secondly, it allows, in necessary cases, to perform such a useful action as “gluing together” a full font from two incomplete ones, containing Latin and Cyrillic letters, respectively .

When analyzing an incomplete Cyrillic font, the recognition module additionally checks the volume of its image. If it is larger than the allowed limit (which means that it contains not only 64 characters with codes 0CH-0FFH, but also some other information), the file will be loaded as a full font, but its first character will not be a space character, but a letter A. By doing this, the editor provides the user with the opportunity to understand the contents of the font himself.

All font files pass through the recognition module, regardless of their origin. But it ignores the key information contained in the file name created using the first version of the editor, which allows you to completely abandon it, simplifying the structure of the file name.

It is clear that the capabilities of the recognition algorithm are limited and unsuccessful attempts at automatic downloading are quite possible. In this case, the editor will offer to download the file, after specifying the font parameters manually. It is also possible that the editor recognizes the font incorrectly. To get out of this situation, the user is given the opportunity to disagree with the program’s decision and proceed to manually entering font parameters.

In all cases of manual input of parameters, the font will be loaded into the image from the starting position, regardless of what font (full or incomplete) is in the file.

The new version of the editor also adds the ability to copy a character from one familiarity to another within the current font. The “Pencil” and “Eraser” modes have been introduced, allowing you to draw a symbol inside a familiar place with the mouse. This makes it easier to create or edit characters, especially for large format fonts. The number of ways to expand bytes in the familiarity matrix has been increased. Added the ability to write a continuous fragment of a font image of arbitrary length to a file, i.e. create a file with an incomplete font.

Loading a font file into the editor

After the user selects a downloaded file in a standard Windows dialog, the editor automatically starts the procedure for recognizing the parameters of the font it contains. If the font parameters cannot be determined, a message will be displayed prompting you to set them manually. The reason for this may be either the format of the font contained in the font file is unknown to the program, or a significant difference in the style of the characters in it from the samples. After the user confirms consent to manually enter parameters, a window for entering them will open. At this stage, you can refuse to download the selected file.

If the editor recognizes a full or incomplete font without Cyrillic, a message will be displayed on the screen with the parameters of the recognized font. Keep in mind that the word "none" next to the name of a symbol group does not mean that there are no symbols in that group at all. In general, this is only evidence that the editor was unable to recognize the first four characters of the group.

Next, the user can either allow the file to be downloaded using the parameters defined by the recognition module, or enter the font parameters manually, or refuse to download the file.

If the editor recognizes an incomplete Cyrillic font, then it can be loaded with an overlay on the font image already in the computer’s memory, or loaded with preliminary clearing of the current image. As noted earlier, the editor always loads such a font into the image, starting from the position of the Russian letter A (character code 0C0H).

The operation of overlaying the current image allows you to create a complete font from two parts, in other words, “Russify” a font that did not have a Cyrillic font. To do this, you must first load into the editor the font that you want to Russify, and then load the incomplete Cyrillic font in overlay mode.

However, it should be borne in mind that for proper gluing it is absolutely necessary that both fonts (located in the current image and loaded) have the same parameters, otherwise the product will not work. To prevent the user from making such a mistake, the editor always stores the parameters of a previously downloaded font and, if an incomplete Cyrillic font is detected, compares its parameters with them. If they match, a message is displayed and by clicking on the "Yes" screen button, loading of the overlay file can be allowed. When you click on the "No" screen button, the download will be performed with preliminary clearing of the font image located in memory. It is also possible to refuse the download (using the "Cancel" button on the screen).

If the formats do not match, only the font can be loaded into a pre-cleaned image (“Yes”) or the download can be refused (“No”).

The main editor window after loading or creating a font is shown in Fig. 1. In general, it is the same as in [L], with the exception of a few changes, which will be discussed later.

New features of the bitmap font editor for LCD
Rice. 1. The main editor window after loading or creating a font

Copying a character from one familiar location to another

This operation is performed in the symbol selection area. Double-click the left mouse button on the source symbol. The background of his familiar place will turn blue (symbol B in Fig. 1). Then click once on the destination symbol. The operation is completed. The blue background of the source symbol will be removed, and the background of the destination symbol will turn red and the symbol will be displayed for editing. If the source symbol is selected incorrectly, then to exit the copy mode just click on this symbol again.

Pencil and Eraser modes

To enable Pencil mode, you must press and hold the Shift key. In this mode, familiarity elements over which the mouse cursor is moved change color to blue. There is no need to click mouse buttons. After releasing the Shift key, the editor returns to normal editing mode, in which each mouse click on a familiarity element inverts the state of this element.

To enable Eraser mode, press and hold the Ctrl key. The mouse cursor will leave a white mark in the familiar location. To exit the mode, just release the Ctrl key.

Types of byte scanning

In the new version of the editor, you can specify two options for vertical and two options for horizontal scanning of bytes in familiarity. They are shown in Fig. 2. The vertical mode from the first version of the editor corresponds to the "Vertical 1" mode, the horizontal mode - "Horizontal 1".

New features of the bitmap font editor for LCD
Rice. 2. Two options for vertical and two options for horizontal scanning of bytes in familiarity

To make it easier for the user to navigate when choosing the desired type of byte scan, the appearance of the window for entering font parameters, which opens when creating a new font or when manually entering its parameters during loading, has been changed. Now it contains a graphical hint for the selected type of development - one of the four fragments of Fig. 2.

In the newly opened window, only the “Cancel” on-screen button and the field for selecting the format of the familiar place are visible. The remaining elements will appear only after this selection is made. Clicking on the "Change scan type" button opens a window similar to that described above.

The current sweep type will be marked in the window that opens. It can be replaced by any valid one (valid types of development were discussed in [L]). There is no "Cancel" screen button in the window. To perform such an operation, just click on the “OK” screen button without changing the sweep type.

Creating partial font files

The first version of the editor wrote the full font file to disk in all cases. In the new version, you can save any continuous sequence of images of code table characters in a file, i.e. create files of incomplete fonts.

To create such a file, you must select the “Incomplete GR” item in the “Output file” field. Two input windows will appear in the field with the names “Symbols: from...” and “to...”. The codes of the first and last characters to be recorded (according to the code table) are entered into these windows. By default, the entire code table is indicated - the full font.

The required values ​​can be entered manually, but the editor allows you to do this in a more convenient way. In the symbol selection area, click on the first symbol of the interval (its background will turn red), and then double-click in the "Symbols with..." input window. The code of the selected symbol will appear in this window.

Then click once on the last character of the interval and twice in the "by..." input window. The code of the last character will appear in it. After this, you should select the desired option for formatting information in the output file, the required type of character image (positive or negative) and click on the “Save character generator” screen button.

By default, the editor builds the name of the saved file in the same way as described in [L], with the only difference that it adds the number 1 or 2 to the byte scan type symbol. If the saved font is incomplete, then at the end of the name generated for it, the editor adds characters LAT for a font that does not contain Cyrillic, or RUS for a font containing only Cyrillic. The name is given the .fnt extension in all cases. For example, the file name Font12x16v1nRUS.fnt means that it contains an incomplete Cyrillic font of 12x16 format, vertical byte scan 1, negative image.

As already noted, the version of the editor in question does not analyze the name of the downloaded file, so the user has the right to replace the name of the saved file (including extension) suggested by the program with any other one at his discretion. However, it is still recommended to give files meaningful names that allow you to judge the contents of the file without opening it.

Other changes

After analyzing the list of familiarity formats that the editor works with, the practically unused 24x16 px format was removed from it. The appearance of the main editor window has been slightly changed. Otherwise, version 2.50 of the editor is no different from that described in [L].

Features of the editor version 2.52

In the WIN-1251 code table, characters with codes 7FH-BFH do not belong to the main characters of the Latin or Cyrillic alphabet and are used extremely rarely. Very often in a full font this area is left empty or almost empty. As noted in [J1], in this area you can place arbitrary characters necessary for display on the indicator in the specific device for which the font is being developed. In previous versions of the editor, the contents of this group in the character selection field corresponded to the WIN-1251 code table and did not in any way reflect its true state.

Of course, it would be nice to display the true style of characters in the selection field, including during the process of editing them. However, moving a symbol from the editing area to the selection area generally requires scaling it, and scaling the raster graphics that the editor works with entails significant image distortion.

When scaling, a symbol is distorted due to the fact that its original image in the familiarity matrix has insufficient resolution, and when moving to another resolution, the image elements merge or split up in an unpredictable way. Therefore, transfer with scaling had to be abandoned, since the transferred symbol became, as a rule, unreadable.

However, in version 2.52, an alarm about the presence of symbols in the 7FH-BFH area appeared, which allows you to better navigate in it. When the editor starts, this area of ​​the symbol selection field is empty (Fig. 3). But during the process of loading the font file, the editor checks for the presence of characters in each of its familiar places. It is considered that a symbol exists if at least one bit of any byte of its image has the value 1. If such a familiar place is detected, then a symbol with code 95n (a thick dot in the center of the familiar place) will be displayed in the corresponding cell of the selection area (a bold dot in the center of the familiar place), as shown in Fig. 4. This is evidence that there is some symbol here. You can see and change its style by selecting this cell for editing. When you create a new symbol in this area, the corresponding cell in the symbol selection area will also be marked with a bold dot.

New features of the bitmap font editor for LCD
Rice. 3. Character selection field

New features of the bitmap font editor for LCD
Rice. 4. Character selection field

If the familiarity of a symbol located in the area under consideration is cleared (for example, as a result of clicking on the “Erase” screen button), then the corresponding cell of the symbol selection area is also cleared. This does not correspond to the principle adopted in the editor of indicating the fact that symbols have been edited. In other areas of the font, any editing of a character (including its complete erasure) is signaled by highlighting this character in the selection area in bold, larger font size. Therefore, the exception to the rule described above just needs to be remembered.

Otherwise, the editor of version 2.52 is completely similar to version 2.50. The updated editors of both versions include the executable file CGE-250.exe or CGE-252.exe and the Model folder, which contains ten files: t0.mod-t5.mod and v0.bmp-v3.bmp. These files must not be deleted, renamed, or moved to another location. The editor does not require installation and can be placed anywhere (including on removable media). The only condition is that the Model folder must be in the same folder as the executable file.

The programs described in the article can be downloaded from ftp://ftp.radio.ru/pub/2016/10/250-252.zip.

Literature

  1. Savchenko A. Raster font editor for graphic LCDs. - Radio, 2016, No. 3, p. 25-27.

Author: A. Savchenko

See other articles Section Radio amateur designer.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

A New Way to Control and Manipulate Optical Signals 05.05.2024

The modern world of science and technology is developing rapidly, and every day new methods and technologies appear that open up new prospects for us in various fields. One such innovation is the development by German scientists of a new way to control optical signals, which could lead to significant progress in the field of photonics. Recent research has allowed German scientists to create a tunable waveplate inside a fused silica waveguide. This method, based on the use of a liquid crystal layer, allows one to effectively change the polarization of light passing through a waveguide. This technological breakthrough opens up new prospects for the development of compact and efficient photonic devices capable of processing large volumes of data. The electro-optical control of polarization provided by the new method could provide the basis for a new class of integrated photonic devices. This opens up great opportunities for ... >>

Primium Seneca keyboard 05.05.2024

Keyboards are an integral part of our daily computer work. However, one of the main problems that users face is noise, especially in the case of premium models. But with the new Seneca keyboard from Norbauer & Co, that may change. Seneca is not just a keyboard, it is the result of five years of development work to create the ideal device. Every aspect of this keyboard, from acoustic properties to mechanical characteristics, has been carefully considered and balanced. One of the key features of Seneca is its silent stabilizers, which solve the noise problem common to many keyboards. In addition, the keyboard supports various key widths, making it convenient for any user. Although Seneca is not yet available for purchase, it is scheduled for release in late summer. Norbauer & Co's Seneca represents new standards in keyboard design. Her ... >>

The world's tallest astronomical observatory opened 04.05.2024

Exploring space and its mysteries is a task that attracts the attention of astronomers from all over the world. In the fresh air of the high mountains, far from city light pollution, the stars and planets reveal their secrets with greater clarity. A new page is opening in the history of astronomy with the opening of the world's highest astronomical observatory - the Atacama Observatory of the University of Tokyo. The Atacama Observatory, located at an altitude of 5640 meters above sea level, opens up new opportunities for astronomers in the study of space. This site has become the highest location for a ground-based telescope, providing researchers with a unique tool for studying infrared waves in the Universe. Although the high altitude location provides clearer skies and less interference from the atmosphere, building an observatory on a high mountain poses enormous difficulties and challenges. However, despite the difficulties, the new observatory opens up broad research prospects for astronomers. ... >>

Random news from the Archive

Mitsubishi Laser TVs 18.04.2013

Mitsubishi is preparing to add two new models to its Real LaserVue Series laser projection TV product line. Both new products use red, blue and green laser diodes as illumination, which provides a high quality image.

The TVs have a built-in Blu-ray disc player and a 1TB hard drive. Support for displaying 3D content is noted, but this requires the appropriate glasses. For wireless transmission of content from external sources, a Bluetooth module is provided.

The LCD-50LSR4 has a 50" screen, ten speakers and measures 113,2 x 81,1 x 36,3 cm. The 39" version of the LCD-39LSR4 also includes 10 speakers and measures 88,9 x 67,4 ,36,3 x XNUMX cm. New items will go on sale in Japan at the end of May. You can read about how Mitsubishi laser TVs work in our article.

Other interesting news:

▪ Antenna using sea water fountain

▪ gold mining bacteria

▪ Fossil Giant Rabbit

▪ Polyploidy phenomenon found in insects

▪ Fabric with built-in heating

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ section of the site Security and safety. Article selection

▪ article Drugs and the dangers of their use for health. Basics of safe life

▪ Article Who first discovered that the Earth is round? Detailed answer

▪ article Warehouse keeper of scrap and metals. Standard instruction on labor protection

▪ article Universal Probe Generator. Encyclopedia of radio electronics and electrical engineering

▪ article Summer miracles. Chemical experience

Leave your comment on this article:

Name:


Email (optional):


A comment:





All languages ​​of this page

Home page | Library | Articles | Website map | Site Reviews

www.diagram.com.ua

www.diagram.com.ua
2000-2024