| 1 |
Working with Bitmap Fonts |
| 2 |
========================= |
| 3 |
|
| 4 |
|
| 5 |
Opening & Importing Bitmap strikes |
| 6 |
---------------------------------- |
| 7 |
|
| 8 |
FontForge is primarily an outline font editor, but it does have some facility |
| 9 |
for editing bitmap (and greymap, or anti-aliased) fonts. A useful term here is a |
| 10 |
"strike"; a strike is one particular size of a bitmap font. When FontForge |
| 11 |
displays a font, that font will contain at most one outline but potentially many |
| 12 |
bitmap (or greymap) strikes (for several different pixel sizes). |
| 13 |
|
| 14 |
You might wonder if it is really necessary to provide bitmaps along with |
| 15 |
outlines given the high quality results of modern rasterizers, and for Latin |
| 16 |
(Greek, Cyrillic) fonts it may not be, but for CJK fonts at small pixel sizes a |
| 17 |
human eye can still make a better choice than even the best rasterizer. Back in |
| 18 |
the 1980s when Apple first adopted PostScript fonts they felt it was essential |
| 19 |
to have bitmaps to go with the outline -- so much so that it was not even |
| 20 |
possible to use a PostScript font without also providing at least one bitmap |
| 21 |
with it. Even today, when using a Type1 font on a mac there must be a bitmap |
| 22 |
font to point to it. |
| 23 |
|
| 24 |
Of course Type1 fonts are a bit old-fashioned now, but the sfnt file format (the |
| 25 |
format used for both OpenType and TrueType fonts) supports embedded bitmap |
| 26 |
strikes along with the outline version of the font. These strikes will be used |
| 27 |
in preference to rasterizing the outline in any pixel sizes for which they are |
| 28 |
present. |
| 29 |
|
| 30 |
If you have an sfnt with both an outline font and bitmap strikes you can open it |
| 31 |
directly with the :ref:`File->Open <filemenu.Open>` command and FontForge will |
| 32 |
load all the bits and pieces. |
| 33 |
|
| 34 |
You can also open a bitmap only font directly with the |
| 35 |
:ref:`File->Open <filemenu.Open>` command, however if you have multiple strikes |
| 36 |
of the same underlying font in separate files, you will probably want to open |
| 37 |
only the first (or only the outline version) with Open, and use |
| 38 |
:ref:`File->Import <filemenu.Import>` to merge the other strikes into one |
| 39 |
FontForge font. |
| 40 |
|
| 41 |
Suppose you have ``Ambrosia.pfb`` (an outline font), ``Ambrosia-12.bdf``, and |
| 42 |
``Ambrosia-24.bdf`` (two bitmap strikes, one 12 pixels high, one 24), and you |
| 43 |
want them all in one font. First use :ref:`File->Open <filemenu.Open>` to open |
| 44 |
Ambrosia.pfb, then :ref:`File->Import <filemenu.Import>` and select both of the |
| 45 |
bitmap strikes (hold down the shift key). |
| 46 |
|
| 47 |
On the other hand, if you have only two bitmaps: ``Ambrosia-12.bdf``, and |
| 48 |
``Ambrosia-24.bdf``, then use :ref:`File->Open <filemenu.Open>` to open either |
| 49 |
strike, and use :ref:`File->Import <filemenu.Import>` and import the other. |
| 50 |
|
| 51 |
You may have noticed that Import has a checkbox labeled ``[] As Background``. If |
| 52 |
you check this, then your bitmap font will not be loaded as a font itself, but |
| 53 |
will be loaded into the background of the outline font whence you can |
| 54 |
:ref:`Element->Autotrace <elementmenu.AutoTrace>` it to provide an outline font |
| 55 |
from a bitmap. Be warned: This produces fairly bad results unless you have a |
| 56 |
large (100+ pixel) font to trace. |
| 57 |
|
| 58 |
|
| 59 |
Creating Bitmap strikes |
| 60 |
----------------------- |
| 61 |
|
| 62 |
.. image:: /images/bitmapsavail.png |
| 63 |
:align: right |
| 64 |
|
| 65 |
If you want to add a bitmap strike with a given pixel size to a font then use |
| 66 |
:ref:`Element->Bitmap Strikes Available <elementmenu.Bitmaps>`. Simply add the |
| 67 |
pixel size you are interested in to the list at the "Pixel sizes" field. |
| 68 |
|
| 69 |
For convenience, the available pixel sizes are also shown in point sizes, which |
| 70 |
depend on screen resolution. This dialog shows you the conversion between point |
| 71 |
and pixel sizes for the actual resolution of your monitor, as reported by the |
| 72 |
operating system, and for the typical 96 PPI resolution. |
| 73 |
|
| 74 |
You may add more than one pixel size, of course. You may also remove pixel sizes |
| 75 |
if you no longer want them. |
| 76 |
|
| 77 |
Normally when you create a new strike it will be rasterized from the outline |
| 78 |
font -- if there is no outline font then FontForge will attempt to scale the |
| 79 |
biggest strike available to the new size (in most cases this will be fairly |
| 80 |
ugly, but it may be better than nothing. |
| 81 |
|
| 82 |
There is also a checkbox ``[*] Create Rasterized Strikes (Not empty ones)`` at |
| 83 |
the bottom of the dialog. If you turn this off, then the rasterization process |
| 84 |
described above will not happen, and any new strikes will be created containing |
| 85 |
no glyphs (you can add glyphs later, of course). |
| 86 |
|
| 87 |
|
| 88 |
Bitmap Properties |
| 89 |
----------------- |
| 90 |
|
| 91 |
In the old days of bdf and pcf fonts on X11 each font had a set of properties |
| 92 |
attached to it. It is not clear to me whether these properties are still useful |
| 93 |
as X11 moves to OpenType Bitmaps. They may be. At any rate FontForge will store |
| 94 |
them both in BDF fonts and in OpenType Bitmap fonts. Each strike may have its |
| 95 |
own set of properties. FontForge will generate them automatically when you |
| 96 |
create a strike (and will retain them when it reads in a font that has them). |
| 97 |
You may override the current values with the |
| 98 |
:ref:`Element-Bdf Info <elementmenu.BDF-Info>` dialog. |
| 99 |
|
| 100 |
|
| 101 |
Creating a new bitmap only font |
| 102 |
------------------------------- |
| 103 |
|
| 104 |
If you want to create a new font with no outlines, only bitmap strikes, you |
| 105 |
would use :ref:`File->New <filemenu.New>` to create a new font, and then |
| 106 |
:ref:`Element->Bitmap Strikes Available <elementmenu.Bitmaps>` to add some |
| 107 |
(empty) strikes to it. As soon as you add a strike to a new font, the font will |
| 108 |
become a bitmap only font. |
| 109 |
|
| 110 |
Apple has a bitmap only version of the sfnt file format, and X11 does too. Of |
| 111 |
course the two formats are slightly different. Windows has no support for a |
| 112 |
bitmap only sfnt format. |
| 113 |
|
| 114 |
|
| 115 |
Bitmaps in the Font View |
| 116 |
------------------------ |
| 117 |
|
| 118 |
The :ref:`View <viewmenu.bitmaps>` menu of the Font View (and the Metrics View) |
| 119 |
contains a list of all bitmap strikes in the font. You may select which one will |
| 120 |
be displayed in the Font View. You may also change the magnification at which a |
| 121 |
strike is displayed with |
| 122 |
:ref:`View->Bitmap Magnification... <viewmenu.BitmapMag>` (it can be hard to see |
| 123 |
the details of an 8 pixel font on a high resolution screen, so you might want to |
| 124 |
display it at 3 times its actual size). |
| 125 |
|
| 126 |
Many commands in the Font View will apply to all strikes (and the outline) in |
| 127 |
the font. For instance :ref:`Edit->Copy <editmenu.Copy>` will copy the outline |
| 128 |
glyph and all bitmap glyphs. Sometimes you only want to affect one strike, if so |
| 129 |
then deselect :ref:`Edit->Copy From->All Fonts <editmenu.Fonts>`. |
| 130 |
|
| 131 |
The :ref:`Element->Build <elementmenu.Accented>` commands will build accented |
| 132 |
bitmap glyphs just as it builds accented outline glyphs. |
| 133 |
|
| 134 |
If the Font View is displaying a bitmap strike and you double click on a |
| 135 |
character, then FontForge will bring up a |
| 136 |
:doc:`bitmap editing window </ui/mainviews/bitmapview>` displaying that character in the |
| 137 |
current strike (rather than opening an outline editing window). If the character |
| 138 |
does not have a matching glyph in the current strike FontForge will create one |
| 139 |
by rasterizing the outline version of the font. |
| 140 |
|
| 141 |
|
| 142 |
Editing Bitmaps |
| 143 |
--------------- |
| 144 |
|
| 145 |
.. image:: /images/BitmapView.png |
| 146 |
:align: left |
| 147 |
|
| 148 |
The bitmap editing window should be fairly self explanatory. The window is a |
| 149 |
simple bitmap editor. With the pencil tool, clicking on a pixel will make it |
| 150 |
change. The line tool will draw a straight line between the start and end |
| 151 |
points. |
| 152 |
|
| 153 |
You can see the outline glyph in the background of the bitmap. |
| 154 |
|
| 155 |
You can regenerate the bitmap (by rasterizing the outline) by pressing the |
| 156 |
``[Recalculate Bitmaps]`` button. |
| 157 |
|
| 158 |
Editing an anti-aliased greymap has the added complexity that you need to select |
| 159 |
a color (actually a level of greyness) to be applied with the pencil. There will |
| 160 |
be an additional palette with all possible greys for this. |
| 161 |
|
| 162 |
|
| 163 |
Sparse Bitmap Strikes |
| 164 |
--------------------- |
| 165 |
|
| 166 |
Sometimes you don't need a complete set of bitmap glyphs in a strike. Perhaps |
| 167 |
the rasterizer does a good job for all glyphs except one. Then you can create an |
| 168 |
empty strike (with |
| 169 |
:ref:`Element->Bitmap Strikes Available <elementmenu.Bitmaps>` unchecking the |
| 170 |
``[*] Create Rasterized Strikes`` checkbox) and then select the one glyph you |
| 171 |
care about and say |
| 172 |
:ref:`Element->Regenerate Bitmap Glyphs <elementmenu.Regenerate>`. |
| 173 |
|
| 174 |
Alternately you could create a fully rasterized strike and then select the |
| 175 |
glyphs you don't need and say |
| 176 |
:ref:`Element->Remove Bitmap Glyphs <elementmenu.RemoveBitmaps>`. |