Page 1 of 1

RegisterFontFile() True Type Font vs Open Type Font

Posted: Mon Sep 25, 2023 11:20 pm
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

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

Posted: Tue Sep 26, 2023 12:06 am
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 ?

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

Posted: Tue Sep 26, 2023 12:54 am
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