Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TWebrowser load page with big fonts

Tags:

browser

delphi

I found a strange behavior in the component TwebBrowser, when I load certain pages they are shown with larger fonts. different from what is used in internet explorer.

see these sample images

Here in this link http://docwiki.embarcadero.com/RADStudio/en/Main_Page is loaded with larger fonts in TWebBrowser and with small fonts (another style) in IE.

alt text

this page https://stackoverflow.com/ is loaded with same style in the TWebBrowser component and IE.

alt text

I tried it on different machines and same thing happens.

how can i fix this behavior ? this is a problem with a CSS?

like image 656
Salvador Avatar asked Nov 14 '22 06:11

Salvador


1 Answers

I think the problem is that the TWebBrowser component is running Internet Explorer in compatibility mode. Indeed, if you open the docwiki page in Internet Explorer 8 and later, the fonts are small and pleasant, in contrast to how they look in the TWebBrowser. But if you click the "Compatibility View" button in the Internet Explorer window, you will get the same large text as you do get in the TWebBrowser component. (It is well-known that IE6 use too large text.)

According to this MSDN blog entry and the MSDN docs, to control the compatibility mode of the TWebBrowser control, use the registry:

procedure TForm3.FormCreate(Sender: TObject);
begin

  with TRegistry.Create do
    try
      RootKey := HKEY_CURRENT_USER;
      if OpenKey('Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION', true) then
        WriteInteger(ExtractFileName(Application.ExeName), 8888);
    finally
      Free;
    end;

  WebBrowser1.Navigate('http://docwiki.embarcadero.com/RADStudio/en/Main_Page');
end;

The values are 8000, 7000, and 8888 for "IE8 Standards Mode", "IE7 Standards Mode", and "IE8 Standards Mode (Forced)", respectively. Hence, the above code will force IE8 standards mode.

Surprisingly, however, setting the mode to standard will only make the font even larger.

like image 165
Andreas Rejbrand Avatar answered Dec 23 '22 10:12

Andreas Rejbrand