[Done] SvgVectorOutput and fonts

Post bugreports for the Windows version here
punak
User
User
Posts: 89
Joined: Tue Sep 07, 2021 12:08 pm

[Done] SvgVectorOutput and fonts

Post by punak »

Hello, why are the fonts used in the project not applied to the generated svg file when we use SvgVectorOutput?
What should be done to solve this problem?
infratec
Always Here
Always Here
Posts: 7620
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: SvgVectorOutput and fonts

Post by infratec »

Please provide a working example which shows the problem.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: SvgVectorOutput and fonts

Post by RASHAD »

Hi
If you are a windows user
The vector lib deals only with the installed fonts
Egypt my love
punak
User
User
Posts: 89
Joined: Tue Sep 07, 2021 12:08 pm

Re: SvgVectorOutput and fonts

Post by punak »

For example, when I run the following code:

Code: Select all

 If OpenWindow(0, 0, 0, 500, 250, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CanvasGadget(0, 0, 0, 500, 250)
    LoadFont(0, "tahoma", 20, #PB_Font_Italic)
    
    If StartVectorDrawing(SvgVectorOutput("nt.svg",500,250))
    
      VectorFont(FontID(0), 125)
      Text$ = "Sample"
      
      ; draw text
      MovePathCursor(25, 25)
      DrawVectorText(Text$)
      
      ; draw logical bounding box
      AddPathBox(25, 25, VectorTextWidth(Text$), VectorTextHeight(Text$))
      VectorSourceColor(RGBA(0, 0, 255, 255))
      DashPath(2, 10)

      ; draw visible bounding box
      AddPathBox(25 + VectorTextWidth(Text$, #PB_VectorText_Visible|#PB_VectorText_Offset), 
                 25 + VectorTextHeight(Text$, #PB_VectorText_Visible|#PB_VectorText_Offset), 
                 VectorTextWidth(Text$, #PB_VectorText_Visible), 
                 VectorTextHeight(Text$, #PB_VectorText_Visible))
      VectorSourceColor(RGBA(255, 0, 0, 255))
      DashPath(2, 10)        
      
      ; draw baseline
      MovePathCursor(25, 25 + VectorTextHeight(Text$, #PB_VectorText_Baseline))
      AddPathLine(VectorTextWidth(Text$), 0, #PB_Path_Relative)
      VectorSourceColor(RGBA(0, 255, 0, 255))
      DashPath(2, 10)                    

      StopVectorDrawing()
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf

I get the following result, which is not correct.
When I manually change font-family="t" to font-family="tahoma", the result is correct.

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="500pt" height="250pt" viewBox="0 0 500 250">
<defs>
</defs>
<text xml:space="preserve" x="25" y="150.061" font-family="t" font-size="125" font-weight="400" font-style="italic"  stroke="none" fill-rule="evenodd" fill="#000000">Sample</text>
<path stroke-dasharray="10" stroke-dashoffset="0" fill="none" stroke-width="2" stroke="#0000FF" d="M 25 25 L 428.687 25 L 428.687 175.879 L 25 175.879 Z "/>
<path stroke-dasharray="10" stroke-dashoffset="0" fill="none" stroke-width="2" stroke="#FF0000" d="M 31.546 55.0903 L 441.454 55.0903 L 441.454 175.208 L 31.546 175.208 Z "/>
<path stroke-dasharray="10" stroke-dashoffset="0" fill="none" stroke-width="2" stroke="#00FF00" d="M 25 150.061 L 428.687 150.061 "/>
</svg>
infratec
Always Here
Always Here
Posts: 7620
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: SvgVectorOutput and fonts

Post by infratec »

This looks like a bug.
Only "t" is wrong.

A moderator should move this in the bug section for investigation.
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 460
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: SvgVectorOutput and fonts

Post by Mindphazer »

Strange, the code runs fine here (on Windows and MacOS, PB 6.21)
The generated .svg has the full font name (on MacOS, for a reason i don't understand, tahoma is replaced by system Font, but if you try Arial or Courier, it works fine)
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
punak
User
User
Posts: 89
Joined: Tue Sep 07, 2021 12:08 pm

Re: SvgVectorOutput and fonts

Post by punak »

I'm trying it on Windows and I'm having this problem for all fonts. :|
User avatar
mk-soft
Always Here
Always Here
Posts: 6251
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: SvgVectorOutput and fonts

Post by mk-soft »

OS Window
Works with PB v6.12 but not since v6.20.
So a bug
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 18244
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: SvgVectorOutput and fonts

Post by Fred »

Fixed.
Post Reply