Delphi

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Detecting Large Fonts

    14 answers - 464 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I'm looking for a way to detecting rather I'm running on a LargeFonts system
    R on a normal font system. I googled for "detect large font" and found two
    code samples both trying to detect large fonts using:
    DPI := GetDeviceCaps(DC, LGPIXELSX);
    Unfortunatelly this code returns 96 on my WinXP Large Fonts test system.
    Any idea how to detect this?
    Thanks!
    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.1 | | 918 bytes | |

    I believe you can simply check the PixelsPerInch property of your main
    form.

    Regards,
    Ross.

    Message
    From: "Cosmin Prund" <pcosmin (AT) adicomsoft (DOT) ro>
    To: "Moderated discussion list about programming with Borland's Delphi"
    <delphi (AT) elists (DOT) org>
    Sent: Friday, September 02, 2005 3:55 AM
    Subject: Detecting Large Fonts

    I'm looking for a way to detecting rather I'm running on a LargeFonts
    system
    R on a normal font system. I googled for "detect large font" and found
    two
    code samples both trying to detect large fonts using:

    DPI := GetDeviceCaps(DC, LGPIXELSX);

    Unfortunatelly this code returns 96 on my WinXP Large Fonts test system.

    Any idea how to detect this?
    Thanks!

    Delphi mailing list -Delphi (AT) elists (DOT) org

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.2 | | 1596 bytes | |

    Cosmin,
    I picked this up on the web some time back. It worked on an XP system set
    to large fonts. I'm not using it now, but as I recall it worked for me.

    function hasLargeFonts : Boolean;
    {
    Returns a boolean indicating whether or not the user has
    Large Fonts enabled in Display Properties.
    }
    var
    liPPI : longInt; // holds pixels per inch for canvas
    hCanvas : HDC; // device context for current canvas

    const
    LGFPPI = 120; // PPI when LgFonts active
    begin

    hCanvas := getDC( 0 ); // get current canvas
    try
    liPPI := getDeviceCaps( hCanvas, LGPIXELSX );
    finally
    releaseDC( 0, hCanvas ); // prevent leaks
    end;
    result := ( liPPI = LGFPPI ); // compare and return

    end; // hasLargeFonts

    Message
    From: "Cosmin Prund" <pcosmin (AT) adicomsoft (DOT) ro>
    To: "Moderated discussion list about programming with Borland's Delphi"
    <delphi (AT) elists (DOT) org>
    Sent: Thursday, September 01, 2005 10:55 AM
    Subject: Detecting Large Fonts

    I'm looking for a way to detecting rather I'm running on a LargeFonts
    system
    R on a normal font system. I googled for "detect large font" and found
    two
    code samples both trying to detect large fonts using:

    DPI := GetDeviceCaps(DC, LGPIXELSX);

    Unfortunatelly this code returns 96 on my WinXP Large Fonts test system.

    Any idea how to detect this?
    Thanks!

    Delphi mailing list -Delphi (AT) elists (DOT) org

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.3 | | 1164 bytes | |

    That would make sence. Unfortunatelly PixelsPerInch says 96 on both my
    "normal fonts" developement machine AND on my "Extra Large Fonts" test
    machine.

    Ross Levis wrote:
    I believe you can simply check the PixelsPerInch property of your main
    form.

    Regards,
    Ross.

    Message
    From: "Cosmin Prund" <pcosmin (AT) adicomsoft (DOT) ro>
    To: "Moderated discussion list about programming with Borland's
    Delphi" <delphi (AT) elists (DOT) org>
    Sent: Friday, September 02, 2005 3:55 AM
    Subject: Detecting Large Fonts
    --
    I'm looking for a way to detecting rather I'm running on a LargeFonts
    system
    R on a normal font system. I googled for "detect large font" and
    found two
    code samples both trying to detect large fonts using:

    DPI := GetDeviceCaps(DC, LGPIXELSX);

    Unfortunatelly this code returns 96 on my WinXP Large Fonts test
    system.

    Any idea how to detect this?
    Thanks!

    Delphi mailing list -Delphi (AT) elists (DOT) org

    Delphi mailing list -Delphi (AT) elists (DOT) org

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.4 | | 2155 bytes | |

    I also found this code, and an other variation (as I've sayd - I'm allready
    using GetDeviceCaps) but it unfortunatelly says 96 on both my "normal font"
    developement machine and on my "Extra Large Fonts" test machine :-(

    ShowMe Software wrote:
    Cosmin,
    I picked this up on the web some time back. It worked on an XP
    system set to large fonts. I'm not using it now, but as I recall it
    worked for me.

    function hasLargeFonts : Boolean;
    {
    Returns a boolean indicating whether or not the user has
    Large Fonts enabled in Display Properties.
    }
    var
    liPPI : longInt; // holds pixels per inch for canvas
    hCanvas : HDC; // device context for current canvas

    const
    LGFPPI = 120; // PPI when LgFonts active
    begin

    hCanvas := getDC( 0 ); // get current canvas
    try
    liPPI := getDeviceCaps( hCanvas, LGPIXELSX );
    finally
    releaseDC( 0, hCanvas ); // prevent leaks
    end;
    result := ( liPPI = LGFPPI ); // compare and return

    end; // hasLargeFonts

    Message
    From: "Cosmin Prund" <pcosmin (AT) adicomsoft (DOT) ro>
    To: "Moderated discussion list about programming with Borland's
    Delphi" <delphi (AT) elists (DOT) org>
    Sent: Thursday, September 01, 2005 10:55 AM
    Subject: Detecting Large Fonts
    >
    >
    >I'm looking for a way to detecting rather I'm running on a LargeFonts
    >system
    >R on a normal font system. I googled for "detect large font" and
    >found two
    >code samples both trying to detect large fonts using:
    >>

    >DPI := GetDeviceCaps(DC, LGPIXELSX);
    >>

    >Unfortunatelly this code returns 96 on my WinXP Large Fonts test
    >system.
    >>

    >Any idea how to detect this?
    >Thanks!
    >>

    >
    >Delphi mailing list -Delphi (AT) elists (DOT) org
    >
    >


    Delphi mailing list -Delphi (AT) elists (DOT) org

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.5 | | 1843 bytes | |

    I think I'm on the right track with this solution but for some raison it
    feels like a "hack".

    My conclusion is that on WinXP changing to Large Fonts doesn't actually
    change the display driver's DPI, it simply does as it says: it increases
    standard fonts. In order to detect rather Large Fonts is enabled or not I'm
    simply reading the height for "Message Box Font" and I'm comparing that to
    the hight for the same font without Large Fonts enabled.

    the few systems I tested the font for the system message box when large
    fonts is NT enabled is Tahoma 8 point (11 pixels); the same systems with
    Large Fonts enabled I get Tahoma 10 point (16 pixels).

    Considering the user might manually change the fonts to make them larger or
    easyer to read (not necesarily by selecting Large Fonts), scaling the
    application in proportion to the change in hight of this fonts makes sense.

    Unfortunatelly automatic scaling of Delphi forms (via the Scaled property)
    seems to work in proportion with the DotsPerInch reading and for this raison
    my forms don't seem to automatically scale on XP.

    For anyone interested in this problem take a look at SystemParametersInfo
    with SPI_GETNNCLIENTMETRICS as parameter.

    Cosmin Prund wrote:
    I'm looking for a way to detecting rather I'm running on a LargeFonts
    system R on a normal font system. I googled for "detect large font"
    and found two code samples both trying to detect large fonts using:

    DPI := GetDeviceCaps(DC, LGPIXELSX);

    Unfortunatelly this code returns 96 on my WinXP Large Fonts test
    system.

    Any idea how to detect this?
    Thanks!

    Delphi mailing list -Delphi (AT) elists (DOT) org

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.6 | | 703 bytes | |

    Unfortunatelly automatic scaling of Delphi forms (via the Scaled property)
    seems to work in proportion with the DotsPerInch reading and for this raison
    my forms don't seem to automatically scale on XP.

    All you need to do to support large fonts in delphi is to make sure
    Scaled is TRUE and AutoScroll is FALSE. If you have anchored controls
    (such as [akTop, akRight]) these may require special placement for the
    Large Font application.

    Setting those 2 properties will solve 95% of your Large Font issues.
    Note with bsDialog style forms, the properties are set correctly.

    cheers,
    Jeremy

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.7 | | 1068 bytes | |

    Cosmin Prund wrote:
    That would make sence. Unfortunatelly PixelsPerInch says 96 on both my
    "normal fonts" developement machine AND on my "Extra Large Fonts" test
    machine.

    PixelsPerInch tells the resolution of the screen on which the form was
    designed. That way, the form will know how much to scale itself by when
    it runs on a different screen.

    But there are two PixelsPerInch properties. belongs to TForm. That's
    no good. The other belongs to TScreen. Use that one to determine the
    font size.

    Also note that font size is no longer limited to just "small" and
    "large." Many video drivers allow you to choose a resolution of your
    own; 96 and 120 are common, but you can also find 200, or 126, or 108,
    or any other value. Rather than ask, "Am I in large-font mode?" you need
    to ask, "What font size am I in?" and then do some math to compensate.

    You can see how TForm accounds for font size by looking in
    TCustomForm.ReadState, in Forms.pas. It adjusts the font size right
    after its inherited call.
  • No.8 | | 491 bytes | |

    Cosmin Prund wrote:
    I also found this code, and an other variation (as I've sayd - I'm allready
    using GetDeviceCaps) but it unfortunatelly says 96 on both my "normal font"
    developement machine and on my "Extra Large Fonts" test machine :-(

    Just so you know, this is not as simple an issue as it may appear
    and you're not alone:

    Stephen Posey
    slposey (AT) concentric (DOT) net

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.9 | | 1129 bytes | |

    Jeremy North wrote:
    []
    All you need to do to support large fonts in delphi is to make sure
    Scaled is TRUE and AutoScroll is FALSE. If you have anchored controls
    (such as [akTop, akRight]) these may require special placement for the
    Large Font application.

    Setting those 2 properties will solve 95% of your Large Font issues.
    Note with bsDialog style forms, the properties are set correctly.

    Jeremy.

    I must admit this is the exact opposite of what I do! I can't stand the
    layout of the form being changed outside my control, so Scaled = False for
    me. I try and test the application on a Large Fonts system to ensure
    there is room for the text.

    BTW: I'm using Delphi 5, and part of my form initialisation sequence is to
    set DesktoFont = True. Even now, many commercial applications seem to
    stick with the horrible unsmoothed fonts rather than simply honouring what
    font the user has already chosen. (I'm a great fan of ClearType, even
    when using a CRT).

    Cheers,
    David

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.10 | | 3088 bytes | |

    This becomes a VERY interesting problem. my system, after selecting Large
    Fonts, there's no change in the DPI but there's a change in the actual font
    size for "Message Box"; I tryed reading the DPI using all the tricks I know,
    it's allways 96. Also reading this mailing list it seems I'm the NLY one
    that doesn't get a change in DPI when switching to Large Fonts!

    The problem with fonts changing without actually changing DPI is that
    Delphi's code for automatically scaling forms on load will not work.

    Like many other programmers I allways avoided the Large Font problem (by
    setting Scaled = False) but that will no longer work and that's because of
    LCD displays: All the LCD's I've seen work at a native resolution that's too
    high for anyone using reading glasses, and there are lots of people using
    reading glasses! CRT monitors people that need to have taller fonts can
    always run a lower resolution. This is not possible on LCD's so the only
    solution is "Large Fonts".

    At the moment I'm manually scaling my forms (using ScaleBy) in proportion
    with the change in message box font size. So far this worked very well and
    it has a few benefits: I can scale frames created at run time! Delphi by
    itself will only scale stuff that's on the form at design time. You allready
    noticed the only refference to Scaled in the Forms unit is in the code for
    ReadState.

    Also scaling my forms in proportion to "Message Box Font" has a hidden
    advantage: Selecting Large Fonts is one way the user can inform Windows
    he/she actually wants larger fonts, but the user can also manually customize
    this font making it any size (s)he whishes!

    For I'm going to go with this solution, running a few experiments on my
    customers :-)

    Rob Kennedy wrote:
    Cosmin Prund wrote:
    >That would make sence. Unfortunatelly PixelsPerInch says 96 on both
    >my "normal fonts" developement machine AND on my "Extra Large Fonts"
    >test machine.
    >

    PixelsPerInch tells the resolution of the screen on which the form was
    designed. That way, the form will know how much to scale itself by
    when it runs on a different screen.

    But there are two PixelsPerInch properties. belongs to TForm.
    That's no good. The other belongs to TScreen. Use that one to
    determine the font size.

    Also note that font size is no longer limited to just "small" and
    "large." Many video drivers allow you to choose a resolution of your
    own; 96 and 120 are common, but you can also find 200, or 126, or 108,
    or any other value. Rather than ask, "Am I in large-font mode?" you
    need to ask, "What font size am I in?" and then do some math to
    compensate.

    You can see how TForm accounds for font size by looking in
    TCustomForm.ReadState, in Forms.pas. It adjusts the font size right
    after its inherited call.

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.11 | | 1613 bytes | |

    Cosmin Prund wrote:
    This becomes a VERY interesting problem. my system, after selecting Large
    Fonts, there's no change in the DPI but there's a change in the actual font
    size for "Message Box";

    Well, as I think I mentioned before, there are *two* settings in Windows
    XP for which "large fonts" is one of the possible values. There's a
    "font size" option on the "Appearance" tab, which is nothing more than a
    quick way of setting lots of font sizes on the "advanced" dialog for
    that tab. There's also a "DPI" setting on the "advanced" dialog of the
    "Settings" tab. They are completely different settings. I think you have
    them confused. You've set the "font size" option instead of the "DPI"
    option. If it doesn't say "DPI" next to it, you've got the wrong one
    (accounting for language differences, of course).

    Also scaling my forms in proportion to "Message Box Font" has a hidden
    advantage: Selecting Large Fonts is one way the user can inform Windows
    he/she actually wants larger fonts, but the user can also manually customize
    this font making it any size (s)he whishes!

    Exactly. The choice of DPI is not the only way to set a font's size. In
    fact, changing the DPI is a way of changing the appearance of a font
    without actually choosing a new size. An 8-point font at 96 DPI is fewer
    pixels high than an 8-point font at 120 DPI, and since the size of a
    pixel doesn't change, the font appears bigger. The other way of making
    the font bigger is by choosing something larger than 8 points.
  • No.12 | | 663 bytes | |

    I try and test the application on a Large Fonts system to ensure
    there is room for the text.

    I guess you must have a lot of wasted space on your forms or do a lot
    of control positioning manually then. What happens when the user
    selects Very Large Fonts or even a default DPI? Do your forms cater
    for this?

    Your approach seems to not respect the end users need for having the
    windows larger than they normally would appear. Can you post some
    screenshots of how your apps that do this appear under Normal, Large
    and Very Large fonts?

    cheers,
    Jeremy

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.13 | | 2097 bytes | |

    Yes, I've got the two confused. And I just realised how difficult it must be
    supporting ALL possible appereance options. A more complex system for laying
    out controls is required for this to work, I hope WinFX got this

    Thanks everyone
    (feeling really silly)

    Rob Kennedy wrote:
    Cosmin Prund wrote:
    >This becomes a VERY interesting problem. my system, after
    >selecting Large Fonts, there's no change in the DPI but there's a
    >change in the actual font size for "Message Box";
    >

    Well, as I think I mentioned before, there are *two* settings in
    Windows
    XP for which "large fonts" is one of the possible values. There's a
    "font size" option on the "Appearance" tab, which is nothing more
    than a quick way of setting lots of font sizes on the "advanced"
    dialog for
    that tab. There's also a "DPI" setting on the "advanced" dialog of the
    "Settings" tab. They are completely different settings. I think you
    have them confused. You've set the "font size" option instead of the
    "DPI" option. If it doesn't say "DPI" next to it, you've got the
    wrong one (accounting for language differences, of course).
    >
    >Also scaling my forms in proportion to "Message Box Font" has a
    >hidden advantage: Selecting Large Fonts is one way the user can
    >inform Windows he/she actually wants larger fonts, but the user can
    >also manually customize this font making it any size (s)he whishes!
    >

    Exactly. The choice of DPI is not the only way to set a font's size.
    In fact, changing the DPI is a way of changing the appearance of a
    font
    without actually choosing a new size. An 8-point font at 96 DPI is
    fewer pixels high than an 8-point font at 120 DPI, and since the size
    of a
    pixel doesn't change, the font appears bigger. The other way of making
    the font bigger is by choosing something larger than 8 points.

    Delphi mailing list -Delphi (AT) elists (DOT) org
  • No.14 | | 1188 bytes | |

    Jeremy North wrote:
    >I try and test the application on a Large Fonts system to ensure
    >there is room for the text.
    >

    I guess you must have a lot of wasted space on your forms or do a lot
    of control positioning manually then. What happens when the user
    selects Very Large Fonts or even a default DPI? Do your forms cater
    for this?

    Your approach seems to not respect the end users need for having the
    windows larger than they normally would appear. Can you post some
    screenshots of how your apps that do this appear under Normal, Large
    and Very Large fonts?

    Jeremy

    Here are some sample screen-shots:

    The only allowance I make for large text is to alter the forms if a
    problem is reported. You can download some of the applications and test
    them for yourselves. There is little manual control positioning.

    My general principle is to try and respect all user settings (including
    the DesktopFont), but as there is a lot of graphics in these applications,
    perhaps the text is secondary.

    Cheers,
    David

    Delphi mailing list -Delphi (AT) elists (DOT) org

Re: Detecting Large Fonts


max 4000 letters.
Your nickname that display:
In order to stop the spam: 0 + 0 =
QUESTION ON "Delphi"

EMSDN.COM