Webapplication (console) exports blurry fonts in PDF

The AddFontToCache is asynchronous, you need to await the font cache.

program Project40;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  WEBLib.TMSFNCPDFLib, WEBLib.TMSFNCTypes, WEBLib.TMSFNCGraphicsTypes, WEBLib.Forms,
  browserconsole;

type
  TExport = class
    class procedure DoFontCacheReady(Sender: TObject);
  end;

{ TExport }

class procedure TExport.DoFontCacheReady(Sender: TObject);
var
  p: TTMSFNCPDFLib;
  r: TRectF;
  s: string;
begin
  p := TTMSFNCPDFLib.Create;

  try
    s := 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry''s standard dummy'+
      'text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. '+
      'It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It'+
      ' was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with des'+
      'ktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.';
    p.BeginDocument();
    p.HeaderFont.Name := 'Roboto';
    p.FooterFont.Name := 'Roboto';
    p.PageNumberFont.Name := 'Roboto';

    p.NewPage;

    p.Graphics.Font.Name := 'Roboto';
    p.Graphics.Font.Size := 14;
    p.Graphics.Fill.Color := gcNull;
    r := RectF(10, 50, 500, 400);
    p.Graphics.DrawRectangle(r);
    p.Graphics.DrawText(s, r, 3);
    p.EndDocument(True).SaveToFile('test4.pdf');
  finally
    p.Free;
  end;
end;

begin
  Application.OnFontCacheReady := @TExport.DoFontCacheReady;
  AddFontToCache('https://download.tmssoftware.com/tmsweb/pdf/fonts/Roboto-Regular.ttf');
  AddFontToCache('https://download.tmssoftware.com/tmsweb/pdf/fonts/Roboto-Bold.ttf');
  AddFontToCache('https://download.tmssoftware.com/tmsweb/pdf/fonts/Roboto-BoldItalic.ttf');
  AddFontToCache('https://download.tmssoftware.com/tmsweb/pdf/fonts/Roboto-Italic.ttf');
end.