Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: Calin Leafshade on Fri 02/09/2011 21:30:53

Title: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Fri 02/09/2011 21:30:53
Ok so a while ago someone (Icey Games i thnk) expressed an interest in using spritefonts because he has totally got the rest of his game down and wanted to add some sparkle.

Now SSH wrote a spritefont module but it was awkward to use since it didnt integrate with the normal ags text functions. This plugin solves that problem.

So you can set a spritefont to override a normal font and just use .Say() or Display() calls and the plugin will draw.

This means you can bypass all the issues with font outlining and stuff just by providing your own, multi coloured, anti aliased, fonts.

Functions


//sets a fixed width font
void SetSpriteFont(int fontNum, int sprite, int rows, int columns, int charWidth, int charHeight, int charMin, int charMax, bool use32bit)


where:

fontNum is the font number you wish to replace.
sprite is the sprite number that contains the sprite font
rows is the number of rows in the font
columns is the number of columns
charWidth is the width of a single character (must all be the same)
charHeight ditto height.
charMin is the lowest ASCII number that the font contains
charMax ditto highest.
use32bit is currently unused and can be either true or false.

the spritefont must be formatted sequentially like this one:

(http://www.algonet.se/~guld1/fonts/010.gif)

the function for this one would be:


SetSpriteFont(0, 1,  3, 20, 16, 16, 32, 91, true);



void SetVariableSpriteFont(int fontNum, int sprite);


This overrides font 'fontNum' with sprite 'sprite'


void SetSpacing(int fontNum, int spacing)


This allows you to adjust the spacing of a variable width font if its too spread out with drop shadows and stuff


void SetGlyph(int fontNum, int charNum, int x, int y, int width, int height)


This sets a glyph (character) size and location in the spritefont's texture.

I have included a utility which will generate the code for you.

Usage of variable width fonts

- In the archive is a program called SpriteFont.exe. This program will generate variable width sprite fonts for you with shadows and outlines and all kinds of shit.
- The program generates 2 files. The PNG which is the actual font and a file called metrics.xml.
- In the archive there is also AGSSpriteFontGen.exe. This program will take the metrics.xml and convert it to AGSScript that you can copy into your game.

download

The archive contains a demo and all the files needed.

The helper programs need .Net4.0 to run but the plugin itself has no dependencies.

https://dl.dropboxusercontent.com/u/20918686/ags/ags_sprtitefont.zip

What does it look like? Is it better than AGS's normal font renderering?

Yes it is. It looks like this:

(http://i.imgur.com/sNPtu.png)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: on Fri 02/09/2011 23:20:43
Looks useful AND easy to use. Downloading now, will report later!

[edit]
Yes, very sweet indeed. Easy to set up and use; and it's really cool to have it "behind the scenes" with all the standard commands still in charge. Thanks for sharing!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sat 03/09/2011 02:52:54
Thanks ghost.

Working on variable width fonts now which will make it much more useful for general purpose stuff but its quite challenging for a c++ novice.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Dualnames on Sat 03/09/2011 13:45:34
So from what I'm understanding the restraints so far are:

-Standard size for characters (All characters must have the same width and height).
-Order of characters.

Most font sites actually offer a bitmap containing all the characters of a font in that order, but I haven't browsed bitmap fonts for years, so I can't know.
Regardless this is a nice leap forward.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sat 03/09/2011 15:59:24
Yes, although the characters dont need the same height *and* width. That is to say that they dont have to be square but al the characters need to be the same as each other.

And yea, the characters have to be horizontally sequential according to the ascii codes. Normally they will start with space (char 32) and end with Z (char 90)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sat 03/09/2011 21:26:41
Updated to support variable width fonts

See first post.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Dualnames on Sat 03/09/2011 22:31:23
Quote from: Calin Leafshade on Sat 03/09/2011 21:26:41
Updated to support variable width fonts

See first post.

I stand corrected. And I edited my post. :D :D :D
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Knox on Sun 04/09/2011 04:07:48
Dang you Calin!!

Now I have yet another cool thing to add to my ever-expanding/never-ending/forever-bloating project!!

Seems awesome, downloading now :)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sun 04/09/2011 11:00:35
Bugs are possible so bug reports would be nice if anyone tries it out.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Monsieur OUXX on Mon 05/09/2011 09:47:35
Thanks for the variable width functions. That will come handy.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: David Ostman on Fri 09/09/2011 06:23:34
This is extremely useful, Calin, thanks a tonne :)

By the way, what kind of license are you providing this under? If it wouldn't be too much trouble, when/if you next update it, could you include a license in the zip?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Fri 09/09/2011 14:26:09
Yea, I'll GPL it or something when I release the code. Everything I do has a *very* liberal license that usually just requires credit.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Icey on Sat 10/09/2011 04:36:46
yay! I wasn't even aware of this topic. Now I can try and use that font.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: StillInThe90s on Thu 15/09/2011 16:41:43
Thanks for making an effort Calin! This will be very useful once I get it working properly.
Now, I wonder if someone could have pity and reach out a helping hand to the blind and the deaf of the ags community. I have no idea how to implement this plugin. Is it supposed to work alongside SSHs plugin, or on its own? What code and what files goes where? Do I import the font -png as an ordinary ags sprite?
An open agf -version of the demo might help. Possibly.

Sorry for lowering the intellectual level to kindergarten, everyone.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Khris on Thu 15/09/2011 22:15:07
It's a replacement for SSH's module and allows native commands like Display to use the sprite font.

Copy the dll in AGS' main directory.
Then open your game and check the Plugins node in the project tree. It should get listed there and after you activate it, you can use the additional commands it provides.
The font sprite is imported as usual.

Calin's opening post should explain the rest.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: StillInThe90s on Fri 16/09/2011 14:31:13
Got it. Thanks!
Title: Set Glyph Glitch?
Post by: None on Fri 14/09/2012 12:01:41
In a game I'm working on I want to use your plugin, I installed it and created a bitmap font:
(http://charlescreations.com/pxfont.png)
It's spaced 10x10 to accomodate the largest characters or 'glyphs' on the sprite-sheet.

Then in function game_start() I put this:
Code (AGS) Select

SetSpriteFont(0, 57, 6, 16, 10, 10, 32, 126, false);
  SetSpacing(0, 1);
  SetGlyph(0, 32, 0, 0, 4, 7); //Blank
  SetGlyph(0, 33, 10, 0, 2, 7); //!
  SetGlyph(0, 34, 20, 0, 5, 7); //"
  SetGlyph(0, 35, 30, 0, 6, 7); //#
  SetGlyph(0, 36, 40, 0, 4, 7); //$
  SetGlyph(0, 37, 50, 0, 6, 7); //%
  SetGlyph(0, 38, 60, 0, 4, 7); //&
  SetGlyph(0, 39, 70, 0, 3, 7); //'
  SetGlyph(0, 40, 80, 0, 4, 7); //(
  SetGlyph(0, 41, 90, 0, 4, 7); //)
  SetGlyph(0, 42, 100, 0, 6, 7); //*
  SetGlyph(0, 43, 110, 0, 4, 7); //+
  SetGlyph(0, 44, 120, 0, 3, 7); //,
  SetGlyph(0, 45, 130, 0, 4, 7); //-
  SetGlyph(0, 46, 140, 0, 4, 7); //.
  SetGlyph(0, 47, 150, 0, 5, 7); // /
  //Row2
  SetGlyph(0, 48, 0, 10, 5, 7); //0
  SetGlyph(0, 49, 10, 10, 5, 7); //1
  SetGlyph(0, 50, 20, 10, 5, 7); //2
  SetGlyph(0, 51, 30, 10, 5, 7); //3
  SetGlyph(0, 52, 40, 10, 5, 7); //4
  SetGlyph(0, 53, 50, 10, 5, 7); //5
  SetGlyph(0, 54, 60, 10, 5, 7); //6
  SetGlyph(0, 55, 70, 10, 5, 7); //7
  SetGlyph(0, 56, 80, 10, 5, 7); //8
  SetGlyph(0, 57, 90, 10, 5, 7); //9
  SetGlyph(0, 58, 100, 10, 2, 7); //:
  SetGlyph(0, 59, 110, 10, 3, 7); //;
  SetGlyph(0, 60, 120, 10, 4, 7); //<
  SetGlyph(0, 61, 130, 10, 4, 7); //=
  SetGlyph(0, 62, 140, 10, 4, 7); //>
  SetGlyph(0, 63, 150, 10, 4, 7); // ?
  //Row3
  SetGlyph(0, 64, 0, 20, 8, 7); //@
  SetGlyph(0, 65, 10, 20, 5, 7); //A
  SetGlyph(0, 66, 20, 20, 5, 7); //B
  SetGlyph(0, 67, 30, 20, 5, 7); //C
  SetGlyph(0, 68, 40, 20, 5, 7); //D
  SetGlyph(0, 69, 50, 20, 5, 7); //E
  SetGlyph(0, 70, 60, 20, 5, 7); //F
  SetGlyph(0, 71, 70, 20, 5, 7); //G
  SetGlyph(0, 72, 80, 20, 5, 7); //H
  SetGlyph(0, 73, 90, 20, 4, 7); //I
  SetGlyph(0, 74, 100, 20, 5, 7); //J
  SetGlyph(0, 75, 110, 20, 5, 7); //K
  SetGlyph(0, 76, 120, 20, 5, 7); //L
  SetGlyph(0, 77, 130, 20, 6, 7); //M
  SetGlyph(0, 78, 140, 20, 6, 7); //N
  SetGlyph(0, 79, 150, 20, 5, 7); //O
  //Row4
  SetGlyph(0, 80, 0, 30, 5, 7); //P
  SetGlyph(0, 81, 10, 30, 6, 7); //Q
  SetGlyph(0, 82, 20, 30, 5, 7); //R
  SetGlyph(0, 83, 30, 30, 5, 7); //S
  SetGlyph(0, 84, 40, 30, 6, 7); //T
  SetGlyph(0, 85, 50, 30, 5, 7); //U
  SetGlyph(0, 86, 60, 30, 6, 7); //V
  SetGlyph(0, 87, 70, 30, 6, 7); //W
  SetGlyph(0, 88, 80, 30, 6, 7); //X
  SetGlyph(0, 89, 90, 30, 6, 7); //Y
  SetGlyph(0, 90, 100, 30, 5, 7); //Z
  SetGlyph(0, 91, 110, 30, 3, 7); //[
  SetGlyph(0, 92, 120, 30, 5, 7); // \
  SetGlyph(0, 93, 130, 30, 3, 7); //]
  SetGlyph(0, 94, 140, 30, 4, 7); //^
  SetGlyph(0, 95, 150, 30, 4, 7); //_
  //Row5
  SetGlyph(0, 96, 0, 40, 3, 7); //`
  SetGlyph(0, 97, 10, 40, 5, 7); //a
  SetGlyph(0, 98, 20, 40, 5, 7); //b
  SetGlyph(0, 99, 30, 40, 5, 7); //c
  SetGlyph(0, 100, 40, 40, 5, 7); //d
  SetGlyph(0, 101, 50, 40, 5, 7); //e
  SetGlyph(0, 102, 60, 40, 5, 7); //f
  SetGlyph(0, 103, 70, 40, 5, 7); //g
  SetGlyph(0, 104, 80, 40, 5, 7); //h
  SetGlyph(0, 105, 90, 40, 2, 7); //i
  SetGlyph(0, 106, 100, 40, 4, 7); //j
  SetGlyph(0, 107, 110, 40, 4, 7); //k
  SetGlyph(0, 108, 120, 40, 2, 7); //l
  SetGlyph(0, 109, 130, 40, 6, 7); //m
  SetGlyph(0, 110, 140, 40, 5, 7); //n
  SetGlyph(0, 111, 150, 40, 5, 7); //o
  //Row6
  SetGlyph(0, 112, 0, 50, 5, 7); //p
  SetGlyph(0, 113, 10, 50, 5, 7); //q
  SetGlyph(0, 114, 20, 50, 5, 7); //r
  SetGlyph(0, 115, 30, 50, 5, 7); //s
  SetGlyph(0, 116, 40, 50, 4, 7); //t
  SetGlyph(0, 117, 50, 50, 5, 7); //u
  SetGlyph(0, 118, 60, 50, 6, 7); //v
  SetGlyph(0, 119, 70, 50, 6, 7); //w
  SetGlyph(0, 120, 80, 50, 5, 7); //x
  SetGlyph(0, 121, 90, 50, 5, 7); //y
  SetGlyph(0, 122, 100, 50, 5, 7); //z
  SetGlyph(0, 123, 110, 50, 4, 7); //({)
  SetGlyph(0, 124, 120, 50, 3, 7); //|
  SetGlyph(0, 125, 130, 50, 4, 7); //(})
  SetGlyph(0, 126, 140, 50, 5, 7); //"
  SetGlyph(0, 127, 150, 50, 5, 7); //~

Here I've assigned the sprite font sheet at slot 57 over the default ags 0 font and then manually defined each glyph on the sheet, and this works, the problem is it still seems to be spacing it based on '10-10'. How do I fix this? Can I fix this, it's really depressing me at this point.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Fri 14/09/2012 12:40:31
use the function for variable width fonts. currently you are using the fixed width font function.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: None on Fri 14/09/2012 12:45:46
THANK YOU, I just TOTALLY overlooked that in the documentation, wtheck. It's 7:00am here and I've been awake for hours trying to finish getting my text-box working. Thanks so much for your quick reply, and awesome addon.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Fri 14/09/2012 12:50:19
Sorry, I haven't examine the plugin very closely, but cannot there be some kind of helper function to evade repeating SetGlyph for 100 times?
Here, in charlescreations's example, we have all glyths arranged in similar fashion, just having different widths. Would it be possible to make a function that takes a number of glyths per row, common spacing and array of glyth widths?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Fri 14/09/2012 12:56:39
The setglyph functions are generated by a helper program based on a metrics xml file. parsing the file at runtime was beyond the scope of the plugin.

It's possible that a helper function of some kind could reduce the code required tho.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Knox on Mon 03/12/2012 15:29:00
I'd like to re-download this plugin but the link seems to be broken. Would anyone have a copy somewhere?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: JSH on Mon 21/01/2013 19:19:14
*edit nevermind, better link below :)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Khris on Mon 21/01/2013 19:40:04
Could you upload the helper programs, too?

Or could you, Calin?

Somebody?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Mon 21/01/2013 20:43:43
I managed to find the original archive from my server dump and reuploaded it. It should have all the helper programs and shit in it.

http://www.sanctuary-interactive.com/~steve/agspritefont2.zip
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Thomas on Tue 22/01/2013 07:15:45
Does this work with D3D? I know the obvious answer would be 'no' since I get the error message saying it doesn't, but I don't see it mentioned in the post - so hoping that I might have overlooked something?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Tue 22/01/2013 08:15:27
There's no reason it shouldnt work in D3D...

Whats the error?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Thomas on Tue 22/01/2013 09:32:14
When trying the SpriteFontTest.exe with D3D I get this right before the text should appear:

in "room1.asc",line 5
from "room1.asc",line 28
Error: This plugin is not compatible with the Direct3D driver

Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Tue 22/01/2013 09:35:28
Which function is causing that error?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Thomas on Tue 22/01/2013 09:58:28
When trying with DD5 the first text-message is a Display(), based on what text message say.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: JJS on Tue 22/01/2013 10:26:38
Quote from: Calin Leafshade on Tue 22/01/2013 09:35:28
Which function is causing that error?
Probably engine->GetVirtualScreen(). It is not possible to get the screen contents when using the D3D driver. Funnily enough, the function is called in the plugin but the result is never used.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Tue 22/01/2013 10:35:21
Yes, I thought there shouldnt be any good reason why it doesnt work in D3D.. and theres is the no-good reason.

Easy enough to fix. I will do so when i am next at home unless the miraculous happens and someone fixes it before me.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Sslaxx on Thu 24/01/2013 15:14:41
Any way of setting the font colour used separate from the sprite? So if you wanted it displayed in black, it would be?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Lake A. on Thu 24/01/2013 18:31:24
Hi!
This plugin is fantastic, I've just downloaded the files and run the exe... But I can't see a way to install the plugin. It looks there are not scm files.
I know, excuse me but I'm new and I can't speak English very well so I can't understand everything! Thanks! :)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Khris on Thu 24/01/2013 19:27:21
scm files are script modules; plugins are dll files.
Four of them are from the SpriteFont program, you only need "apsspritefont.dll".
With AGSEditor not running, copy it into the same dir. Then open your game. The plugin should now appear in the project tree. Right-click it and click on "Use this plugin".
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Thu 24/01/2013 22:08:46
Quote from: Sslaxx on Thu 24/01/2013 15:14:41
Any way of setting the font colour used separate from the sprite? So if you wanted it displayed in black, it would be?

Not currently but I dont see any reason why that wouldnt be possible.



Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Lake A. on Sat 26/01/2013 19:02:15
Thanks, Khris!
Now... I'm sorry, but I have another problem. I used the exe files, I made the metric file and the sprite font. Then I loaded it in AGS Sprites, and I copied the code in game start function, but it still doesn't work. Where's the mistake?... Thanks!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Khris on Sat 26/01/2013 19:37:47
Pretty difficult to see the mistake without looking at your code, right...?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Thomas on Thu 14/02/2013 22:52:22
Out of curiosity, any updates on this?
Sslaxx suggestion sound great(if I even understood it correctly), and if it would use the color of the character text color setting it would be the icing on the cake IMO. :)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Thu 14/02/2013 23:12:12
Sorry I completely forgot.

I'll pull the repo tomorrow when my NEW COMPUTER arrives and I'll see if I can add colouring and fix the D3D problem on my NEW COMPUTER.

...

NEW COMPUTER
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: san.daniele on Sun 14/04/2013 20:24:33
This Sir probably saved me weeks of worktime!
I made a custom font for my game and was extremely happy with it (any existing font would have destroyed the whole look). But had no idea how to implement it. Your plugin is better than I could have ever expected … and only took me a few hours to get it working (well, I am an absolute beginner and at first I did everything wrong that could be done wrong ;) ).

Short: Thanks so much!!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: san.daniele on Thu 18/04/2013 09:33:57
When reworking my custom font and playing around with some glyphs I decided to use a variable width instead of a fixed one.

Unfortunately, now the line breaks don't work anymore. Everything is just written in one line. When there should be a line break, it just jumps to the beginning of the same line and draws the next letters on top of the previous ones. I could work around it using a lot of %s but I'm sure I'm just missing an obvious detail. How do I set the line spacing?

here's the code I'm using. As soon as I'm deleting SetVariableSpriteFont all lines break perfectly.

Code (AGS) Select


// SetSpriteFont(0, 18, 5, 20, 43, 45, 32, 122, false);  //Custom Font

  SetVariableSpriteFont(0, 18);
  SetSpacing(0, 5);

  //SetGlyph(int fontNum, int charNum, int x, int y, int width, int height)

  SetGlyph(0, 48, 688, 7, 27, 38); //0
  SetGlyph(0, 49, 731, 7, 20, 38); //1
  SetGlyph(0, 50, 774, 7, 27, 38); //2
  SetGlyph(0, 51, 817, 7, 27, 38); //3
  SetGlyph(0, 52, 0, 52, 27, 38); //4
 
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: JSH on Thu 18/04/2013 10:12:03
Quote from: Calin Leafshade on Thu 14/02/2013 23:12:12
Sorry I completely forgot.

I'll pull the repo tomorrow when my NEW COMPUTER arrives and I'll see if I can add colouring and fix the D3D problem on my NEW COMPUTER.

...

NEW COMPUTER

I hate to be that guy, but we're still waiting for this?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Thomas on Thu 18/04/2013 13:31:03
Thanks Joel, that means I didn't have to be the guy. :)

In other words, I'm also still interesting in this - I didn't want to bother as I assumed you were too busy.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Thu 18/04/2013 16:13:19
My apologies, I completely forgot.

I shall begin today!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Thu 18/04/2013 18:05:35
Ok new version here: https://dl.dropboxusercontent.com/u/27247158/ags-spritefont-plugin.dll

The filename has changed to match the reorganisation so make sure you delete the old version from your game directory and the ags directory.

All the functions and stuff are the same so it should be a drop in replacement.

Quote from: san.daniele on Thu 18/04/2013 09:33:57
When reworking my custom font and playing around with some glyphs I decided to use a variable width instead of a fixed one.

Unfortunately, now the line breaks don't work anymore. Everything is just written in one line. When there should be a line break, it just jumps to the beginning of the same line and draws the next letters on top of the previous ones. I could work around it using a lot of %s but I'm sure I'm just missing an obvious detail. How do I set the line spacing?

I can't reproduce this. For me line breaks work fine as seen here:

(http://i.imgur.com/AMP08AY.png)

Quote from: Calin Leafshade on Tue 22/01/2013 10:35:21
Yes, I thought there shouldnt be any good reason why it doesnt work in D3D.. and theres is the no-good reason.

Easy enough to fix. I will do so when i am next at home unless the miraculous happens and someone fixes it before me.

This is also fixed. The plugin now works in D3D

I will tackle the font tinting next.

Github: https://github.com/CalinLeafshade/ags-spritefont
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: san.daniele on Thu 18/04/2013 19:14:18
Quote from: Calin Leafshade on Thu 18/04/2013 18:05:35

Quote from: san.daniele on Thu 18/04/2013 09:33:57
When reworking my custom font and playing around with some glyphs I decided to use a variable width instead of a fixed one.

Unfortunately, now the line breaks don't work anymore. Everything is just written in one line. When there should be a line break, it just jumps to the beginning of the same line and draws the next letters on top of the previous ones. I could work around it using a lot of %s but I'm sure I'm just missing an obvious detail. How do I set the line spacing?

I can't reproduce this. For me line breaks work fine as seen here:


I fixed it myself (well, "fixed" is a big word). I only tested it with numbers 0-9. Now I defined all 90 characters with SetGlyph and voilá: all works fine (maybe that makes sense to you).

I don't understand why this plugin doesn't get more love (like an insane amount). It's just amazing and I'm quite sure I'm going to use it for every project I'm going to do in AGS. So thanks again.
(or maybe I just didn't realize yet that there are several other plugins/methods to use a custom font).
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Thu 18/04/2013 19:54:06
No one ever likes my plugins :(
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Thu 18/04/2013 20:41:09
Updated with colour tinting:

https://dl.dropboxusercontent.com/u/27247158/ags-spritefont-plugin.dll

(http://i.imgur.com/tjfeCHE.png)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Thomas on Sat 20/04/2013 05:44:21
I can confirm that it works now, both tinting and using it in D3D.

There seem to be a transparency problem when used for dialogues (a room with a background image). Seems to work fine when used over a GUI though - so I suspect it's the AGS transparency limitation which is causing this?

(Your plugins should get some more love, it does fix some of the AGS limitations, but I suspect it's just a minority of the developers who think it's a problem)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sat 20/04/2013 05:57:09
Quote from: Daniel Thomas on Sat 20/04/2013 05:44:21
There seem to be a transparency problem when used for dialogues (a room with a background image). Seems to work fine when used over a GUI though - so I suspect it's the AGS transparency limitation which is causing this?

Is "Antialias Truetype fonts" set to true in the options? AGS doesnt provide a 32-bit canvas to draw fonts on unless that is selected and so transparency will completely mess up.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Thomas on Sat 20/04/2013 06:06:05
Yes, that fixed it. :)

(http://dontforgetatowel.com/wp-content/uploads/2012/08/thumbs-up-fallout.jpg)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: selmiak on Wed 24/04/2013 12:05:28
is there a way to apply this to guis and especially text displayed on buttons and textboxes?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Wed 24/04/2013 12:09:42
Yes, it will work anywhere where a font is rendered.

However it wont show up on the preview in the editor because the plugin is only loaded at runtime and theres nothing i can do about that.

But the example picture i posted is text on a GUI label.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Ghost on Fri 26/04/2013 17:35:22
Quote from: Calin Leafshade on Thu 18/04/2013 19:54:06
No one ever likes my plugins :(

I am loving this!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: san.daniele on Sat 27/04/2013 12:09:36
Quote from: Calin Leafshade on Sat 20/04/2013 05:57:09
Quote from: Daniel Thomas on Sat 20/04/2013 05:44:21
There seem to be a transparency problem when used for dialogues (a room with a background image). Seems to work fine when used over a GUI though - so I suspect it's the AGS transparency limitation which is causing this?

Is "Antialias Truetype fonts" set to true in the options? AGS doesnt provide a 32-bit canvas to draw fonts on unless that is selected and so transparency will completely mess up.

I'm having a transparency issue as well. If the text is displayed in a GUI, it looks messed up if the GUI is transparent or the GUI background has an alpha channel. All sprites are 32-bit (of course game set to that as well) and Antialias Font set to true. The room background has no alpha channel.

I've been playing around with it for hours now without finding any solution. If wanted, I can upload an example dialog I quickly set up in the AGS Demo Game.
Am I missing something?

I found several topics about problems using transparency over an already (semi-)transparent GUI (most of them being a little over my head). But everything works fine using transparent sprites in a transparent inventory GUI, so my guess is it has something to do with the font rendering.

edit: actually, I should specify a little more. It kinda recognices the general transparent area around the characters, but looses all details.
Instead of explaining, here's two screenshots:

here's how a simple Say("") or Display("") looks like:
[imgzoom]http://www.whalesplash.com/CrossStitchCasper/Examples/1.png[/imgzoom]
and here's what happens if inside a transparent gui
[imgzoom]http://www.whalesplash.com/CrossStitchCasper/Examples/2.png[/imgzoom]
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sat 27/04/2013 18:01:24
I can't reproduce the issue.

A demonstration game with the source would be useful.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: san.daniele on Sat 27/04/2013 21:12:42
http://www.whalesplash.com/CrossStitchCasper/Examples/FontGame.zip

The .zip might look a little messed up as I packed it using my mac.
I hope that's all you need. There's some sprites in there to test inventory item/font. just start it and talk to the 2nd character in the room.

If you miss anything just tell me and I'll add it right away.

Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sun 28/04/2013 18:17:47
That looks to be a bug in AGS's TextWindow system. I will forward it on to the engine team.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Sun 28/04/2013 19:10:55
I am yet to check this, but it looks like the bug I was fixing recently, related to alpha blending on gui:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=47666.0
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sun 28/04/2013 19:15:28
I dont think so. It seems to only be related to TextWindow GUIs. Font rendering on other GUIs works fine.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Sun 28/04/2013 19:42:27
Hmm, well, at the moment I can tell only that the surface bitmap IS 32-bit. But the drawing algorythm there is a bit complicated...

E: I believe it is related strictly to magic pink (transparent color). I've already saw similar problems when blending translucent buttons over gui with magic pink areas.

EE: I must be mistaken. Although the surface seem to be 32-bit, the alpha channel is definitely lost at some point. More simple way to see this is to assign translucent sprite as Text Window background.
This might be due some drawing operation used.


EEE: Ok, the last guess was right, it simply discarded alpha channel at the point of creating a renderer-compatible bitmap.
Quick-fix won't do, because simply forcing alpha there will make text window borders dissapear :).
Need more careful approach.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: san.daniele on Sun 28/04/2013 20:19:57
Quote from: Calin Leafshade on Sun 28/04/2013 19:15:28
It seems to only be related to TextWindow GUIs. Font rendering on other GUIs works fine.

It's even more specific. Using SetTextWindowGUI has no problems with rendering the text in said TextGUI. It's just the dialog options that don't work.

p.s. does it make sense to discuss this further in here? As this is apparently only remotely related to the plugin.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Sun 28/04/2013 20:23:07
Quote from: san.daniele on Sun 28/04/2013 20:19:57
p.s. does it make sense to discuss this further in here? As this is apparently only remotely related to the plugin.
Right, sorry. Calin made the issue post here: http://www.adventuregamestudio.co.uk/forums/index.php?issue=405.0
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Knox on Sun 15/09/2013 20:04:57
(Sorry for re-opening)

Everything worked great with this plugin up until now: I was fiddling with it today (since looking into how to maybe make my own) and I'm not sure but perhaps I found a possible bug?

If my GUI label is set to "Inventory" from within the editor at the start of the game, but then I change it via script later after a button is pressed to something else ("Closeup", for example),
Code (ags) Select
lblInventoryTitle.Text = "Closeup";

...the new title text gets clipped after the 1st character (All I see is "C" as the GUI's new title).
To debug, I tested this using a standard font, and the title switches without that clipping.

What would I have to do to get around that?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sun 15/09/2013 21:17:15
Could you try making the label a little taller.

I think it might not be cutting it off but rather forcing new lines. See if the rest of the text is just on a new line.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Knox on Sun 15/09/2013 23:46:51
Ok so I tried making the label taller (even really tall values like 400, to test)...still everything but the 1st character gets truncated. I'll continue to do more tests to see if I can pinpoint it.

Ok so I found the prob: my font sheet only has capital letters, so yeah, I'm retarded, lol! :tongue:
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Eakins on Tue 29/10/2013 16:20:25
Okay dumb question time: where do I put the PNG file that SpriteFont.exe produces? :confused:

My game_start function looks like this and obviously it's missing something to work but I don't know what:
Code (ags) Select
function game_start()
{
SetGlyph(0, 32, 8, 8, 3, 14);
SetGlyph(0, 33, 19, 8, 1, 14);
SetGlyph(0, 34, 28, 8, 3, 14);
SetGlyph(0, 35, 39, 8, 5, 14);
SetGlyph(0, 36, 52, 8, 5, 14);
SetGlyph(0, 37, 65, 8, 7, 14);
SetGlyph(0, 38, 80, 8, 4, 14);
SetGlyph(0, 39, 92, 8, 1, 14);
SetGlyph(0, 40, 101, 8, 2, 14);
SetGlyph(0, 41, 111, 8, 2, 14);
SetGlyph(0, 42, 121, 8, 5, 14);
SetGlyph(0, 43, 134, 8, 5, 14);
SetGlyph(0, 44, 147, 8, 2, 14);
SetGlyph(0, 45, 157, 8, 3, 14);
SetGlyph(0, 46, 168, 8, 1, 14);
SetGlyph(0, 47, 177, 8, 5, 14);
SetGlyph(0, 48, 8, 30, 4, 14);
SetGlyph(0, 49, 20, 30, 2, 14);
SetGlyph(0, 50, 30, 30, 4, 14);
SetGlyph(0, 51, 42, 30, 4, 14);
SetGlyph(0, 52, 54, 30, 4, 14);
SetGlyph(0, 53, 66, 30, 4, 14);
SetGlyph(0, 54, 78, 30, 4, 14);
SetGlyph(0, 55, 90, 30, 4, 14);
SetGlyph(0, 56, 102, 30, 4, 14);
SetGlyph(0, 57, 114, 30, 4, 14);
SetGlyph(0, 58, 126, 30, 1, 14);
SetGlyph(0, 59, 135, 30, 2, 14);
SetGlyph(0, 60, 145, 30, 3, 14);
SetGlyph(0, 61, 156, 30, 3, 14);
SetGlyph(0, 62, 167, 30, 3, 14);
SetGlyph(0, 63, 178, 30, 4, 14);
SetGlyph(0, 64, 8, 52, 8, 14);
SetGlyph(0, 65, 24, 52, 4, 14);
SetGlyph(0, 66, 36, 52, 4, 14);
SetGlyph(0, 67, 48, 52, 4, 14);
SetGlyph(0, 68, 60, 52, 4, 14);
SetGlyph(0, 69, 72, 52, 4, 14);
SetGlyph(0, 70, 84, 52, 4, 14);
SetGlyph(0, 71, 96, 52, 4, 14);
SetGlyph(0, 72, 108, 52, 4, 14);
SetGlyph(0, 73, 120, 52, 1, 14);
SetGlyph(0, 74, 129, 52, 3, 14);
SetGlyph(0, 75, 140, 52, 4, 14);
SetGlyph(0, 76, 152, 52, 3, 14);
SetGlyph(0, 77, 163, 52, 5, 14);
SetGlyph(0, 78, 176, 52, 5, 14);
SetGlyph(0, 79, 189, 52, 4, 14);
SetGlyph(0, 80, 8, 74, 4, 14);
SetGlyph(0, 81, 20, 74, 4, 14);
SetGlyph(0, 82, 32, 74, 4, 14);
SetGlyph(0, 83, 44, 74, 4, 14);
SetGlyph(0, 84, 56, 74, 5, 14);
SetGlyph(0, 85, 69, 74, 4, 14);
SetGlyph(0, 86, 81, 74, 5, 14);
SetGlyph(0, 87, 94, 74, 5, 14);
SetGlyph(0, 88, 107, 74, 4, 14);
SetGlyph(0, 89, 119, 74, 5, 14);
SetGlyph(0, 90, 132, 74, 4, 14);
SetGlyph(0, 91, 144, 74, 2, 14);
SetGlyph(0, 92, 154, 74, 5, 14);
SetGlyph(0, 93, 167, 74, 2, 14);
SetGlyph(0, 94, 177, 74, 3, 14);
SetGlyph(0, 95, 188, 74, 3, 14);
SetGlyph(0, 96, 8, 96, 2, 14);
SetGlyph(0, 97, 18, 96, 4, 14);
SetGlyph(0, 98, 30, 96, 4, 14);
SetGlyph(0, 99, 42, 96, 4, 14);
SetGlyph(0, 100, 54, 96, 4, 14);
SetGlyph(0, 101, 66, 96, 4, 14);
SetGlyph(0, 102, 78, 96, 3, 14);
SetGlyph(0, 103, 89, 96, 4, 14);
SetGlyph(0, 104, 101, 96, 4, 14);
SetGlyph(0, 105, 113, 96, 1, 14);
SetGlyph(0, 106, 122, 96, 2, 14);
SetGlyph(0, 107, 132, 96, 4, 14);
SetGlyph(0, 108, 144, 96, 1, 14);
SetGlyph(0, 109, 153, 96, 7, 14);
SetGlyph(0, 110, 168, 96, 4, 14);
SetGlyph(0, 111, 180, 96, 4, 14);
SetGlyph(0, 112, 8, 118, 4, 14);
SetGlyph(0, 113, 20, 118, 4, 14);
SetGlyph(0, 114, 32, 118, 3, 14);
SetGlyph(0, 115, 43, 118, 4, 14);
SetGlyph(0, 116, 55, 118, 3, 14);
SetGlyph(0, 117, 66, 118, 4, 14);
SetGlyph(0, 118, 78, 118, 4, 14);
SetGlyph(0, 119, 90, 118, 5, 14);
SetGlyph(0, 120, 103, 118, 4, 14);
SetGlyph(0, 121, 115, 118, 4, 14);
SetGlyph(0, 122, 127, 118, 3, 14);
SetGlyph(0, 123, 138, 118, 3, 14);
SetGlyph(0, 124, 149, 118, 1, 14);
SetGlyph(0, 125, 158, 118, 3, 14);
SetGlyph(0, 126, 169, 118, 4, 14);
SetGlyph(0, 161, 181, 118, 1, 14);
SetGlyph(0, 162, 8, 140, 4, 14);
SetGlyph(0, 163, 20, 140, 4, 14);
SetGlyph(0, 164, 32, 140, 5, 14);
SetGlyph(0, 165, 45, 140, 5, 14);
SetGlyph(0, 166, 58, 140, 1, 14);
SetGlyph(0, 167, 67, 140, 4, 14);
SetGlyph(0, 168, 79, 140, 3, 14);
SetGlyph(0, 169, 90, 140, 8, 14);
SetGlyph(0, 170, 106, 140, 3, 14);
SetGlyph(0, 171, 117, 140, 6, 14);
SetGlyph(0, 172, 131, 140, 3, 14);
SetGlyph(0, 173, 142, 140, 3, 14);
SetGlyph(0, 174, 153, 140, 8, 14);
SetGlyph(0, 175, 169, 140, 3, 14);
SetGlyph(0, 176, 180, 140, 3, 14);
SetGlyph(0, 177, 191, 140, 5, 14);
SetGlyph(0, 178, 8, 162, 3, 14);
SetGlyph(0, 179, 19, 162, 3, 14);
SetGlyph(0, 180, 30, 162, 2, 14);
SetGlyph(0, 181, 40, 162, 4, 14);
SetGlyph(0, 182, 52, 162, 5, 14);
SetGlyph(0, 183, 65, 162, 1, 14);
SetGlyph(0, 184, 74, 162, 2, 14);
SetGlyph(0, 185, 84, 162, 2, 14);
SetGlyph(0, 186, 94, 162, 3, 14);
SetGlyph(0, 187, 105, 162, 6, 14);
SetGlyph(0, 188, 119, 162, 9, 14);
SetGlyph(0, 189, 136, 162, 10, 14);
SetGlyph(0, 190, 154, 162, 10, 14);
SetGlyph(0, 191, 172, 162, 4, 14);
SetGlyph(0, 192, 184, 162, 4, 14);
SetGlyph(0, 193, 196, 162, 4, 14);
SetGlyph(0, 194, 8, 184, 4, 14);
SetGlyph(0, 195, 20, 184, 4, 14);
SetGlyph(0, 196, 32, 184, 4, 14);
SetGlyph(0, 197, 44, 184, 4, 14);
SetGlyph(0, 198, 56, 184, 7, 14);
SetGlyph(0, 199, 71, 184, 4, 14);
SetGlyph(0, 200, 83, 184, 4, 14);
SetGlyph(0, 201, 95, 184, 4, 14);
SetGlyph(0, 202, 107, 184, 4, 14);
SetGlyph(0, 203, 119, 184, 4, 14);
SetGlyph(0, 204, 131, 184, 2, 14);
SetGlyph(0, 205, 141, 184, 2, 14);
SetGlyph(0, 206, 151, 184, 3, 14);
SetGlyph(0, 207, 162, 184, 3, 14);
SetGlyph(0, 208, 173, 184, 5, 14);
SetGlyph(0, 209, 186, 184, 5, 14);
SetGlyph(0, 210, 8, 206, 4, 14);
SetGlyph(0, 211, 20, 206, 4, 14);
SetGlyph(0, 212, 32, 206, 4, 14);
SetGlyph(0, 213, 44, 206, 4, 14);
SetGlyph(0, 214, 56, 206, 4, 14);
SetGlyph(0, 215, 68, 206, 5, 14);
SetGlyph(0, 216, 81, 206, 5, 14);
SetGlyph(0, 217, 94, 206, 4, 14);
SetGlyph(0, 218, 106, 206, 4, 14);
SetGlyph(0, 219, 118, 206, 4, 14);
SetGlyph(0, 220, 130, 206, 4, 14);
SetGlyph(0, 221, 142, 206, 5, 14);
SetGlyph(0, 222, 155, 206, 4, 14);
SetGlyph(0, 223, 167, 206, 4, 14);
SetGlyph(0, 224, 179, 206, 4, 14);
SetGlyph(0, 225, 191, 206, 4, 14);
SetGlyph(0, 226, 8, 228, 4, 14);
SetGlyph(0, 227, 20, 228, 4, 14);
SetGlyph(0, 228, 32, 228, 4, 14);
SetGlyph(0, 229, 44, 228, 4, 14);
SetGlyph(0, 230, 56, 228, 7, 14);
SetGlyph(0, 231, 71, 228, 4, 14);
SetGlyph(0, 232, 83, 228, 4, 14);
SetGlyph(0, 233, 95, 228, 4, 14);
SetGlyph(0, 234, 107, 228, 4, 14);
SetGlyph(0, 235, 119, 228, 4, 14);
SetGlyph(0, 236, 131, 228, 2, 14);
SetGlyph(0, 237, 141, 228, 2, 14);
SetGlyph(0, 238, 151, 228, 3, 14);
SetGlyph(0, 239, 162, 228, 3, 14);
SetGlyph(0, 240, 173, 228, 4, 14);
SetGlyph(0, 241, 185, 228, 4, 14);
SetGlyph(0, 242, 8, 250, 4, 14);
SetGlyph(0, 243, 20, 250, 4, 14);
SetGlyph(0, 244, 32, 250, 4, 14);
SetGlyph(0, 245, 44, 250, 4, 14);
SetGlyph(0, 246, 56, 250, 4, 14);
SetGlyph(0, 247, 68, 250, 5, 14);
SetGlyph(0, 248, 81, 250, 5, 14);
SetGlyph(0, 249, 94, 250, 4, 14);
SetGlyph(0, 250, 106, 250, 4, 14);
SetGlyph(0, 251, 118, 250, 4, 14);
SetGlyph(0, 252, 130, 250, 4, 14);
SetGlyph(0, 253, 142, 250, 4, 14);
SetGlyph(0, 254, 154, 250, 4, 14);
SetGlyph(0, 255, 166, 250, 4, 14);
}
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Tue 29/10/2013 17:23:08
You load it as a sprite like any other sprite and then pass the sprite number to the SetGlyph function as the first parameter.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Daniel Eakins on Tue 29/10/2013 18:00:38
Oh right! :shocked: Thanks, it works now. This plugin is perfect for translations and support for 256-character fonts.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: JSH on Thu 31/10/2013 12:55:48
I must say this is an awesome plugin, pretty much the only way to get a flawless result in AGS regarding fonts. Great work Calin, gave you a spot in the credits :)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Igor Hardy on Mon 04/11/2013 21:15:08
Great plugin. Thanks, Calin!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Monsieur OUXX on Thu 14/11/2013 20:55:11
More detailed guidelines, courtesy of Daniel Eakins :

Quote
1) Once you have downloaded Calin's plugin, you have to launch "SpriteFont.exe". This is program will create two files: "Texture.png" and "Metrics.xml". Make sure you select the ranges of characters that you want to include in your future font (in the cart icon):
(http://i.imgur.com/FitIg3t.jpg)
2) In AGS, activate AGSSpriteFont in the Plugins icon in the right panel.
3) Import "Texture.png" as a sprite.
4) In function game_start(), type a SetVariableSpriteFont(AAA, BBB) command (where AAA is the font slot you want to use, such as 0, and BBB is the number of the sprite you have just imported).
5) Launch "AGSSpriteFontGen.exe" and open "Metrics.xml" in it to get some AGS coding. Paste that coding in function game_start() after the SetVariableSpriteFont command.

That's all, that should work. The best thing about this plugin is that you can open "Texture.png" in any image editor if you want to edit the font pixel by pixel. Also check Calin's first post in his thread (http://www.adventuregamestudio.co.uk/forums/index.php?topic=44359.0) to understand what the coding you get from "AGSSpriteFontGen.exe" means if you want to also edit that.



Also, for all those interested in multilingual fonts, this page could come handy : http://www.adventuregamestudio.co.uk/wiki/Fonts
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: is a cool guy. on Fri 03/01/2014 06:23:55
How do I apply a tint to a sprite font? I read in a previous reply that tinting was implemented, but changing the font colour of my labels doesn't seem to do anything. Am I doing it wrong?

Edit: I also ran into the new line bug when not all of my characters were defined. Here's a suggestion: have SetVariableSpriteFont take a height parameter to use as the default height when some characters are used but not defined. It would make building and testing incomplete fonts a bit easier. That said, variable heights seem to inconsistently alter the line height anyway, so maybe it'd be an idea to remove that parameter from SetGlyph.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Fri 03/01/2014 23:47:53
Tinting should be automatic and follow the label color. Tinting is multiplicative not additive so white = your tint color, black = black.

As for the line height, yea youre right that it probably doesnt handle it very well. I'll consider changing for the next version (which will be OOP)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Gurok on Sat 04/01/2014 02:06:25
Thanks Calin! The white/black thing sent me in the right direction. Importantly, I found you must also use the file from page 3 of this thread. The file in the original post has not been updated to support tinting.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Gurok on Sun 05/01/2014 16:56:24
I have a 9 pixel high font with 1 pixel of spacing. In GUI windows, the spacing looks correct. In Text windows, however, the vertical spacing appears to be ignored. GetTextHeight also returns 18 for two lines of text. I'm thinking there's some bug with sprite fonts and text windows, but it's also possible I've overlooked something. Any ideas?

(http://i.imgur.com/1FW9X3b.png)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Calin Leafshade on Sun 05/01/2014 20:25:29
The rendering should be same either way from the plugins point of view. I will investigate.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Gurok on Sun 26/01/2014 13:35:41
Any luck on that text v/s GUI line spacing issue, Calin?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Gurok on Thu 27/03/2014 13:54:24
I have worked out what this is, Calin.

From line 229 of graphics_mode.cpp, labels use this value for font height:

usetup.textheight = wgetfontheight(0) + 1;

And regular fonts in text window GUIs use this value for font height (display.cpp, line 94):

texthit = wgetfontheight(usingfont);

I am not sure what the best course of action is here. Breaking font height handling in labels would probably break legacy code.

The ideal would be for both to use wgetfontheight(n) + line_spacing, but that would require some kind of switch between legacy<-->rational mode.

For now, I might have to stick to single line descriptions in GUIs and just add 1 to the overall font height.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Thu 27/03/2014 14:00:19
Quote from: Gurok on Thu 27/03/2014 13:54:24
I am not sure what the best course of action is here. Breaking font height handling in labels would probably break legacy code.
<...>
The ideal would be for both to use wgetfontheight(n) + line_spacing, but that would require some kind of switch between legacy<-->rational mode.
There are simple ways to deal with compatibility, that's what I explained in regards to your very first pull request - checking game data version.
(Or against GUI version - if you were adding new properties to gui class)
In this case there may be a global variable (well, "global" by scope of applicance, not in C meaning) that defines message spacing, 0 for old games and 1 (or settable) for new ones.

Also I don't think GUI should use this usetup.textheight. Looking at its usage in code - it appears to be a very old legacy way to define text height, and it is used mostly in "built-in" dialogs. The only "new" gui using it is GUILabel. Maybe it was "forgotten" there.

EDIT: Wait... I've got confused myself. On more close examination, labels do not use usetup.textheight. They calculate their line height as
Code (cpp) Select

TEXT_HT = wgettextheight("ZhypjIHQFb", font) + 1;

The source of confusion is that TEXT_HT is also a macro defined as "usetup.textheight", but that macro is declared only for old built-in dialogs. And, there's a second set of control classes that are created on built-in dialogs, including label (MyLabel)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Gurok on Thu 27/03/2014 23:09:47
Quote from: Crimson Wizard on Thu 27/03/2014 14:00:19
Quote from: Gurok on Thu 27/03/2014 13:54:24
I am not sure what the best course of action is here. Breaking font height handling in labels would probably break legacy code.
<...>
The ideal would be for both to use wgetfontheight(n) + line_spacing, but that would require some kind of switch between legacy<-->rational mode.
There are simple ways to deal with compatibility, that's what I explained in regards to your very first pull request - checking game data version.
(Or against GUI version - if you were adding new properties to gui class)
In this case there may be a global variable (well, "global" by scope of applicance, not in C meaning) that defines message spacing, 0 for old games and 1 (or settable) for new ones.

Well, yeah, checking against the game data version or the GUI version is what I wanted to avoid, as that would provide no way for people to obtain the legacy behaviour when compiling in a new version of AGS. I wanted to ensure things wouldn't break for people with old projects.

I think your second suggestion is probably the way to go if I understand it correctly. e.g.:

Code (ags) Select
game.use_global_line_spacing = true;
game.global_line_spacing = 1;


And in the default game template, we could just define:

Code (ags) Select
game.use_global_line_spacing = true;

Thus preserving old behaviour for people upgrading to 3.3.1 (or whatever). I'm sorry. I didn't mean to give you the impression that I wasn't taking note when you told me about checking against game versions. I just meant that it wasn't straightforward and I wanted to avoid complicating the API where possible. For instance, I think defining a number like:

Code (ags) Select
game.message_line_spacing = 0;

Might be too much because then game authors would need knowledge of how message spacing works (message_line_spacing + global_line_spacing = actual_line_spacing).
Quote

EDIT: Wait... I've got confused myself. On more close examination, labels do not use usetup.textheight. They calculate their line height as
Code (cpp) Select

TEXT_HT = wgettextheight("ZhypjIHQFb", font) + 1;

The source of confusion is that TEXT_HT is also a macro defined as "usetup.textheight", but that macro is declared only for old built-in dialogs. And, there's a second set of control classes that are created on built-in dialogs, including label (MyLabel)

Yes, sorry about that. I did get confused. I ended up looking at MyLabel last night because I think I just jumped to the first label definition I found. The principle is the same for both though. That pesky +1. I need to stop and consider things a bit more before I post sometimes though.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Thu 27/03/2014 23:16:41
I am not sure I understand why you need two "spacings" and not just one for "message box". Are we talking about same problem? I've got an impression that you just needed extra spacing for Display box.


E: Uh, and I just realized that we are spamming this into Calin's plugin thread :tongue:
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Dropped Monocle Games on Wed 21/01/2015 19:59:32
Quote from: Gurok on Sat 04/01/2014 02:06:25
Thanks Calin! The white/black thing sent me in the right direction. Importantly, I found you must also use the file from page 3 of this thread. The file in the original post has not been updated to support tinting.
Sorry to open this but I'm having a little problem,
The link on page 3 is broken and I'm using download from page 1


everything is working great apart from I can't seem to get tinting to work, should it work with .say and the colour set by the characters speech colour? if not is there a way for me to change colours for different characters speaking?
I have set my font sprite to be white with a black outline/shadow.
Really sorry if I have misunderstood this
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Gurok on Thu 22/01/2015 10:43:45
Yes, all was broken for me too until I got the magic version. Here's the one I'm using, Soxbrooker:

http://goo.gl/5xo2v7 (http://goo.gl/5xo2v7)

I believe it should use the character's speech colour, but I haven't tested that recently. I know that drawing to surfaces works, e.g.:

surface.DrawingColor = 14; // Set to yellow
surface.DrawStringWrapped(1 + offset1, 1, widthMax - 1, font1, align, text1); // Draw some text in yellow
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Dropped Monocle Games on Thu 22/01/2015 18:09:32
Awesome yeah, that worked great! Thank you :D
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: nims on Mon 06/04/2015 15:28:16
I am very interested in this plugin and the tool "Spritefont.exe". It seems that almost all download links are broken. Does anyone have a copy that he/she wishes to share?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: nims on Thu 09/04/2015 21:30:28
Well, I did some carefull digging and found the sources at:

https://github.com/CalinLeafshade/ags-spritefont

So I fired up visual studio and recompiled all. Als I've found the original spritefont tool, so added this to the package at all.

It is working in my AGS game, so grab your binaries here:
https://dl.dropboxusercontent.com/u/20918686/ags/ags_sprtitefont.zip
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Monsieur OUXX on Fri 10/04/2015 10:17:16
thanks a lot nims! Broken links are always a pain.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: JSH on Thu 10/09/2015 11:19:09
Hey Calin, it looks like the source on github wasn't updated after the tinting fix. Would it be possible to have that uploaded? :)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Aaron Best on Tue 19/12/2017 16:18:46
Sorry to dig this up

Does anyone have a working link to a compiled version

Thanks
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Honza on Mon 09/04/2018 12:27:18
Another attempt to bump this up, a link to a compiled version would be great! Thanks.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Mon 09/04/2018 13:29:39
Here: https://www.dropbox.com/s/k67znqeiyk8juic/AGSSpriteFont.zip?dl=0

Not sure if it works, just built it, not tested.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Honza on Mon 09/04/2018 13:45:18
Perfect, thank you!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Honza on Tue 10/04/2018 23:32:16
Works like a charm, but manually setting up the character widths is a pain. Any chance of also getting my hands on AGSSpriteFontGen.exe mentioned in the first post?

Also if I'm using a sprite font for dialogue options, they don't highlight on mouseover anymore. Any way around this? Maybe the version with tinting... ?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Wed 11/04/2018 00:37:43
Quote from: Honza on Tue 10/04/2018 23:32:16
Works like a charm, but manually setting up the character widths is a pain. Any chance of also getting my hands on AGSSpriteFontGen.exe mentioned in the first post?

Probably this: https://www.dropbox.com/s/n1hwnh2kqikja6c/AGSSpriteFontGen.zip?dl=0
In Calin's repository project is called "agssprite-helper", but output file is AGSSpriteFontGen.exe.

Quote from: Honza on Tue 10/04/2018 23:32:16
Also if I'm using a sprite font for dialogue options, they don't highlight on mouseover anymore. Any way around this? Maybe the version with tinting... ?
I don't know how spritefont works, but if it does not support glyth recoloring itself, you would need to write the custom dialog options rendering script.
For example, create second font from the same images, applying tint (DynamicSprite.Tint). Then in the dialog rendering script choose either font depending on whether option is active or not.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Honza on Wed 11/04/2018 09:55:22
That's it, thanks once more, this makes it really easy to use. Not up to writing a custom dialog rendering script just yet, still a relative AGS beginner, but might get there eventually. Too bad the version of the plugin with tinting functionality isn't available anymore :/. This is a great plugin otherwise.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Wed 11/04/2018 10:26:35
I built the plugin from Calin's repository this time, but from the quick glance on the code the difference is negligible, and also I do not see "color" parameter being used anywhere, so idk if tinting work: https://www.dropbox.com/s/tcdmy3meuh3ml4f/ags-spritefont-plugin.zip?dl=0

Calin has mentioned working tinting same day he created repository, so maybe he just forgot to push latest code there.

UPD: I noticed higher in this thread Gurok said that he has the version with tinting, and the download link still works.
Quote from: Gurok on Thu 22/01/2015 10:43:45
Yes, all was broken for me too until I got the magic version. Here's the one I'm using, Soxbrooker:

http://goo.gl/5xo2v7 (http://goo.gl/5xo2v7)

I believe it should use the character's speech colour, but I haven't tested that recently. I know that drawing to surfaces works, e.g.:

surface.DrawingColor = 14; // Set to yellow
surface.DrawStringWrapped(1 + offset1, 1, widthMax - 1, font1, align, text1); // Draw some text in yellow

Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Honza on Wed 11/04/2018 13:01:41
Overlooked that one, tried it and everything works now! I'm in your debt sir :)
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: imsomnia212 on Tue 07/08/2018 08:39:41
Sorry for bump this but anyone have a link of the SpriteFont.exe? I downloaded the dll and the generator but I need the creator
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: shaun9991 on Sat 19/02/2022 18:23:04
Sorry to dredge up this ancient post! I'm trying to get my head around this plugin but have reached a roadblock with SpriteFont 2.0.

In the list of available fonts, the font I want doesn't actually appear on the list, despite being installed on my computer. (The font I want to use is called Munro Regular)

(https://tinyimg.io/i/lWnb2Lk.PNG)

Long shot, but does anyone have any idea why SpriteFont doesn't show all the fonts installed on your computer and if there is any way around this?

Thanks!
Shaun
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: fernewelten on Sat 19/02/2022 23:48:49
Quote from: shaun9991 on Sat 19/02/2022 18:23:04
Long shot, but does anyone have any idea why SpriteFont doesn't show all the fonts installed on your computer and if there is any way around this?

Inkscape may have had just this problem, or used to have:

See to it that your font is"installed  for all users", not only "installed". (Right-click on the font, choose "Install for all users"). I think in the olden times there wasn't any other way of installing fonts than installing them for all users. The option to install a font only for the current user is new. So programs that predate this innovation will only read the fonts that are installed "for all users" and not know about the others.
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: shaun9991 on Sun 20/02/2022 11:09:00
That worked! Thank you so much :)

I would never have thought of that!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: fernewelten on Mon 21/02/2022 16:44:33
AFAICS, there are ways to download SpriteFont although the company that produced it doesn't have it on their homepage anymore. I found the following download location via Bing: https://download.freedownloadmanager.org/Windows-PC/SpriteFont/FREE-2.0.1.html

But the old download address of the AGS plugin has become unavailable. And I haven't been able to turn up a download location for the executable "AGSSpriteFontGen.exe" either.

So, where can you download the plugin now? Are there perhaps even sources available somewhere?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: eri0o on Mon 21/02/2022 17:12:57
The sources are available here: https://github.com/CalinLeafshade/ags-spritefont
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Crimson Wizard on Mon 21/02/2022 17:15:53
There are also SpriteFont sources in AGS repository, with some later fixes:
https://github.com/adventuregamestudio/ags/tree/master/Plugins/AGSSpriteFont
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: shaun9991 on Mon 21/02/2022 17:26:41
Thanks everyone.

I've got it all up and running nicely, but have one issue left. No matter how much I seem to adjust the glyph settings manually, there is always slightly too much space between words. See below.

(https://tinyimg.io/i/t94d5S7.PNG)

I'd like this gap to be two pixels less, as it with a normal font in AGS (below).

(https://tinyimg.io/i/6qyMD8h.PNG)

To get this correctly, would I have to adjust settings in SpriteFont 2.0 before generating the template/metrics file?

I'm using a font called Munro - generating the template and metric file, then manually adding a black outline to the text using Aseprite. I then manually adjust the the glyph code generated in AGSSpriteFontGen to get things aligned properly, but the "slightly too big" spacing remains.

I hope that makes sense. I can paste the code here if that helps.

Many thanks,
Shaun
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: shaun9991 on Mon 21/02/2022 21:06:13
Please ignore my ramblings above, I worked it out!

Didn't realise I could still use OutlineStyle - Automatic with the spritefont!!
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: AndreasBlack on Tue 29/03/2022 21:10:06
Links appear dead for SpriteFont 2.0, anyone?
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Dualnames on Mon 25/04/2022 07:46:21
https://spritefont.software.informer.com/download/
Title: Re: Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.
Post by: Dualnames on Mon 25/04/2022 09:22:43
Has anyone used this with a lot of characters? I'm trying to do 1238 individual glyphs, no errors but I'm quite sure this is not correct either.