Can't help further though because it seems to be a PB / Linux related issue (as you said before
the later versions the performance was better) and I don't use Linux.
Sorry.
Code: Select all
Structure glyph
glyph.i
refcount.i
width.i
height.i
EndStructure
Global NewMap glyphs.glyph()
Procedure GlyphCache()
tf=LoadFont(#PB_Any,"arial",14,0)
For a = 32 To 126
timg = CreateImage(#PB_Any,1,1)
StartDrawing(ImageOutput(timg))
DrawingFont(FontID(tf))
width = TextWidth(Chr(a))
height = TextHeight(Chr(a))
StopDrawing()
FreeImage(timg)
If width And height
glyphs(Chr(a))\glyph = CreateImage(#PB_Any,width,height,24)
StartDrawing(ImageOutput(glyphs(Chr(a))\glyph))
DrawingMode(#PB_2DDrawing_Default)
DrawingFont(FontID(tf))
DrawText(0,0,Chr(a),RGB(255,0,0),0)
StopDrawing()
glyphs(Chr(a))\width = width
glyphs(Chr(a))\height = height
EndIf
Next
EndProcedure
Procedure myDrawtext(output.i,text.s,x,y)
Protected chr.s
len = Len(text)
If StartDrawing(output)
For a = 1 To len
chr = Mid(text,a,1)
DrawImage(ImageID(glyphs(chr)\glyph),x,y)
x+glyphs(chr)\width
Next
StopDrawing()
EndIf
EndProcedure
GlyphCache()
OpenWindow(0,0,0,800,600,"test")
Repeat
ev = WindowEvent()
myDrawtext( WindowOutput(0),"test",Random(700)+50,Random(500)+50)
Delay(20)
Until ev =#PB_Event_CloseWindow
