Jump to content

FontAwesome UDF V1.0 - Easy to add cool Icon text to your project


nvt
 Share

Recommended Posts

I'm written this UDF with purpose to help you can write cool Icon in your project by used FontAwesome easily.
- Have 634 cool icons.
- Based on FontAwesome orginal.
- Easy to use with IconName (You can get Icon Name at this site: http://fontawesome.io/icons)
- You can use different version of FontAwesome(must be use CSS (font-awesome.css) in "FontAwesome Source") 
  with _FontAwesome_Load($sFontFile, $sCSSFile) function because CSS file contain UnicodeHex of IconName.
  Example: _FontAwesome_Load("Awesome\fonts\FontAwesome.otf", "Awesome\css\font-awesome.css")
  Default _FontAwesome_Load() use FontAwesome V4.6.3 (Base64Encoded) with __FontAwesome_HexTable() function return UnicodeHex of IconName.
 

Screenshot

MeXVRKj.png


Example

#This Script was written by TNV
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "_FontAwesome_UDF.au3"

#Region Load Fontawesome
    _FontAwesome_Load() ;Default use FontAwesome V4.6.3 and HEXTable function
    ;~ _FontAwesome_Load("Awesome\fonts\FontAwesome.otf", "Awesome\css\font-awesome.css") ;Load custom Font, and custom HexTable CSS
#EndRegion

;To get Icon name, you can visit website: http://fontawesome.io/icons

GUICreate("FontAwesome UDF V1.0 Example - TNV", 408, 128, 192, 124, -1, BitOR($WS_EX_APPWINDOW,$WS_EX_WINDOWEDGE))

GUICtrlCreateLabel(_FontAwesome_Icon("desktop"), 48, 48, 64, 29, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16, 400, 0, "FontAwesome")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x800000)

GUICtrlCreateLabel(_FontAwesome_Icon("edit"), 128, 48, 64, 29, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16, 400, 0, "FontAwesome")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x800000)

GUICtrlCreateLabel(_FontAwesome_Icon("dashboard"), 208, 48, 64, 29, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16, 400, 0, "FontAwesome")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x800000)

GUICtrlCreateLabel(_FontAwesome_Icon("envelope-o"), 288, 48, 64, 29, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 16, 400, 0, "FontAwesome")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x800000)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

I come from Vietnamese so my English not good!
(c) Nguyễn Việt Thái (TNV)

FontAwesome_UDF.zip

Edited by nvt
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...

I like this UDF. However, there is a bug that you should probably fix: FileInstall

The source file must be specified using a string literal and can not be a variable, a macro, a calculation nor function call

Func _FontAwesome_Load($sFont = "", $sFontCSS = "")
    If Not $sFont Then
        __FontData(1, @TempDir)
    ;Else
        ;FileInstall($sFont, @TempDir & "\FontAwesome.otf", 1)
    EndIf
    If FileExists(@TempDir & "\FontAwesome.otf") Then
        If _WinAPI_AddFontResourceEx(@TempDir & "\FontAwesome.otf", $FR_PRIVATE) Then
            OnAutoItExitRegister("_FontAwesome_Unload")
            If $sFontCSS Then
                $___fontawesome_css = @TempDir & StringRegExpReplace($sFontCSS, "^.*\\", "\\")
                ;If FileInstall($sFontCSS, $___fontawesome_css, 1) Then
                ;   $___IsLoadCSS = True
                ;   __FontAwesome_ImportCSS($___fontawesome_css, $___sFontCSS_Data)
                ;EndIf
            EndIf
            Return 1
        EndIf
    EndIf
    Return SetError(1, 0, 0)
EndFunc

I had to comment out the FileInstall just so I could compile my script.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...