Re: Font size when changing screen resolution

From: John Carson (donaldquixote_at_datafast.net.au)
Date: 02/15/04


Date: Sun, 15 Feb 2004 23:23:10 +1100


"Mark Hatsell" <mark.hatsell@btinternet.com> wrote in message
news:ePEbXTl8DHA.1548@tk2msftngp13.phx.gbl
> Hello
>
> I am having a problem with fonts in my application changing point
> size after changing the screen resolution in Display Properties. This
> problem only seems to occur in Win NT, 2000 and XP and not in Win 98.
> Basically I have a window into which I am drawing some text. I have
> changed the map mode and viewport origin so that I have a metric
> coordinate system with positive y going up.
>
> dc.SetMapMode(MM_HIMETRIC);
> TPoint origin (0, GetClientRect().Height());
> dc.SetViewportOrg (origin);
>
> In order to draw the text I have converted the font point size
> specified by the user into mm by multiplying by 0.3514598. This
> figure is derived from the fact that 1 point = 1/72 inch and there
> are 25.4 mm in an inch.
> This seems to draw at the correct size in my
> native resolution of 1280x1024. However, if I switch to 800x600, the
> text in drawn in a much smaller point size (about half of what it
> should be). As I mentioned this only happens in NT, 2000 and XP. In
> Win 98 the text draws at the correct point size regardless of the
> screen resolution.
>
> I did a bit of investigation and found that on XP etc. the HORZSIZE
> and VERTSIZE returned from GetDeviceCaps are always the same whatever
> the screen resolution. In Win 98 however, these values change
> according to the resolution of the screen. This implies that in XP
> there are more logical units per pixel the lower the screen res. This
> means that a font with a certain height in logical units will draw at
> a smaller point size in lower res modes. In 98 however, the logical
> units per pixel is the same regardless of resolution and instead the
> HORZSIZE and VERTSIZE change. This gives a consistent point size
> across all resolutions.

I see more or the less the opposite to what you describe. Either you are
using "size" in an unexpected way or you are making some other compensating
change. Are you aiming for a constant size in terms of the number of pixels
used or as measured by a ruler placed against the screen? And how EXACTLY do
you set the lfHeight value in the LOGFONT structure?

Normally, people aim for a pixel count that is independent of screen
resolution, with the result that higher resolutions lead to a smaller font
size as measured by a ruler against the screen. That is what Windows does in
its user interface elements.

You are right that Windows 9x/ME behaves differently from Windows
NT/2000/XP. If you want consistent behaviour, then one way to do it is to
use MM_ISOTROPIC or MM_ANISOTROPIC rather than MM_HIMETRIC. If you can
clarify what you are trying to do and how you are going about it, than I can
be more specific.

-- 
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)


Relevant Pages

  • Re: Vector Graphics - was MFC and GDI+
    ... The solution is to use a music font; ... which can end up being either one pixel or two pixels wide depending on the layout. ... Vector GRAPHICS representations of musical symbols don't work well because the mappings to ... Nowadays printers generally gave a better resolution, ...
    (microsoft.public.vc.mfc)
  • Re: How to make form resize for the screen resolution?
    ... One way is to design the form at 800x600 and scale everything up for higher resolutions. ... Large/Small system font settings have a huge impact on your coordinate system as well. ... Since Large Fonts give you 12 twips per pixel and Small Fonts give you 15 twips per pixel, ... But when I lower my resolution to ...
    (microsoft.public.vb.general.discussion)
  • Re: problem getting TRUE height of text???
    ... a X pt font will not ... yield a X pixel high text, even if a character is exactly X pts - a pixel is ... > draws underscores horizontally instead of vertically and it wouldn't draw ... > I've tried GetTextMetrics, DrawText, GetTextExtent on both ...
    (microsoft.public.vc.mfc)
  • Re: Print Preview (again?)
    ... There's definitely a quantum jump, even if I increase the .lfHeight value directly, it 'sticks' at certain sizes. ... it deals with pixel roundoff; whatever font size 40 and 41 are round to the ... I'm getting very confused with trying to draw a small print preview box. ...
    (microsoft.public.vc.mfc)
  • Re: Frightened new owner of wide screen finds her web pages are in tiny print on it...
    ... Select the resolution that suits you. ... The set your browserto use a default font size that suits you, and hope that web authors are clever enough to let the user decide on the font size, or at least don't mess too much with it. ... One thing to be learned from this is that setting font size in pixels is a bad thing, just as setting it in points or millimeters is, though for somewhat different reasons. ... You cannot know the size of a pixel on a user's screen, and 12px might mean just illegible, or something else. ...
    (comp.infosystems.www.authoring.stylesheets)

Loading