Suitable fonts for DrawVectorText()?

Just starting out? Need help? Post your questions and find answers here.
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Suitable fonts for DrawVectorText()?

Post by dige »

Hello folks,

I would like to use the Vector library for PDF creation and use certain fonts for it.
While testing, I noticed that it works with Arial & Co, but not with certain fonts, for example.

An ID is created when the font is loaded, but the text is not drawn. What is the reason for this? My selected font is also a TrueType font: ‘FuturaStd-Bold’.

Have I possibly used the wrong font name? How can I check this? When I use the font viewer, this name is displayed.

Are there some limitations for PDF creation?

I am at a loss :cry:

Edit:
I've found this nice tool: viewtopic.php?t=36198 to find the right font name. But this seems not the problem.

Code: Select all

 LoadFont(0, "Futura Std Book", 100, #PB_Font_Bold)
  
If StartVectorDrawing(PdfVectorOutput("C:\Temp\test.pdf", 2480, 3508))  
    
  VectorFont(FontID(0), 100)
  VectorSourceColor(RGBA(0, 0, 0, 80))
  MovePathCursor(0, 0)
  DrawVectorText("Titel Maximilian")
  StopVectorDrawing()
EndIf

RunProgram("C:\Temp\Test.pdf")
  
End
"Daddy, I'll run faster, then it is not so far..."
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Suitable fonts for DrawVectorText()?

Post by RASHAD »

If Futura-Std-Bold.otf is the name of the font file
Then use FuturaStd-Bold to load the font
You must install the font first :)
Egypt my love
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Suitable fonts for DrawVectorText()?

Post by dige »

Thx RASHAD,

I forgot to mention that it works when I draw on a canvas or picture. But not when PDF is the output.
"Daddy, I'll run faster, then it is not so far..."
User avatar
mk-soft
Always Here
Always Here
Posts: 6202
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Suitable fonts for DrawVectorText()?

Post by mk-soft »

I think OTF is not supported ...
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
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Suitable fonts for DrawVectorText()?

Post by dige »

Ok, but it is a TrueType font. Please try it out for yourself:

https://www.wfonts.com/download/data/20 ... futura.zip

Is that the right way to find out the correct font names?

Code: Select all

Procedure CFP_EnumProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
  Protected CHRSET = *lpelfe\elfLogFont\lfCharSet & 255
  Protected name.s

 	If CHRSET = #ANSI_CHARSET Or CHRSET = #OEM_CHARSET Or CHRSET = #SYMBOL_CHARSET
			
		name = PeekS(@*lpelfe\elfLogFont\lfFaceName[0])
		If FindString(name, "futura", 0, #PB_String_NoCase )
		  Debug name
		EndIf
		
	EndIf

  ProcedureReturn #True
EndProcedure
 
 
Define lplf.LOGFONT, hdc, Index

lplf\lfCharset = #DEFAULT_CHARSET
 
hdc = GetDC_(0)
EnumFontFamiliesEx_(hdc,lplf,@CFP_EnumProc(),hdc,0)
ReleaseDC_(0,hdc)
 
It shows me 5 futura fonts:

Futura Std Book
Futura Std Light
Futura BdCn BT
Futura MdCn BT
Futura LT Condensed

But none of them work for drawing text within the PDF creation.
"Daddy, I'll run faster, then it is not so far..."
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Suitable fonts for DrawVectorText()?

Post by dige »

With this great tool from Fluid Byte you can quickly test fonts with PDF.
If you install the Futura fonts above, they are listed as TT fonts, but unfortunately they do not work.

Code: Select all

; Title: Font Preview ComboBox
; Author: Fluid Byte
; Platform: Windows
; Created: Jan 27, 2009
; Updated: May 29, 2017
; E-Mail: fluidbyte@web.de

EnableExplicit

Declare CFP_CreateGagdet(Gadget,X,Y,Width,Height,ItemHeight=20,FontSize=11)
Declare.s CFP_GetGadgetText(Gadget,Item)
Declare CFP_FreeGadget(Gadget)
Declare CFP_EnumFonts(Gadget)
Declare CFP_EnumProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
Declare CFP_WndProc(hWnd,uMsg,wParam,lParam)

Structure CFP_FONTDATA
	Type.b
	Symbol.b
	Name.s
EndStructure

Structure CFP_USERDATA
	himlFontType.i
	FontSize.b
	hwndParent.i
EndStructure

Global NewList ftd.CFP_FONTDATA()



Define EventID, Quit

OpenWindow(0,0,0,320,240,"Font Preview ComboBox",#WS_OVERLAPPEDWINDOW | #PB_Window_ScreenCentered)
CFP_CreateGagdet(101,10,10,300,24)
ButtonGadget(1, 10, 50, 300, 30, "Create PDF")
; ---------------------------------------------------------------------------------------
; MAIN LOOP
; ---------------------------------------------------------------------------------------
Procedure CreatePDF(fontname.s)
  
  
 #PDF = 1
 
 Debug "Load Font: " + fontname
 Debug LoadFont(0, fontname, 100, #PB_Font_Bold)
 
  
  If StartVectorDrawing(PdfVectorOutput("C:\Temp\test.pdf", 2480, 3508))  
    
    
    VectorFont(FontID(0), 100)
    VectorSourceColor(RGBA(0, 0, 0, 255))
    
    MovePathCursor(140, 20)
    DrawVectorText(fontname + " ?")
    
    MovePathCursor(140, 420)
    DrawVectorText("1234567890abcdefgABCDEFGmM")
    StopVectorDrawing()
  EndIf

  RunProgram("C:\Temp\Test.pdf")
EndProcedure


Repeat
	EventID = WaitWindowEvent()
	
	If EventID = #PB_Event_CloseWindow
	   ; The ImageList used will remain in memory even after you quit, you have to free it manually
	   CFP_FreeGadget(101)
	   Quit = 1
	   
	 ElseIf  EventID = #PB_Event_Gadget And EventGadget() = 1 And EventType() = #PB_EventType_LeftClick
	   SelectElement(ftd(), GetGadgetState(101))
	   CreatePDF(ftd()\Name)
   EndIf
	   

Until Quit = 1

; ---------------------------------------------------------------------------------------
; FUNCTIONS
; ---------------------------------------------------------------------------------------

Procedure CFP_CreateGagdet(Gadget,X,Y,Width,Height,ItemHeight=20,FontSize=11)
	Protected himlFontType, hwndParent, *cfpu.CFP_USERDATA
	
	himlFontType = ImageList_Create_(16,12,#ILC_MASK,0,0)
	ImageList_AddMasked_(himlFontType,CatchImage(0,?FontType),#Yellow)	
		
	hwndParent = GadgetID(ContainerGadget(#PB_Any,X,Y,Width,Height))
	ComboBoxGadget(Gadget,0,0,Width,Height,#CBS_OWNERDRAWFIXED)
	SendMessage_(GadgetID(Gadget),#CB_SETITEMHEIGHT,0,ItemHeight)	
	CloseGadgetList()
	
	*cfpu = AllocateMemory(SizeOf(CFP_USERDATA))
	*cfpu\himlFontType = himlFontType
	*cfpu\FontSize = FontSize
	*cfpu\hwndParent = hwndParent
	SetWindowLongPtr_(GadgetID(Gadget),#GWLP_USERDATA,*cfpu)
	
	SetWindowLongPtr_(hwndParent,#GWL_WNDPROC,@CFP_WndProc())
	
	CFP_EnumFonts(Gadget)
	
	SetGadgetState(Gadget,0)
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure.s CFP_GetGadgetText(Gadget,Item)
	If IsGadget(Gadget)
		Protected *cfpf.CFP_FONTDATA 
		*cfpf = GetGadgetItemData(Gadget,Item)		
		ProcedureReturn *cfpf\Name
	EndIf
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CFP_FreeGadget(Gadget)
	If IsGadget(Gadget)
		Protected *cfpu.CFP_USERDATA, Result
		
		*cfpu = GetWindowLongPtr_(GadgetID(Gadget),#GWLP_USERDATA)

		If *cfpu
			Result = ImageList_Destroy_(*cfpu\himlFontType)
			
			If Result : Result = FreeMemory(*cfpu) : EndIf
		EndIf
	EndIf
	
	ProcedureReturn Result
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CFP_WndProc(hWnd,uMsg,wParam,lParam)
	Select uMsg
		Case #WM_DRAWITEM
		Protected *lpdis.DRAWITEMSTRUCT = lParam	
		
		; --- Draw item focus rectangle or normal state		
		If *lpdis\itemState & #ODS_SELECTED
			Protected hbrFocus = CreateSolidBrush_(GetSysColor_(#COLOR_HIGHLIGHT))
			FillRect_(*lpdis\hDC,*lpdis\rcItem,hbrFocus)
			DeleteObject_(hbrFocus)
			DrawFocusRect_(*lpdis\hDC,*lpdis\rcItem)				
			SetTextColor_(*lpdis\hDC,GetSysColor_(#COLOR_HIGHLIGHTTEXT))
		Else
			Protected hbrFace = CreateSolidBrush_(GetSysColor_(#COLOR_WINDOW))
			FillRect_(*lpdis\hDC,*lpdis\rcItem,hbrFace)
			DeleteObject_(hbrFace)
			SetTextColor_(*lpdis\hDC,GetSysColor_(#COLOR_WINDOWTEXT))
		EndIf	

		Protected *ftd.CFP_FONTDATA = GetGadgetItemData(wParam,*lpdis\itemID)			
		Protected *cfpu.CFP_USERDATA = GetWindowLongPtr_(*lpdis\hwndItem,#GWLP_USERDATA)

		; --- Draw Font Icons
		If *ftd\Type > -1
			ImageList_Draw_(*cfpu\himlFontType,*ftd\Type,*lpdis\hDC,2,*lpdis\rcItem\top + 3,#ILD_TRANSPARENT)
		EndIf
		
		; --- Create Preview Font
		Protected lplf.LOGFONT, hfntPreview
		
		lplf\lfHeight = -MulDiv_(*cfpu\FontSize,GetDeviceCaps_(*lpdis\hDC,#LOGPIXELSY),72)			
		
		If *ftd\Symbol : lplf\lfCharSet = #SYMBOL_CHARSET : EndIf			
		
		PokeS(@lplf\lfFaceName[0] ,*ftd\name)			
		
		hfntPreview = CreateFontIndirect_(lplf)

		; --- Draw Preview Text
		SetBkMode_(*lpdis\hDC,#TRANSPARENT)	
		
		If *ftd\Symbol ; If it's a smybol font like Webdings
			Protected fsz.SIZE
			
			; Write the fonts name
			*lpdis\rcItem\left + 20
			SelectObject_(*lpdis\hDC,GetStockObject_(#DEFAULT_GUI_FONT))
			GetTextExtentPoint32_(*lpdis\hDC,*ftd\Name,Len(*ftd\Name),fsz)
			DrawText_(*lpdis\hDC,*ftd\Name,-1,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)	
			
			; Display demo charachters next to the name
			*lpdis\rcItem\left + fsz\cx + 3
			SelectObject_(*lpdis\hDC,hfntPreview)
			DrawText_(*lpdis\hDC,"ABC123",6,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)
		Else
			*lpdis\rcItem\left + 20
			SelectObject_(*lpdis\hDC,hfntPreview)			
			DrawText_(*lpdis\hDC,*ftd\Name,-1,*lpdis\rcItem,#DT_SINGLELINE | #DT_VCENTER)
		EndIf	
		
		DeleteObject_(hfntPreview)

						
		ProcedureReturn #True
	EndSelect
	
	ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CFP_EnumFonts(Gadget)
	Protected lplf.LOGFONT, hdc, Index
	
	lplf\lfCharset = #DEFAULT_CHARSET
	
	hdc = GetDC_(0)
	EnumFontFamiliesEx_(hdc,lplf,@CFP_EnumProc(),hdc,0)
	ReleaseDC_(0,hdc)
	
	SortStructuredList(ftd(),#PB_Sort_Ascending,OffsetOf(CFP_FONTDATA\Name),#PB_String)
	
	ForEach ftd()
		AddGadgetItem(Gadget,-1,ftd()\Name)	
		SetGadgetItemData(Gadget,Index,ftd())
		Index + 1				
	Next
EndProcedure

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Procedure CFP_EnumProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
	Protected CHRSET = *lpelfe\elfLogFont\lfCharSet & 255
	
	; WESTERN FONTS / SYSTEM FONTS / SYMBOL FONTS

 	If CHRSET = #ANSI_CHARSET Or CHRSET = #OEM_CHARSET Or CHRSET = #SYMBOL_CHARSET
		AddElement(ftd())
		
		Select FontType
			Case #TRUETYPE_FONTTYPE : ftd()\Type = 0
			Case #DEVICE_FONTTYPE : ftd()\Type = 1
			Case #RASTER_FONTTYPE : ftd()\Type = 2
			Default : ftd()\Type = -1
		EndSelect
		
		If CHRSET = #SYMBOL_CHARSET : ftd()\Symbol = 1 : EndIf
		
		; Using 'lfFaceName' of the LOGFONT structure gives unique fontnames and avoids dublicates.
		; When using 'elfFullName' of the ENUMLOGFONTEX structure you still can get dublicates even
		; though you limit the character set like above. Also you don't need to cycle through the 
		; whole LinkedList everytime to find out if a fontname already exists.
		;
		; The created fontlist SHOULD be identical to the one in MS Wordpad + bitmap fonts (Courier, etc.)
			
		ftd()\Name = PeekS(@*lpelfe\elfLogFont\lfFaceName[0])
		
		
		If FindString(ftd()\Name, "futura", 0, #PB_String_NoCase )
		  Debug ftd()\Name
		EndIf
	EndIf

   ProcedureReturn #True
EndProcedure

; ---------------------------------------------------------------------------------------
; DATA SECTION
; ---------------------------------------------------------------------------------------

DataSection
	FontType:
	Data.l $01964D42,$00000000,$00760000,$00280000,$00300000,$000C0000,$00010000,$00000004,$01200000,$00000000
	Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$80000080,$80000000,$00800080,$00800000,$80800080
	Data.l $80800000,$C0C00080,$000000C0,$FF0000FF,$FF000000,$00FF00FF,$00FF0000,$FFFF00FF,$FFFF0000,$BBBB00FF
	Data.l $5555BBBB,$BBBBBB55,$BB7B77B8,$B9BBBBBB,$97B97B99,$BBBBBBBB,$55BBBBBB,$BBBBBBBB,$8B868870,$99BBBBBB
	Data.l $79999799,$BBBBBBBB,$55BBBBBB,$B8BBBBBB,$68B8BB00,$99BBBBBB,$B799797B,$BBBBBB9B,$55666666,$B8BBBBBB
	Data.l $76BBBB00,$99BBBB8B,$7B99B77B,$BBBBBBBB,$55BB66BB,$B8BBBBBB,$86BBBB00,$99BBBB6B,$9B79BB7B,$BBBBBBBB
	Data.l $55BB65BB,$B8BB5BBB,$B6BB8B00,$79BBBB68,$97B9BB9B,$BBBBBBBB,$55BB65BB,$BBBB5BBB,$B6BB7B00,$B9BBBB68
	Data.l $99B7BB97,$BBBBBBBB,$555B65BB,$BBBB5BB5,$B7BB0B70,$B7BBBB66,$99BBBB99,$B6BBBB7B,$555565BB,$BBBB5B55
	Data.l $B7BB08B0,$BBBBBB68,$79BB9B79,$B6BBBB9B,$6BBB66BB,$BBBBBBBB,$B7BB00B8,$BBBBBB68,$79BB99B7,$B6BBBB97
	Data.l $6BB6666B,$BBBBBBBB,$867880BB,$BBBBBB6B,$9799B9BB,$B6BBBB79,$6B666666,$BBBBBBBB,$6887BBBB,$BBBBBBBB
	Data.l $BBBBBBBB
	Data.b $BB,$BB
EndDataSection

"Daddy, I'll run faster, then it is not so far..."
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Suitable fonts for DrawVectorText()?

Post by RASHAD »

dige one very important question
Did you installed the group of fonts to your Windows ?
PB vector lib will not work with any font not installed
Note: PB register font not enough the font files must be in Windows\fonts
Egypt my love
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Suitable fonts for DrawVectorText()?

Post by dige »

Yes, I have copied all the files on the Futura Zip archive to Windows\Fonts.
As I said, the fonts work when I draw with the Vector Lib on a canvas, but not when I select PDF as output.
So it must be a special problem with the PDF creation.

As a workaround, I can also draw everything on a canvas and transfer the result as an image to the PDF...
"Daddy, I'll run faster, then it is not so far..."
TassyJim
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Suitable fonts for DrawVectorText()?

Post by TassyJim »

Windows 11.
I downloaded the zip of fonts and extracted them to a suitable folder.
I selected one of the fonts and right click - install font.
I then went to the font viewer in control panel and found the font.
The full name for the font was "Futura LtCn BT Light"
Using that full name and it worked.
Just using "Futura LtCn BT" failed even though that is what gets listed in MS Word as the font name.

I am reasonably certain the PB is using the actual font and not a Windows substitute.

I also note that the file has a copyright notice included so I would be reluctant to use it without further investigation.

Jim

Edit.
I uninstalled the Futura font, rebooted Windows and now Windows is kindly substituting the Futura font with something it thinks is close enough.
Before installing the Futura font, the resulting pdf was 1k and no font details.
when it does work the file size is 40k because it includes a font.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Suitable fonts for DrawVectorText()?

Post by RASHAD »

Hi TassyJim
I think you covered the case very well
Egypt my love
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Suitable fonts for DrawVectorText()?

Post by dige »

I removed all fonts again and restarted Windows. Then added all Futura fonts again with "Install". Restarted Windows.

Then I used EnumFontFamiliesEx() to determine the font names (and filtered out only Arial and Futura).
I tried VectorDrawing with these fonts on an image and in a PDF. (you will find the code at the end)

The fonts were used correctly on the image, but the PDF shows a different font instead of the Futura fonts.

Another thing I noticed is that the TextWidth () calculation is not exact:

ImageOutput:
Image

PDFOutput:
Image]

Code: Select all

EnableExplicit

Declare CFP_EnumFonts()
Declare CFP_EnumProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)

Structure CFP_FONTDATA
	Type.b
	Symbol.b
	Name.s
EndStructure

Structure CFP_USERDATA
	himlFontType.i
	FontSize.b
	hwndParent.i
EndStructure

Global NewList ftd.CFP_FONTDATA()




; ---------------------------------------------------------------------------------------
; MAIN LOOP
; ---------------------------------------------------------------------------------------
Procedure CreatePDF()
  Static PosY
  Protected txt.s, w
  
  LoadFont(1, "Arial", 40)
 
  CreateImage(0, 2480, 3508, 24, #White)
 
   ;If StartVectorDrawing(PdfVectorOutput("C:\Temp\test.pdf", 2480, 3508))  
   If StartVectorDrawing(ImageVectorOutput(0))  
    
    VectorSourceColor(RGBA(0, 0, 0, 255))
    
    ForEach ftd()
      If ftd()\Type <> 0
        Continue
      EndIf
      
      
      If LoadFont(0, ftd()\Name, 40) = 0
        Debug "Loading Font: " + ftd()\Name + " error"
        Continue
      EndIf
      
      txt = ftd()\Name + " TextWitdh: " + Str(VectorTextWidth(ftd()\Name))
      
      VectorFont(FontID(1), 40)
      MovePathCursor(20, PosY)
      DrawVectorText(txt)
      
      w = VectorTextWidth(txt)
      MovePathCursor(w, PosY)
      
      VectorFont(FontID(0), 40)
      DrawVectorText("1234567890 abcdefg ABCDEFG m M !§$%&/()=?*+öä")
      
      PosY + 50
      
      If PosY > 3500
        PosY = 0
        NewVectorPage()
      EndIf  
    Next
    
    
    StopVectorDrawing()
  EndIf
  
  SaveImage(0, "C:\Temp\Test.bmp")
  RunProgram("C:\Temp\test.bmp")
  ;RunProgram("C:\Temp\test.pdf")

EndProcedure

Procedure CFP_EnumFonts()
	Protected lplf.LOGFONT, hdc, Index
	
	lplf\lfCharset = #DEFAULT_CHARSET
	
	hdc = GetDC_(0)
	EnumFontFamiliesEx_(hdc,lplf,@CFP_EnumProc(),hdc,0)
	ReleaseDC_(0,hdc)
	
	SortStructuredList(ftd(),#PB_Sort_Ascending,OffsetOf(CFP_FONTDATA\Name),#PB_String)
EndProcedure
Procedure CFP_EnumProc(*lpelfe.ENUMLOGFONTEX,*lpntme.NEWTEXTMETRICEX,FontType,lParam)
	Protected CHRSET = *lpelfe\elfLogFont\lfCharSet & 255
	
	; WESTERN FONTS / SYSTEM FONTS / SYMBOL FONTS

 	If CHRSET = #ANSI_CHARSET Or CHRSET = #OEM_CHARSET Or CHRSET = #SYMBOL_CHARSET
		AddElement(ftd())
		
		Select FontType
			Case #TRUETYPE_FONTTYPE : ftd()\Type = 0
			Case #DEVICE_FONTTYPE : ftd()\Type = 1
			Case #RASTER_FONTTYPE : ftd()\Type = 2
			Default : ftd()\Type = -1
		EndSelect
		
		If CHRSET = #SYMBOL_CHARSET : ftd()\Symbol = 1 : EndIf
		
		ftd()\Name = PeekS(@*lpelfe\elfLogFont\lfFaceName[0])
		
		
		If FindString(ftd()\Name, "futura", 0, #PB_String_NoCase ) Or FindString(ftd()\Name, "arial", 0, #PB_String_NoCase )
		  Debug ftd()\Name
		Else
		  DeleteElement(ftd())
		EndIf
	EndIf

   ProcedureReturn #True
EndProcedure

Define EventID, Quit

OpenWindow(0,0,0,320,240,"Font Test")
CFP_EnumFonts()
CreatePDF()




; ---------------------------------------------------------------------------------------
; DATA SECTION
; ---------------------------------------------------------------------------------------

DataSection
	FontType:
	Data.l $01964D42,$00000000,$00760000,$00280000,$00300000,$000C0000,$00010000,$00000004,$01200000,$00000000
	Data.l $00000000,$00000000,$00000000,$00000000,$00000000,$80000080,$80000000,$00800080,$00800000,$80800080
	Data.l $80800000,$C0C00080,$000000C0,$FF0000FF,$FF000000,$00FF00FF,$00FF0000,$FFFF00FF,$FFFF0000,$BBBB00FF
	Data.l $5555BBBB,$BBBBBB55,$BB7B77B8,$B9BBBBBB,$97B97B99,$BBBBBBBB,$55BBBBBB,$BBBBBBBB,$8B868870,$99BBBBBB
	Data.l $79999799,$BBBBBBBB,$55BBBBBB,$B8BBBBBB,$68B8BB00,$99BBBBBB,$B799797B,$BBBBBB9B,$55666666,$B8BBBBBB
	Data.l $76BBBB00,$99BBBB8B,$7B99B77B,$BBBBBBBB,$55BB66BB,$B8BBBBBB,$86BBBB00,$99BBBB6B,$9B79BB7B,$BBBBBBBB
	Data.l $55BB65BB,$B8BB5BBB,$B6BB8B00,$79BBBB68,$97B9BB9B,$BBBBBBBB,$55BB65BB,$BBBB5BBB,$B6BB7B00,$B9BBBB68
	Data.l $99B7BB97,$BBBBBBBB,$555B65BB,$BBBB5BB5,$B7BB0B70,$B7BBBB66,$99BBBB99,$B6BBBB7B,$555565BB,$BBBB5B55
	Data.l $B7BB08B0,$BBBBBB68,$79BB9B79,$B6BBBB9B,$6BBB66BB,$BBBBBBBB,$B7BB00B8,$BBBBBB68,$79BB99B7,$B6BBBB97
	Data.l $6BB6666B,$BBBBBBBB,$867880BB,$BBBBBB6B,$9799B9BB,$B6BBBB79,$6B666666,$BBBBBBBB,$6887BBBB,$BBBBBBBB
	Data.l $BBBBBBBB
	Data.b $BB,$BB
EndDataSection


"Daddy, I'll run faster, then it is not so far..."
TassyJim
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Suitable fonts for DrawVectorText()?

Post by TassyJim »

I tried again and now Windows substitutes it's own font every time.

I can install other fonts and use them OK so it looks like there is something about the Futura fonts you have that the PB PDF engine doesn't like.
Perhaps you can source a set from somewhere else and hope they are a different version of TTF.

Sorry I have run out of ideas.

Jim
miskox
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Aug 27, 2017 7:37 pm
Location: Slovenia

Re: Suitable fonts for DrawVectorText()?

Post by miskox »

Just saw this topic and couldn't compile then and then I opened the documentation and it says there that PdfVectorOutput is only available on Linux and Mac. You mention fonts on Windows... so does these examples here work on Windows?

And then I saw that I am still using 6.03. Looks like I have to upgrade to make .pdf files.

Thanks.
Saso
TassyJim
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Suitable fonts for DrawVectorText()?

Post by TassyJim »

My current though is:
The font has to be digitally signed to use with PdfVectorOutput.

I tried a number of fonts and so far, any that were not digitally signed failed and those that were digitally signed worked.

The easiest way to tell if it is signed is to preview the font in Windows.

I could be wrong again but so far it seems a reasonable answer.

Jim
juergenkulow
Enthusiast
Enthusiast
Posts: 581
Joined: Wed Sep 25, 2019 10:18 am

Re: Suitable fonts for DrawVectorText()?

Post by juergenkulow »

If LoadFont has found exactly the right font under Windows, the following lines should appear in test.pdf:

Code: Select all

...
8 0 obj
<<
/Type /Font
/BaseFont /HPDFAA+FuturaStd-Book
/Subtype /Type0
/Encoding /Identity-H
/ToUnicode 9 0 R
/DescendantFonts [ 11 0 R ]
>>
endobj
...
Otherwise:

Code: Select all

...
8 0 obj
<<
/Type /Font
/BaseFont /HPDFAA+Arial-BoldMT,Bold
/Subtype /Type0
/Encoding /Identity-H
/ToUnicode 9 0 R
/DescendantFonts [ 11 0 R ]
>>
endobj
...
Helpful was: https://fontforge.org/en-US/
Post Reply