Another Plugin: SpriteFont Renderer. Native Bitmap Fonts.

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

Previous topic - Next topic

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

SMF spam blocked by CleanTalk