Hi kenmo
I do not know
But at least it is easier than MV naming scheme
Who can use one line to define a variable
Next some extra staff
Using TabbedTextOut_()
Code: Select all
; LoadClearTypeFont() By STARGÅTE
CreateImage(0, 200, 200)
Procedure LoadClearTypeFont(Name$, Size.i, Style=0)
Protected LogFont.LOGFONT
With LogFont
\lfHeight = Size
\lfWidth = 0
\lfEscapement = 0
\lfOrientation = 0
If Style & #PB_Font_Bold : \lfWeight = 700 : Else : \lfWeight = 400 : EndIf
If Style & #PB_Font_Italic : \lfItalic = #True : Else : \lfItalic = #False : EndIf
If Style & #PB_Font_Underline : \lfUnderline = #True : Else : \lfUnderline = #False : EndIf
If Style & #PB_Font_StrikeOut : \lfStrikeOut = #True : Else : \lfStrikeOut = #False : EndIf
\lfCharSet = #DEFAULT_CHARSET
\lfOutPrecision = #OUT_DEFAULT_PRECIS
\lfClipPrecision = #CLIP_DEFAULT_PRECIS
\lfQuality = #CLEARTYPE_NATURAL_QUALITY
\lfPitchAndFamily = #DEFAULT_PITCH | #FF_DONTCARE
PokeS(@\lfFaceName[0], Name$)
EndWith
ProcedureReturn CreateFontIndirect_(@LogFont)
EndProcedure
Procedure TabbedText()
x = 10
hDC = StartDrawing(ImageOutput(0))
SelectObject_(hDC,FontID(1))
;SelectObject_(hDC,LoadClearTypeFont("Broadway", 20))
For i = 1 To Len("Hello")
Result$ = Mid("Hello", i,1)
xx = TabbedTextOut_(hDC, x, 10, @Result$, 1, 0, 0, 0)
;(xx >> 16 & $FFFF) ;Height of text
;xx & $FFFF ;Width of Text
x = x + (xx & $FFFF)
Next
StopDrawing()
EndProcedure
LoadFont(0, "Broadway",12,#PB_Font_Underline)
LoadFont(1, "Arial",12,#PB_Font_Bold)
If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StartDrawing(ImageOutput(0))
Box(0, 0, 200, 200, $FFFFFF)
StopDrawing()
TabbedText()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Adding align (Left - Center - Right) & Differnt font size
Code: Select all
CreateImage(0, 200, 100)
CopyImage(0,1)
Procedure TextOut(Text$,x,y,schar,Align)
xs = x
ys = y
StartDrawing(ImageOutput(1))
DrawingMode(#PB_2DDrawing_Transparent)
For i = 1 To Len(Text$)
If i = schar
DrawingFont(FontID(0))
Color = $0102FE
y = ys
Else
DrawingFont(FontID(1))
Color = 0
y = ys + 6
EndIf
Result$ = Mid(Text$, i,1)
x = DrawText(x,y, Result$, Color)
Next i
StopDrawing()
If align = 0
x = 2
ElseIf align = 1
x = (ImageWidth(0) - x + xs)/2
ElseIf align = 2
x = ImageWidth(0) - x + xs - 2
EndIf
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
For i = 1 To Len(Text$)
If i = schar
DrawingFont(FontID(0))
Color = $0102FE
y = ys
Else
DrawingFont(FontID(1))
Color = 0
y = ys + 6
EndIf
Result$ = Mid(Text$, i,1)
x = DrawText(x,y, Result$, Color)
Next i
StopDrawing()
EndProcedure
LoadFont(0, "Arial",18,#PB_Font_Underline)
LoadFont(1, "Arial",12)
If OpenWindow(0, 0, 0, 400, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StartDrawing(ImageOutput(0))
Box(0, 0, 200, 100, $FFFFFF)
StopDrawing()
TextOut("Hello World!",10,5,7,0) ;0 = Left Aligned - 1 = Center Aligned - 2 = Right Aligned
TextOut("How about That",10,35,11,1)
TextOut("Is it OK ?",10,65,1,2)
FreeImage(1)
ImageGadget(0, 100,50, 200, 200, ImageID(0),#PB_Image_Border)
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow