setting the color of the font outline

Started by selmiak, Sat 20/02/2016 20:32:12

Previous topic - Next topic

selmiak

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

You can change the colour of the outline with:

Code: AGS
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


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: ags
fontX.text_shadow_color = x;

in AGS.

Scavenger

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: AGS

int text_color = 15;
int outline_color = 16;

DynamicSprite *textlabel;

function UpdateLabel (String text, int font)
{
    int w = GetTextWidth (text, font);
    int h = GetTextHeight(text, font, w);
    DynamicSprite *outline;
    DynamicSprite *textemp;
    if (textlabel) textlabel.Delete ();
    textemp = DynamicSprite.Create (w+2,h+2);
    textlabel = DynamicSprite.Create (w+2,h+2);
    outline = DynamicSprite.Create (w+2,h+2);
    DrawingSurface *surf = textemp.GetDrawingSurface ();
    surf.DrawingColor = textcolor;
    surf.DrawStringWrapped(1, 1, w+1, font, eAlignCentre /*or whatever*/, text);
    surf.Release ();
    surf = outline.GetDrawingSurface ();
    surf.Clear (outline_color);
    surf.Release ();
    outline.CopyTransparencyMask (textemp);
    surf = textlabel.GetDrawingSurface ();
    surf.DrawImage (0,1 ,outline.Graphic);
    surf.DrawImage (1,0 ,outline.Graphic);
    surf.DrawImage (0,-1,outline.Graphic);
    surf.DrawImage (-1,0,outline.Graphic);
    surf.DrawImage (0,0,textemp.Graphic);
    surf.Release ();
    btnWhateverTheButtonIs.NormalGraphic = textlabel.Graphic;
    outline.Delete ();
    textemp.Delete ();
}

selmiak

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 :)

SMF spam blocked by CleanTalk