README.md 4.25 KB
Newer Older
1
2
3
4
FONS
====
A tool to make fonts out of bitmap images.

5
6
7
8
9
10
11
12
13
Tools needed
------------
- Gimp
- Gimp G'MIC plugin
- Autotrace
- Fontforge with Autotrace



14
Process
svilayphiou's avatar
svilayphiou committed
15
-------
16

17
18
### Preparing the image

19

svilayphiou's avatar
svilayphiou committed
20
#### Get a bitmap image of characters (crop unnecessary white parts for a faster process, you can use Gimp's automatic crop for that).
21

22
![](http://osp.kitchen/api/osp.tools.fons/raw/input/scan_bitmap.jpg)
23
24
:    A scan in bitmap

25
![](http://osp.kitchen/api/osp.tools.fons/raw/input/scan_gray_1200dpi.jpg)
26
27
:    A scan in gray levels

svilayphiou's avatar
svilayphiou committed
28
29
30
![](http://osp.kitchen/api/osp.tools.fons/raw/input/characters-table.svg)
:    A rasterized font: to typeset it, you can use the template characters-table.svg in the `/input/` folder

31
32
33
34
35





svilayphiou's avatar
svilayphiou committed
36
#### Levels (have a white background, black characters but still shades of gray)
37

38
![](http://osp.kitchen/api/osp.tools.fons/raw/documentation/01-bitmap_levels.png)
39
40
41



svilayphiou's avatar
svilayphiou committed
42
#### Small boost 
43
44
45

Scale up the image to something like 254% with the "Sinc (Lanczos 3)" algorithm. We choose on purpose a non-round number of scaling to break the bitmap patterns.

46
![](http://osp.kitchen/api/osp.tools.fons/raw/documentation/02-scale-254percent.png)
47
48
49



svilayphiou's avatar
svilayphiou committed
50
#### Sharpen with "Unsharp mask"
51
52
53

Put the amount to the maximum and then search for the point where you don't see 

54
![bad](http://osp.kitchen/api/osp.tools.fons/raw/documentation/03-sharpen-too_few.png)
55
56
:    Radius too small

57
![ok](http://osp.kitchen/api/osp.tools.fons/raw/documentation/03-sharpen-ok.png)
58

59
![bad](http://osp.kitchen/api/osp.tools.fons/raw/documentation/03-sharpen-too_much.png)
60
61
62



svilayphiou's avatar
svilayphiou committed
63
#### Big boost
64

65
66
Scale up to 403% (check on notebook or with PierreH if it's enough)

67
![](http://osp.kitchen/api/osp.tools.fons/raw/documentation/04-big_boost.png)
68
69
70



svilayphiou's avatar
svilayphiou committed
71
72
73
#### Threshold


74
![bad](http://osp.kitchen/api/osp.tools.fons/raw/documentation/05-threshold-bad.png)
75
76


77
![ok](http://osp.kitchen/api/osp.tools.fons/raw/documentation/05-threshold-ok.png)
svilayphiou's avatar
svilayphiou committed
78
79


80
81
82
83
84
85
86
87
88
89
90
#### Baseline

When importing a bitmap, Fontforge scales up/down the bitmap so that it fits into the glyph box. If we use GlyphTracer 1.4, this ends up with different scales of glyphs. In order to prevent this, we can put a black rectangle of the height of the maximum ascendant and maximum descendant.

![baseline](http://osp.kitchen/api/osp.tools.fons/raw/documentation/06-baseline.png)


#### Bitmap

- Change the color mode to Indexed mode with 1 black/white bit.
- Save as a .bmp file.
svilayphiou's avatar
svilayphiou committed
91

92

93
### GlyphTracer
94

svilayphiou's avatar
svilayphiou committed
95
96
97
98
- To launch GlyphTracer, there are two possibilities:
    - from your file manager, double-click on the file `glyphtracer` inside the `glyphtracer-1.4` folder
    - from the terminal, go to the `glyphtracer-1.4` folder and run `./glyphtracer`. This will let you know more output in case of errors.
- Feed in the .bmp image in 1 bit (otherwise it will complain).
99
100
- For each given glyph, click on the letter you want to use.
- Change the characters subset in the bottom left dropdown menu to select more glyphs.
101
102
103



svilayphiou's avatar
svilayphiou committed
104
### Post-production
105

svilayphiou's avatar
svilayphiou committed
106
#### Merging fonts
107
108
109
110
111
112

In case you want to complete an existing font, you can use the script `mergeFonts.py`.

    python mergeFonts.py fonte1.ufo fonte2.ufo ...  fonte17.ufo fonte-out.ufo


svilayphiou's avatar
svilayphiou committed
113
#### Metrics and kernings
114
115
116
117
118

A big part of type design is about managing the white space around the letters (metrics) and exceptions for specific couples of letters (kernings).

- For the metrics, we make an auto-spacing while generating the .sfd file with GlyphTracer.
- For the kernings, you can try the tool (Kernagic)[https://github.com/hodefoting/kernagic].
119

120
But if you want to get back metric and kerning data from an existing font, you can use the script `mergeSpacing.py`. It can be any font format than `.otf`.
svilayphiou's avatar
svilayphiou committed
121

122
   python mergeSpacing.py font.otf original-font.otf spaced-font.otf
svilayphiou's avatar
svilayphiou committed
123
124
125
126



Troubleshooting
127
---------------
svilayphiou's avatar
svilayphiou committed
128

129
130
131
### My image is too big to manipulate it.
Split it into several images and generate several .sfd files. Then you can merge the fonts with the script `mergeFonts.py`.

svilayphiou's avatar
svilayphiou committed
132

svilayphiou's avatar
svilayphiou committed
133
### From the terminal, I have the following error:
svilayphiou's avatar
svilayphiou committed
134

svilayphiou's avatar
svilayphiou committed
135
136
    File "./glyphtracer", line 415
        except Exception, e:
svilayphiou's avatar
svilayphiou committed
137
                          ^
svilayphiou's avatar
svilayphiou committed
138
    SyntaxError: invalid syntax
svilayphiou's avatar
svilayphiou committed
139

svilayphiou's avatar
svilayphiou committed
140
This means your fontforge runs with python3, whereas the majority of installs run still with python2. I didn't find a convenient way yet to maintain both versions at the same time. Let me know and I send you the version for python3 which I use.