User Tools

Site Tools


arduino:custom_fonts_for_ucglib

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
arduino:custom_fonts_for_ucglib [2018/11/15 17:35] – [Convert OTF or TTF to BDF] mithatarduino:custom_fonts_for_ucglib [2021/02/04 02:08] (current) – [Add new code to Ucglib] mithat
Line 2: Line 2:
  
 This is how I built custom fonts for [[https://github.com/olikraus/ucglib | Ucglib]]/[[https://github.com/olikraus/Ucglib_Arduino | Ucglib_Arduino]] on Linux. This is how I built custom fonts for [[https://github.com/olikraus/ucglib | Ucglib]]/[[https://github.com/olikraus/Ucglib_Arduino | Ucglib_Arduino]] on Linux.
 +
 +Ucglib uses [[https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format | BDF]] fonts as a source. The basic process to convert a typical font file for use in Ucglib is:
 +  * Convert an OTF or TTF font to BDF format using ''[[ http://sofia.nmsu.edu/~mleisher/Software/otf2bdf/ | otf2bdf ]]'', ''[[http://sofia.nmsu.edu/~mleisher/Software/gbdfed/ | gbdfed]]'', or ''[[https://fontforge.github.io/en-US/ | fontforge]]''. //Check font licenses!//
 +  * Use ''bdconf'' to convert the BDF format to C.
 +  * Add the new code to the appropriate Ucglib file.
 +
 +Details are provided below.
  
 ===== Requirements ===== ===== Requirements =====
-Ucglib uses [[https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format | BDF]] fonts as a source. You will need: + 
-  * OTF and/or TTF files of the fonts you want to convert. //Check licenses!// +==== Getting otf2bdf and fontforge ==== 
-  * A way to convert these to BDF format: ''[[ http://sofia.nmsu.edu/~mleisher/Software/otf2bdf/ | otf2bdf ]]'', ''[[http://sofia.nmsu.edu/~mleisher/Software/gbdfed/ | gbdfed]]'', or possibly ''[[https://fontforge.github.io/en-US/ | fontforge]]'' + 
-  * A way to convert BDF files to the C structures used in Ucglib: ''bdfconv'', which you will build below.+''%%otf2bdf%%'', ''%%gbdfed%%'' and ''%%fontforge%%'' are available in many Linux distributions.
  
 ==== Building bdfconv ==== ==== Building bdfconv ====
  
-Download the [[https://github.com/olikraus/ucglib|Ucglib repository]], head into ''%%tools/font/bdfconv%%'' and+You will probably have to build ''%%bdfconv%%'' yourself. Download the [[https://github.com/olikraus/ucglib|Ucglib repository]], move into ''%%tools/font/bdfconv%%'' and
  
 <code shell> <code shell>
Line 21: Line 28:
 ===== The process ===== ===== The process =====
  
-==== Convert OTF/TTF to BDF ====+==== Convert OTF or TTF to BDF ====
  
 Using ''otf2bdf'': Using ''otf2bdf'':
Line 29: Line 36:
 </code> </code>
  
-''%%gbdfed%%'' also can import and convert fonts, but the monospace/proportional setting seems to be wonky. ''%%fontforge%%'' appears to be another option.+''%%gbdfed%%'' also can import and convert fonts, but the monospace/proportional setting seems to be wonky. ''%%fontforge%%'' may be another option.
  
-View the result using ''%%gbdfed%%''.+View the result using ''%%gbdfed%%'' or ''%%fontforge%%''
 + 
 +Once the font is in BDF format, you can use ''%%fontforge%%'' to edit it, which might include removing unused characters or tweaking bitmaps.
  
 ==== Convert the BDF file to C using bdfconv ==== ==== Convert the BDF file to C using bdfconv ====
Line 44: Line 53:
 ==== Add new code to Ucglib ==== ==== Add new code to Ucglib ====
  
-Paste the content of the new file to ''%%src/clib/ucg_pixel_font_data.c%%'' +  - Paste the content of the new file to ''%%src/clib/ucg_pixel_font_data.c%%'' --- making sure to remove the redundant<code c>#include "ucg.h"</code> 
- +  Add an ''%%extern%%'' entry for the above variable to ''%%src/clib/ucg.h%%''
-Add an ''%%extern%%'' entry for the above to ''%%src/clib/ucg.h%%''+
  
  
  
arduino/custom_fonts_for_ucglib.1542303317.txt.gz · Last modified: 2018/11/15 17:35 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki