FontHandler

FontHandler

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

FontHandler

Post by Argh »

1. Could fontTexture tool be made available somewhere around here? I am sorry in advance if it's here already, I can't seem to find it atm, and was looking at making a few custom fonts for UI stuff.

2. Could Spring just load up and auto-create font-sets for new fonts in a game's /fonts directory?

3. The behavior of this area of Spring has changed since 0.79.2, and the :n: parameter is now required.

That breaks a lot of UI mods, better let people know about it on release, if not before (i.e., I just found this while testing, fixed it, and there we are).
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

1. lua fontsystem is deprecated, don't use it
2+3. the commit messages comprehensively explain everything, read them (fonthandler update were 2-4 commits)

(and when you are doing so you could write an extensive changelog for 77->79 :mrgreen: )
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

I'm saying that between 0.79.2 and where we are now, something's gotten changed that broke the previous behavior, is all.

As for no. 1... so what is the favored path for using new fonts from here on out? All I wanted to know was how to use new TTF fonts for certain things...
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

Argh wrote:I'm saying that between 0.79.2 and where we are now, something's gotten changed that broke the previous behavior, is all.
nothing has changed. the 'n' param isn't even processed at all since 79.
Argh wrote:As for no. 1... so what is the favored path for using new fonts from here on out? All I wanted to know was how to use new TTF fonts for certain things...
read the commit messages
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

If somebody would explain to me how I'm supposed to view them, when the RSS feed from Git only shows the last few entries, I'll do that. I've been going here:

http://github.com/feeds/spring/commits/spring/master

And I'd really like to see a blow-by-blow that I can go back through, like I could with WebSVN, but I haven't had time to figure out how to get that overview again... this situation makes it really hard to follow what's going on, let alone document anything :P
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

github doesn't have a nice in commit search afaik (like websvn).
So you need to get git itself and download the repro, so you can use gitk. (there is a thread about using git with spring here on the forum)
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

So, in order to go back and see what you're referring to, I have to use Git?

That's... rather lame :| Why can't the RSS feed simply be configured to allow us to view previous entries on GitHub?
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: FontHandler

Post by aegis »

seems you can just look at commits individually
http://github.com/spring/spring/commits/master
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

That'll work. Certainly better than what I was using before. I don't mind having to wade through commits, I just couldn't find a blow-by-blow that would allow me to walk back through time.

So... jK... when did you do this, approximately?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

check history of the files? http://github.com/spring/spring/tree/master

PS: one of the files is LuaOpengl.cpp
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: FontHandler

Post by hoijui »

he said 2-4 months ago.
i think he means commit 1d191877b614c730c990a50d173e456e5e925d2c
i still recommend using gitk, all you need is initial git setup, and then git pull && gitk every time you want to check something.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

OK... so... this is the documentation:
lua interface for the new FontSystem:
gl.LoadFont( fontfile , size = 14, outlinewidth = 2, outlineweight = 15) ->
lua_font
gl.DeleteFont( lua_font )

lua_font userdata object:
font:Begin() -> nil
font:End() -> nil
font:Print( text, x, y, size, options ) -> nil
options is a string which can contain a combination of:
'c' := horizontal centered
'r' := right aligned
't' := top ..
'v' := vertical centered
'b' := bottom
'a' := ascender
's' := shadowed
'o'|'O' := outlined
font:WrapText( text, maxWidth, [maxHeight, [size]]) -> string wrappedText,
number lines
font:GetTextWidth( text ) -> norm_width
font:GetTextHeight( text ) -> height, descender
font:SetTextColor({r,g,b[,a]} || r,g,b[,a]) -> nil
font:SetOutlineColor({r,g,b[,a]} || r,g,b[,a]) -> nil
font:SetAutoOutlineColor( bool enable ) -> nil
By default the renderer auto adjust the outline color to the textColor,
but sometimes this is unwanted for inlined colorcodes,
so you can turn it off here.
font:BindTexture() -> nil

read-only properties:
font.size
font.height || font.lineheight
font.descender
font.outlinewidth
font.outlineweight
font.path
font.family
font.style
font.texturewidth
font.textureheight
That doesn't really answer my questions, though.

If we're supposed to use that instead of fontHandler, do we still have to use the bzFlag font tool? And if so, does anybody know where it can be found atm, or am I going to have to look at bzFlag's source?

And if not... is there a working example of this in CA atm? Or is nobody using this at all yet?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

fontfile := ttf,otf,... files

and no nothing is using it yet, but it's tested.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

OK... so basically we just load up a TTF, and it's now a named font object?

So...

local myNiftyFont = gl.LoadFont(myNifty.TTF,size = 14, outlinewidth = 2, outlineweight = 15)

Then...

myNiftyFont:Print(parameters)?

Sorry, but it's not entirely clear to me what the use case is based on what I'm reading. If it's that easy, that would be super-cool- it'd get rid of the need for gl.Text entirely...
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

o_O

1. fontfile is a string (thought this is obvious, and yeah it checks the vfs, too)
2. "size = 14" means there is a number param which defines the wanted size and its default is 14
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

So this is correct?

local myNiftyFont = gl.LoadFont("fonts/myNifty.TTF",size = 14, outlinewidth = 2, outlineweight = 15)

Sorry, it's late and I'm tired. If that's all there is to it, I'll have P.U.R.E. retrofitted this afternoon, after I get some sleep, and give out some working source using it, so that it won't be sitting around any more.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

you should have worked with lua long enough to see that your code isn't valid at all ...

to speed it up:
local myNiftyFont = gl.LoadFont("fonts/myNifty.TTF")
local myNiftyFont2 = gl.LoadFont("fonts/myNifty.TTF", 20) --glyphtexture is rendered with a fontsize of 20 (you can always use a different size with :Print(), but it would get interpolated)
local myNiftyFont3 = gl.LoadFont("fonts/myNifty.TTF", 10, 10, 10) --huge outline :x
User avatar
Evil4Zerggin
Posts: 557
Joined: 16 May 2007, 06:34

Re: FontHandler

Post by Evil4Zerggin »

What do font:Begin and font:End do?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: FontHandler

Post by jK »

it saves unneeded opengl state changes, try always to collect as many as possible of your text printings between such 'begin .. end's
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: FontHandler

Post by Argh »

Tested this. It's not exactly working right yet.

First test resulted in a crash upon initialization.

Second test resulted in the fonts loading, but it flickered on and off.

Third test resulted in a crash upon initialization.

Infolog attached.

Also... looking at it... how are we supposed to have different colors / properties for text in the same string?

That's one thing that fontHandler does that's pretty useful, and frankly I don't think this is an improvement unless it's there. Maybe a special character or characters that allow for new colors / options, so that long strings can be something like this:

myVal1#${1.0,1.0,0.5,0.5}..myVal2#${0.0,1.0,1.0,1.0}

That would be nifty, because it'd be a lot simpler to use. I'd happily get rid of every use of gl.Text and fontHandler in a heartbeat, if it worked that way.
Attachments
infolog.txt
(28.81 KiB) Downloaded 182 times
Last edited by Argh on 26 Jul 2009, 06:37, edited 1 time in total.
Post Reply

Return to “Engine”