Jump to content

font border


noemen

Recommended Posts

I'm working a lot with the Torque3D GUI ... I noticed that it works with fonts that are installed on the pc. My question is: Can I put borders on these fonts? A white font with a black border ... I see that some games use custom fonts in a png file and they come colored and bordered.


I thought of putting one text on top of the other, with the back text being larger than the front and dark in color (this would be the border). But I realized it's the absurd idea lol

Link to comment
Share on other sites

What you first suggested is probably best and a lot less expensive, rendering of font is damn expensive to an engine lol this is why most games developed use the png format you described. I would create 2 versions, one that is just the text and another that is just the border both in white, that way you can change the color to whatever you want if later on down the line you dont want the text to be say red with a green border, you wont have to modify your png file for each character again u would just go into the editor and change the font colors there

Link to comment
Share on other sites

if u use what i said about splitting the border from the actual text then yeah, but this is the thing rendering 2 polygons to a screen is far better and easier than rendering the amount required by rendering an actual font to a screen. I cant remember but i know i read it somewhere that the amount of polygons required for rendering an actual font is colossal like we are talking near 20 polygons each character.

Link to comment
Share on other sites

so the way the font system works, is first the system looks under https://github.com/GarageGames/Torque3D/tree/9ebebc1f5ec93d52b2b1cba6e0625a3d5e0ff327/Templates/BaseGame/game/core/gui/scripts/fonts (https://github.com/GarageGames/Torque3D/tree/development/Templates/Full/game/core/fonts in the case of older builds) for an appropriately sized font file entry and tries to find the character within it. if it can't, it'll look up the system font of the same name. if it *still* can't, it'll fall back to a standard font.


this end, what we ended up doing is installing the font on my machine as a forinstance, and executing:

 

function populateAllFonts(%font)
{
   populateFontCacheRange(%font,14,0,65535);
   populateFontCacheRange(%font,18,0,65535);
   populateFontCacheRange(%font,24,0,65535);
   populateFontCacheRange(%font,32,0,65535);
   populateFontCacheRange(%font,36,0,65535);
}

 

which leverages https://github.com/GarageGames/Torque3D/blob/561f010f2e6411d8253d23f0cfcff794e81f60bf/Engine/source/gfx/gFont.cpp#L1052

which in turn lets everyone else use it without having to ship a system font installer along with the game one.

Link to comment
Share on other sites

so the way the font system works, is first the system looks under https://github.com/GarageGames/Torque3D/tree/9ebebc1f5ec93d52b2b1cba6e0625a3d5e0ff327/Templates/BaseGame/game/core/gui/scripts/fonts (https://github.com/GarageGames/Torque3D/tree/development/Templates/Full/game/core/fonts in the case of older builds) for an appropriately sized font file entry and tries to find the character within it. if it can't, it'll look up the system font of the same name. if it *still* can't, it'll fall back to a standard font.


this end, what we ended up doing is installing the font on my machine as a forinstance, and executing:

 

function populateAllFonts(%font)
{
   populateFontCacheRange(%font,14,0,65535);
   populateFontCacheRange(%font,18,0,65535);
   populateFontCacheRange(%font,24,0,65535);
   populateFontCacheRange(%font,32,0,65535);
   populateFontCacheRange(%font,36,0,65535);
}

 

which leverages https://github.com/GarageGames/Torque3D/blob/561f010f2e6411d8253d23f0cfcff794e81f60bf/Engine/source/gfx/gFont.cpp#L1052

which in turn lets everyone else use it without having to ship a system font installer along with the game one.

 

Got it now ... I'm learning a lot. I will work now with Torque3D, if I get a good result ... I will share here.

Link to comment
Share on other sites

It didn't work when I went to Chat ... Then I had an idea: I hid the dark background of Chat, and it is only visible if I call or if I hit PageUp (or PageDown). It was much more elegant. But in principle, the idea of ​​placing two fonts (one being the border) might work very well on other occasions; in buttons, texts and etc. When I'm on the notebook, I'll share it with you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...