Load a font from file (like AddFontResource_)

Mac OSX specific forum
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Load a font from file (like AddFontResource_)

Post by Danilo »

Example: Embedded_font_in_app.zip (51KB)

Code: Select all

;
; 1.) Compile your .app
;
; 2.) Create the "Resources" directory within your .app/Contents/ directory
;
; 3.) Create a "fonts" directory within the Resources directory and copy your fonts there
;
; 4.) Add the following key and string to your Info.plist:
;     <key>ATSApplicationFontsPath</key>
;     <string>fonts</string>
;
;     the string "fonts" is the name of the directory
;     within your Resources folder, where your fonts are located
;
;
;
; The embedded font is „Crystal“ by Allen R Walden:
; http://www.fontspace.com/allen-r-walden/crystal
;
crystal = LoadFont(#PB_Any,"Crystal", 100, #PB_Font_HighQuality)
image   = CreateImage(#PB_Any, 800,600, 32, RGB(255,255,255))

If StartDrawing( ImageOutput(image) )
    DrawingFont( FontID(crystal) )
    DrawingMode(#PB_2DDrawing_Transparent)
    DrawText(10,10,"CRYSTAL FONT",RGB(0,0,0))
    StopDrawing()
EndIf

OpenWindow(0,0,0,800,600,"Load embedded font from .app",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ImageGadget(0,0,0,800,600,ImageID(image))
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
User avatar
glomph
User
User
Posts: 48
Joined: Tue Apr 27, 2010 1:43 am
Location: St. Elsewhere / Germany
Contact:

Re: Load a font from file (like AddFontResource_)

Post by glomph »

Thank you very much for that.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Load a font from file (like AddFontResource_)

Post by luis »

Thank you Danilo, could be useful :)
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply