Page 1 of 1
[Done] SvgVectorOutput and fonts
Posted: Fri Sep 05, 2025 5:28 pm
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?
Re: SvgVectorOutput and fonts
Posted: Fri Sep 05, 2025 5:39 pm
by infratec
Please provide a working example which shows the problem.
Re: SvgVectorOutput and fonts
Posted: Fri Sep 05, 2025 8:50 pm
by RASHAD
Hi
If you are a windows user
The vector lib deals only with the installed fonts
Re: SvgVectorOutput and fonts
Posted: Fri Sep 05, 2025 9:29 pm
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>
Re: SvgVectorOutput and fonts
Posted: Fri Sep 05, 2025 9:55 pm
by infratec
This looks like a bug.
Only "t" is wrong.
A moderator should move this in the bug section for investigation.
Re: SvgVectorOutput and fonts
Posted: Sat Sep 06, 2025 9:13 am
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)
Re: SvgVectorOutput and fonts
Posted: Sat Sep 06, 2025 10:43 am
by punak
I'm trying it on Windows and I'm having this problem for all fonts.

Re: SvgVectorOutput and fonts
Posted: Sun Sep 07, 2025 12:22 am
by mk-soft
OS Window
Works with PB v6.12 but not since v6.20.
So a bug
Re: SvgVectorOutput and fonts
Posted: Wed Sep 10, 2025 8:50 am
by Fred
Fixed.