RegisterFontFile() True Type Font vs Open Type Font

Just starting out? Need help? Post your questions and find answers here.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

RegisterFontFile() True Type Font vs Open Type Font

Post by StarBootics »

Hello everyone,

According to the documentation RegisterFontFile() is limited to TrueType font file but under Linux it's possible to register OpenType font as well.
So test are needed under Windows and Mac OS about the OpenType font.

This post is about a possible problem with the documentation.

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : Test RegisterFontFile
; File Name : Test RegisterFontFile.pb
; File version: 1.0.0
; Programming : OK
; Programmed by : StarBootics
; Date : September 25th, 2023
; Last Update : September 25th, 2023
; PureBasic code : V6.03 beta 9 LTS
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Programming Notes
;
; 1. To test this code you have to download two fonts from :
;    https://www.dafont.com/videophreak.font
;    https://www.dafont.com/coolvetica.font
;
;    Do not install the fonts on your computer, place them in
;    same folder as this source.
;
; 2. According to the documentation, only TrueType font are 
;    supported but apparently OpenType font can registered as
;    well, at least on Linux. Confirmation on other OS is 
;    needed. If it's confirmed, the documentation need to be 
;    corrected accordingly.
;
; 3. The Debugger out is showing this under Linux Debian 12 :
;
;    /home/starbootics/
;    1
;    1
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

ProgramPath.s = GetPathPart(ProgramFilename())
Debug ProgramPath

If FileSize(ProgramPath + "Videophreak.ttf") > 0
  Debug RegisterFontFile(ProgramPath + "Videophreak.ttf")
  Font00 = LoadFont(0, "Videophreak", 15)
EndIf

If FileSize(ProgramPath + "coolvetica condensed rg.otf") > 0
  Debug RegisterFontFile(ProgramPath + "coolvetica condensed rg.otf")
  Font01 = LoadFont(1, "coolvetica condensed rg", 15)
EndIf

If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
  DrawingFont(Font00)
  DrawText(50,30,"Videophreak", RGB(255, 000, 0))
  DrawingFont(Font01)
  DrawText(50,60,"Coolvetica", RGB(000, 255, 0))
  StopDrawing() 
EndIf

If OpenWindow(0, 150, 150, 200, 200, "RegisterFontFile", #PB_Window_SystemMenu)
  
  ImageGadget(0, 0, 0, 200, 200, ImageID(0))
  
  Repeat
    Event = WaitWindowEvent()      
  Until Event = #PB_Event_CloseWindow
EndIf

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: RegisterFontFile() True Type Font vs Open Type Font

Post by luis »

On Windows I have used RegisterFontFile() with open type fonts, so I can confirm it works.

BTW: have you encountered this bug viewtopic.php?t=81284 with RegisterFontFile() on Linux ?
"Have you tried turning it off and on again ?"
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: RegisterFontFile() True Type Font vs Open Type Font

Post by StarBootics »

luis wrote: Tue Sep 26, 2023 12:06 am On Windows I have used RegisterFontFile() with open type fonts, so I can confirm it works.
So we have a problem in the documentation, thanks for confirming, any one under Mac OS ?
luis wrote: Tue Sep 26, 2023 12:06 am BTW: have you encountered this bug viewtopic.php?t=81284 with RegisterFontFile() on Linux ?
Yes, thanks for the link I will add a post in this bug report.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
Post Reply