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

Bitmap font editor for graphic 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

The author proposes a computer program of his own design, designed to create and edit fonts for graphic LCDs that are common today.

In recent years, radio amateurs are increasingly using graphic LCDs in their developments to display information. A feature of most of these devices is the presence of a character generator partially or completely loaded by an external control device, or the complete absence of such. In the first case, when initializing the indicator, it is required to load a font (a set of symbol images) into the character generator memory. To display a symbol on the screen, the program sends only its code (address in the character generator) to the LCD controller, and the display of the symbol on the screen is provided by the LCD controller. In the second case, all the operations necessary to display the symbol on the screen are performed by the program of the control device. Often, ready-made procedures are available in the libraries of software development systems.

But in both cases, external fonts are required. On the one hand, this is good, as it makes it possible to use character sets that are most suitable for solving specific problems. However, you have to either look for the necessary fonts or create them yourself. This is not to say that font files for graphic LCDs are rare. They are easy to find on the Internet, but not always the found font can be used.

The fact is that different LCD controllers unfold the character image in the familiarity matrix in different ways. For example, the KS0107 (KS0108) controller of the WG12864 indicator flips the image bytes vertically, as shown in fig. 1, and the controller RA6963 indicator WG240128 - horizontally (Fig. 2). In the first case, the character R must be described by the byte sequence 00H, 00H, 00H, 7FH, 09H, 19H, 29H, 49H, in the second - 1EH, 11H, 11H, 1EH, 14H, 12H, 11H, 00H. Consequently, a font prepared for an LCD with horizontal byte scan of character images will be displayed incorrectly on vertical scan indicators, and vice versa.

Bitmap font editor for graphic LCDs
Rice. 1. The image of the character in the familiarity matrix

Bitmap font editor for graphic LCDs
Rice. 2. The image of the character in the familiarity matrix

From a programming point of view, a font is an array of constants. When developing programs that display information on LCDs, different programming languages ​​are used with different rules for describing such arrays. For example, in assembly language, constants are specified by db (define byte) directives, and in BASIC language, by Data operators. In C, an array of constants can be specified simply by a set of their values. The representation of hexadecimal numbers is also different. Different programming languages ​​use, for example, the formats 0xNN, &hNN, $NN, NNH, where NN are hexadecimal digits.

Given the above, we can conclude that finding a file with a suitable ready-made font is not an easy task, and given the possible need to have some specific characters in it, the task often becomes completely unsolvable. In such cases, you have to correct the font found somewhere or develop a new one from scratch. It is convenient to do this with the help of specialized programs - the so-called font editors.

Such editors can be found on the Internet. Their main drawback (at least those with which the author dealt) is their narrow focus. It seems that the program was developed by an enthusiast to solve his specific problem. For example, one program produces an output file in a format that is understood by a single programming language compiler, while another produces character images that are only suitable for a certain type of LCD. Therefore, it is either not possible to create the desired font with their help, or the output file has to be corrected, for example, using a text editor, which takes a lot of time and rarely does without errors. The ability of these programs to edit fonts created by other editors is often quite limited.

The proposed CG-Edit program was developed by the author as a more versatile tool. It allows you to develop new and correct previously created (including "foreign") fonts in the formats most commonly used in amateur radio practice.

The following dimensions of familiarity are allowed (the first factor is the number of pixels horizontally, the second factor is vertical): 6x8, 8x8, 12x16, 16x16, 16x24, 24x16, 24x24. You can design and edit fonts in both positive and negative images, as well as change the direction of byte scanning in familiarity from vertical to horizontal, and vice versa. The output information can be optimized for use in assembly language programs in various versions of BASIC and C.

The program is designed for personal computers running 32-bit and 64-bit versions of Windows. It consists of a single executable file CG-Edit.exe and does not require installation, is easy to use and has an intuitive user interface.

After starting the program, a window will open on the computer screen, shown in Fig. 3. In its upper left part there is a selection area for the edited character in the form of a table, in the cells of which the characters of the Windows-1251 code page are placed. Only characters with codes 20H-0FFH are displayed, the control code area 0H-1FH is missing because they have no graphical equivalents. All the main characters of Latin, Cyrillic and numbers are outside the 7FH-0BFH code area, so this area is convenient to use to create any characters needed for the task being solved instead of those available there according to the Windows-1251 code page.

Bitmap font editor for graphic LCDs
Rice. 3. Program window on the computer screen

In the right part of the window there is an editing area, in which the familiarity with the required character will be displayed, while this area is empty. On the bottom left there are on-screen buttons "Create character generator" and "Import character generator". The first of them puts the program into the mode of creating a new character generator. This opens a window for entering the parameters of the created font, in which you must select from the list the size of the familiarity and the direction of the byte scan in it.

It should be noted that not all sizes of familiarity allow both directions of byte scanning. The fact is that the program is focused on the maximum density of information packing. After all, the main "consumers" of the fonts created with its help are microcontroller devices with a relatively small amount of memory.

On fig. 4 it can be seen that with a horizontal scan of a byte in a familiar space of 6x8 px, only six digits are usefully used, and two digits remain superfluous. In total, the character image occupies eight bytes. With a vertical scan (Fig. 5), each character space column occupies a full byte, so only six bytes are required for the character image. The difference of two bytes per font character is quite significant, so in all character spaces where the number of columns is not a multiple of eight, only vertical scanning is allowed.

Bitmap font editor for graphic LCDs
Rice. 4. Horizontal scanning of a byte in a familiar space with dimensions of 6x8 px

Bitmap font editor for graphic LCDs
Rice. 5. Vertical scanning of a byte in a familiar space with dimensions of 6x8 px

After selecting the font options, click on the "Create" screen button. This closes the parameter input window, and the main window takes the form shown in Fig. 6.

Bitmap font editor for graphic LCDs
Rice. 6. View of the computer program window

The program creates an empty character generator image in the computer's RAM. It will remain empty until a font is loaded into it from an existing file by pressing the "Import character generator" screen button, or until you create your own characters by pressing the "Create character generator" screen button. The characters in the "Character selection" field do not reflect the actual contents of the character generator image. They always remain unchanged and serve only for orientation. In the editing area, the program displays an image of the familiarity of the selected size.

The symbol of the created or edited character generator, the cell of which is selected in the "Symbol selection" table (it is highlighted in it with a red background), is displayed in the "Editable familiarity" field. Initially, this is a symbol with the code 20H. To move to another symbol, you need to click on the corresponding table cell with the left mouse button. The inscription above the familiarity characterizes the parameters of the created font.

Edit the contents of the familiarity by clicking on its pixels with the left mouse button. Each such click reverses the state of the pixel. At the bottom of the editing field are four on-screen buttons for group pixel control. Clicking on one of them shifts the contents of the familiarity by a pixel up, down, left or right within it. Pressing the on-screen button "Erase" completely clears the familiarity, and pressing the "Revert" button restores the original style of the character being edited. Due to the fact that the delete and rollback operations permanently delete the results of editing a symbol, the program issues appropriate warning messages before they are executed.

The bottom row and the right column of the familiarity are highlighted with a yellow background. This is a reminder that included pixels in them are undesirable, since these areas serve as separators for adjacent characters on the LCD screen. However, the term "undesirable" does not mean prohibition. You can turn on a pixel, which you have to do by creating symbols such as "D" or "W". When working with large familiarity spaces, the two lower rows and two extreme right columns are highlighted with a yellow background, since for a good perception of large characters it is advisable to have increased gaps between them.

Below the editing area there are two screen buttons, with which you can either completely clear the character generator, or recode it by changing the direction of scanning bytes in the familiarity. If you try to delete a font that has unsaved changes, the program will display a warning message.

Arbitrary order of symbols selection and their multiple re-editing are allowed. After the first change in the state of any pixel, the character in the corresponding selection cell will be highlighted in bold and enlarged. This shows that it has been edited. Everything that is displayed in the program window during editing is shown in Fig. 7. It can be seen that the symbols "3" and "Щ" have already been edited, now the symbol "Щ" is being edited, and its "tail" is in the unwanted zone.

Bitmap font editor for graphic LCDs
Rice. 7. Program window in the process of editing

If necessary, you can at any time change the scan of bytes in familiarity from vertical to horizontal, and vice versa. To do this, click on the screen button "Change flat pattern view". The operation acts simultaneously on all characters of the character generator. After its execution, a corresponding message will be displayed on the screen and the font parameters displayed above the familiarity will be changed. It is not possible to change the sweep direction if this results in an increase in the size of the font image.

A few words about working with negative fonts. The very concept of a negative font has already become an atavism, since many modern LCD controllers can invert the image on their own. Nevertheless, the program has the ability to create and edit negative fonts. There are no differences from working with a positive font. Symbols in any case look positive on the computer screen. The transformation of their images into negative ones occurs in the process of writing the created font to the computer disk. Looking ahead, we note that when loading a file containing a negative font for editing, the information is entered into the character generator image in the computer memory in an inverted (positive) form and is inverted again when written to disk.

After setting the font parameters, another panel appears in the program window, entitled "Output File". It contains controls that allow you to write a character generator file to disk in the required format.

In the drop-down list "Line format" (Fig. 8) select the structure of the line in the output text file. The comma-separated hexadecimal sequence may be preceded by the keyword "Data" or ".Db" or may be omitted.

Bitmap font editor for graphic LCDs
Rice. 8. Drop-down list "String format"

In the drop-down list "Number format" (Fig. 9) select the way to represent the hexadecimal number. The two hexadecimal digits NN can be appended with one of the prefixes in the list or the suffix "h".

Bitmap font editor for graphic LCDs
Rice. 9. Drop-down list "Number format"

By checking the item "Negative font", you can create a file with such a font.

To write a file to a computer disk, click on the "Save character generator" screen button. The path to it is indicated in the standard Windows dialog. The default name for the file is FontXXxYYmn.fnt, where XXxYY is the familiarity format; m - the character "v" or "h", meaning, respectively, the vertical or horizontal scan of the byte; n is the character "p" or "n", denoting respectively the positive or negative image of the characters; fnt is a name extension.

The file name can be modified by adding valid characters at the beginning or end. However, it is not recommended to destroy the "FontXXxYYmn" construct. According to it, the program recognizes the parameters of "its" font when it is loaded. Otherwise, the program will consider the file "alien" and require manual input of parameters.

If necessary, edit the finished character generator file in the window shown in Fig. 3, click on the "Import character generator" screen button. The standard Windows file upload dialog will open, in which you should select the file to be edited. The download process for this file varies depending on its format.

The file created with the editor in question is loaded into it without user intervention. All the necessary information about the font parameters is available in the file name, of course, if the structure described above is saved in it.

If the file name does not contain the information required for identification, the program will prompt you to enter it manually and open a window in which you must specify the size of the familiarity, the direction of scanning bytes, the positive or negative font is in the file. Therefore, before editing a "foreign" file, you should get an idea about these parameters.

If the parameters are correct, then the "foreign" font will be loaded successfully with a high probability. The algorithm for reading the information contained in the file "understands" both decimal and hexadecimal numbers in various representations, extracts useful information from the Data and .Db statements, and ignores comments. Perhaps the only thing that can become an obstacle to proper loading is the presence of any additional information in the file in an uncommented form.

The process of editing a downloaded font is no different from the process of creating a new one. The last step will be to save the work done in a file that will become "own" for the program.

Editor program file: ftp://ftp.radio.ru/pub/2016/03/CG-Edit.zip.

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

Cat language inspires scientists to discover new things 23.01.2019

A small cat language can become the basis for a huge number of new scientific discoveries. Scientists are trying to copy the beneficial properties of cat language in order to create new useful things. Its rough surface may be suitable for more than just licking. Scientists at the Georgia Tech Research Institute believe that the useful properties of language can be copied.

It all started with researcher Alexis Noel becoming interested in Murphy's own cat. One day, in front of a scientist, a cat decided to lick a microfiber blanket and its tongue stuck to the fabric. The researcher thought: why did the tongue stick at all? At first she thought cats had tongues like sandpaper. She began to study it under a microscope. As a result, I found out that the tongue of a cat is covered with sharp, wrapped processes in the form of a claw. They are pressed to the tongue. But when a cat licks its fur, they rise up.

The researcher also found a small channel on each process. Noel came to the conclusion that it is through them that the saliva of a cat passes through a thick layer of wool to the skin. This is necessary not only for cleansing: this is how the cat cools down in the heat.

Now the researchers want to patent their research so they can develop a variety of useful things, such as carpet cleaning brushes or devices for applying drugs to the skin of thickly furred pets.

Other interesting news:

▪ Asphalt cleans the air

▪ Transgenic product causes allergies

▪ PHILIPS OM6777 Stereo Wireless Headset

▪ Corals don't tan

▪ Silver nanowire instead of ITO film

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ section of the site The most important scientific discoveries. Article selection

▪ article Man retinue. Popular expression

▪ article How did Europeans cross two Indian symbols of war and peace? Detailed answer

▪ article Head of the consumer service center and the sale of services. Job description

▪ article Electron micrometer. Encyclopedia of radio electronics and electrical engineering

▪ article Machine for drilling boards. Encyclopedia of radio electronics and electrical engineering

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