vectordrawing and font offset, bigdifferences

Just starting out? Need help? Post your questions and find answers here.
Mesa
Enthusiast
Enthusiast
Posts: 460
Joined: Fri Feb 24, 2012 10:19 am

vectordrawing and font offset, bigdifferences

Post by Mesa »

I have a large difference in text offset calculation between the default font loaded with loadfont() and the default font from getgadgetfont(). Is that normal ?

pb630b4 x64 windows

See under:

Code: Select all

If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 400, 200)
  
  LoadFont(0, "", 11)
  font=GetGadgetFont(#PB_Default)
  
  If StartVectorDrawing(CanvasVectorOutput(0))
    
    VectorSourceColor(RGBA(0, 0, 0, 180))
    Text$ = "ÎÇ"
    
    VectorFont(FontID(0))
    Debug VectorTextHeight(Text$, #PB_VectorText_Visible | #PB_VectorText_Offset)
    
    
    
    VectorFont(font) 
    Debug VectorTextHeight(Text$, #PB_VectorText_Visible | #PB_VectorText_Offset)
    ;===>big difference (not due to the size),  and also, with pb602x86 32b, i've got 0.0 
    
    StopVectorDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

M.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 5014
Joined: Sun Apr 12, 2009 6:27 am

Re: vectordrawing and font offset, bigdifferences

Post by RASHAD »

Hi Mesa
I think your approach to get the default font is not quit right

Code: Select all

If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 400, 200)
  
;   FID = GetGadgetFont(#PB_Default)
;   fnt.LOGFONT    
;   GetObject_(FID,SizeOf(fnt),@fnt)
;   FName$ =  PeekS(@fnt\lfFaceName[0])
;   font = LoadFont(0,Fname$,11)

    sinfo.NONCLIENTMETRICS
    sinfo\cbSize = SizeOf(sinfo)
    SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS,0,@sinfo,0)
    Fname$ = PeekS(@sinfo\lfCaptionFont\lfFaceName[0])
    font = LoadFont(0,Fname$,11)
    
  If StartVectorDrawing(CanvasVectorOutput(0))
    
    VectorSourceColor(RGBA(0, 0, 0, 180))
    Text$ = "ÎÇ"
    
    VectorFont(FontID(0))
    Debug VectorTextHeight(Text$, #PB_VectorText_Visible | #PB_VectorText_Offset)
    
    
    
    VectorFont(font) 
    Debug VectorTextHeight(Text$, #PB_VectorText_Visible | #PB_VectorText_Offset)
    ;===>big difference (not due to the size),  and also, with pb602x86 32b, i've got 0.0 
    
    StopVectorDrawing()
  EndIf
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Egypt my love
Post Reply