Announcement

Collapse
No announcement yet.

Font New problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Font New problem

    I found this problem:
    1. Code that works
    GRAPHIC COLOR %YELLOW, -2
    FONT NEW "Times New Roman", 40, 1, 1, 0, 300 TO hFont300
    GRAPHIC SET FONT hFont300
    GRAPHIC SET POS (tx, ty)
    GRAPHIC PRINT sEntryText
    2. Using variable as fontname will no longer rotate the text
    ftname = "Times New Roman"
    FONT NEW ftname , 40, 1, 1, 0, 300 TO hFont300
    GRAPHIC SET FONT hFont300
    GRAPHIC SET POS (tx, ty)
    GRAPHIC PRINT sEntryText

    Is this a bug? Any workaround?


    Thanks,

    Peter Redei

  • #2
    This seems to work

    Macro ftname = "Times New Roman"

    LATER: Actually variable as fontname works too..
    Code:
    #Dim All 
    #INCLUDE "WIN32API.INC"
     
    Function PbMain()
     Dim hWin???, hFont300???, ftname$, tx&, ty&, sEntryText$
     
      GRAPHIC WINDOW "", 59, 50, 200, 400 TO hWin
      GRAPHIC ATTACH hWin, 0
     
      tx = 10 : ty = 100 : sEntryText = "Test"
     
      '1. Code that works
     
      GRAPHIC COLOR %YELLOW, -2 
      FONT NEW "Times New Roman", 40, 1, 1, 0, 300 TO hFont300
      GRAPHIC SET FONT hFont300 
      GRAPHIC SET POS (tx, ty)
      GRAPHIC PRINT sEntryText 
     
      Sleep 1000
     
      '2. Using variable as fontname will no longer rotate the text ?
     
      ftname = "Times New Roman"
      FONT NEW ftname , 40, 1, 1, 0, 300 TO hFont300
      GRAPHIC SET FONT hFont300 
      GRAPHIC SET POS (tx, ty+40)
      GRAPHIC PRINT sEntryText 
     
      Sleep 2000
     
    End Function
    '------------------/PBMain
    Last edited by Dave Biggs; 21 Jan 2009, 06:54 AM. Reason: Further testing
    Rgds, Dave

    Comment


    • #3
      >LATER: Actually variable as fontname works too..

      I'll bet string equates would work, too.

      Think your code mght be a little easier to understand if you set up a few equates like..
      Code:
      $FONTNAME_SCREEN_1  = "Times New Roman" 
      %FONTSIZE_SCREEN_1  =  10& 
       
      $FONTNAME_SCREEN_2  = "Arial" 
      %FONTSIZE_SCREEN_2  =  12& 
      
      ...
         FONT  NEW $FONTNAME_SCREEN_1 ....%FONTSIZE_SCREEN_1
      How about when your user (which could be you!) says, "I don't like that font, make it something else and make it a little smaller?" A little easier to change perhaps?
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        >Think your code mght be a little easier to understand if you set up a few equates like..
        ..
        >How about when your user (which could be you!) says, "I don't like that font, make it something else and make it a little smaller?" A little easier to change perhaps?

        Context? - I posted a compilable example to illustrate a narrow point.
        Rgds, Dave

        Comment


        • #5
          Thanks Dave,

          I was wrong, but it indeed does not work with MS Sans Serif.

          Peter Redei

          Comment


          • #6
            But it does work with Microsoft Sans Serif

            Seems that True Type fonts are required for escapement to work in the Font New statement..?
            Rgds, Dave

            Comment


            • #7
              Yes, only true type fonts can be rotated (have an escapement).
              Last edited by Steve Rossell; 21 Jan 2009, 01:08 PM.
              Sincerely,

              Steve Rossell
              PowerBASIC Staff

              Comment


              • #8
                >Yes, only true type fonts can be rotated (have an escapement).

                Easy mod to generate list of installed TT fonts:

                Determine if font with given face name is installed on user system

                MCM
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment

                Working...
                X