Code: Select all
Procedure BaseLine(hdc,font)
SelectObject_(hdc, FontID(font))
GetTextMetrics_(hdc, @tm.TEXTMETRIC)
bLine = tm\tmDescent
ProcedureReturn bLine
EndProcedure
LoadFont(0, "Arial", 12)
LoadFont(1, "Cambria", 32)
LoadFont(2, "Times New Roman", 45)
LoadFont(3, "Verdana", 24)
LoadFont(4, "Courier New", 16)
If OpenWindow(0, 0, 0, 800, 600, "DrawText Exemple", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
iniH = 20
CreateImage(0, 800, 600)
hdc = StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent )
DrawingFont(FontID(0))
bLine = BaseLine(hdc,0)
h1 = TextHeight("Hello, ")
x1 = DrawText(10,iniH+bLine,"Hello, ",RGB(Random(255), Random(255), Random(255)))
DrawingFont(FontID(1))
bLine = BaseLine(hdc,1)
h2 = TextHeight("this ")
x2 = DrawText(x1+2 ,iniH+bLine + h1-h2,"this ",RGB(Random(255), Random(255), Random(255)))
DrawingFont(FontID(2))
bLine = BaseLine(hdc,2)
h3 = TextHeight("a ")
x3 = DrawText(x2+2,iniH+bLine + h1-h3,"a ",RGB(Random(255), Random(255), Random(255)))
DrawingFont(FontID(3))
bLine = BaseLine(hdc,3)
h4 = TextHeight("Multi-Font ")
x4 = DrawText(x3+2,iniH+bLine + h1-h4,"Multi-Font ",RGB(Random(255), Random(255), Random(255)))
DrawingFont(FontID(4))
bLine = BaseLine(hdc,4)
h5 = TextHeight("Text !")
x5 = DrawText(x4+2,iniH+bLine + h1-h5,"Text !",RGB(Random(255), Random(255), Random(255)))
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
For f = 0 To 4
FreeFont(f)
Next
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf