Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.

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

Previous topic - Next topic

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?

SMF spam blocked by CleanTalk