Page 1 of 1

Re: Load a font from file (like AddFontResource_)

Posted: Fri Feb 28, 2014 7:33 am
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

Re: Load a font from file (like AddFontResource_)

Posted: Fri Feb 28, 2014 3:51 pm
by glomph
Thank you very much for that.

Re: Load a font from file (like AddFontResource_)

Posted: Fri Feb 28, 2014 9:31 pm
by luis
Thank you Danilo, could be useful :)