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