No announcement yet.

Fonts in Win2000 ????

  • Filter
  • Time
  • Show
Clear All
new posts

  • Fonts in Win2000 ????

    Has anybody developed a program (in PB 5/6) for Win 95/98 which uses Fonts (defined using CreateFont API call) which works fine in Win 95/98, but when run from Win 2000 (or NT), the fonts defined are not always correct (ie. Font becomes bold, when it wasn't defined as bold) ?

    I have code that works fine in Win 95/98, but when run in NT (especially 2000) the font sometimes will be bold, when it wasn't defined as bold.

    Are there any "differences" between Win 95/98 and NT/2000 when using CreateFont that I should know about ?
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"

  • #2
    Bold is defined by weight, so maybe the problem is there.
    Do you set it to 400 (= normal)?


    • #3
      Yes !

      The problem is not with selecting the font, but if I create the same font multiple times, sometimes the font will come back bold and sometimes it will come back normal. I use 400 for a normal font.

      What I want to know is, is Win2000 more sensitive in selecting a font, so with certain values passed in CreateFont, sometimes it returns a bold and sometimes it won't.

      Chris Boss
      Computer Workshop
      Developer of "EZGUI"


      • #4
        Chris, I'm running Win2K here, so if you want to post or email me a short app to demo your problem, I'll see what I can find out. I've done extensive testing of DOSPRINT with Win2K (using test files containing hundreds of font changes within a single Print Preview window) and I've not seen the problem as you describe it.

        PowerBASIC Support
        ( mailto:[email protected][email protected]</A> )
        mailto:[email protected]


        • #5
          Here is the code I use for Creating a Font. Is there anything here that could "confuse" Win 2000 and cause to return a Bold Font, when Bold was Not asked for:

          Sub EZ_DefFont (byval N&, byval TFace$, byval PSize&, byval FProp$) EXPORT
          Local hFont as Long
          Local W&, E&, O&, FW&, I&, U&, ST&, CS&, PR&, CL&, Q&, PF&, FF&
          Local zTemp as AsciiZ*80, OKFlag&
          Local PT!
          ' PT!=abs(PSize&)
          ' PT!=int(PT!*App_EZ_PointOffSet!)
          ' PSize&=-int(PT!)    ' a negative value defines by character height, not cell height
          PSize&=-MulDiv(PSize&, App_EZ_PixelSY&, 72)
          if (N&>5 and N&<=ubound(AppFont)) or N&=-1 then
              if N&=-1 then OKFlag&=1
              if N&>5 then
                 if AppFont(N&)=0 then OKFlag&=1
              end if
              if OKFlag& then
                  if instr(FProp$,"B") then FW&=%FW_BOLD
                  if instr(FProp$,"X") then FW&=%FW_HEAVY
                  if instr(FProp$,"I") then I&=1
                  if instr(FProp$,"U") then U&=1
                  if instr(FProp$,"-") then ST&=1
                  if instr(FProp$,"D") then CS&=%DEFAULT_CHARSET
                  if instr(FProp$,"S") then CS&=%SYMBOL_CHARSET
                  if instr(FProp$,"O") then CS&=%OEM_CHARSET
                  if instr(FProp$,"Q") then Q&=%PROOF_QUALITY     ' letter quality
                  if instr(FProp$,"F") then PF&=%FIXED_PITCH
                  if instr(FProp$,"V") then PF&=%VARIABLE_PITCH
                  '  I can add choices for Font Families later
                  PF&=PF& or FF&
                  if len(TFace$)>31 then TFace$=left$(TFace$,31)
                  ' Remember this font in LOGFONT structure
                  if N&=-1 then
                     hFont=CreateFont(PSize&,W&, E&, O&, FW&, I&, U&, ST&, CS&, PR&, CL&, Q&, PF&, zTemp)
                     if hFont>0 then AppFont(N&)=hFont
                   end if
              end if
          end if
          End Sub
          Note: While the code above does come from a CopyRighted program (EZGUI), please feel free to modify it for your own use and use it as you please !

          The Subroutine is very easy to use, since you just pass it the Font Name, Point size and a simple Property string with single characters for properties (ie. B=Bold, X=Heavy, Q=Quality, F=Fixed Width, V=Variable width, I=Italics, U=Underlined, etc.).

          There are some other features in the code , you can remove since it is for use with other EZGUI functions (ie. the LOGFONT UDT is a Global for use with other EZGUI functions). You may want to convert the sub to a Function to return the font handle.
          Chris Boss
          Computer Workshop
          Developer of "EZGUI"


          • #6
            I believe the last 4 or 5 fields (not including lfFacename) are defined
            as BYTE in the LOGFONT udt. You are using LONG's.
            Regards... Ed


            • #7
              Chris --

              > Are there any "differences" between Win 95/98 and NT/2000
              > when using CreateFont that I should know about ?

              I can't give you any concrete answers, but it has been my experience that fonts are not very consistent between 95/98 and NT. Even within one version of Windows, the results of creating a font are not always what you might expect. For example, when increasing the size of a font by a small amount, I often perceive a difference in the boldness of the resulting font.

              For an example of this effect on NT, use the Control Panel's "Fonts" applet to look at the Arial font. To my eye, the 12-point font is much less bold than the 18-point font. On the other hand, Courier New seems very consistent to me.

              I've never looked into it in detail, but here are a few thoughts. Let's say that you have a relatively small font, and Windows draws it with lines that are one pixel wide and high. Increase the width/height by a small amount and Windows will continue to use one-pixel lines, until a certain size-threshhold is reached and it starts using 2-pixel lines. (I'm not accurately describing the way characters are drawn, but you get the idea.) It is impossible for Windows to draw with a one-point-five-pixel line, so it has to jump abruptly from 1 to 2 pixels, and the resulting font looks very different. Not many fonts are drawn with 1-pixel fonts... I'm just trying to communicate the fact that Windows must deal with "integers only" is some unexpected places, and (I'm guessing) it could affect font creation.

              I have often noticed that a certain font will appear to become significantly bolder when the size is increased beyond a certain threshhold. I don't know what the mechanism is that makes it happen, but it is a real and hard-to-predict effect.

              I'm not certain, but I think that monitor resolution has an effect as well. I have designed a number of menus using one screen resolution, and when the programs were run on another machine with a different resolution, the relative boldness of certain fonts did appear to change.

              Generally speaking, I have obtained much more consistent results with TrueType fonts than with other types. But all Windows fonts suffer from these effects to some degree.

              -- Eric

              Perfect Sync: Perfect Sync Development Tools
              Email: mailto:[email protected][email protected]</A>

              [This message has been edited by Eric Pearson (edited January 11, 2000).]
              "Not my circus, not my monkeys."


              • #8
                The problem that my Beta testers have experienced is that on Win NT or 2000 that a bunch of controls can be defined with the same Font (using my code above) , and yet the first control displays with Bolder text. The Font is the same (different handle, but defined with the same attributes).

                The first time Win 2000 creates the font it is bolder, than the next time it creates it.

                Chris Boss
                Computer Workshop
                Developer of "EZGUI"


                • #9
                  Chris --

                  Yes, sorry, you said that in a previous message and I missed it.

                  -- Eric

                  Perfect Sync: Perfect Sync Development Tools
                  Email: mailto:[email protected][email protected]</A>

                  "Not my circus, not my monkeys."


                  • #10
                    In Win95
                    nEscapment and nOrientation should be same value
                    In NT/2000
                    If graphics mode is set to GM_COMPATIBLE, nEscapement specifies both
                    the escapement and orientation.
                    You should set nEscapement and nOrientation to the same value
                    If graphic mode is set to GM_ADVANCED, you can specify the escapement
                    angle of the string independently

                    This does not explain the inconsistent behaviors in WinNT/2000
                    But perhaps would help to get the same inconsistency in Win95
                    It was a yoke!
                    Using %PROOF_QUALITY ?
                    Character quality of the font is more important than exact matching
                    of the logical-font attributes. For GDI raster fonts, scaling is disabled
                    and the font closest in size is chosen. Although the chosen font size may
                    not be mapped exactly when PROOF_QUALITY is used, the quality of the font
                    is high and there is no distortion of appearance. Bold, italic, underline,
                    and strikeout fonts are synthesized, if necessary.

                    mailto:[email protected][email protected]</A>

                    [This message has been edited by Fred Oxenby (edited January 11, 2000).]
                    mailto:[email protected][email protected]</A>