Author Topic: setting the color of the font outline  (Read 906 times)

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on a game that won an AGS Award!
    •  
    • selmiak worked on a game that was nominated for an AGS Award!
setting the color of the font outline
« on: 20 Feb 2016, 20:32 »
It is easy to use the automatic outline function in AGS but then the outline is always black.
I use a bitmap font, looks good with the auto-outline, can I somehow use the auto-outline to generate the already outlined font as a new font so I can then somehow set the color of the outline font?
Or if I manually paint the outline with e.g. radiants editor and import the result as a new font to AGS, set the new outlinefont as the outline of the normal font, can I set the color of this outline font somwhere? When using a textlabel I only found settings for one font and only colorsettings for one font and that is for the normal font and not the outline of course.

Scavenger

  • Cavefish
  • In Four Glorious Colours!
    • I can help with animation
    • I can help with backgrounds
    • I can help with characters
    • I can help with scripting
    • Scavenger worked on a game that won an AGS Award!
    •  
    • Scavenger worked on a game that was nominated for an AGS Award!
Re: setting the color of the font outline
« Reply #1 on: 21 Feb 2016, 00:09 »
You can change the colour of the outline with:

Code: Adventure Game Studio
  1. game.text_shadow_color = x;

but that changes ALL outline colours. If you just want your label to have a specific outline colour, make a new label with an outline font, set the colour there, and overlay it over the top of the real label.

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on a game that won an AGS Award!
    •  
    • selmiak worked on a game that was nominated for an AGS Award!
Re: setting the color of the font outline
« Reply #2 on: 21 Feb 2016, 00:57 »

can I generate that outline font somehow within AGS or do I have to create it in a font editor?

sadly there is no
Code: Adventure Game Studio
  1. fontX.text_shadow_color = x;
in AGS.

Scavenger

  • Cavefish
  • In Four Glorious Colours!
    • I can help with animation
    • I can help with backgrounds
    • I can help with characters
    • I can help with scripting
    • Scavenger worked on a game that won an AGS Award!
    •  
    • Scavenger worked on a game that was nominated for an AGS Award!
Re: setting the color of the font outline
« Reply #3 on: 21 Feb 2016, 01:42 »
Unfortunately, you have to make it in a font editor.

AGS, I believe, doesn't even generate a font, it just draws the normal font at (X+1,Y), (X-1,Y),(X,Y+1) and (X,Y-1) underneath in the outline colour.

And I guess you could do that too, if you make the GUI Control a button instead of a label:

Code: Adventure Game Studio
  1. int text_color = 15;
  2. int outline_color = 16;
  3.  
  4. DynamicSprite *textlabel;
  5.  
  6. function UpdateLabel (String text, int font)
  7. {
  8.     int w = GetTextWidth (text, font);
  9.     int h = GetTextHeight(text, font, w);
  10.     DynamicSprite *outline;
  11.     DynamicSprite *textemp;
  12.     if (textlabel) textlabel.Delete ();
  13.     textemp = DynamicSprite.Create (w+2,h+2);
  14.     textlabel = DynamicSprite.Create (w+2,h+2);
  15.     outline = DynamicSprite.Create (w+2,h+2);
  16.     DrawingSurface *surf = textemp.GetDrawingSurface ();
  17.     surf.DrawingColor = textcolor;
  18.     surf.DrawStringWrapped(1, 1, w+1, font, eAlignCentre /*or whatever*/, text);
  19.     surf.Release ();
  20.     surf = outline.GetDrawingSurface ();
  21.     surf.Clear (outline_color);
  22.     surf.Release ();
  23.     outline.CopyTransparencyMask (textemp);
  24.     surf = textlabel.GetDrawingSurface ();
  25.     surf.DrawImage (0,1 ,outline.Graphic);
  26.     surf.DrawImage (1,0 ,outline.Graphic);
  27.     surf.DrawImage (0,-1,outline.Graphic);
  28.     surf.DrawImage (-1,0,outline.Graphic);
  29.     surf.DrawImage (0,0,textemp.Graphic);
  30.     surf.Release ();
  31.     btnWhateverTheButtonIs.NormalGraphic = textlabel.Graphic;
  32.     outline.Delete ();
  33.     textemp.Delete ();
  34. }
  35.  

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on a game that won an AGS Award!
    •  
    • selmiak worked on a game that was nominated for an AGS Award!
Re: setting the color of the font outline
« Reply #4 on: 28 Feb 2016, 23:18 »
thanks for your elaborate explanation, got it working now, I didn't use your code but made 8 clones of the text and this works :)