Fonts: Difference between revisions
Jump to navigation
Jump to search
no edit summary
No edit summary |
|||
Line 1: | Line 1: | ||
Preliminary remark: for demonstration purposes, this page makes use of special characters. This wiki page is supposed to be encoded in Unicode (UTF-8), therefore, you should see all the special characters correctly. | |||
<big>'''Introduction'''</big> | |||
This page is meant to provide '''in-depth explanations''' about how AGS manages fonts, and how to create fonts for AGS. | This page is meant to provide '''in-depth explanations''' about how AGS manages fonts, and how to create fonts for AGS. | ||
If you only want to read the short version, read [[Tutorial_Part_9_-_Cursors_and_fonts#Fonts|this]]. | If you only want to read the short version, read [[Tutorial_Part_9_-_Cursors_and_fonts#Fonts|this]]. | ||
== The MOST IMPORTANT part: define your needs == | == The MOST IMPORTANT part: define your needs == | ||
Line 8: | Line 17: | ||
=== | === >> Language === | ||
:'''Do I want my game to be:''' | :'''Do I want my game to be:''' | ||
::'''a.''' '''In''' '''English only'''? | ::'''a.''' '''In''' '''English only'''? | ||
Line 26: | Line 35: | ||
=== | === >> Resolution === | ||
:'''Do I want my game to be:''' | :'''Do I want my game to be:''' | ||
::'''a.''' '''high-resolution'''? | ::'''a.''' '''high-resolution'''? | ||
Line 37: | Line 46: | ||
::- Either an archaic '''SCI''' font (see the "more about the formats" section of this document) that would still be around in year 201x, and would fit perfectly into your game (you like old things, don't you?) , | ::- Either an archaic '''SCI''' font (see the "more about the formats" section of this document) that would still be around in year 201x, and would fit perfectly into your game (you like old things, don't you?) , | ||
::- or an existing '''WFN''' font (AGS' internal font format) also floating around somewhere on the forums, | ::- or an existing '''WFN''' font (AGS' internal font format) also floating around somewhere on the forums, | ||
::- or an actual '''TTF''' font, designed to look like pixel-art (for example [http://www.dafont.com/fr/pixel-perfect.font this one]). | ::- or an actual '''TTF''' font, but designed to look like pixel-art (for example [http://www.dafont.com/fr/pixel-perfect.font this one]). | ||
Line 49: | Line 58: | ||
=== SCI === | === SCI === | ||
Historically, this format is inherited from Sierra video games, but it doesn't matter here. What does matter is that the SCI format is a very, very old format. It's kept only for legacy reasons, mostly because it used to be a convenient format to manipulate pixel-based fonts (as opposed to vector-based fonts, such as TTF). | Historically, this format is inherited from [http://en.wikipedia.org/wiki/Sierra_Entertainment Sierra]'s video games, but it doesn't matter here. What does matter is that the SCI format is a very, very old format. It's kept only for legacy reasons, mostly because it used to be a convenient format to manipulate pixel-based fonts (as opposed to vector-based fonts, such as TTF). | ||
The main issue is that it's tricky to extend it to 256 characters (read further to know why). | The main issue is that it's tricky to extend it to 256 characters (read further to know why). | ||
Line 70: | Line 79: | ||
:'''Q:''' '''Does it support 256 characters?''' | :'''Q:''' '''Does it support 256 characters?''' | ||
:'''A:''' ''' | :'''A:''' '''Normally yes, but be careful'''. TTF fonts rely on the Unicode standard (see the "understanding character encoding" section), which means they can virtually represent any character in the entire universe. BUT it depends if the graphic designer who created the font went into the trouble of drawing the characters that you're interested in. Chances are, if you download an English TTF font, open (for example) MS Word, and type any character outside of the 127 standard characters, your text editor will rollback to Times New Roman for those characters. Because that font has them. And your cheap font doesn't. | ||
At least try to find a TTF font that has the 256 characters from the Latin-1 characters set (see "understanding character encoding"). | At least try to find a TTF font that has the 256 characters from the Latin-1 characters set (see "understanding character encoding"). | ||
Line 76: | Line 85: | ||
=== Bitmap === | === Bitmap === | ||
By "bitmap", we mean any sprites table that you will later use to create a font. It's not a font format in itself and needs work. | By "bitmap", we mean any sprites table that you will later use to create a font. It's not a font format in itself and needs work. Read more about that further below. | ||
Line 92: | Line 101: | ||
=== WFN fonts === | === WFN fonts === | ||
If you search the AGS forums properly, you will find resources of WFN fonts collections. | If you search the AGS forums properly, you will find resources of WFN fonts collections. Don't forget that WFN fonts are virtually the same thing as SCI fonts, so you can switch from one format tot he other with the correct tool (see section "how can I make fonts?") | ||
'''Attention:''' there is a catch to import WFN fonts into AGS. See the "How to import fonts into AGS?" section of this document. | '''Attention:''' there is a catch to import WFN fonts into AGS. See the "How to import fonts into AGS?" section of this document. | ||
Line 98: | Line 107: | ||
=== TTF fonts === | === TTF fonts === | ||
There are plenty of sites providing free fonts. The only catch is that you should make sure that the fonts are free to use (Respect the work of other people! ''' | There are plenty of sites providing free fonts. The only catch is that you should make sure that the fonts are free to use (Respect the work of other people! '''Always check the fonts' licence!''') | ||
Line 113: | Line 122: | ||
# rename the file to "font.0", or "font.1", etc. | # rename the file to "font.0", or "font.1", etc. | ||
# import from within AGS | # import from within AGS | ||
'''Note:''' if you import a "'''fake'''" SCI font (256 characters instead of 128, see section "more about the formats"), then the import might fail with an error. Or it could work, but obviously AGS will use only the first 128 characters, and you will lose the benefit of the extended font. | |||
=== WFN fonts === | === WFN fonts === | ||
WFN is AGS' internal font format. The only (very) weird thing is that (as of 2013, AGS 3.2.x) '''there is a bug preventing AGS from importing its own format'''! The only way to import a WFN font is : | WFN is AGS' internal font format. The only (very) weird thing is that (as of 2013, AGS 3.2.x) '''there is a bug preventing AGS from importing its own format'''! The only way to import a WFN font is : | ||
# in AGS, create a new font. Note down its number (e.g. "I just created font number 4"), | |||
# close AGS, | |||
# replace file agsfnt4.wfn with your font (and rename your font "agsfnt4.wfn") | |||
# re-open AGS. Font number 4 should now be your font. | |||
'''Note:''' if you import a "'''fake'''" WFN font (256 characters instead of 128, see section "more about the formats"), then the import should work, but obviously AGS will use only the first 128 characters, and you will lose the benefit of the extended font. | |||
Line 140: | Line 153: | ||
::'''Cons:''' | ::'''Cons:''' | ||
::* Limited to 128 characters | ::* Limited to 128 characters | ||
::* I'm still using the archaic SCI format! | ::* Oh noes! I'm still using the archaic SCI format! http://www.barnrunner.com/OSD/Roger-Dennis-Wink.gif | ||
::* That tool is not maintained (not that it's been an issue so far) | ::* That tool is not maintained (not that it's been an issue so far, since it works as expected) | ||
Line 157: | Line 170: | ||
::* If used as a plugin, integrated directly in your AGS editor | ::* If used as a plugin, integrated directly in your AGS editor | ||
::* Converts from WFN to SCI and back | ::* Converts from WFN to SCI and back | ||
::* '''Handles 256 characters''' | ::* '''Handles 256 characters''' (but, then again, AGS might not! See "more about the file formats") | ||
::'''Cons:''' | ::'''Cons:''' | ||
::* | ::* Still a young tool. | ||
::* | |||
::* | === Making fonts from bitmaps === | ||
==== Calin Leafshade's SpriteFont renderer ==== | |||
It can be found [http://www.adventuregamestudio.co.uk/forums/index.php?topic=44359.0 here]. | |||
::'''Pros:''' | |||
::* Allows very '''fancy fonts''', including pixel-art fonts ('''outlines''' are also not too complicated) | |||
::* Enables '''256-characters''' fonts in the least hacky way to-date. | |||
::* Directly converts from TTF to pixel-ready. | |||
::'''Cons:''' | |||
::* It's a '''plugin'''. Some people hate to have plugins in their games. | |||
::* It requires some thinking with the mapping of extended characters slots with sprites. Overall, your font is not "out of the box". | |||
:{| class="wikitable" | |||
|- | |||
| Pro-tip: the most important part is to understand the "characters selection" tab of SpriteFont 2.0. The characters "keys" are the code in the ANSI table. Just lookup your own local codes page (e.g. [http://www.unicodetools.com/unicode/img/latin-iso-8859-1.gif iso-8859-1] to know which characters you want to use. | |||
|} | |||
==== Nirogen's FontStudio ==== | |||
It can be found [http://www.ogre3d.org/forums/viewtopic.php?f=11&t=47802 here]. | |||
That tools was not designed for AGS but it might be a nice alternative to manipulate sprites tables generated from TTF fonts. | |||
You must consider it an additional tool to Calin Leafshade's SpriteFont renderer. | |||
=== Making TTF Fonts === | |||
That's outside of the scope of this document. Creating "real" fonts is a rather difficult task. | |||
== how to surf from 128 to 256 characters, and back == | |||
=== Understanding characters encoding === | |||
Before you go further, you '''need''' to read this : [http://www.joelonsoftware.com/articles/Unicode.html "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)"] | Before you go further, you '''need''' to read this : [http://www.joelonsoftware.com/articles/Unicode.html "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)"] | ||
This way you'll know what '''ASCII, ANSI, "Latin" ISO-8859-1, Unicode''' and '''UTF-8''' mean. | This way you'll know what '''ASCII, ANSI, "Latin" ISO-8859-1, Unicode''' and '''UTF-8''' mean. | ||
=== Use a GOOD text editor === | |||
Do yourself a favour. '''Never EVER use Notepad to open a text file'''. Instead, use an editor that won't silently mess with the current encoding when you save. | |||
My favourite one is '''[http://notepad-plus-plus.org Notepad++]''' (notice the "++" at the end). You can switch between encodings (ANSI to UTF-8 and back) and you can switch between rendering codepages (ANSI: Western Europe, ANSI:Central Europe, etc.) | |||
=== How does it apply to AGS? === | |||
You must make the difference between : | |||
:* The '''scripting window''' of the '''AGS Editor''' | |||
:* The '''"Fonts" resources folder''' of the '''AGS Editor''' | |||
:* The '''AGS engine''' when it uses WFN or SCI fonts | |||
:* The '''AGS engine''' when it uses TTF fonts | |||
* '''The scripting window of the AGS Editor''' works in '''256 characters'''. As you know, that doesn't mean much (the characters from 128 to 255 could be anything). The AGS Editor being based on the .Net Framework, it will use your local Windows codepage (that is, your regional settings) to display the text you typed into the scripting window. If you're a '''Western European or an American''', it's most likely to be '''[http://i.msdn.microsoft.com/cc305145.1252%28en-us,MSDN.10%29.gif Windows-1252]'''. | |||
:For example, it means that symbol "153" is the trademark symbol (™). Go on, you try and type it (or copy and paste it) into AGS. If your Windows is using Windows-1252, you'll see it appear correctly. Otherwise you might see something else being rendered in place of it. | |||
::::'''Why is it interesting?''' Because the Windows-1252 has the '''exact same mapping''' as [http://www.unicodetools.com/unicode/img/latin-iso-8859-1.gif iso-8859-1] (a.k.a "Latin-1"), except for characters 128 to 159. I chose the TM symbol on purpose because it's within that range, to show you that sometimes that slight difference can cause an issue. But in 99.9% cases, you won't care, because all the important characters (especially the funny French/Spanish/German characters) will be the '''same''' in Windows-1252 (in your script editor) as in iso-8859-1 (in your external text editor or in your browser). | |||
::::'''Let's take a concrete situation:''' You're programming your game in French, and you want an in-game dialog to contain character "'''é'''". That means you either typed "é" into the dialogs editor, or into the script editor (e.g. "'''player.Say("ééééé");'''). Well, because Windows-1252 is the same as iso-8859-1, that means you can copy and paste any text generated externally to AGS (with any good text editor or browser) as long as it was displayed using iso-8859-1. In the same fashion, if you export translation files outside of AGS, they will be encoded in ANSI, and if you watch them with code page iso-8859-1, then every character will appear correctly. Immediate characters matching = less mistakes! | |||
* '''The "Fonts" resources folder''' of the AGS Editor only ever displays 128 characters. But don't forget that if you use TTF fonts, the engine will then be able to display all 256 characters in-game. They're here, you just don't see them in the Editor. | |||
::::'''Note:''' Don't forget either that some experimental versions of AGS can use 256-characters WFN or SCI fonts. Read further to learn more about that. | |||
* '''The AGS engine (when it uses WFN or SCI fonts)''' can display only 128 characters. | |||
::::'''Note:''' Don't forget that some experimental versions of AGS can use 256-characters WFN or SCI fonts. Read further to learn more about that. | |||
* '''The AGS engine (when it uses TTF fonts)''' can display 256 characters. Let's say you typed "é" in the script editor. That's character number 233. In-game, the engine will simply render it with the font character number 233 from your TTF font. If your TTF font has a drawing for that character, and if the drawing is correct, it will display an "é" in-game. | |||
== AND FINALLY, CHOOSE YOUR DESTINY (how to have 256 characters in your game) == | |||
=== A. The hacker's strategy === | |||
People used to do this : | |||
# Stick to 128-chars SCI or WFN font | |||
# Pick a handful of rarely-used characters within the 128 characters. For example, ASCII characters [http://www.morbleu.com/wp-content/uploads/2009/08/ascii.gif 92 to 96, and 123 to 127]. (Note: Don't pick 91 ( "'''['''" ) as it's a special character for AGS). | |||
# Decide that these characters will be used for something completely different. For example: "_" won't be "_" anymore, but instead it will be "é". | |||
# Edit your font and replace "_" with a nice drawing of a "é". | |||
# Export the translation files and make your translator(s) translate it --> The resulting file is likely to contain some "é". (reminder: Make them use a good text editor! Not notepad!) | |||
# Do a "replace all" in the file, and replace every "é" with "_". | |||
# Import the translation file back into AGS. | |||
# Play the game. With your custom, every "_" appears as a "é", and everything looks fine. | |||
::'''Pros:''' | |||
::* Quick hack | |||
::'''Cons:''' | |||
::* You might run out of special characters. | |||
::* If you translate into several languages, you'll need several fonts for sure... | |||
::* You might make human mistakes with all those "replace all" | |||
=== B. The lucky guy's strategy === | |||
:1. Find one (or several similar-looking) TTF font(s) that has(have) all the special characters you need. | |||
::'''Pro-tip:''' Search free fonts websites '''of the targeted country'''. For example, if you need French characters, search [www.dafont.com this one], type "pixel" in the search box, and download only the fonts that have the "accents" flag on the left-hand side. | |||
:2. Use them in your game. Special characters should be rendered correctly. | |||
::'''Pros:''' | |||
::* Simplest and most elegant solution. | |||
::'''Cons:''' | |||
::* If you don't find the TTF font with the special characters you need, you're done for. | |||
::* If you need an '''outlined''' font, you're done for! | |||
=== C. The mad scientist's strategy === | |||
# Use [http://www.adventuregamestudio.co.uk/forums/index.php?topic=44502.0 "AGS Draconian"], the experimental AGS that enables 256-characters SCI or WFN fonts. | |||
# Use Rulaman's WFN-FontEditor (see corresponding section in this document) | |||
# If you're European, directly edit an existing '''256-char''' SCI or WFN font (see corresponding section in this document) -- this way you already know what slots match what characters in that code page (Reminder: 256-char SCI or WFN are "fake" formats that can be used only in that context. Regular SCI or WFN allow only 128 characters). | |||
# Save it as your own font, import it into AGS Draconian. | |||
# Run the game. All characters should be displayed correctly. | |||
::'''Pros:''' | |||
::* Very convenient solution. | |||
::'''Cons:''' | |||
::* You're using an experimental AGS with a non-standard font format... BUT '''the Draconian edition is very reliable''', and an important part of its tweaks are later on merged into the regular AGS. There's a good chance that this becomes AGS standard at some point. | |||
=== D. The powerful strategy === | |||
# Create a bitmap font from any TTF font using Calin Leafshade's SpriteFont renderer (see corresponding section of this document) | |||
# Follow the steps to integrate it into your game | |||
::'''Pros:''' | |||
::* Prettier rendering of the fonts | |||
::* You gain in compatibility with vanilla AGS, because you use only standard AGS tech | |||
::'''Cons:''' | |||
::* You lose in compatibility with less-used Operating Systems, as plugins work only on Windows. |