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