arduinoprojects

git clone https://git.tarina.org/arduinoprojects
Log | Files | Refs

fontconvert_win.md (3831B)


      1 ### A short guide to use fontconvert.c to create your own fonts using MinGW.
      2 
      3 #### STEP 1: INSTALL MinGW
      4 
      5 Install MinGW (Minimalist GNU for Windows) from [MinGW.org](http://www.mingw.org/).
      6 Please read carefully the instructions found on [Getting started page](http://www.mingw.org/wiki/Getting_Started).
      7 I suggest installing with the "Graphical User Interface Installer".
      8 To complete your initial installation you should further install some "packages".
      9 For our purpose you should only install the "Basic Setup" packages.
     10 To do that:
     11 
     12 1. Open the MinGW Installation Manager
     13 2. From the left panel click "Basic Setup".
     14 3. On the right panel choose "mingw32-base", "mingw-gcc-g++", "mingw-gcc-objc" and "msys-base"
     15 and click "Mark for installation"
     16 4. From the Menu click "Installation" and then "Apply changes". In the pop-up window select "Apply".
     17 
     18 
     19 #### STEP 2: INSTALL Freetype Library
     20 
     21 To read about the freetype project visit [freetype.org](https://www.freetype.org/).
     22 To Download the latest version of freetype go to [download page](http://download.savannah.gnu.org/releases/freetype/)
     23 and choose "freetype-2.7.tar.gz" file (or a newer version if available).
     24 To avoid long cd commands later in the command prompt, I suggest you unzip the file in the C:\ directory.
     25 (I also renamed the folder to "ft27")
     26 Before you build the library it's good to read these articles:
     27 * [Using MSYS with MinGW](http://www.mingw.org/wiki/MSYS)
     28 * [Installation and Use of Supplementary Libraries with MinGW](http://www.mingw.org/wiki/LibraryPathHOWTO)
     29 * [Include Path](http://www.mingw.org/wiki/IncludePathHOWTO)
     30 
     31 Inside the unzipped folder there is another folder named "docs". Open it and read the INSTALL.UNIX (using notepad).
     32 Pay attention to paragraph 3 (Build and Install the Library). So, let's begin the installation.
     33 To give the appropriate commands we will use the MSYS command prompt (not cmd.exe of windows) which is UNIX like.
     34 Follow the path C:\MinGW\msys\1.0 and double click "msys.bat". The command prompt environment appears.
     35 Enter "ft27" directory using the cd commands:
     36 ```
     37 cd /c
     38 cd ft27
     39 ```
     40 
     41 and then type one by one the commands:
     42 ```
     43 ./configure --prefix=/mingw
     44 make
     45 make install
     46 ```
     47 Once you're finished, go inside "C:\MinGW\include" and there should be a new folder named "freetype2".
     48 That, hopefully, means that you have installed the library correctly !!
     49 
     50 #### STEP 3: Build fontconvert.c
     51 
     52 Before proceeding I suggest you make a copy of Adafruit_GFX_library folder in C:\ directory.
     53 Then, inside "fontconvert" folder open the "makefile" with an editor ( I used notepad++).
     54 Change the commands so in the end the program looks like :
     55 ```
     56 all: fontconvert
     57 
     58 CC     = gcc
     59 CFLAGS = -Wall -I c:/mingw/include/freetype2
     60 LIBS   = -lfreetype
     61 
     62 fontconvert: fontconvert.c
     63 	$(CC) $(CFLAGS) $< $(LIBS) -o $@
     64 
     65 clean:
     66 	rm -f fontconvert
     67 ```
     68 Go back in the command prompt and with a cd command enter the fontconvert directory.
     69 ```
     70 cd /c/adafruit_gfx_library\fontconvert
     71 ```
     72 Give the command:
     73 ```
     74 make
     75 ```
     76 This command will, eventually, create a "fontconvert.exe" file inside fontconvert directory.
     77 
     78 #### STEP 4: Create your own font header files
     79 
     80 Now that you have an executable file, you can use it to create your own fonts to work with Adafruit GFX lib.
     81 So, if we suppose that you already have a .ttf file with your favorite fonts, jump to the command prompt and type:
     82 ```
     83 ./fontconvert yourfonts.ttf 9 > yourfonts9pt7b.h
     84 ```
     85 You can read more details at: [learn.adafruit](https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts).
     86 
     87 Taraaaaaammm !! you've just created your new font header file. Put it inside the "Fonts" folder, grab a cup of coffee
     88 and start playing with your Arduino (or whatever else ....)+ display module project.