Thanks for helping, the
pjay's idea is genius - but can't fix all errors here (one extreme case can be checked by downloading my
demo program* or with the simple code below. It uses the font Bahnschrift but there are many more showing the same issues.
#Null's code snippet does still show holey areas here
I think, vector font drawing does need a different mode for drawing where overlapping object areas needs to be painted as well.
*) The program is a fully working image filter program but starts with a text example at the first run. Font & Text options are set by using the shortcut Ctrl+Shift+F, Shift+Escape quits the program.
Code: Select all
#Text="HEKTX"
#Size=40
#Font="Bahnschrift"
#Img_BG = 0
#Img_FG = 1
#Img_Final = 2
OpenWindow(0, 0, 0, 1000, 200, "Hole in One", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
LoadFont(0,#Font,#Size,#PB_Font_Bold)
CreateImage(#Img_FG,250,50,32,#Black)
CreateImage(#Img_BG,250,50,32,#Black)
CreateImage(#Img_Final,250,50,32,#Black)
StartVectorDrawing(ImageVectorOutput(#Img_BG))
VectorFont(FontID(0),#Size)
For i=-50 To 250 Step 10
MovePathCursor(i,50)
AddPathLine(50,-50,#PB_Path_Relative)
Next i
VectorSourceColor($FF804040)
StrokePath(3)
StopVectorDrawing()
Procedure outlinedText_ToImg_Alpha(img,x,y,text.s, fontID = 0, size.f = 16.5, outlineSize = 13, txtCol = $ff0000ff, outlineCol = $80ffffff)
Protected ola = Alpha(outlineCol), olc = RGBA(Red(outlineCol),Green(outlineCol),Blue(outlineCol),255),px,py,p,r,g,b,a
StartVectorDrawing(ImageVectorOutput(img))
VectorFont(FontID(fontID),#Size)
MovePathCursor(x, y)
AddPathText(text)
For px = 1 To outlineSize Step 2 : VectorSourceColor(olc) : StrokePath(px,#PB_Path_Preserve|#PB_Path_RoundCorner) : Next
StopVectorDrawing()
StartDrawing(ImageOutput(img))
DrawingMode(#PB_2DDrawing_AllChannels)
For px = 0 To OutputWidth()-1
For py = 0 To OutputHeight()-1
p = Point(px,py) : r = Red(p) : g = Green(p) : b = Blue(p)
If r > 0 Or g > 0 Or b > 0 : Plot(px,py,RGBA(r,g,b,ola)) : Else : Plot(px,py,RGBA(0,0,0,0)) : EndIf
Next
Next
StopDrawing()
StartVectorDrawing(ImageVectorOutput(img))
VectorFont(FontID(fontID),#Size)
VectorSourceColor($FF0000ff)
MovePathCursor(x, y)
AddPathText(text)
FillPath()
StopVectorDrawing()
EndProcedure
txt.s = "'Simple ; * : ~ errors!'"
outlinedText_ToImg_Alpha(#Img_FG,20,10,#Text)
; final composition:
StartDrawing(ImageOutput(#Img_Final))
DrawImage(ImageID(#Img_BG),0,0)
DrawingMode(#PB_2DDrawing_AlphaBlend)
DrawImage(ImageID(#Img_FG),0,0)
StopDrawing()
ResizeImage(#Img_Final,1000,200,#PB_Image_Raw)
ImageGadget(0, 0, 0, 1000, 200, ImageID(#Img_Final))
SetWindowTitle(0,"Time for process: "+Str(time)+"ms")
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow