AggPas - Anti-Grain Geomertry for Object Pascal

TAgg2D.Font(fileName, height, bold, italic, cache, angle)

Description

Changes the current font to be used for text rendering.

Parameters

fileName: AnsiString

If FreeType font engine is used, this parameter defines the filename containing the font face to be used.

If Windows TRUEType font engine is used, this parameter defines the face name of the font to be used.

height: double

Defines the height of the font [in subpixels].

bold: boolean = FALSE

Indicates if font has to be bold.

italic: boolean = FALSE

Indicates if font has to be italic.

cache: TAggFontCacheType [*] = AGG_VectorFontCache

Defines the type of internal AGG font cache.

Fonts are cached in TAgg2D automatically, which means that the procedure of loading a particular glyph definition is performed just once per font.

Generally vector font cache is more versatile, but it's slower than raster font cahce when rendering.

Raster font cache produces faster text renderings, but the text can't be rotated (also affine transformations don't apply).

angle: double = 0.0

Explicit font rotation [in radians]. Doesn't apply to the raster font cache.

Example

if VG.Attach(Image1.Picture.Bitmap) then begin

  VG.ClearAll(255, 255, 255);

  // Draw different text variations
  VG.LineColor($1E, $90, $FF);
  VG.FillColor($1E, $90, $FF);

  VG.Font('Times New Roman', 25, FALSE, FALSE,
  AGG_VectorFontCache, Deg2Rad(270));
  VG.Text(200, 210, 'Times New Roman');

  VG.LineColor($00, $00, $CD);
  VG.FillColor($00, $00, $CD);

  VG.Font('Arial', 25, FALSE, TRUE,
  AGG_VectorFontCache, Deg2Rad(315));
  VG.Text(220, 210, 'Arial Italic');

  VG.LineColor($6A, $5A, $CD);
  VG.FillColor($6A, $5A, $CD);

  VG.Font('Courier', 25, TRUE, FALSE,
  AGG_RasterFontCache);
  VG.Text(220, 230, 'Courier Bold Raster');

  VG.LineColor($20, $B2, $AA);
  VG.FillColor($20, $B2, $AA);

  VG.Font('Verdana', 25, FALSE, FALSE,
  AGG_VectorFontCache, Deg2Rad(45));
  VG.Text(205, 245, 'Verdana');

  VG.LineColor($2E, $8B, $57);
  VG.FillColor($2E, $8B, $57);

  VG.Font('Tahoma', 25, FALSE, FALSE,
  AGG_VectorFontCache, Deg2Rad(90));
  VG.Text(185, 250, 'Tahoma');

  VG.LineColor($B8, $86, $0B);
  VG.FillColor($B8, $86, $0B);

  VG.Font('Lucida Console', 25, TRUE, FALSE,
  AGG_VectorFontCache, Deg2Rad(135));
  VG.Text(165, 240, 'Lucida Console');

  VG.NoLine;
  VG.FillColor($FF, $00, $00);

  VG.Font('Galleria', 20, TRUE, FALSE,
  AGG_VectorFontCache, Deg2Rad(180));
  VG.Text(160, 220, 'Galleria');

  VG.FillColor($FF, $A5, $00);

  VG.Font('Briquet', 30, FALSE, TRUE,
  AGG_VectorFontCache, Deg2Rad(225));
  VG.Text(170, 200, 'Briquet Italic');

end;

Screenshot: example