How can I combine two fonts automatically, so glyphs those are not available in the first font, but available in second one can be merged into the first font?
This is an easy task with fontforge.
Addendum from comments: Before merging, click Element > Font info... in both fonts first to see whether the values like em size match. Otherwise, update either to match the values of the other font. This prevents issues like different character sizes. This info should probably be added to the answer. – Cristan
First, you want to open the font with the missing glyphs and select
Element -> Merge Fonts. In this example, the glyphs for
F are the ones missing.
Select the font from which you want to pull glyphs. You will be asked whether you want to keep the existing kerning; you most likely want to select
No here, but if you get strange results close fontforge and try again with
The missing glyphs should be added in a few moments:
File -> Generate Fonts and export your font to a desired location.
- Install FontForge
- It usually gets installed at
C:\Program Files (x86)\FontForgeBuilds\bin, so add that to your path environmental variable(Only for Windows Users).
- Paste the below code in a file named
#!/usr/local/bin/fontforge Open($1) SelectAll() ScaleToEm(Strtol($3)) Generate("1.ttf") Close() Open($2) SelectAll() ScaleToEm(Strtol($3)) Generate("2.ttf") Close() Open("1.ttf") MergeFonts("2.ttf") Generate($4) Close()
- mergefonts.ff Script Usage:
fontforge -lang=ff -script mergefonts.ff <font1> <font2> <font_size_in_em> <output_merged_font>
fontforge -lang=ff -script mergefonts.ff font1.ttf font2.ttf 1000 mergedfont.ttf