User Tools

Site Tools


Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
guisys:making_new_fonts [2009-07-04 13:39]
127.0.0.1 external edit
guisys:making_new_fonts [2013-01-07 12:07] (current)
Line 1: Line 1:
-====== ​Making New Fonts ======+====== ​The Font Wizard: Creating new fonts ======
  
-Making ​new fonts for use with a GUI is very easy. The latest Cafu SDK includes the ''​MakeFont''​ command-line program for this purpose. The ''​MakeFont'' ​is included both in version for Microsoft Windows as well as for i386 Linuxbut in the examples below I'll just assume ​that you work under Windows. Using Linux, ​the process is analogous.+Preparing ​new fonts for rendering text within ​a GUI is very easy. 
 +The key idea is to convert ​font file (e.g. one of those installed with your OSor downloaded from the Internet) to a set of graphics files that the Cafu GuiSys can use:
  
-As a first step, you should create or obtain a font file of your desired font. +{{ :fontwizard:​fontwizard_0.png?|Open the Font Wizard}} Start CaWE and select the related menu item to open the Font Wizard<​clear>​
-For example, http://​www.fontasy.de/ has a library of thousands of free fonts, I'm sure that there are many other places where fonts can be found if you don't want to create your own from scratch.+
  
-Then, please open the Windows command console, and ''​cd''​ into the proper directory of your copy of the Cafu SDK: +{{ :fontwizard:fontwizard_1.png?|Step 1}} Step 1: The welcome page. <​clear>​
-<​code>​ +
-C:\>cd Cafu-9.06+
  
-C:\Cafu-9.06> +{{ :fontwizard:​fontwizard_2.png?​|Step 2}} Step 2: Click the "''​...''"​ browse button to select the desired font, or enter the filename directly into the related field.
-</​code>​+
  
-Lets assume ​that we wanted ​to add the "Times" ​font for use with a GUI of our own. Just ''​cd''​ into the ''​Fonts'' ​directory, create a new directory ''​Times''​ there, and ''​cd''​ into that, too: +**Microsoft Windows** users, please note that for some versions of Windows, most notably **Windows 7**, Microsoft has chosen ​to special-case ​the related ​"File Open" ​dialog so that the system folder ​''​C:\Windows\Fonts'' ​cannot be browsed(The problem is neither related to access rights nor is it specific to CaWE.)
-<​code>​ +
-C:\Cafu-9.06>cd Fonts+
  
-C:\Cafu-9.06\Fonts>mkdir Times+In order to overcome the problem, i.e. if you want to use a system font from ''​C:\Windows\Fonts''​ with the Font Wizard, we recommend to either 
 +  * type the path and file name of the desired font manually into the input field, or 
 +  * at the command prompt copy the desired font files from ''​C:​\Windows\Fonts''​ into any other directory, then use the "''​...''"​ browse button to select the related file. <clear>
  
-C:\Cafu-9.06\Fonts>​dir +{{ :fontwizard:​fontwizard_3.png?|Step 3}} Step 3Check the preview of the generated font texture. Optionally click the button to see a preview of all generated texture images.<​clear>​
- ​Datenträger in Laufwerk Cist Carsten +
- ​Datenträgernummer:​ BC03-5EAF+
  
- ​Verzeichnis von C:\Cafu-9.06\Fonts+{{ :fontwizard:​fontwizard_4.png?​|Step 4}} Step 4: Enter the name under which you would like to save the font. A new directory is created with the given name and all files related to the font are saved into this directory.<​clear>​
  
-02.09.2006 ​ 13:09       <​DIR> ​         . +{{ :fontwizard:fontwizard_5.png?|Step 5}} Step 5Use the indicated name in the GUI Editor or a GUI script to activate the new font (see below for details).<​clear>​
-02.09.2006 ​ 13:09       <​DIR> ​         .. +
-02.09.2006 ​ 12:56       <​DIR> ​         Arial +
-02.09.2006 ​ 12:56       <​DIR> ​         Impact +
-02.09.2006 ​ 13:09       <​DIR> ​         Times +
-08.03.2005 ​ 14:36                9.924 Arial.png +
-15.03.2005 ​ 17:07               ​28.359 FixedWidth.png +
-               2 Datei(en        38.283 Bytes +
-               5 Verzeichnis(se), ​  ​3.013.181.440 Bytes frei+
  
-C:​\Cafu-9.06\Fonts>​cd Times 
  
-C:​\Cafu-9.06\Fonts\Times>​ +===== Creating fonts at the command prompt ===== 
-</​code>​+ 
 +As an alternative to the above, fonts can also be created with the ''​MakeFont''​ program at the command prompt. Here is the sequence of commands that creates the same font as above:
  
-Next let's run the ''​MakeFont''​ program: +<​code ​dos
-<​code>​ +d:\Dev\Cafu>​ cd Fonts 
-C:\Cafu-9.06\Fonts\Times>​..\..\MakeFont.exe C:\WINNT\Fonts\times.ttf -m=Times+d:​\Dev\Cafu\Fonts>​ mkdir Segoe 
 +d:​\Dev\Cafu\Fonts>​ cd Segoe 
 +d:\Dev\Cafu\Fonts\Segoe>​..\..\MakeFont.exe C:\Windows\Fonts\segoe.ttf -m=Segoe
 The Cafu Font Maker, version July 01 2009. The Cafu Font Maker, version July 01 2009.
  
 Portions of this software are copyright (c) 2006 The FreeType Project Portions of this software are copyright (c) 2006 The FreeType Project
 (www.freetype.org). All rights reserved. (www.freetype.org). All rights reserved.
 +</​code>​
 +''​MakeFont''​ takes two parameters: the name of the font file whose font you want to use with Cafu GUIs, and the base name of the font materials. The base name is specified as ''​-m=<​base_name>''​. Although ''​MakeFont''​ will also work if you omit the ''​-m=...''​ part, your fonts will not work properly without it, so please make sure to include it. (The Cafu MatSys needs this option in order to be able to render the fonts properly.)
  
  
-C:​\Cafu-9.06\Fonts\Times>​ +===== Using the newly created font ===== 
-</​code>​ + 
-As you can see, ''​MakeFont''​ takes two parametersfirst the name of the font file whose font you want to use with Cafu GUIsthen the base name of the font materials. The base name is specified as ''​-m=<​base_name>​''​. ​Although ''​MakeFont''​ will also work if you omit the ''​-m=...''​ part, your fonts will not work properly without itso please make sure to include it. (The Cafu MatSys needs this option in order to be able to render ​the fonts properly.)+{{ :fontwizard:​new_font_gui_editor.png?​|Activate ​the new font in the GUI Editor}} Your font is now ready to be used in a GUI. Its name always begins ​with ''​Fonts/''​followed by the previously chosen font name. In our example above, ​the font name is ''​Fonts/Segoe''​. 
 + 
 +In the GUI Editorenter the font name into the appropriate field of the window that should use the font.
  
-**Wellthat's all! :-) Your font is ready to be used in a GUI.** In the associated ​script, just write+Alternativelyif you edit the GUI script ​manually, just add
 <​code=lua>​ <​code=lua>​
-    self:​set("​font",​ "​Fonts/​Times");+    self:​set("​font",​ "​Fonts/​Segoe");
 </​code>​ </​code>​
-in the appropriate ''​OnInit()''​ function ​of the GUI window that should ​use the new "​Times" ​font+to the appropriate ''​OnInit()''​ function ​to use the new font.
- +
-By the way: The name of the new font is always the name of its directory, using '/'​ slashes instead of '​\'​.+
  
guisys/making_new_fonts.1246707597.txt.gz · Last modified: 2013-01-07 12:07 (external edit)