(c) Eraser/Delirium Tremens`1999
------------------------------------------
Format *.chr - vector fonts

somehow I had to do it
high-quality inscription on Specky... And cool
broke off... I remembered such a program as
Picasso under iS-Dos, where there were 2-3 sets with
fonts, but everything was breaking me off
someone to take it. Fumbling around on the disk
*.chr - font and having found the document from Chronos
(in the book on Faronov's Lampoon), I for the day
I wrote a sign - there was no joy for me
limit! This is cool: you increase
font, and it almost does not lose quality when
in this case the font itself takes from 4 to 18
kilobyte
There are, of course, other formats
vector fonts (*.ttf, for example), but
The choice fell on *.chr, and here's why:1) I had a full description of this
format with which I am ready with you
share;
2) It is very small in volume and works
to increase, unlike *.ttf (if
reduce *.ttf, then it looks worse);
3) Ease of implementation *.chr;
4) I found this one on my disks
format.
To create your own fonts, you will have to
For now (I hope) use the editor on the PC.
Description of the *.chr format
These fonts are widely used in
various software products of the company
Borland, including in compilers
Turbo Pascal, Turbo C, Borland C++.
There is a professional Borland package
BGI Toolkit, which includes
FE.EXE editor (although I haven't seen it :()
Any CHR file consists of five
parts: header, parameter block,
offset tables, width tables, block tables
vector commands. File structure shown
in the table: CHR FILE STRUCTURE
┌──────────────┬───────┬─ ────────┬────────── ───────────────────┐
│ NAME │ SIZE │ OFFSET │ CONTENTS │
│ FIELDS │ FIELDS │ │ │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│FontFileID │ 4 │ 0 │ "PK",#08,#08 │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│Copyright │ 0..253│ 2 │ Any (except #1A) │
├──────────────┤───────┤──────── ─┤─────────────────────────────┤
│CopyrightEnd │ 1 │ ? │ #1A │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│HeaderOffset │ 2 │ CopEnd+1│ HeaderSize │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│FontName │ 4 │ CopEnd+3│ Font name │
├──────────────┼───────┼─ ────────┼────────── ───────────────────┤
│FontSize │ 2 │ CopEnd+7│ Loading part length │
├──────────────┼───────┼──────── ─┼─────────────────────────────│
│FontVersion │ 3 │ CopEnd+9│ 1 │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤│ParPrefix(Pfx)│ 1 │ ?(128) │ "+" │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│CharsCount(Ch)│ 2 │ Pfx+1 │ Number of characters in the font│
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│Reseru1 │ 1 │ Pfx+3 │ Not used │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│FirstChar │ 1 │ Pfx+4 │ First character code │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│DataOffset │ 2 │ Pfx+5 │ FontStart-ParPrefix │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│FillFlag │ 1 │ Pfx+7 │ Fill flag │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│UpperMargin │ 1 │ Pfx+8 │ Upper limit of the symbol │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│Reseru2 │ 1 │ Pfx+9 │ Not used │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│LowerMargin │ 1 │ Pfx+10 │ Lower limit of the symbol │
├──────────────┼───────┼─ ────────┼────────── ───────────────────┤
│Reseru3 │ 5 │ Pfx+11 │ Not used │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│Offsets │ 2*[Ch]│ Pfx+1b │ Offset table │├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│Widths │ [Ch] │ Pfx+1b+ │ Width table │
│ │ │ 2*[Ch] │ │
├──────────────┼───────┼──────── ─┼─────────────────────────────┤
│FirstData │ ? │ Pfx+1b+ │ Images of symbols │
│ │ │ 3*[Ch] │ │
├──────────────┼───────┴──────── ─┴─────────────────────────────┤
│FontEnd │ │
└──────────────┴──────────────── ───────────────────────────────┘
The FontFileID field opens the CHR file and
always contains the characters "RK", #08, #08,
which serve to determine
file correctness. The symbols of "RK" are
Philip Khan's initials -
founder of Borland. Symbols #08
(“Backhole”) erase these initials when outputting
the contents of the dial on the screen with the command
TPascal Toure. Length of Copyright in principle
can be arbitrary, because he always
ends with the CopyrightEnd field,
containing character 26(#1A) - end of file.
Immediately following the CopyrightEnd field is
a two-byte HeaderSize field containing
header length in bytes plus 1.
Field FontNamecontains
four-letter font name.
The two-byte FileSize field contains
length of the CHR file minus the length
header.
The three-byte FontVersion field contains
Apparently the version number of the font.
The rest of the title has no
values and can be arbitrary.
The ParPrefix field is spaced at HeaderSize
byte from the beginning of the file. It opens the block
font parameters and always contains "+". B
the CharsCount field is general
number of characters whose styles
are defined in the CHR file, and in FirstChar -
code of the first defined character.
A collection of CharsCount and FirstChar fields
set the range of character codes.
The DataOffset field contains the distance in
bytes from ParPrefix field to field
FirstData. Its value is determined by
formula
DataOffset=16+3*CharsCount
in which term 16 takes into account the length
block of parameters, and 3*CharsCount is the length
two tables immediately following the block
parameters.
The FillFlag field contains the so-called
character fill flag. Since the contours
not many charactersclosed, this flag
almost always reset.
The UpperMargin field contains
maximum, and LowerMargin - minimum
the value of local coordinates for the Y axis.
Local vertical coordinates
vector commands can have values in
range from -64 to +63. Thus,
these fields define the maximum
vertical size of any character: margin
UpperMargin specifies heights from the base line
to the top edge of the tallest character
font, and the LowerMargin field usually contains
a negative type value indicating
how much below the baseline can
located at the bottom edge of any symbol.
The remaining fields of the parameter block are not
are used and contain zeros.
Immediately after the parameter block begins
Offsets table. This table
contains CharsCount of double-byte words - by
one word per character. In it
indicates at what distance from the field
FirstData contains the beginning of the vector
commands for each character. The very first
a table element always contains zero.
Widths field length CharsCount bytes
contains a table of widths in which
the width is indicated (length along the X axis)
each character. Usually every character
aligned left relative to local
coordinates, so its width istable
should also set a small
the character spacing to the right of it,
so that the characters do not merge with each other.
The FirstData field defines the beginning
vector commands used for
drawing the first character. Each
vector team takes one
double-byte word and contains local
coordinates and the command itself:
VECTOR COMMANDS
┌─┬─┬──────────────────── ─────────────────── ───────────────────┐
│A│В│ Team │
├─┼─┼─────────────────────────── ───────────────────────────────┤
│0│0│ End of character image │
├─┼─┼─────────────────────────── ───────────────────────────────┤
│1│0│ Not used (although you can use it for filling?) │
│─┼─┼──────────────────── ─────────────────── ───────────────────┤
│0│1│ Raise the “feather” and move it to t.X,Y │
├─┼─┼─────────────────────────── ───────────────────────────────┤
│1│1│ Lower the “pen” and move it to point X,Y │
└─┴─┴─────────────────────────── ───────────────────────────────┘
5x enlarged vectorшрифт (lcom)
с помощью программы ChrPrint:
Typically the sequence
vectors begins with command 01, by
with an imaginary "feather" held up
state is transferred to the beginning of the
the first vector to be drawn.
The sequence ends with the command
00, in which the X and Y coordinates
are ignored, so this is usually the command
#0000. Directly in front of her often
the command Widths[N]+#80 is indicated, which
means setting the "pen" to
horizontal axis at a distance of width
character from the origin.
TEAM STRUCTURE
┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐
│7│b│5│4│3│2│1│0│7│b│5│4│3│2│1│0│
├─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─┴─┴─┴─┴─┤
│B Y Coordinate │A X Coordinate │
└───────────────┴───────────────┘
The X coordinate defines the usual
Cartesian coordinates of the x-axis and always
has a value in the range from 0 to
Widths[N] (Widths[N] - character width in
width table). Y coordinate can
set both positive and
negative values because the lower
character edge (LowerMardin field) can
be located below coordinate Y=0
(“tails” of the letters p, q, g, etc.). Therefore
when determining the Y coordinate is used
following convention: if Y<=63,
the coordinate is used as it is
has a value in the range from 0 to
Widths[N] (Widths[N] - character width in
width table). Y coordinate can
set both positive and
negative values because the lower
character edge (LowerMardin field) can
be located below coordinate Y=0
(“tails” of the letters p, q, g, etc.). Therefore
when determining the Y coordinate is used
following convention: if Y<=63,
the coordinate is used as it is
specified in the command, otherwise it
determined by the difference Y-128.
Well, we figured out the format - all the elements
tarno! The advantages of this font are:
tso: minimal loss of font quality
when it increases; small size; easy-
there is the possibility of creating originalinscriptions (his
can be “set” on a certain target-
ria); In short, he is a vector in Africa too.
Share your thoughts about the article