Font Size

Just starting out? Need help? Post your questions and find answers here.
jak64
Enthusiast
Enthusiast
Posts: 502
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Font Size

Post by jak64 »

Hello,
I've programmed all day, so I must be tired!

I don't understand why the font size is not taken into account in this program!!!

Thank you for your help

Code: Select all

EnableExplicit

InitSprite()

Enumeration
  #FenetreWindows
  #Bouton
  #FenetreScreen
EndEnumeration

Global Event.i
Global Police.w
Global Libelle.s, Largeur.w, Hauteur.w
Global y.w

Global Dim TPolices.w(30)

For Police=1 To 30
  TPolices(Police)=LoadFont(#PB_Any, "Calibri", Police+1)
Next Police

OpenWindow(#FenetreWindows, 0, 0, 800, 600, "Test taille polices", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#Bouton, 750, 0, 45, 20, "Quitter")
OpenWindowedScreen(WindowID(#FenetreWindows), 0, 0, 700, 550)

Libelle="Ceci est un test de police"
Repeat
  Repeat      
    Event = WindowEvent()            
    Select Event 
      Case #PB_Event_Gadget          
        If EventGadget() = #Bouton
          End
        EndIf
      Case #PB_Event_CloseWindow
        End 
    EndSelect
  Until Event = 0
  ClearScreen(#White)
  y=10
  For Police=1 To 30
    StartDrawing(ScreenOutput())
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawingFont(TPolices(Police))
    Largeur=TextWidth(Libelle)
    Hauteur=TextHeight(Libelle)
    DrawText(10,y,"Police=" + Str(police+9) + " " + Libelle + " = " + Str(largeur) + " pixels", #Black)
    StopDrawing()
    y+Hauteur+2
  Next Police
  FlipBuffers() 
ForEver
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Font Size

Post by Mijikai »

Store the font into an Integer instead of Word.
Use the FontID() of the font in DrawingFont().
Dont forget to close the screen and window!
jak64
Enthusiast
Enthusiast
Posts: 502
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Re: Font Size

Post by jak64 »

I don't understand !!!

I change

Code: Select all

DrawingFont(FontID(TPolices(Police)))
but syntax error
jak64
Enthusiast
Enthusiast
Posts: 502
Joined: Sat Aug 15, 2020 5:02 pm
Location: Ciboure (France)

Re: Font Size

Post by jak64 »

ok i found it, thanks
Post Reply