I had second thoughts about adding extra parameters, so I revised my upper-case font to use a macro instead.
Code: Select all
Declare.i A2M (file$, img.i, size.i, color.i)
Declare.i N2Z (file$, img.i, size.i, color.i)
Macro UcaseFont(_x_,_y_,_size_,_Char_,_rotation_=0)
hh = _size_ *0.3125
SaveVectorState()
RotateCoordinates(size * 0.5,size * 0.5,_rotation_)
Select _Char_
Case Asc("A")
hw = hh * 0.9
MovePathCursor(_x_ - hw,_y_ + hh)
AddPathLine(_x_,_y_ - hh)
AddPathLine(_x_ + hw, _y_ + hh)
MovePathCursor(_x_ - hw/1.8,_y_ + hh/3)
AddPathLine(_x_ + hw/1.8,_y_ + hh/3)
Case Asc("B")
hw = hh * 0.81
MovePathCursor(_x_ + hw * 0.08,_y_ - hh)
AddPathLine(_x_ - hw ,_y_ - hh)
AddPathLine(_x_ - hw, _y_ + hh)
MovePathCursor(_x_ - hw + hh,_y_)
AddPathLine(_x_ - hw,_y_)
AddPathCircle(_x_ + hw * 0.08,_y_ - hh/2,hh/2,270,90)
MovePathCursor(_x_ - hw + hh,_y_ + hh)
AddPathLine(_x_ - hw,_y_ + hh)
AddPathCircle(_x_ - hw + hh,_y_ + hh/2,hh/2,270,90)
Case Asc("C")
hw = hh * 0.9
AddPathCircle(_x_, _y_ + hw - hh,hw,200,340)
AddPathCircle(_x_, _y_ - hw + hh,hw,20,160)
MovePathCursor(_x_ - hw * 0.95,_y_ - hh/2.75)
AddPathLine(_x_ - hw * 0.95,_y_ + hh/2.75)
Case Asc("D")
hw = hh * 0.81
MovePathCursor(_x_ - hw/2.5,_y_ - hh)
AddPathLine(_x_ - hw ,_y_ - hh)
AddPathLine(_x_ - hw, _y_ + hh)
MovePathCursor(_x_ - hw/2.5,_y_ + hh)
AddPathLine(_x_ - hw,_y_ + hh)
AddPathCircle(_x_ - hw/2.5,_y_ ,hh,270,90)
Case Asc("E")
hw = hh * 0.81
MovePathCursor(_x_ + hw,_y_ - hh)
AddPathLine(_x_ - hw ,_y_ - hh)
AddPathLine(_x_ - hw, _y_ + hh)
AddPathLine(_x_ + hw,_y_ + hh)
MovePathCursor(_x_ - hw,_y_)
AddPathLine(_x_ + hw * 0.8,_y_)
Case Asc("F")
hw = hh * 0.81
MovePathCursor(_x_ + hw,_y_ - hh)
AddPathLine(_x_ - hw ,_y_ - hh)
AddPathLine(_x_ - hw, _y_ + hh)
MovePathCursor(_x_ - hw,_y_)
AddPathLine(_x_ + hw * 0.8,_y_)
Case Asc("G")
hw = hh * 0.9
AddPathCircle(_x_, _y_ + hw - hh,hw,200,340)
AddPathCircle(_x_, _y_ - hw + hh,hw,20,160)
MovePathCursor(_x_ - hw * 0.95,_y_ - hh/2.75)
AddPathLine(_x_ - hw * 0.95,_y_ + hh/2.75)
MovePathCursor(_x_ + hw/5,_y_ + hh/5)
AddPathLine(_x_ + hw * 0.95,_y_ + hh/5)
AddPathLine(_x_ + hw * 0.95,_y_ + hh/2.75)
Case Asc("H")
hw = hh * 0.81
MovePathCursor(_x_ - hw,_y_ - hh)
AddPathLine(_x_ - hw ,_y_ + hh)
MovePathCursor(_x_ + hw,_y_ - hh)
AddPathLine(_x_ + hw ,_y_ + hh)
MovePathCursor(_x_ - hw,_y_)
AddPathLine(_x_ + hw ,_y_)
Case Asc("I")
hw = hh * 0.81
MovePathCursor(_x_ ,_y_ - hh)
AddPathLine(_x_ ,_y_ + hh)
Case Asc("J")
hw = hh * 0.81
MovePathCursor(_x_ ,_y_ - hh)
AddPathLine(_x_ ,_y_ + hh * 0.55)
AddPathCircle(_x_ - hh/2,_y_ + hh/2, hh/2,0,180)
Case Asc("K")
hw = hh * 0.6
MovePathCursor(_x_ - hw,_y_ - hh)
AddPathLine(_x_ - hw,_y_ + hh)
MovePathCursor(_x_ - hw,_y_ + hh/3)
AddPathLine(_x_ + hw, _y_ - hh)
MovePathCursor(_x_ - hw/8,_y_ - hh/10)
AddPathLine(_x_ + hw,_y_ + hh)
Case Asc("L")
hw = hh * 0.45
MovePathCursor(_x_ - hw,_y_ - hh)
AddPathLine(_x_ - hw ,_y_ + hh)
AddPathLine(_x_ + hw, _y_ + hh)
Case Asc("M")
hw = hh * 0.9
MovePathCursor(_x_ - hw,_y_ + hh)
AddPathLine(_x_ - hw,_y_ - hh)
AddPathLine(_x_, _y_ + hh * 0.05)
AddPathLine(_x_ + hw,_y_ - hh)
AddPathLine(_x_ + hw,_y_ + hh)
Case Asc("N")
hw = hh * 0.81
MovePathCursor(_x_ - hw,_y_ + hh)
AddPathLine(_x_ - hw ,_y_ - hh)
AddPathLine(_x_ + hw ,_y_ + hh)
AddPathLine(_x_ + hw ,_y_ -hh)
Case Asc("O")
hw = hh * 0.9
AddPathCircle(_x_, _y_ + hw - hh,hw,200,340)
AddPathCircle(_x_, _y_ - hw + hh,hw,20,160)
MovePathCursor(_x_ - hw * 0.95,_y_ - hh/2.75)
AddPathLine(_x_ - hw * 0.95,_y_ + hh/2.75)
MovePathCursor(_x_ + hw * 0.95,_y_ - hh/2.75)
AddPathLine(_x_ + hw * 0.95,_y_ + hh/2.75)
Case Asc("P")
hw = hh * 0.81
MovePathCursor(_x_ - hw + hh,_y_ - hh)
AddPathLine(_x_ - hw ,_y_ - hh)
AddPathLine(_x_ - hw, _y_ + hh)
MovePathCursor(_x_ - hw + hh,_y_)
AddPathLine(_x_ - hw,_y_)
AddPathCircle(_x_ - hw + hh,_y_ - hh/2,hh/2,270,90)
Case Asc("Q")
hw = hh * 0.9
AddPathCircle(_x_, _y_ + hw - hh,hw,200,340)
AddPathCircle(_x_, _y_ - hw + hh,hw,20,160)
MovePathCursor(_x_ - hw * 0.95,_y_ - hh/2.75)
AddPathLine(_x_ - hw * 0.95,_y_ + hh/2.75)
MovePathCursor(_x_ + hw * 0.95,_y_ - hh/2.75)
AddPathLine(_x_ + hw * 0.95,_y_ + hh/2.75)
MovePathCursor(_x_ + hw/4,_y_ + hh/4)
AddPathLine(_x_ + hw * 1.1,_y_ + hh * 1.1)
Case Asc("R")
hw = hh * 0.81
MovePathCursor(_x_ - hw + hh,_y_ - hh)
AddPathLine(_x_ - hw ,_y_ - hh)
AddPathLine(_x_ - hw, _y_ + hh)
MovePathCursor(_x_ - hw + hh,_y_)
AddPathLine(_x_ - hw,_y_)
AddPathCircle(_x_ - hw + hh,_y_ - hh/2,hh/2,270,90)
MovePathCursor(PathCursorX() - hw/6,PathCursorY())
AddPathLine(_x_ + hw * 0.7,_y_ + hh)
Case Asc("S")
hw = hh * 0.9
AddPathCircle(_x_ + 0.0125 * _size_,_y_ - 0.0125 * _size_, 0.315625 * _size_,240,320)
AddPathCircle(_x_ - 0.09375 * _size_,_y_ - 0.15625 * _size_, 0.140625 * _size_,250,95,#PB_Path_CounterClockwise)
AddPathLine(_x_ + 0.125 * _size_, _y_ + 0.046875 * _size_)
AddPathCircle(_x_ + 0.125 * _size_,_y_ + 0.1875 * _size_, 0.140625 * _size_,275,70)
AddPathCircle(_x_ + 0.01875 * _size_,_y_ + 0.04375 * _size_, 0.315625 * _size_,60,140)
Case Asc("T")
hw = hh * 0.81
MovePathCursor(_x_ - hw,_y_ - hh)
AddPathLine(_x_ + hw ,_y_ - hh)
MovePathCursor(_x_, _y_ - hh)
AddPathLine(_x_,_y_ + hh)
Case Asc("U")
hw = hh * 0.81
AddPathCircle(_x_, _y_ - hw + hh,hw,20,160)
MovePathCursor(_x_ - hw * 0.95,_y_ - hh)
AddPathLine(_x_ - hw * 0.95,_y_ + hh/2.3)
MovePathCursor(_x_ + hw * 0.95,_y_ - hh)
AddPathLine(_x_ + hw * 0.95,_y_ + hh/2.3)
Case Asc("V")
hw = hh * 0.9
MovePathCursor(_x_ - hw,_y_ - hh)
AddPathLine(_x_ ,_y_ + hh)
AddPathLine(_x_ + hw, _y_ - hh)
Case Asc("W")
hw = hh * 1.5
MovePathCursor(_x_ - hw, _y_ - hh)
AddPathLine(_x_ - hw * 0.5,_y_ + hh)
AddPathLine(_x_,_y_ - hh * 0.5)
AddPathLine(_x_ + hw * 0.5,_y_ + hh)
AddPathLine(_x_ + hw,_y_ - hh)
Case Asc("X")
hw = hh * 0.81
MovePathCursor(_x_ - hw,_y_ - hh)
AddPathLine(_x_ + hw ,_y_ + hh)
MovePathCursor(_x_ + hw, _y_ - hh)
AddPathLine(_x_ - hw,_y_ + hh)
Case Asc("Y")
hw = hh * 0.9
MovePathCursor(_x_ - hw,_y_ - hh)
AddPathLine(_x_ ,_y_)
AddPathLine(_x_ + hw, _y_ - hh)
MovePathCursor(_x_,_y_)
AddPathLine(_x_,_y_ + hh)
Case Asc("Z")
hw = hh * 0.81
hw = hh * 0.81
MovePathCursor(_x_ - hw,_y_ - hh)
AddPathLine(_x_ + hw ,_y_ - hh)
AddPathLine(_x_ - hw, _y_ + hh)
AddPathLine(_x_ + hw,_y_ + hh)
EndSelect
StrokePath(_size_ / 16,#PB_Path_RoundEnd | #PB_Path_RoundCorner)
RestoreVectorState()
EndMacro
Procedure.i A2M (file$, img.i, size.i, color.i)
; file$: name of SVG file which is to be created (only supported on Linux),
; or "" for creating an image in memory
; in : img : number of the image which is to be created, or #PB_Any
; size : width and height (number of pixels)
; color: foreground color
; out: return value: if img = #Pb_Any => number of the created image,
; error => 0
; [by davido]
Protected ret.i, p.d, hh.d, hw.d, M.i
ret = StartVectorIconOutput(file$, img, size)
p = size / 32.0
If ret
VectorSourceColor(color)
UcaseFont(size * 0.125,size * 0.125,size * 0.25,Asc("A"))
UcaseFont(size * 0.375,size * 0.125,size * 0.25,Asc("B"))
UcaseFont(size * 0.625,size * 0.125,size * 0.25,Asc("C"))
UcaseFont(size * 0.875,size * 0.125,size * 0.25,Asc("D"))
UcaseFont(size * 0.125,size * 0.375,size * 0.25,Asc("E"))
UcaseFont(size * 0.375,size * 0.375,size * 0.25,Asc("F"))
UcaseFont(size * 0.625,size * 0.375,size * 0.25,Asc("G"))
UcaseFont(size * 0.875,size * 0.375,size * 0.25,Asc("H"))
UcaseFont(size * 0.125,size * 0.625,size * 0.25,Asc("I"))
UcaseFont(size * 0.375,size * 0.625,size * 0.25,Asc("J"))
UcaseFont(size * 0.625,size * 0.625,size * 0.25,Asc("K"))
UcaseFont(size * 0.875,size * 0.625,size * 0.25,Asc("L"))
UcaseFont(size * 0.125,size * 0.875,size * 0.25,Asc("M"))
StopVectorDrawing()
EndIf
ProcedureReturn ret
EndProcedure
Procedure.i N2Z (file$, img.i, size.i, color.i)
; file$: name of SVG file which is to be created (only supported on Linux),
; or "" for creating an image in memory
; in : img : number of the image which is to be created, or #PB_Any
; size : width and height (number of pixels)
; color: foreground color
; out: return value: if img = #Pb_Any => number of the created image,
; error => 0
; [by davido]
Protected ret.i, p.d, hh.d, hw.d
ret = StartVectorIconOutput(file$, img, size)
p = size / 32.0
If ret
VectorSourceColor(color)
UcaseFont(size * 0.125,size * 0.125,size * 0.25,Asc("N"))
UcaseFont(size * 0.375,size * 0.125,size * 0.25,Asc("O"))
UcaseFont(size * 0.625,size * 0.125,size * 0.25,Asc("P"))
UcaseFont(size * 0.875,size * 0.125,size * 0.25,Asc("Q"))
UcaseFont(size * 0.125,size * 0.375,size * 0.25,Asc("R"))
UcaseFont(size * 0.375,size * 0.375,size * 0.25,Asc("S"))
UcaseFont(size * 0.625,size * 0.375,size * 0.25,Asc("T"))
UcaseFont(size * 0.875,size * 0.375,size * 0.25,Asc("U"))
UcaseFont(size * 0.125,size * 0.625,size * 0.25,Asc("V"))
UcaseFont(size * 0.375,size * 0.625,size * 0.25,Asc("W"))
UcaseFont(size * 0.625,size * 0.625,size * 0.25,Asc("X"))
UcaseFont(size * 0.875,size * 0.625,size * 0.25,Asc("Y"))
UcaseFont(size * 0.125,size * 0.875,size * 0.25,Asc("Z"))
StopVectorDrawing()
EndIf
ProcedureReturn ret
EndProcedure
, "N2Z", "A2M"
NewIcon( A2M (file$, img.i, size.i, #CSS_Blue))
NewIcon( N2Z (file$, img.i, size.i, #CSS_Blue))
NewIcon( A2M (file$, img.i, size.i, #CSS_Silver))
NewIcon( N2Z (file$, img.i, size.i, #CSS_Silver))