Tuesday, May 29, 2012

Menggunakan Fonts Tanpa Menginstalnya

Di bawah ini merupakan kode untuk menggunakan fonts tanpa harus menginstalnya.
Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" ByVal lpFileName As String) As Long 
Private Declare Function
RemoveFontResource Lib "gdi32" Alias "RemoveFontResourceA" ByVal lpFileName As String) As Long

Public Function
AddFontToResource(Filename As String)
Dim lFont As Long
lFont = RemoveFontResource(Filename)
End Function

Public Function
RemoveFontFromResource(Filename As String)
Dim lFont As Long
lFont = AddFontResource(Filename)
End Function
Contoh penggunaan fungsi di atas:
Private Sub Form_Load() 
AddFontResource App.Path & "\Fonts\Trado.ttf"
Text1.FontName = "Traditional Arabic"
End Sub