Fonts

Post topics regarding Level Building/Design and Entity Usage with Reality Factory
Post Reply
User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Fonts

Post by steven8 » Sun Jul 13, 2014 4:57 am

I've read the docs, but I can not understand how to use my own fonts.
Steve Dilworth - Resisting change since 1965!

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Fonts

Post by QuestOfDreams » Sun Jul 13, 2014 6:14 pm

First, you can use either static bitmapped fonts (Pixmap)or dynamically created fonts based upon standard font files such as .ttf files (FreeType).

Both types require a .font file (by default stored in gui/fonts) in xml format that describes the font (name, filename, type ...; see GUI -> Font XML Files in the manual for details). For bitmapped fonts this file also contains information about mapping characters to a region (image) of the font bitmap.

Pixmap fonts also require an image file containing the characters and an .imageset xml file describing the region (image) of each character on the font bitmap. These files should be placed in the gui/imagesets folder.
FontStudio can automatically generate all three required files for you (.font file, .imageset file, image).

FreeType fonts require a .ttf font file that is present in your system folder or in the gui/fonts folder (the save way when giving your game to others; Note that also ttf files have licenses telling you if/how they can be redistributed). You may have a look at the sample .font files (e.g. tahoma.font) to see how they are defined.

That's all to define the font itself for CEGUI.

To actually use your font it must be loaded via a scheme you are using. You have to add a line like

Code: Select all

<Font Name="Tahoma" Filename="tahoma.font" />
to your .scheme file.

To use your font as default font, you can change the DefaultFont setting in gui/configs/cegui.config (also an xml file).

To use your font only for a specific window you can add a line like

Code: Select all

<Property Name="Font" Value="Tahoma" />
to a window definition in a layout file.

User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: Fonts

Post by steven8 » Mon Jul 14, 2014 8:21 am

Okay. It's a lot to soak in. I thought I followed the help file all the way, but I must have missed something. This coming weekend, I will give this a go. Thanks, QOD!
Steve Dilworth - Resisting change since 1965!

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Fonts

Post by QuestOfDreams » Sun Jul 27, 2014 8:23 pm

Have you figured it out or do you need some more information?

User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: Fonts

Post by steven8 » Mon Jul 28, 2014 8:42 am

I looked it it, but it made my head swim. I just gave up. :|

I need it spelled out more.
Steve Dilworth - Resisting change since 1965!

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Fonts

Post by QuestOfDreams » Sun Aug 03, 2014 11:40 am

Ok, let's assume you just want a different (bitmapped) font for the New Game button in the main menu.
  • If you haven't done so already, extract the FontStudio421.zip file in the tools folder.
  • Open FontStudio. On the left side you see a preview of the font image, on the right side you can customize the font.
  • Select the the font, its size and attributes. I chose Calibri and size 12.
  • In this example I left the character range and placement at their default values.
  • On the General Settings tab increase the texture size to 256x256 (click Apply) so all characters fit on the image.
  • Click on the Export button and select Export to CEGUI Font File. Save as Calibri12.
  • This will generate 3 files: Calibri12.font, Calibri12.imageset and Calibri12.png.
Move the Calibri12.font file to the gui/fonts folder.
Move the Calibri12.imageset file and the Calibri12.png file to the gui/imagesets folder.

Open the RFLook.scheme file in the gui/schemes folder with the RF Script Editor. After the line

Code: Select all

	<Font Name="Tahoma" Filename="tahoma.font" />
add

Code: Select all

	<Font Name="Calibri12" Filename="Calibri12.font" />
Open the menu_main.layout file in the gui/layouts folder with the RF Script Editor.
Find the definition of the New Game Button that starts with the line

Code: Select all

<Window Type="RFLook/Button" Name="Menu/Main/NewGame" >
To the list of properties add the Font property:

Code: Select all

<Property Name="Font" Value="Calibri12" />
If RF doesn't display the png file correctly, you may have to convert it to a tga file (e.g. using GIMP).
Then you have to open the Calibri12.imageset file and in the 2nd line find

Code: Select all

Imagefile="Calibri12.png"
and change it to

Code: Select all

Imagefile="Calibri12.tga"

User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: Fonts

Post by steven8 » Tue Aug 05, 2014 1:47 am

Got it!!! Thank you, Daniel, for all your patience and help. I also was able to figure how to do what I really wanted in the first place...change the text on the countdown timer. Not the type style I want yet, but that will come this weekend now that I know how. :D

[edit]I had to convert to TGA.
Steve Dilworth - Resisting change since 1965!

User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: Fonts

Post by steven8 » Thu Aug 28, 2014 6:36 am

All right! I have successfully placed my own font in the HUD for the health indicator. I have also created my own graphic health indicator. I'll attach a screen.

The Eye of Horus disappears as you lose health, and yes...that is a flying carpet!
Attachments
newhud3.jpg
(74.35 KiB) Not downloaded yet
Steve Dilworth - Resisting change since 1965!

Veleran
Posts: 891
Joined: Mon Aug 22, 2005 10:22 am
Location: Greece

Re: Fonts

Post by Veleran » Thu Aug 28, 2014 11:09 am

Very nice Egyptian Hud graphic Steve, feels like am back in the good old game days of 2001.
Is that carpet a magic flying one that you can carry you to that place?Maybe spoil the of the elements.
It is not absolutely needed to answer and spoil the adventure surprise ,I am glad i see a new RF level screenshot.

User avatar
steven8
Posts: 1487
Joined: Wed Aug 24, 2005 9:08 am
Location: Barberton, OH

Re: Fonts

Post by steven8 » Thu Aug 28, 2014 10:26 pm

Veleran wrote:Very nice Egyptian Hud graphic Steve, feels like am back in the good old game days of 2001.
Is that carpet a magic flying one that you can carry you to that place?Maybe spoil the of the elements.
It is not absolutely needed to answer and spoil the adventure surprise ,I am glad i see a new RF level screenshot.
Thank you, Veleran. I'm loving creating with RF again. Hard to believe it was 2003 when I completed Castle of the Pharaoh. So long ago...

Yep, magic carpet to take you to the entrance of the pyramid. You will have to find it, though. I haven't added in all the buildings.
Steve Dilworth - Resisting change since 1965!

Post Reply