Difference between revisions of "Font Tutorial"

From Oldunreal-Wiki
Jump to navigation Jump to search
(fixed code)
Line 44: Line 44:


MyCanvas.uc should contain code like that:<br>
MyCanvas.uc should contain code like that:<br>
<code>
class MyCanvas extends Canvas;
<nowiki>
#exec Font Import File=Textures\SmallFont.pcx Name=SmallFont<br>


#exec Font Import File=Textures\MedFont.pcx  Name=MedFont
  class MyCanvas extends Canvas;
 
 
#exec Font Import File=Textures\LargeFont.pcx Name=LargeFont
  #exec Font Import File=Textures\SmallFont.pcx Name=SmallFont
 
  #exec Font Import File=Textures\MedFont.pcx  Name=MedFont
#exec Font Import File=Textures\BigFont.pcx  Name=BigFont
  #exec Font Import File=Textures\LargeFont.pcx Name=LargeFont
 
  #exec Font Import File=Textures\BigFont.pcx  Name=BigFont
</nowiki>
 
defaultproperties<br>
  defaultproperties
{<br>
  {
Z=1.000000<br>
  Z=1.000000
Style=1<br>
  Style=1
DrawColor=(R=127,G=127,B=127)<br>
  DrawColor=(R=127,G=127,B=127)
SmallFont=Font'MyFonts.SmallFont'<br>
  SmallFont=Font'MyFonts.SmallFont'
MedFont=Font'MyFonts.MedFont'<br>
  MedFont=Font'MyFonts.MedFont'
BigFont=Font'MyFonts.BigFont'<br>
  BigFont=Font'MyFonts.BigFont'
LargeFont=Font'MyFonts.LargeFont'<br>
  LargeFont=Font'MyFonts.LargeFont'
}<br>
  }
</code><br>
Copy your fonts to MyFonts/Textures directory. Note: font files must be named as in #exec block.  
Copy your fonts to MyFonts/Textures directory. Note: font files must be named as in #exec block.  



Revision as of 13:56, 7 November 2009

Creating Localized Fonts

Bitmap Fonts

Base

First, you need base fonts to make yours.

I created fonts imported from Unreal with grid.

It's SmallFont, MedFont, BigFont, LargeFont and WhiteFont

Download Fonts

NOTE: Grid might be incorrect, report if you find mistake.

Editing

You need to explore which position corresponds each character from your charset. And just substitute glyph with your symbol's glyph. But obey order!

Importing

Save this text in text file and place it into your System/ directory. Remember to change it for your purposes.

Font Import File=texture0.pcx PACKAGE="Engine" Name=SmallFont
Font Import File=texture1.pcx PACKAGE="Engine" Name=MedFont
Font Import File=texture2.pcx PACKAGE="Engine" Name=LargeFont
Font Import File=texture3.pcx PACKAGE="Engine" Name=BigFont
OBJ SAVEPACKAGE PACKAGE="Engine" FILE="Engine.u"
Font Import File=texture7.pcx PACKAGE="UnrealShare" Name=WhiteFont
OBJ SAVEPACKAGE PACKAGE="UnrealShare" FILE="UnrealShare.u"

When type exec <you_file_name>.txt in UnrealEd to import fonts into Unreal!

Known Problems

LargeFont(and BigFont?) doesn't work when language is not int.

Importing in that way is incompatible with network game. I found a way how to use fonts(except WhiteFont) and leave game compatible with net.

Workaround:

Make new directory in your Unreal folder. Name it MyFonts, for example. Inside this directory make new directories Classes and Textures.

Create file MyCanvas.uc in Classes directory.

MyCanvas.uc should contain code like that:

  class MyCanvas extends Canvas;
  
  #exec Font Import File=Textures\SmallFont.pcx Name=SmallFont
  #exec Font Import File=Textures\MedFont.pcx   Name=MedFont
  #exec Font Import File=Textures\LargeFont.pcx Name=LargeFont
  #exec Font Import File=Textures\BigFont.pcx   Name=BigFont
  
  defaultproperties
  {
  	Z=1.000000
  	Style=1
  	DrawColor=(R=127,G=127,B=127)
  	SmallFont=Font'MyFonts.SmallFont'
  	MedFont=Font'MyFonts.MedFont'
  	BigFont=Font'MyFonts.BigFont'
  	LargeFont=Font'MyFonts.LargeFont'
  }

Copy your fonts to MyFonts/Textures directory. Note: font files must be named as in #exec block.

Add "EditPackages=MyFonts" line without quotes to [Editor.EditorEngine] block of your Unreal.ini

Do "UCC.exe make" in your Unreal/System directory. Note: Output must not contain any errors or warnings.

Then edit [Engine.Engine] block of your Unreal.ini. Change "Canvas=Engine.Canvas" line to "Canvas=MyFonts.MyCanvas"

Now your fonts should work in game and you can play online!

TrueType Fonts

Base

You can use your system fonts as a base for in-game fonts.

Editing

Edit fonts in font editor by copying your set of characters to first 255 entries.

TODO: Add Count overview

Importing

Use this script to import TrueType fonts to Unreal

new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=Tahoma10 FontName="Tahoma" Height=10 AntiAlias=0
new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=Tahoma20 FontName="Tahoma" Height=20 AntiAlias=1
new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=Tahoma30 FontName="Tahoma" Height=30 AntiAlias=1 CharactersPerPage=32
new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=TahomaB10 FontName="Tahoma Bold" Height=10 AntiAlias=1
new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=TahomaB20 FontName="Tahoma Bold" Height=20 AntiAlias=1 XPad=2
new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=TahomaB30 FontName="Tahoma Bold" Height=30 AntiAlias=1 CharactersPerPage=32 XPad=2
new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=UTFont12 FontName="Verdana" Height=12 AntiAlias=0
new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=UTFont24 FontName="Arial Narrow" Height=24 AntiAlias=1
new TrueTypeFontFactory PACKAGE="UWindowFonts" Name=UTFont40 FontName="Arial Bold" Height=40
CharactersPerPage=32 AntiAlias=1
OBJ SAVEPACKAGE PACKAGE="UWindowFonts" FILE="..\Textures\UWindowFonts.utx"

Save it as text file, launch UnrealEd and write in command field exec <text_file_name>.txt

Known Problems

Fonts Tahoma and Arial Bold don't import, but succesfully import in Wine.

Links

http://unreal.epicgames.com/TTFImport.htm