OnSupportsWebFont

Top  Previous  Next

The OnSupportsWebfont event is fired when a browser connects to the application. Inside this event you can describe how WebFMX should handle the fonts mapping.

 

Delphi Syntax

 

Object.OnSupportsWebfont := MySupportsWebFont;

 

procedure MySupportsWebFont(Sender: TObject; var ASupports: Boolean);

begin

 ASupports := True;

 // Your code here

end;

 

Arguments

 

Sender

The Sender object.

TObject

ASupports

Indicates whether the browser should support WebFonts or not. If set to false, the FontMode will be set to fmBitmap.

Boolean

 

Remarks

In order to find out the kind of browser is connecting to the application, you should read the RemoteInfo.UserAgent property.

The code below is used as a default behavior that allows WebFMX to disable WebFonts for versions under 6 of iPad, iPod and iPhone.

You can use it as an example to right down your own code:

 

iOS := (Pos('iPad',RemoteInfo.UserAgent)>0) or (Pos('iPod',RemoteInfo.UserAgent)>0) or (Pos('iPhone',RemoteInfo.UserAgent)>0);

if iOS then

begin

MajorVersion := StrToInt(Copy(RemoteInfo.UserAgent,Pos('Version/',RemoteInfo.UserAgent)+8,1));

FSupportsWebFont := (MajorVersion>=6);

end;

 

See also

Read also the TFontMode, FontMode, AddDefaultWebFonts ClearWebFonts and RegisterWebFont topics.