unifont-7.0.06.tar.gz
[unifont.git] / doc / unifont.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename unifont.info
4 @settitle Unifont
5 @c %**end of header
6
7 @paragraphindent none
8
9 @copying
10 This tutorial describes Unifont, a bitmap-based font covering the
11 Unicode Basic Multilingual Plane and beyond, and its utility programs.
12
13 Copyright @copyright{} 2008--2014 Paul Hardy
14
15 @quotation
16 Permission is granted to copy, distribute and/or modify this document
17 under the terms of the GNU Free Documentation License, Version 1.3 or
18 any later version published by the Free Software Foundation; with no
19 Invariant Sections, with no Front-Cover Texts and no Back-Cover Texts.
20 @end quotation
21
22 @end copying
23
24 @dircategory Fonts
25
26 @direntry
27 * Unifont (unifont).  A bitmap-based font covering the Unicode BMP.
28 @end direntry
29
30 @titlepage
31
32 @title Unifont
33 @author Paul Hardy
34 @page
35 @vskip 0pt plus 1filll
36
37 @insertcopying
38
39 @end titlepage
40
41 @contents
42
43
44 @node Top, Introduction, (dir), (dir)
45
46 @menu
47 * Introduction:: General overview.
48 * Tutorial:: Tutorial on Unifont utilities and Unifont modification.
49 * Reference:: Detailed description of each Unifont utility.
50 @end menu
51
52
53 @node Introduction, Tutorial, Top, Top
54 @chapter Introduction
55
56
57 This document describes the process of using the GNU Unifont utilities
58 to create a font.  The steps described in the "Using Graphical Tools"
59 section in the "Tutorial" chapter are more or less the steps that
60 I (Paul Hardy) followed to add thousands of glyphs to GNU Unifont,
61 except that I didn't have the luxury of just typing @code{make}
62 to make a new font while adding those glyphs in the beginning.
63
64 I streamlined the font build process after I was done drawing the
65 Unicode 5.1 glyphs.
66
67 I know that plain ASCII text is *so* last millennium, especially for
68 a package related to Unicode.  Yet ASCII can be read with anything;
69 hence this format.
70
71 If you have questions, please email
72 @code{unifoundry@@unifoundry.com}.
73 You can check for the latest Unifont news at
74 @code{http://savannah.gnu.org/projects/unifont} and
75 @code{http://unifoundry.com}.
76 You can also submit a bug report through the
77 @code{http://savannah.gnu.org/projects/unifont} page.
78
79 DISCLAIMER: Donald Knuth warned in his Metafont book that if someone
80 started designing type, they would never again be able to look at
81 a page of text normally and just read its content.  There is a
82 point of no return beyond which a serious font designer begins
83 looking at how individual letters in a font on a page are drawn,
84 and how they might be improved.  Be warned!
85
86
87 --- Paul Hardy (@code{unifoundry@@unifoundry.com})  2008, 2013
88
89
90 @node Tutorial, Reference, Introduction, Top
91 @chapter Tutorial
92
93 This chapter provides a step-by-step tutorial on using the Unifont
94 utility programs to modify a font in the GNU Unifont format.
95
96 @menu
97 * Unicode:: Brief Overview of The Unicode Standard.
98 * Unifont Structure:: The format of Unifont files.
99 * Hex File Format:: The @code{unifont.hex} file format.
100 * Using Graphical Tools:: The Unifont graphical utilities.
101 * Using Hexdraw:: The Unifont ASCII utility for text editors.
102 * Checking Coverage:: Checking Unicode Basic Multilingual Plane coverage.
103 * Custom Builds:: Customizing the composition of a Unifont derivative.
104 * Viewing a Unifont File Interactively:: Using @code{unifont-viewer}
105 * Seeing the Big Picture (Literally!):: Creating a Unifont poster.
106 * Combining Circles:: Glyphs with zero width.
107 * Installing Fonts on GNU/Linux:: font installation on Unix/Linux.
108 * Creating a Brand New Font:: advice on adding a new Unicode script.
109 * Updates to Unicode:: modifying Unifont for Unicode updates.
110 @end menu
111
112 @node Unicode, Unifont Structure, Tutorial, Tutorial
113 @section Unicode
114
115
116 Unicode is an international standard to encode all the world's
117 scripts with one universal scheme.  Unicode is the default encoding
118 for web pages and is gaining popularity in many other applications.
119 To learn more about Unicode, look at code charts, and see the
120 latest developments, check out
121
122 @example
123 http://unicode.org
124 @end example
125
126 Unifont follows the Unicode encoding scheme.  Unicode
127 defines the numeric value of a character, but does not define
128 one particular font.  There can be (and are) many fonts that
129 support a subset of Unicode characters.
130
131 In 1998, Roman Czyborra observed that there was still no font,
132 free or commercial, with complete Unicode coverage.  He envisioned
133 a low-quality bitmapped font as an easy way to produce a font
134 that covered much of the Unicode standard.
135
136
137 @node Unifont Structure, Hex File Format, Unicode, Tutorial
138 @section Unifont Structure
139
140
141 GNU Unifont is a bitmapped pixel font, which is also converted
142 to an outline TrueType font.  Roman Czyborra began this font
143 in 1998 with a goal of having one glyph rendered for each visible
144 character in the Unicode Basic Multilingual Plane (Plane 0, the
145 first 65,536 characters).  His original writing on this is at
146 @code{http://czyborra.com/unifont/}.
147
148 (Note that the term "character" is used very loosely here for
149 simplicity; the Unicode Standard has a stricter definition
150 of what constitutes a character.)
151
152 The font is dual-width.  Each character is 16 pixels tall, and
153 either 8 or 16 pixels wide.  The characters are stored in a
154 unique .hex file format invented by Roman Czyborra as a convenient
155 way of giving each character exactly a one line specification.
156 Conversion between this .hex format and BDF font format is trivial.
157
158
159 @node Hex File Format, Using Graphical Tools, Unifont Structure, Tutorial
160 @section Hex File Format
161
162
163 By convention, files containing the Unifont native font format
164 have the extension ".hex".  Their format is extremely simple, consisting
165 of two fields separated with a colon (":") and ending with a newline.
166
167 The first field is the Unicode code point, in hexadecimal.  For all
168 Plane 0 code points, this is a four digit hexadecimal number.  Hexadecimal
169 digits are (in order) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E,
170 and F.  The Unicode Standard uses a hexadecimal number to assign
171 each character a location.  These locations are called "code points"
172 and their range is 0 through 10FFFF, inclusive.
173
174 The range 0000 through FFFF, inclusive, is called the Basic Multilingual
175 Plane (BMP), or Plane 0.  This plane contains glyphs for most of
176 the world's modern writing scripts.
177
178 Unifont utilities support glyphs across the entire Unicode range.
179 The current distribution includes glyphs for Unicode's Plane 0,
180 Plane 1 (the Supplemental Multilingual Plane, or SMP), and others.
181 Coverage of the SMP is only partial.
182
183 The first field in a @code{.hex} file should be either four digits long
184 for the Basic Multilingual Plane, or six digits long for higher Unicode
185 planes, following the convention of the Unicode Standard.
186
187 The second field is a string of hexadecimal digits.  There are 32
188 digits for a character that is 8 pixels wide, and 64 digits for a
189 character that is 16 pixels wide.
190
191 The good news is you don't have to worry about these long digit
192 strings.  Roman Czyborra wrote a utility, @code{hexdraw}, to convert
193 .hex fonts to a form that can be edited with a plain text editor,
194 then converted back into .hex format.
195
196 Paul Hardy wrote two utilities to do the same thing except with
197 bitmapped graphics images for editing with a graphics editor:
198 @code{unihex2bmp} converts a block of 256 characters into a graphics
199 file, and @code{unibmp2hex} converts such a graphics file back into
200 .hex format.  These bitmaps display the 256 characters in a block
201 arranged in a 16 by 16 character grid.  The graphics editor must
202 maintain the image as a monochrome (black and white) file, with
203 one bit per pixel.  After conversion from a .bmp file back to
204 a .hex file, the next step is conversion to a BDF font file.  A BDF
205 file can only encode a pixel being on or off (i.e., black or white
206 only with no intermediate shades of gray).
207
208 Andrew Miller later converted @code{unihex2bmp} and @code{unibmp2hex}
209 to Perl, then transformed them into
210 @code{unihex2png} and @code{unipng2hex}, respectively.  These programs
211 convert Unifont .hex files to and from Portable Network Graphics files.
212
213 These programs will probably handle glyphs beyond the BMP properly, but
214 that capability is considered experimental, as the focus was to cover
215 the BMP.  The @code{unihex2png} and @code{unipng2hex} programs handle
216 the full Unicode code point range of 0x000000 through 0x10FFFF.  The
217 @code{unihex2bmp} and @code{unibmp2hex} programs support the full
218 32-bit unsigned integer range of 0x00000000 through 0xFFFFFFFF, but
219 have not been tested extensively beyond the Unicode BMP.  The range of
220 the C programs might be truncated in the future to only cover to
221 0x10FFFF, the limit of the Unicode code point space.
222
223 The latest release of the @code{hexdraw} program works correctly with .hex
224 files having code points in the full Unicode range of U+0000 through U+10FFFF.
225
226
227 @node Using Graphical Tools, Using Hexdraw, Hex File Format, Tutorial
228 @section Using Graphical Tools
229
230
231 Let's look at an example.  Suppose you want to modify the Coptic letters
232 in the range U+2C80..U+2CFF ("U+" is Unicode shorthand).  These
233 letters are in the upper half of the block U+2C00..U+2CFF.  The
234 Unicode utilities in this package refer to this as "page" 2C.
235 ("Page" is not a Unicode term --- it is just a term unique to this
236 package to refer to a block of 256 code points/characters).
237
238 The steps to follow will be:
239
240 @enumerate
241 @item
242 Convert .hex version of the page 2C range as a 16 by 16
243 bitmapped grid.
244
245 @item
246 Modify the bitmap in any graphics editor, being careful
247 to re-save it as a Windows Bitmap (.bmp) or Wireless
248 Bitmap file when finished.
249
250 @item
251 Convert the modified bitmap back into a .hex font file.
252
253 @item
254 Merge the results with the original @code{unifont.hex} file
255 (or whatever its name might be).
256
257 @item
258 Run @code{unidup} on the resulting file to guard against
259 duplicate character definitions.
260
261 @item
262 Create the new bitmapped version of the font.
263
264 @item
265 Check the compiled font for duplicates.
266
267 @item
268 If there are duplicates, remove them and go back to Step 5.
269
270 @item
271 Create the new TrueType version or other versions of the font.
272
273 @end enumerate
274
275 If the script has combining characters (such as accent glyphs),
276 also add their code points to the proper @code{*combining.txt} file
277 in the directory for the corresponding Unicode plane.  That way,
278 when the font is converted to TrueType those glyphs will have zero
279 space.  For a script with combining characters, all glyphs that can
280 appear with combining characters must have the same width so that
281 the combining characters will be properly positioned.
282
283 @strong{Step 1:} Convert the .hex range into a bitmap grid.
284 Assuming our font file is named @code{unifont.hex}, type
285
286 @example
287 unihex2bmp -p2C < unifont.hex > uni2C.bmp
288 @end example
289
290 @strong{Step 2:} Modify @code{uni2C.bmp} with your favorite graphics editor.
291 Note that whatever graphics editor you use must preserve the
292 file as a black and white bitmap (monochrome), with one bit
293 per pixel.  During editing, you can draw guidelines outside
294 the actual 16x16 font pixel area; they will be ignored when
295 converting back into .hex format.  You can also erase the
296 grid borders between code points on purpose or by accident,
297 and it will have no effect on the generated .hex file.  Just
298 don't erase the code point numbers on the outer edges of
299 the grid.  The conversion from .bmp back to .hex only looks
300 at the "U+0000" in the upper left-hand corner of the bitmap graphic
301 and other code point numbers, and at each code point's
302 16x16 pixel area inside its 32x32 pixel grid area.  Every other
303 artifact in the final graphics file outside these areas is ignored.
304
305 If a new version of Unicode adds glyphs to a page that were
306 previously unassigned, be sure to remove the newly-assigned
307 code points from the @code{unassigned.hex} file because the code
308 point is no longer unassigned.
309
310 @strong{Step 3:} Convert the edited .bmp file back into .hex format:
311
312 @example
313 unibmp2hex < uni2C.bmp > uni2C.hex
314 @end example
315
316 @noindent
317 Note that the conversion from a bitmap image to a .hex file
318 can't distinguish between a legitimate single- or double-width
319 space character and a code point that does not have an assigned
320 value.  Therefore, space glyphs are separately contained in the
321 @code{spaces.hex} file.
322
323 @strong{Step 4:} Merge the results with the original @code{unifont.hex} file.
324 This requires several sub-steps:
325
326 @itemize
327 @item
328 Edit the original @code{unifont.hex} file and delete the
329 lines that begin with "2C".
330
331 @item
332 Insert the @code{uni2C.hex} file into @code{unifont.hex}, either with
333 a text editor such as @code{emacs} or @code{vi}, or with a GNU/Linux
334 command such as:
335        
336 @example
337 sort uni2C.hex unifont.hex > new-unifont.hex
338 @end example
339
340 This second option (using @code{sort}) is preferred, because
341 @code{unidup} (in Step 5) might miss duplicate code points
342 if your final result isn't in proper order.
343
344 @end itemize
345
346
347 @strong{Step 5:} Make sure there are no duplicates with @code{unidup}:
348
349 @example
350 unidup < unifont.hex
351 @end example
352
353 @noindent
354 or
355
356 @example
357 unidup < new-unifont.hex
358 @end example
359
360 @noindent
361 depending on the name of your final font file.  If there
362 is no output, your modified font contains no duplicates.
363
364 This editing is best done on an input .hex file, such as
365 @code{unifont-base.hex}.
366
367 @strong{Step 6:} Create the new bitmapped version of the font.  In the
368 @code{font/} directory, type
369
370 @example
371 make hex
372 @end example
373
374 @strong{Step 7:} Check the compiled font for duplicates.  Change to the
375 @code{font/compiled/} directory and run
376
377 @example
378 unidup < mynewfontfile.hex
379 @end example
380
381 @noindent
382 for whatever font file you created.
383
384 @strong{Step 8:} If there are duplicates, remove them in the @code{font/}
385 directory and go back to Step 5.
386
387 @strong{Step 9:} Create the new TrueType version of the font and all other
388 bitmapped versions.  From the @code{font/} directory, type
389
390 @example
391 make distclean && make
392 @end example
393
394 @noindent
395 Then be prepared to wait a long time unless you are using
396 a computer with plenty of RAM and CPU horsepower.  Your
397 computer should have at least 256 Megabytes of virtual
398 memory (RAM), and at least 250 Megabytes of free disk space.
399
400 To only create a BDF font, in the @code{font/} directory just type
401
402 @example
403 make bdf
404 @end example
405
406 To only create a BDF and PCF font, in the @code{font/} directory type
407
408 @example
409 make pcf
410 @end example
411
412 Creating a BDF font is the first step in creating a PCF font
413 (not counting generating the compiled master ".hex" input file).
414 BDF fonts can be created just with the tools in this package.
415 PCF fonts are created by running @code{bdftopcf} on the BDF font.
416 TrueType fonts require FontForge.
417
418 The Unifont package also includes two new programs
419 for working with Portable Network Graphics (PNG) files instead
420 of BMP files.  These utilities are @code{unihex2png} and
421 @code{unipng2hex}.  They work in a similar manner to the corresponding
422 programs @code{unihex2bmp} and @code{unibmp2hex}, respectively.
423
424 To use @code{unihex2png} instead of @code{unihex2bmp}, continuing
425 the example of the Coptic script in the U+2Cxx range, type:
426
427 @example
428 unihex2png -p 2C -i unifont.hex -o uni2C.png
429 @end example
430
431 Note that with @code{unihex2bmp} specifying input and output files
432 is optional, while with @code{unihex2png} at least the PNG filename
433 must be specified explicitly.  More specifically, @code{unihex2png}
434 will read a .hex file format input from STDIN if no "-i" argument
435 is specified, but the name of the binary PNG file must always be
436 specified with the "-o" option.
437
438 Then edit the resulting PNG file to your heart's content.  When done,
439 convert the file back into a @code{unifont.hex} format file.  In
440 this example, type:
441
442 @example
443 unipng2hex -i uni2C.png -o uni2C.hex
444 @end example
445
446 Similar to @code{unihex2png}, the binary PNG file must be specified
447 with "-i" but the .hex format file will be written to STDOUT if the
448 "-o" option is omitted.
449
450 Finally, merge  your changes in with your main .hex font file as
451 described previously in this section.
452
453
454 @node Using Hexdraw, Checking Coverage, Using Graphical Tools, Tutorial
455 @section Using Hexdraw
456
457
458 Roman Czyborra's original utility to edit glyphs is the @code{hexdraw}
459 Perl script.  Using the same script as in the previous chapter, Coptic,
460 here are the steps for modifying @code{unifont.hex} using @code{hexdraw}.
461
462 First, realize that Unifont has tens of thousands of glyphs
463 (characters, using the term character loosely).  In this example,
464 out of the tens of thousands of glyphs, we want to modify the range
465 U+2C80..U+2CFF (only 128 glyphs).
466
467 The range U+2C80..U+2CFF could be extracted from @code{unifont.hex} by
468 using the @code{egrep} utility to look for lines beginning with "2C8"
469 through "2CF", or that range could be isolated by copying @code{unifont.hex}
470 into another file, and deleting all lines except the desired range.
471
472 The following steps will probably minimize typographical errors,
473 but they aren't the only way.
474
475 @enumerate
476 @item
477 "Grep" the desired block of 256 glyphs (using the @code{grep} utility)
478 and convert this into a text representation for editing.
479
480 @item
481 Edit the block with a text editor, such as @code{emacs} or @code{vi}.
482
483 @item
484 Convert the edited text file back into .hex format.
485
486 @item
487 Delete the edited block range from the original font file.
488
489 @item
490 Merge the two .hex files into one file.
491
492 @item
493 Check for duplicates with @code{unidup}.
494
495 @item
496 Generate new fonts as described in the "Using Graphical Tools" section above.
497
498 @end enumerate
499
500 @strong{Step 1:} Extract the desired block with @code{grep}:
501
502 @example
503 grep "^2C" unifont.hex | hexdraw > uni2C.txt
504 @end example
505
506 @strong{Step 2:} Edit @code{uni2C.txt} with a text editor.
507
508 @strong{Step 3:} Convert the text file back into .hex format:
509
510 @example
511 hexdraw < uni2C.txt > uni2C.hex
512 @end example
513
514 @strong{Step 4:} Delete the lines in the original @code{unifont.hex}
515 file that begin with "2C".
516
517 @strong{Step 5:} Merge the two files:
518
519 @example
520 sort unifont.hex uni2C.hex > new-unifont.hex
521 @end example
522
523 @noindent
524 or use Roman's @code{hexmerge} utility:
525
526 @example
527 hexmerge unifont.hex uni2C.hex > new-unifont.hex
528 @end example
529
530 @strong{Step 6:} Check for duplicates:
531
532 @example
533 unidup < new-unifont.hex
534 @end example
535
536 @noindent
537 Of course, remove any reported duplicates.
538
539 @strong{Step 7:} Build the font as in the "Using Graphical Tools" section
540 above.  This can be as simple as typing
541
542 @example
543 make
544 @end example
545
546 @noindent
547 in the @code{font/} directory.
548
549 I (Paul Hardy) had only used @code{hexdraw} in the very beginning of my
550 work on Unifont.  Once I got my graphics programs working,
551 I ignored it for months.  Then I wanted to go through all of the
552 Yi Syllables and Yi Radicals --- over 1000 glyphs --- to fine-tune
553 their horizontal alignment after I drew them.  @code{hexdraw} turned out
554 to be the perfect tool for this.  By printing hyphens ("-") as
555 place holders where a pixel is off, it allowed me to verify space
556 to the left and right of each character.  I later used @code{hexdraw}
557 for similar fine-tuning of spacing on Hangul and other glyphs.
558 It is ideal for the task.
559
560
561 @node Checking Coverage, Custom Builds, Using Hexdraw, Tutorial
562 @section Checking Coverage
563
564
565 There should never be duplicates in a .hex file.  If there are, remove
566 them before the .hex font is turned into a BDF or other font file.  The
567 recommendations above include making liberal use of @code{unidup} to avoid
568 such a situation.
569
570 The @code{unipagecount} program will print a hexadecimal number of code
571 points that have coverage within each 256 code point block.  The
572 hexadecimal number will therefore range from 0 (no coverage) to
573 100 (= 256 decimal; full coverage).  If a number is ever more than
574 100 hexadecimal, there's an extra character (glyph) for that page.
575
576 To further look at the coverage within just one 256 code point
577 page (using page 2C, containing Coptic, as our example) use
578
579 @example
580 unipagecount -p2C < unifont.hex
581 @end example
582
583 Note that the "page number" can use upper- or lower-case letters:
584 @code{-p2C} or @code{-p2c} will both work.  That will print a 16 x 16 grid
585 of U+2C00..U+2CFF.  Of course, without placeholder glyphs for the
586 unassigned code points from @code{unassigned.hex} in the U+2C00..U+2CFF
587 range, unipagecount can give a lower number than the true coverage.
588
589 Using the @code{-l} flag with @code{unipagecount} will produce an HTML
590 table with links to corresponding graphics images.  You can get
591 an idea of how this works in the @code{font/compiled/} directory after
592 running @code{make}; the @code{index.html} file in that directory will have
593 a table with links to the 256 glyph maps in the @code{font/compiled/bmp/}
594 subdirectory.
595
596 With @code{unipagecount}, the background color of the cells will range from
597 red (for 0% complete in that 256 code point block) to orange
598 (a little coverage) to yellow (more coverage) to green
599 (complete coverage).  If a cell looks light red or pink,
600 the corresponding code page probably has duplicate characters.
601 Verify that with
602
603 @example
604 sort unifont.hex | unidup
605 @end example
606
607 @noindent
608 (substituting the name of your .hex file for @code{unifont.hex}).
609
610 To see the coverage of each Unicode script, copy the file
611 @code{font/coverage.dat} into the same directory as the
612 @code{unifont.hex} file you're examining.  Then run
613
614 @example
615 unicoverage < unifont.hex > coverage.out
616 @end example
617
618 This will give you all the scripts within the Unicode Basic
619 Multilingual Plane, in order, with a percentage (0.0% through
620 100.0%) of each script's coverage.  Note that to get the true
621 coverage of assigned code points, you'll have to merge @code{unassigned.hex}
622 with the rest of @code{unifont.hex} if not done by default in your setup.
623
624 Using the .hex files in @code{font/plane00/}, you can create a font with
625 all available glyphs with
626
627 @example
628 sort font/plane00/*.hex >unifont-whole.hex
629 @end example
630
631 @noindent
632 and run @code{unicoverage} using the resulting @code{unifont-whole.hex} file.
633
634
635 @node Custom Builds, Viewing a Unifont File Interactively, Checking Coverage, Tutorial
636 @section Custom Builds
637
638
639 The font can be built from within the @code{font/} directory by simply typing
640
641 @example
642 make
643 @end example
644
645 @noindent
646 From the top-level directory (one level above the @code{font/} directory),
647 typing
648
649 @example
650 make BUILDFONT=1
651 @end example
652
653 @noindent
654 will also build the font.  The font is not built by default by typing
655 @code{make} from the top-level directory, because a pre-built version
656 already exists in the @code{font/precompiled/} directory.  Font files
657 are architecture-independent, so the only reason to build the font is
658 if you modify its composition.
659
660 By default, source glyphs are read from the @code{font/plane00/} directory.
661 Glyphs for unassigned code points are built into the font by default,
662 but glyphs for Private Use Area code points are not built into the font.
663
664 All of the .hex file names can be replaced selectively on the
665 @code{make} command line to override their default values.
666 Their locations are relative to the @code{font/} directory.
667 The list of component hex file variables is:
668
669 @table @code
670
671 @item UNIFONTBASE
672 The bulk of Unifont scripts
673
674 @item CJK
675 Most of the CJK Ideographs
676
677 @item HANGUL
678 Hangul Syllables block
679
680 @item SPACES
681 Space glyphs, single- and double-width
682
683 @item UNASSIGNED
684 Glyphs for unassigned code points
685
686 @item PUA
687 Glyphs for the Private Use Area
688
689 @end table
690
691 So, for example, to build a font that includes four-digit hexadecimal
692 code point glyphs (as white digits on a black background) for the
693 Private Use Area, type
694
695 @example
696 make PUA="plane00/pua.hex"
697 @end example
698
699 @noindent
700 because those glyphs reside in the @code{font/plane00/pua.hex} file.
701
702 To build a font that includes your own special PUA glyphs, type
703
704 @example
705 make PUA="my-cool-PUA.hex"
706 @end example
707
708 @noindent
709 or whatever the name of your PUA glyph .hex file is named.
710
711 To create a build that includes the supplied PUA glyphs but not the
712 unassigned code point glyphs, type
713
714 @example
715 make PUA="plane00/pua.hex" UNASSIGNED=""
716 @end example
717
718 If you create a custom font build of your own in one gigantic file,
719 you can build with just this file by declaring all the ordinary files
720 to be null:
721
722 @example
723 make UNIFONTBASE="mycustomfont.hex" \ @*
724 CJK="" HANGUL="" UNASSIGNED="" PUA=""
725 @end example
726
727 Note that this command did not include an override for the glyphs for spaces
728 contained in the @code{font/plane00/spaces.hex} file; that is, the variable
729 SPACES was not redefined on the command line.  You could also pass the
730 argument SPACES="", but just be aware that those spaces glyphs are in
731 a separate file for a reason.  When graphical (".bmp") glyph files are
732 converted back into hex string (".hex") format, the @code{unibmp2hex} utility
733 doesn't know if a blank glyph area is a space glyph or not, so it doesn't
734 encode anything.  The @code{font/plane00/spaces.hex} file contains glyphs that
735 are strings of 0s, with length depending on whether the space is nominally
736 a single- or double-width space.  (Unifont does not distinguish between
737 finer spacing used in traditional typesetting, such as a thin space, en space,
738 em space, or quad space; all spaces are either 8 pixels wide or 16 pixels
739 wide.)
740
741
742 @node Viewing a Unifont File Interactively, Seeing the Big Picture (Literally!), Custom Builds, Tutorial
743 @section Viewing a Unifont File Interactively
744
745 The @code{unifont-viewer} Perl script uses the @code{wxWidgets} Perl library
746 to present a dynamic graphical representation of a Unifont hex file.
747 This is a convenient way to scan quickly through a complete Unifont hex file.
748 It is ideal for scanning through a Unifont hex source file after you have made
749 changes.
750
751 Use @code{unifont-viewer} to open any Unifont hex file, whether in the Basic
752 Multilingual Plane up to the maximum Unicode code point of U+10FFFF.  The font
753 is displayed graphically in sections of 16-by-16 glyph grids (256 glyphs---a
754 "page" in Unifont lingo).  The page numbers (the upper portion of the
755 hexadecimal code point range) appear in a list along the left-hand side.
756 Only page ranges that are present in the Unifont hex file are listed.
757
758 When @code{unifont-viewer} loads a hex file, it begins by displaying the first
759 "page" range in that file.
760
761
762 @node Seeing the Big Picture (Literally!), Combining Circles, Viewing a Unifont File Interactively, Tutorial
763 @section Seeing the Big Picture (Literally!)
764
765
766 The GNU Unifont 6.3 release introduced a new program, @code{unifontpic}.
767 This produces a chart of all the Basic Multilingual Plane glyphs in
768 Unifont.  By default the chart is arranged as a 256-by-256 glyph
769 table.  Specifying the @code{-l} option produces a chart that is
770 16 glyphs wide by 4,096 glyphs long.  See unifontpic(1) for more
771 information.
772
773 The "long" version, created with @code{unifontpic -l}, only produces
774 16 glyphs per row.  This is more useful for scrolling through on
775 a computer screen.
776
777 GIMP, the GNU Image Manipulation Program, will properly display
778 the resulting long .bmp file (at least under GNOME), but not all
779 graphics utilities can.  The output file is over 65,536 pixel rows tall,
780 which causes problems with some graphics programs.
781
782 To generate a chart with all your glyphs in one giant @code{unifont.hex}
783 file, type the command
784
785 @example
786 unifontpic < unifont.hex > unifont.bmp
787 @end example
788
789 @noindent
790 The output is a monochrome Bitmap Graphics Format (.bmp) file.
791 If you prefer PNG files, use your favorite graphics program or
792 conversion program to convert the BMP file to a PNG file.
793
794 This utility is especially useful if you're customizing the font,
795 for example if adding your own Private Use Area glyphs.
796
797 The default 256-by-256 code point chart will render satisfactorily
798 on a sheet of paper approximately 3 feet by 3 feet (1 meter by 1 meter)
799 at 120 dots per inch.  Thus the square format is suitable for printing.
800
801
802 @node Combining Circles, Installing Fonts on GNU/Linux, Seeing the Big Picture (Literally!), Tutorial
803 @section Combining Circles
804
805
806 The earliest versions of Unifont (before the 5.1 release) used glyphs
807 that showed dashed circles for combining characters.  This is how the
808 glyphs appear in The Unicode Standard code charts.  In version 5.1,
809 Paul Hardy was able to get combining characters to appear superimposed
810 correctly in the TrueType version of the font.  (There are no plans
811 to try to get combining characters to work in a BDF or PCF version
812 owing to the limitations of those bitmapped font formats.)
813
814 With combining characters working in the TrueType font, Paul Hardy created
815 variations of Unifont with and without combining circles, the idea being
816 that the version without combining circles would be used to create the
817 TrueType font.  The variation with combining circles was kept for reference.
818
819 Unifont Version 6.2 simplified the build to produce only one font variation,
820 without combining circles.
821
822 Unifont Version 6.3 introduced a new utility, @code{unigencircles},
823 to superimpose combining circles over glyphs with code points in
824 a @code{combining.txt} file.
825
826 The latest Unifont release contains a parallel set of font files
827 named @code{unifont_sample.*}.  These "Unifont Sample" font files
828 contain glyphs with combining circles where appropriate.  The
829 "Unifont Sample" font is therefore not intended for general-purpose
830 writing, but only for illustrating each individual glyph as represented
831 in The Unicode Standard.
832
833 To run @code{unigencircles}, start with the file
834 @code{font/ttfsrc/combining.txt} and type a command of this form:
835
836 @example
837 unigencircles combining.txt < unifont.hex > unifont-circles.hex
838 @end example
839
840 @noindent
841 where @code{unifont.hex} is a single file containing all the glyphs you
842 wish to render.  You could create such a file from the @code{font/}
843 directory with the command
844
845 @example
846 sort plane00/*.hex >unifont.hex
847 @end example
848
849 Because the output is another .hex file, you can use all Unifont
850 utilities with this resulting file just as you would with the .hex files
851 in @code{font/plane00/}.
852
853 If you want to build a font from this generated @code{unifont.hex} file,
854 you could type
855
856 @example
857 make UNIFONTBASE="unifont-circles.hex" CJK="" HANGUL="" \ @*
858 UNASSIGNED="" PUA=""
859 @end example
860
861 @noindent
862 as discussed above.  In this case, if you included
863 @code{font/plane00/spaces.hex} in the @code{unifont.hex} input file,
864 you should also set SPACES="" on the command line so that you only
865 read in your final custom @code{unifont-circles.hex} file.
866
867
868 @node Installing Fonts on GNU/Linux, Creating a Brand New Font, Combining Circles, Tutorial
869 @section Installing Fonts on GNU/Linux
870
871
872 The original standard font format of Unifont was a BDF font.  The newer
873 PCF font format loads much faster when a program begins, and so is preferable
874 for installations using the X Window System and similar environments.
875
876 Compress PCF fonts using
877
878 @example
879 gzip -9 fontname.pcf
880 @end example
881
882 Copy the resulting @code{fontname.pcf.gz} file to
883 @code{/usr/share/fonts/X11/misc/} or place in a
884 local font directory if your windowing software supports that (for
885 example, @code{~/.fonts/}).
886
887 Copy TrueType fonts to @code{/usr/share/fonts/truetype/} uncompressed or place
888 in your local font directory.  Note: on some versions of Unix, such as
889 Solaris, the name of the TrueType directory might be TrueType and
890 might be under @code{/usr/share/fonts/X11/} --- examine the system fonts
891 directories, then modify the font @code{make install} rule accordingly.
892
893 On most flavors of GNU/Linux with the latest @code{xset} utility (including
894 the latest Debian and Red Hat releases), the following command should
895 allow you to start using the font immediately:
896
897 @example
898 xset fp rehash
899 @end example
900
901 The safest way to make sure the system knows about the new fonts will
902 be to restart the X Window System or even reboot.
903
904
905 @node Creating a Brand New Font, Updates to Unicode, Installing Fonts on GNU/Linux, Tutorial
906 @section Creating a Brand New Font
907
908
909 The original tools will only produce glyphs that are 16 pixels tall, and
910 either 8 or 16 pixels wide.  The utilities @code{unihex2png},
911 @code{unipng2hex}, @code{hexdraw}, and @code{hex2bdf} now also support
912 glyph heights of 24 and 32 pixels, and glyph widths of 8, 16, 24, and 32
913 pixels, but this is not fully tested.  These new dimensions are currently
914 available for experimental use.  See the respective sections for each
915 of these programs in the Reference chapter of this document, or their
916 respective man pages.
917
918 To create a brand new font (or even to add a new script to Unifont
919 in the future), plan out the basic dimensions of the characters:
920
921 @itemize
922
923 @item
924 How far above the lowest pixel will the baseline appear
925 (in other words, how many rows are necessary for descenders
926 such as in the glyphs for `g', `q', and `y')?
927
928 @item
929 How many pixels must be empty on top and bottom for accents
930 (in other words, what will the height of capital letters be)?
931
932 @item
933 Must glyphs be centered, left-aligned, or right-aligned?
934
935 @item
936 For a Latin font, what will the "x-height" be (the height of
937 a lower-case "x" and related letters, such as "n" and "r")?
938
939 @end itemize
940
941 Consistent capital heights, x-heights, descender depths, and centering
942 will produce a better looking font.  Look over the entire script and
943 plan out a template grid that is consistent for the entire script.
944 Then use that template for each glyph you draw for the script.
945
946 Unifont characters for the most part leave the left-most or right-most
947 column of pixels blank if possible (consistent within each script) for
948 left-to-right scripts.  Centering is done around the fourth pixel (if
949 a glyph is eight pixels wide) or around the eighth pixel (if a glyph is
950 16 pixels wide).
951
952 Experimenting and (above all) having fun with these utilities is
953 the best way to learn.
954
955
956 @node Updates to Unicode, , Creating a Brand New Font, Tutorial
957 @section Updates to Unicode
958
959
960 If a currently unassigned code point is assigned to a character
961 in the future, the font can be updated as follows:
962
963 @enumerate
964
965 @item
966 Delete the code point's entry from @code{font/plane00/unassigned.hex},
967 as that code point will no longer be unassigned.
968
969 @item
970 Determine which existing .hex file should contain the
971 newly defined character (examine the files to see
972 which one contains other glyphs in the script.
973
974 @itemize
975
976 @item
977 @code{unifont-base.hex} contains most scripts
978
979 @item
980 @code{wqy.hex} contains most CJK ideographs; its name pays homage
981 to the Wen Quan Yi font, the source of almost all of its glyphs
982
983 @item
984 @code{hangul-syllables.hex} contains the Hangul Syllables block
985 (U+AC00..U+D7A3); this should never have new code points added as
986 it covers the fixed range of the Unicode Hangul Syllables block
987
988 @item
989 @code{spaces.hex} contains the list of single- and double-width spaces
990
991 @end itemize
992
993 If in doubt (for example, if a new script is added to
994 Unicode and you're not sure which .hex file to augment),
995 add the new glyphs to @code{unifont-base.hex}.
996
997 @item
998 Update the appropriate .hex file.
999
1000 @item
1001 Consider if @code{font/coverage.dat} has to be updated.
1002 Follow its existing format to insert a new script,
1003 being sure to change any previously unassigned ranges
1004 before or after the newly added script.
1005
1006 @item
1007 Make a new .hex version of the font, and verify that
1008 you didn't introduce any duplicates.
1009
1010 @item
1011 Run @code{unipagecount} and/or @code{unicoverage} as described
1012 previously to verify that you have not mistakenly deleted
1013 any existing characters.
1014
1015 @end enumerate
1016
1017 Enjoy!
1018
1019
1020 @node Reference, , Tutorial, Top
1021 @chapter Reference
1022
1023 @menu
1024 * bdfimplode::
1025 * hex2bdf::
1026 * hex2sfd::
1027 * hexbraille::
1028 * hexdraw::
1029 * hexkinya::
1030 * hexmerge::
1031 * johab2ucs2::
1032 * unibdf2hex::
1033 * unibmp2hex::
1034 * unicoverage::
1035 * unidup::
1036 * unifont-viewer::
1037 * unifontchojung::
1038 * unifontksx::
1039 * unifontpic::
1040 * unigencircles::
1041 * unigenwidth::
1042 * unihex2bmp::
1043 * unihex2png::
1044 * unihexfill::
1045 * unihexgen::
1046 * unipagecount::
1047 * unipng2hex::
1048 @end menu
1049
1050 @include bdfimplode.texi
1051 @include hex2bdf.texi
1052 @include hex2sfd.texi
1053 @include hexbraille.texi
1054 @include hexdraw.texi
1055 @include hexkinya.texi
1056 @include hexmerge.texi
1057 @include johab2ucs2.texi
1058 @include unibdf2hex.texi
1059 @include unibmp2hex.texi
1060 @include unicoverage.texi
1061 @include unidup.texi
1062 @include unifont-viewer.texi
1063 @include unifontchojung.texi
1064 @include unifontksx.texi
1065 @include unifontpic.texi
1066 @include unigencircles.texi
1067 @include unigenwidth.texi
1068 @include unihex2bmp.texi
1069 @include unihex2png.texi
1070 @include unihexfill.texi
1071 @include unihexgen.texi
1072 @include unipagecount.texi
1073 @include unipng2hex.texi
1074
1075 @bye