Posted: 29th Apr 2015 6:08
super simple method to check if your desired font is installed, and if not, will silently install it.

+ Code Snippet
if file exist("c:/windows/fonts/OpenSans-Regular.ttf") = 0
    copy file "media/ui/fonts/open-sans/OpenSans-Regular.ttf", "c:/tmp/OpenSans-Regular.ttf"
        while file exist("c:/tmp/OpenSans-Regular.ttf") = 0 : : endwhile
    execute file "media/ui/fonts/open-sans/copy_font.vbs", "", "", 1
    delete file "c:/tmp/OpenSans.ttf"
endif


It uses a little vbs helper script ('copy_font.vbs'):

+ Code Snippet
Set sa = CreateObject("Shell.Application")
Set fonts  = sa.NameSpace(20)
fonts.CopyHere "C:\tmp\OpenSans-Regular.ttf"


tested in XP and win7
Posted: 20th May 2015 10:23
If you have the d3d plugin then unremark then d3d commands


function Make2dBox(x,y,width,height,r,g,b)
rem if using d3d 2d
` d3d_color r/4,g/4,b/4,200
` d3d_box x,y,x+width,y+height
` d3d_color r,g,b,200
` d3d_box x+1,y+1,x+width-1,y+height-1
rem if using dbpro 2d
` ink rgb(r/4,g/4,b/4),1
` box x,y,x+width,y+height
` ink rgb(r,g,b),1
` box x+1,y+1,x+width-1,y+height-1
endfunction
Posted: 31st May 2015 6:38
Haven't used Visual Basic Script in so long, I forgot it existed. These are the functions I use. It will check if the font exists on the users system. If the font is not present it will load the font and clean it from the system on exit. If the font exists on the user system it wont bother and just utilize the pre-existing font.

+ Code Snippet
#constant   GDI32 1

FontPreExist as integer
FontName as string

FontName = "media/ui/fonts/open-sans/OpenSans-Regular.ttf"

load dll "gdi32.dll", GDI32

if (FontExist("Open Sans")=0)
   FontPreExist = 0
   LoadFont(FontName)
else
   FontPreExist = 1
endif

set text font "Open Sans"
set text size 18

print "DBPro Rules!"
wait key

if (FontPreExist=0)
   UnloadFont(FontName)
endif

delete dll GDI32

end

function LoadFont(FontFile as string)
   local result as integer

   result = call dll(GDI32, "AddFontResourceA", FontFile)
endfunction result

function UnloadFont(FontFile as string)
   local result as integer

   result = call dll(GDI32, "RemoveFontResourceA", FontFile)
endfunction

function FontExist(FontName as string)
   local i as integer

   FontName = upper$(FontName)

   perform checklist for fonts
   for i = 1 to checklist quantity()
      if (upper$(checklist string$(i))=FontName)
         exitfunction 1
      endif
   next i
endfunction 0
Posted: 31st May 2015 19:25
handy!