VectorFont ignores font

Just starting out? Need help? Post your questions and find answers here.
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

VectorFont ignores font

Post by User_Russian »

Why VectorFont not use a font?

Code: Select all

If RegisterFontFile("LCD-BOLD.ttf")
  
  If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CanvasGadget(0, 0, 50, 400, 200)
    LoadFont(0, "LCD", 36)
    TextGadget(1, 0 ,0, 400, 50, "1234")
    SetGadgetFont(1, FontID(0))
    
    If StartVectorDrawing(CanvasVectorOutput(0))
      
      VectorFont(FontID(0))
      VectorSourceColor(RGBA(0, 0, 0, 255))
      DrawVectorText("1234")  
      StopVectorDrawing()
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf

EndIf
Font. https://my-files.ru/82005e
Everything
Enthusiast
Enthusiast
Posts: 224
Joined: Sat Jul 07, 2018 6:50 pm

Re: VectorFont ignores font

Post by Everything »

Image

Works fine for me (Win7 x64)
Maybe add some specific for your system like LoadFont(0, "LCD", 36, #PB_Font_Bold)
as it's bold only

Image

хз
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: VectorFont ignores font

Post by RASHAD »

Edit :Just checked your snippet with latest versions of windows 10 and PB and it works fine (I think)

Vector Drawing Lib can not use any font unless it is installed into windows
To use any embedded font

Code: Select all

Text$ = "This is a TEST"
If CreateFile(0, GetTemporaryDirectory()+"LCD-BOLD.ttf")
    WriteData(0, ?Font,?fontend-?font)
  CloseFile(0)
Else
  Debug "can not create the file!"
EndIf

fontname$ =  GetTemporaryDirectory()+"LCD-BOLD.ttf"
AddFontResource_(@fontname$)
SendMessage_(#HWND_BROADCAST, #WM_FONTCHANGE, 0, 0)

LoadFont(0,"LCD",14)

OpenWindow(0,0,0,400,300,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered| #PB_Window_MaximizeGadget)
TextGadget(0,10,10,300,40,Text$,#SS_CENTERIMAGE | #SS_CENTER| #WS_BORDER)
CanvasGadget(1,10,60,300,40)
SetGadgetFont(0, FontID(0))
SetGadgetColor(0,#PB_Gadget_FrontColor,#Red)
SetGadgetColor(0,#PB_Gadget_BackColor,#Yellow)

If StartVectorDrawing(CanvasVectorOutput(1))

 VectorSourceColor(RGBA(247, 249, 13, 255))
 FillVectorOutput()
 VectorFont(FontID(0) , 32)
 VectorSourceColor(RGBA(255, 0, 0, 255))
 MovePathCursor(30,5)
 DrawVectorText(Text$)    
 StopVectorDrawing()
 
EndIf

Repeat
 
 Select WaitWindowEvent()
   
  Case #PB_Event_CloseWindow
    RemoveFontResource_(@fontname$)
    SendMessage_(#HWND_BROADCAST, #WM_FONTCHANGE, 0, 0)
    RunProgram(GetEnvironmentVariable("comspec"),"/c del "+Chr(34)+fontname$+Chr(34),"",2)
    Quit = 1
   
 EndSelect
 
Until Quit = 1
RemoveFontResource_(@fontname$)
SendMessage_(#HWND_BROADCAST, #WM_FONTCHANGE, 0, 0)
RunProgram(GetEnvironmentVariable("comspec"),"/c del "+Chr(34)+fontname$+Chr(34),"",2)
End

DataSection
  Font:
    IncludeBinary "LCD-BOLD.ttf"
  fontend:
EndDataSection

Egypt my love
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: VectorFont ignores font

Post by Olliv »

I am surprised RegisterFontFile() seems to be useless.
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: VectorFont ignores font

Post by Mijikai »

Optional you can also try this (load and register fonts from memory):
viewtopic.php?p=538022#p538022
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: VectorFont ignores font

Post by User_Russian »

Everything wrote:Works fine for me (Win7 x64)
This text is displayed in TextGadget. In CanvasGadget there is no text.
Mijikai wrote:you can also try this (load and register fonts from memory)
Unfortunately this does not work. In CanvasGadget, no text.

This font for some unknown reason cannot use in VectorDrawing library.
User avatar
blueb
Addict
Addict
Posts: 1041
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: VectorFont ignores font

Post by blueb »

This font for some unknown reason cannot use in VectorDrawing library.

I have no problems...
- Your 'Font.zip' program works fine.
- Rashad's sample works well.

Using Win 10 Pro 64 and PureBasic 5.71 LTS x86 and x64

Just a guess: Could it be a graphics card issue?
- It was too lonely at the top.

System : PB 6.10 Beta 9 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply