Jibble

Author Topic: IAGSFontRenderer example  (Read 216 times)

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
IAGSFontRenderer example
« on: 26 Mar 2019, 21:28 »
So I've been reading about IAGSFontRenderer and it looks wonderful and perfect for what I wanna do.
I know how to get the part of what I wanna do (add an extra outline and a gradient effect) done, but my issue lies that I'm not able to make a plugin to work
Is there some sort of easy example,where I can replace the font renderer for font 1 let's say and use the RenderText() function so that I can 'edit' that bitmap?

I've tried looking at the agspritefont code, but there's parts of it that I'm not sure I get or need. So if anyone knows of a simple script to get me rolling that'd be nice.
Like a script that turns all the instances of a certain font to red, that'd be very useful and I could move on from there.
No more military army stuff. I'm alive and back.

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: IAGSFontRenderer example
« Reply #1 on: 26 Mar 2019, 22:43 »
To elaborate, I don't want to change the width of a font or the height, I just want to read the bitmap it returns, edit the bitmap and push it back to the screen, which is what Render does, but my efforts so far have only managed to get me to print an empty font on the screen as if I'm printing a cleared bitmap.
No more military army stuff. I'm alive and back.

Re: IAGSFontRenderer example
« Reply #2 on: 26 Mar 2019, 23:25 »
To elaborate, I don't want to change the width of a font or the height, I just want to read the bitmap it returns, edit the bitmap and push it back to the screen, which is what Render does, but my efforts so far have only managed to get me to print an empty font on the screen as if I'm printing a cleared bitmap.

I don't think that's possible, the idea of IFontRenderer is that you supply your own data (bitmaps or else). The bitmap it gives to you in Render is destination, a clear bitmap where you need to draw the text.
You would have to read a bitmap font from disk probably if you want to adjust it before displaying on screen.
« Last Edit: 26 Mar 2019, 23:28 by Crimson Wizard »

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: IAGSFontRenderer example
« Reply #3 on: 26 Mar 2019, 23:53 »
Alright better question, is there a way to pool/pull said bitmap from the engine, or does that heavily depend on renderer (software, d3d, opengl)?

What I'm also wondering is, is there an 'easy' way to render the font exactly as ags renders it and use render text then? I'm still trying to grasp the whole renderer thing, so apologies if I sound like bicilotti.
No more military army stuff. I'm alive and back.

Re: IAGSFontRenderer example
« Reply #4 on: 27 Mar 2019, 01:16 »
Alright better question, is there a way to pool/pull said bitmap from the engine, or does that heavily depend on renderer (software, d3d, opengl)?
If you mean - get bitmap with text just drawn on it, then answer is no. Plugin hooks only allow you to get "stage bitmap" which is a layer before room drawn / between room and gui / after gui.

What I'm also wondering is, is there an 'easy' way to render the font exactly as ags renders it and use render text then?

May I ask, what exactly are you trying to achieve?

If it is enough for you to draw some text in between rendering stages, e.g. over a room or over whole game, then you may use DrawText from plugin interface and then GetVirtualScreen to get screen bitmap with that text, which you may then edit further.

If you are drawing on some object, you could print it on Dynamic sprite in script and then work with that further (also in script).

But if you want to be able to adjust just any text in game no matter when and where it is drawn (GUI, speech, etc), then can't think of an easy way to do so. You may have to duplicate font drawing code from the engine in your IAGSFontRenderer implementation, and do necessary modifications to it.
« Last Edit: 27 Mar 2019, 01:23 by Crimson Wizard »

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: IAGSFontRenderer example
« Reply #5 on: 27 Mar 2019, 01:24 »
I'm trying to apply a gradient effect on fonts, I've managed to do it in code, and it's great and all, just it creates a couple of issues as well, and i think if i could redraw my font and edit that, it'd be better and more certain.
No more military army stuff. I'm alive and back.

Re: IAGSFontRenderer example
« Reply #6 on: 27 Mar 2019, 10:06 »
This may mean that plugin API is missing another type of hook: for getting intermediate bitmap with text before it gets drawn on screen.
On other hand, 1) text may be drawn on something else, like GUI bitmap; 2) someone suggested we switch to textures completely in the future. So that may not be a good idea to add.

Perhaps better alternative is to allow plugins to load in-game resources, which will let you use fonts from the main package, and draw them the way you like (assuming you copy font code from the engine).
Right now it will only work if you load fonts from game folder.

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    • Kweepa worked on one or more games that won an AGS Award!
    •  
    • Kweepa worked on one or more games that was nominated for an AGS Award!
Re: IAGSFontRenderer example
« Reply #7 on: 27 Mar 2019, 16:46 »
apologies if I sound like bicilotti.
Damn, harsh.
Also, what happened to that guy?  :~(
Still waiting for Purity of the Surf II

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: IAGSFontRenderer example
« Reply #8 on: 27 Mar 2019, 17:44 »
He's definitely around in irc!
No more military army stuff. I'm alive and back.

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: IAGSFontRenderer example
« Reply #9 on: 27 Mar 2019, 17:44 »
Anyhoo, I've managed to clean up my ags code so it seems to be working fine so need to set up the plugin.
No more military army stuff. I'm alive and back.

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: IAGSFontRenderer example
« Reply #10 on: 27 Mar 2019, 21:37 »
No more military army stuff. I'm alive and back.