5.3. tsPostAddBorder

Syntax

Pascal

procedure tsPostAddBorder3ub(Width: tsFloat; Strength: tsFloat;
  Red: tsByte; Green: tsByte; Blue: tsByte);

procedure tsPostAddBorder4ub(Width: tsFloat; Strength: tsFloat;
  Red: tsByte; Green: tsByte; Blue: tsByte; Alpha: tsByte);

procedure tsPostAddBorder3f(Width: tsFloat; Strength: tsFloat;
  Red: tsFloat; Green: tsFloat; Blue: tsFloat);

procedure tsPostAddBorder4f(Width: tsFloat; Strength: tsFloat;
  Red: tsFloat; Green: tsFloat; Blue: tsFloat; Alpha: tsFloat);

C/C++

void tsPostAddBorder3ub(tsFloat Width, tsFloat Strength,
  tsByte Red, tsByte Green, tsByte Blue);

void tsPostAddBorder4ub(tsFloat Width, tsFloat Strength,
  tsByte Red, tsByte Green, tsByte Blue, tsByte Alphas);

void tsPostAddBorder3f(tsFloat Width, tsFloat Strength,
  tsFloat Red, tsFloat Green, tsFloat Blue);

void tsPostAddBorder4f(tsFloat Width, tsFloat Strength,
  tsFloat Red, tsFloat Green, tsFloat Blue, tsFloat Alpha);

Description

Creates an border around the chars. This post processor change some values from the glyphs. The glyph rect will be expanded. The vertical glyphorigin will be expanded. But the baseline of the char wont be touched. So for the glyphs in the lower images the baseline are still at the bottom of the white parts of the glyphs. So it's possible to mix normal and bordered chars and getting an nice looking text layout. Also the advance of the glyph will be enhanced.

[Note] Note

Notice that the post processor can't change any values from the font. If you have apllied an large border and wants to print some multiline texts it's possible that the border of the lines will touch each other. If this happens you should change add the size of the border at the top and at the bottom of the font. Yo can do this with the parameters TS_FONT_ASCENT and TS_FONT_DESCENT.

You can control the strength of the border. You can smooth switch between an hard border. Strength of 1.

Sample Image for tsPostAddBorder (strength 1)

And an border with an gaussian function. Strength of 0.

Sample Image for tsPostAddBorder (strength 0)

Params

Width

Sets the width of the border. Possible value are above zero. But notice. I'm using an gaussian function to calculate the underlaying kernels so the an width of 1 doesn't represents an border of 1 pixel. The mostly ideal 1 pixel border lies near an width of 1.5.

Strength

This controls the hardness of the border. The values can be in range from 0 up to 1. For sample images look above.

[Warning] Warning

Smooth border (strength of 0) needs much more operations for the calculation. So please be careful if you are using an strength less than 0.5. If the chars are large or you create a large number of chars this post process will need some time.

Red, Green, Blue and Alpha

It's the color of the border. If you pass an value for alpha to the post processor you can control the visibility of the border.

The value may have 2 types. tsByte has an rage from 0 to 255. tsFloat is in range from 0 to 1. If you call an version without the alpha parameter the value for the alpha always will be the maximum value (255 or 1).

Error Codes

TS_NO_ACTIVE_CONTEXT

If there was no context bound.

TS_NO_ACTIVE_FONT

If there is no font bound.

TS_INVALID_OPERATION

If the bound font isn't an font creator.