FontForge

Posted on Friday, February 6, 2015



 Recently I was tweaking my command line prompt and adding Unicode characters to snaz it up.    I ran into a problem, with Cygwin, with the Unicode character I was trying to use.  The Unicode character \u276f which looks like







The Unicode Character was available in OSX Courier Font but not in any of the fonts available to Cygwin on my Windows7 box.   (I often switch between Windows, OS X, and Ubuntu)


So what can I do?   I really want this Unicode character to show up correctly in my Cygwin prompt.




This was a long winded adventure, so read the entire thing before you start doing anything (I made and recorded a lot of mistakes on the way).

Or better yet watch this short video I made.




The Answer 

Create a new Font or update an old one using FontForge!






Click on Windows Install








Click on the Download link.









Right click on the FontForge and select Run as Administrator.s










Click OK








Click Next










Accept the license and click Next










Click Next.








Set the destination folder and click Next.









Click Next








Click Next








Click Install









Watch it install










Click Finish







Now what?







When it starts up I see this screen.

My guess is that I need to find and select the font I want to change.
My Cygwin is currently using the Lucida Console Font.  I am going to try and tweak that font first.


After a bit of tweaking I have a procedure that seems to work…

In windows open the folder

C:\Windows\Fonts







You should see all your active fonts.

Copy the one you want to change to the Desktop.   This is your backup, in case you screw up.









In my case I am tweaking Lucida Sans Typewriter Regular.   Some of these fonts are actually a family of fonts together.  If you double click on this…








You see the four fonts that it contains.  I am only concerned with the Regular one for now.  I made a backup of it on the Desktop just in case.


Back to Font Forge.


Put C:/Windows/Fonts  in the location and click OK.










The Fonts Folder should open.










The Font I care about is actually called LTYPE.TTF if you hover over it the actual name of the font should be displayed.


Select it and click OK.











This opens the font.

Scroll down until you find \uni267F








You can see above the selection it shows what that Unicode character should look like.  The X indicates there is no Font there.  

Double click on the X to open the editor.











Here is the editor.











Move this line to 2050 (otherwise it's too narrow)











This is going to be a very simple character.  It will only have six points with straight lines between them.






Select the corner point tool.










Roughly create the font with six points, making sure to connect the last (6th point back to the starting point you made)












Now that you have a rough design, right click on the first point, and select Get Info…








Change the Base to 528, 1500







At the bottom click Next on Contour, to bring up the next point.








Set that one to 1053, 1500

Keep going around all the points…

Here are the settings in order, if you follow the contour.


1778, 770
1053, 25
528, 25
1222, 770







When you are done you should have something like this.

Close the editor tool









Now you should see your font character you made in its proper place.


You need to generate a font.








From the File Menu Select Generate Fonts.









I selected my Desktop, Named it LucidaSans-Typewriter-UTF.ttf  and clicked Generate.







I get this error, but I click Generate. 








And there is my new font.







I dragged and dropped the font to my C:\Windows\Fonts  folder.









Since the Font already Exist I get this warning.  I clicked "Yes" to overwrite it anyway.


That did not work, in fact now I lost my Lucida Sans Typewriter font (in Cygwin).

Poking around I found this post http://superuser.com/questions/195646/monaco-font-not-appearing-in-putty-font-list [2].  The posts talks about Cygwin only using Fixed-Width Fonts.

Maybe because I changed the width of my font I messed this up?









Second Try Fixed Width Font!



Repeat the procedure above up to this point!






Leave this one alone at 1234









Select the corner point tool.








Roughly create the font with six points, making sure to connect the last (6th point back to the starting point you made)











Now that you have a rough design, right click on the first point, and select Get Info…











Change the Base to 125, 1325







At the bottom click Next on Contour, to bring up the next point.






Set that one to 650, 1325

Keep going around all the points…

Here are the settings in order, if you follow the contour.

1000, 675
650, 25
125, 25
475, 675






When you are done you should have something like this. (Skinnier than my last attempt)

Close the editor tool










Now you should see your font character you made in its proper place.


You need to generate a font.







From the File Menu Select Generate Fonts.









I selected my Desktop, Named it LucidaSans-Typewriter-UTF.ttf  and clicked Generate.











I get this error, but I click Generate. 


 Now drag this new Font into C:\Windows\Fonts (overwriting the old font)


Grrr!   That did not work either!






OK I figured it out!!


The fixed width was part of the problem but more needs to be done.

Here is what I figured out…

Cygwin needs "Mono Spaced Fixed-Width fonts.
 A fixed-width font made by FontForge needs two things. Set
  1.  OS/2.panose.proportion = monospace(9)
  2. post.isFixed = 1



The Font I am altering seems to have the OS/2 already set correctly when I open it.



To check that go to







Element and select Font Info








Select OS/2  then the Panose Tab and there make sure that Proportion is set to MonoSpaced.

Click OK to close.


The "post.isFixed = 1" is set only if every character has the same width.

I thought that was already the case with this font, But I guess it was not.

To fix that do the following.









Press Ctrl+a to select all the fonts.









Then select Metrics and click Set Width







Leave the width at 1234 and click OK.








This will change the width of every character all 65K+ of them… This process takes some time.

When it's done, if you try to generate a font, you will get this…







First a very long validation…



Then this error…






Basically you have too many glyphs.

To fix this I scrolled to the bottom





Select a bunch of glyphs, that are empty anyway, right click and press "Clear".








Now it should work.

Generate the font and place it in the fonts folder at C:\Windows\Fonts



Now If I close and reopen Cygwin….






Wahoo it worked!



Little Side journey


One Free monospaced font can be found at http://savannah.gnu.org/projects/freefont/ [5]


But If I can't use it in Cygwin…. I suspect I can fix it in FontForge…

I tried to repeat the process I followed above but it did not seem to work.





I did get this error.  Maybe I have too many Characters in this font?

Well maybe someone out there can get it working, I couldn't




References

[1]        FontForge Web Site
                        http://fontforge.github.io/en-US/
                Accessed 1/2015
[2]        Monaco font not appearing in PuTTY font list
                Accessed 2/2015
[3]        [Fontforge-users] Monospaced fonts
                Accessed 1/2015
[4]        How can I make a font monospaced?
                        http://fontforge.github.io/en-US/
                Accessed 1/2015
[5]        Free UCS Outline Fonts - Summary          http://savannah.gnu.org/projects/freefont/
                Accessed 1/2015


1 comment: