Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.

Started by Calin Leafshade, Fri 02/09/2011 21:30:53

Previous topic - Next topic

Calin Leafshade

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

Code: ags

//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:



the function for this one would be:

Code: ags

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


Code: ags

void SetVariableSpriteFont(int fontNum, int sprite);


This overrides font 'fontNum' with sprite 'sprite'

Code: ags

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

Code: ags

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:


Ghost

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!

Calin Leafshade

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.

Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Calin Leafshade

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)

Calin Leafshade

Updated to support variable width fonts

See first post.

Dualnames

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
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Knox

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 :)
--All that is necessary for evil to triumph is for good men to do nothing.

Calin Leafshade

Bugs are possible so bug reports would be nice if anyone tries it out.

Monsieur OUXX

Thanks for the variable width functions. That will come handy.
 

David Ostman

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?

Calin Leafshade

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.

Icey

yay! I wasn't even aware of this topic. Now I can try and use that font.

StillInThe90s

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.

Khris

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.


None

In a game I'm working on I want to use your plugin, I installed it and created a bitmap font:

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

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.

Calin Leafshade

use the function for variable width fonts. currently you are using the fixed width font function.

None

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.

Crimson Wizard

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?

Calin Leafshade

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.

Knox

I'd like to re-download this plugin but the link seems to be broken. Would anyone have a copy somewhere?
--All that is necessary for evil to triumph is for good men to do nothing.

JSH

*edit nevermind, better link below :)

Khris

Could you upload the helper programs, too?

Or could you, Calin?

Somebody?

Calin Leafshade

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

Daniel Thomas

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?
Check out The Journey of Iesir Demo | Freelance artist, check out my Portfolio

Calin Leafshade

There's no reason it shouldnt work in D3D...

Whats the error?

Daniel Thomas

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

Check out The Journey of Iesir Demo | Freelance artist, check out my Portfolio

Calin Leafshade


Daniel Thomas

When trying with DD5 the first text-message is a Display(), based on what text message say.
Check out The Journey of Iesir Demo | Freelance artist, check out my Portfolio

JJS

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.
Ask me about AGS on PSP, Android and iOS! Source, Daily builds

Calin Leafshade

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.

Sslaxx

Any way of setting the font colour used separate from the sprite? So if you wanted it displayed in black, it would be?
Stuart "Sslaxx" Moore.

Lake A.

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! :)

Khris

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".

Calin Leafshade

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.




Lake A.

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!

Khris

Pretty difficult to see the mistake without looking at your code, right...?

Daniel Thomas

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. :)
Check out The Journey of Iesir Demo | Freelance artist, check out my Portfolio

Calin Leafshade

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

san.daniele

#40
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!!

san.daniele

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


// 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
 

JSH

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?

Daniel Thomas

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.
Check out The Journey of Iesir Demo | Freelance artist, check out my Portfolio

Calin Leafshade

My apologies, I completely forgot.

I shall begin today!

Calin Leafshade

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:



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

san.daniele

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).

Calin Leafshade



Daniel Thomas

#49
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)
Check out The Journey of Iesir Demo | Freelance artist, check out my Portfolio

Calin Leafshade

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.

Daniel Thomas

#51
Yes, that fixed it. :)

Check out The Journey of Iesir Demo | Freelance artist, check out my Portfolio

selmiak

is there a way to apply this to guis and especially text displayed on buttons and textboxes?

Calin Leafshade

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.

Ghost


san.daniele

#55
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]

Calin Leafshade

I can't reproduce the issue.

A demonstration game with the source would be useful.

san.daniele

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.


Calin Leafshade

That looks to be a bug in AGS's TextWindow system. I will forward it on to the engine team.

Crimson Wizard

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

Calin Leafshade

I dont think so. It seems to only be related to TextWindow GUIs. Font rendering on other GUIs works fine.

Crimson Wizard

#61
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.

san.daniele

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.

Crimson Wizard

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

Knox

(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
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?
--All that is necessary for evil to triumph is for good men to do nothing.

Calin Leafshade

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.

Knox

#66
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:
--All that is necessary for evil to triumph is for good men to do nothing.

Daniel Eakins

#67
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
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);
}
We all have our time machines, don't we?

Calin Leafshade

You load it as a sprite like any other sprite and then pass the sprite number to the SetGlyph function as the first parameter.

Daniel Eakins

Oh right! :shocked: Thanks, it works now. This plugin is perfect for translations and support for 256-character fonts.
We all have our time machines, don't we?

JSH

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 :)

Igor Hardy


Monsieur OUXX

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):

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 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
 

is a cool guy.

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.

Calin Leafshade

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)

Gurok

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.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Gurok

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?

[img]http://7d4iqnx.gif;rWRLUuw.gi

Calin Leafshade

The rendering should be same either way from the plugins point of view. I will investigate.

Gurok

Any luck on that text v/s GUI line spacing issue, Calin?
[img]http://7d4iqnx.gif;rWRLUuw.gi

Gurok

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.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

#80
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

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)

Gurok

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
game.use_global_line_spacing = true;
game.global_line_spacing = 1;


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

Code: ags
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
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

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.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Crimson Wizard

#82
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:

Dropped Monocle Games

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

Gurok

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

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.:

Code: ags
surface.DrawingColor = 14; // Set to yellow
surface.DrawStringWrapped(1 + offset1, 1, widthMax - 1, font1, align, text1); // Draw some text in yellow
[img]http://7d4iqnx.gif;rWRLUuw.gi

Dropped Monocle Games


nims

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?

nims

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

Monsieur OUXX

thanks a lot nims! Broken links are always a pain.
 

JSH

Hey Calin, it looks like the source on github wasn't updated after the tinting fix. Would it be possible to have that uploaded? :)

Aaron Best

Sorry to dig this up

Does anyone have a working link to a compiled version

Thanks

Honza

Another attempt to bump this up, a link to a compiled version would be great! Thanks.


Honza


Honza

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... ?

Crimson Wizard

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.

Honza

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.

Crimson Wizard

#97
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

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.:

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


Honza

Overlooked that one, tried it and everything works now! I'm in your debt sir :)

imsomnia212

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
Are u a tuna?

shaun9991

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)



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
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

fernewelten

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.

shaun9991

That worked! Thank you so much :)

I would never have thought of that!
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

fernewelten

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?



shaun9991

#106
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.



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



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
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

shaun9991

Please ignore my ramblings above, I worked it out!

Didn't realise I could still use OutlineStyle - Automatic with the spritefont!!
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

AndreasBlack


Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk