Many thanks for your help !
Strict
Graphics 800,600,0
Type TFont
Field x : Int[255]
Field y : Int[255]
Field w : Int[255]
Field hImage:Timage
Const CTE_NBRE_CARACTERES = 50
Function Charger_police:TFont(FileName$)
Local i:Int
Local Valeur_ascii:Int
Local Caractere$
Local f:TFont = New TFONT
For i=0 To CTE_NBRE_CARACTERES - 1
ReadData Caractere$
Valeur_ascii = Asc (Caractere$)
ReadData f.x[Valeur_ascii]
ReadData f.y[Valeur_ascii]
ReadData f.w[Valeur_ascii]
Next
f.hImage = LoadImage (FileName$)
Return f
End Function
Function DrawImageRect(img:TImage, x#, y#, rx#, ry#, rw#, rh#)
SetViewport x, y, rw, rh
DrawImage img, x - rx, x - ry
SetViewport 0, 0, GraphicsWidth(), GraphicsHeight()
End Function
Method Afficher_texte (Texte$, PosX, PosY)
Local i:Int
Local Caractere : String
Local aw : Int = 0, lx,ly,lw
Local CodeAscii : Int
Texte$ = Texte$.ToUpper()
For i=0 To Len(Texte$)- 1
CodeAscii = Texte$[i]
If CodeAscii = 32 Then
aw = aw + 16
Else
lx = x [CodeAscii]
ly = y [CodeAscii]
lw = w [CodeAscii]
DrawImagepart (hImage, PosX+aw,PosY,lx,ly,64,64)
aw = aw + lw
End If
Next
End Method
Function DrawImagePart(Image:TImage, DrawX#, DrawY#, PartX#, PartY#, PartWidth#, PartHeight#, Frame# = 0)
Local OldX:Int
Local OldY:Int
Local OldWidth:Int
Local OldHeight:Int
Local ViewportX:Int = DrawX
Local ViewportY:Int = DrawY
' Save current viewport settings
GetViewport(OldX, OldY, OldWidth, OldHeight)
' Calculate viewport coordinates based on image's handle
If Image.Handle_X Then
Local PercentX:Float
PercentX = Float(Image.Handle_X) / Float(Image.Width)
ViewportX = DrawX - (PercentX * PartWidth)
EndIf
If Image.Handle_Y Then
Local PercentY:Float
PercentY = Float(Image.Handle_Y) / Float(Image.Height)
ViewportY = DrawY - (PercentY * PartHeight)
EndIf
SetViewport(ViewportX, ViewportY, PartWidth, PartHeight)
DrawImage(Image, DrawX-PartX, DrawY-PartY, Frame)
' Restore old viewport settings
SetViewport(OldX, OldY, OldWidth, OldHeight)
End Function
End Type
Local f:TFONT
f = TFont.Charger_police ("media/bada.png")
While Not KeyDown(KEY_ESCAPE)
f.Afficher_texte ("thanks FOR YOUR HELP !!!", 100, 100)
Flip
Wend
' Symbo, x, y, width
' Symbo, x, y, width
DefData "!",0,0,22
DefData Chr$(34),64,0,25
DefData "#",128,0,32
DefData "$",192,0,23
DefData "%",256,0,34
DefData "&",320,0,29
DefData "'",384,0,15
DefData "(",448,0,21
DefData ")",0,64,21
DefData "*",64,64,21
DefData "+",128,64,17
DefData ",",192,64,17
DefData "-",256,64,17
DefData ".",320,64,13
DefData "/",384,64,32
DefData "0",448,64,26
DefData "1",0,128,18
DefData "2",64,128,26
DefData "3",128,128,24
DefData "4",192,128,23
DefData "5",256,128,23
DefData "6",320,128,24
DefData "7",384,128,23
DefData "8",448,128,27
DefData "9",0,192,26
DefData "A",64,192,25
DefData "B",128,192,24
DefData "C",192,192,24
DefData "D",256,192,25
DefData "E",320,192,22
DefData "F",384,192,22
DefData "G",448,192,25
DefData "H",0,256,26
DefData "I",64,256,16
DefData "J",128,256,22
DefData "K",192,256,26
DefData "L",256,256,18
DefData "M",320,256,33
DefData "N",384,256,26
DefData "O",448,256,26
DefData "P",0,320,24
DefData "Q",64,320,26
DefData "R",128,320,24
DefData "S",192,320,23
DefData "T",256,320,21
DefData "U",320,320,25
DefData "V",384,320,23
DefData "W",448,320,31
DefData "X",0,384,28
DefData "Y",64,384,24
DefData "Z",128,384,27