Page 1 of 1
HPDFPRINT with Font cannot be loaded
Posted: Fri May 16, 2014 3:26 am
by hmgchang
Dear Masters & Friends,
i try to load the ttf font :
[img]d:\test\tscparan_TTF.JPG[/img]
but i get this :
[img]fontcannotbeloaded.JPG[/img]
What am i doing wrong ?
Pls help !
Thks n rgds
Chang
Re: HPDFPRINT with Font cannot be loaded
Posted: Fri May 16, 2014 3:28 am
by hmgchang
this is what i get : error !
HPDFPRINT with Font cannot be loaded
Posted: Fri May 16, 2014 12:38 pm
by Pablo César
It is something quite difficult to guess what is happen without your code !
Probably your font file isn't in current folder. Try to put the FULL path.
Re: HPDFPRINT with Font cannot be loaded
Posted: Tue May 20, 2014 2:50 am
by hmgchang
ok Sir, pls find my ssw,
Code: Select all
#include <hmg.ch>
#include "hfcl.ch"
Function Main
MEMVAR _HMG_SYSDATA
Load Window Main
Main.Center
Main.Activate
Return NIL
FUNCTION ssw_HPdfPrint( cTtf)
LOCAL aLine, aFont
LOCAL cString, cFontname, cPdfname, cStartupFolder
LOCAL nI
LOCAL lSuccess
HB_DEFAULT( @cTtf, '')
cString := MEMOREAD( "List.TXT")
aLine := HB_ATOKENS( cString, CRLF)
lSuccess := .F.
IF EMPTY( cTtf)
aFont := GetFont()
cFontname := aFont[ 1]
ELSE
// cFontname := "MS LineDraw.TTF"
// cFontname := "tahoma.TTF"
// cFontname := "times.TTF"
cFontname:= "cour.TTF"
ENDIF
cPdfName := "ssw_" + STRTRAN( cFontname, ".TTF", "_TTF") + ".pdf"
SELECT HPDFDOC cPdfname TO lSuccess papersize HPDF_PAPER_A4
SET HPDFDOC COMPRESS ALL
SET HPDFDOC PAGEMODE TO OUTLINE
SET HPDFINFO AUTHOR TO 'S. Rathinagiri'
SET HPDFINFO CREATOR TO 'S. Rathinagiri'
SET HPDFINFO TITLE TO 'ssw HPDF Print'
SET HPDFINFO SUBJECT TO 'Test HPdfPrint for Load Font'
SET HPDFINFO KEYWORDS TO 'HMG, HPDF, Documentation, LibHaru, Harbour, MiniGUI'
SET HPDFINFO DATECREATED TO date() TIME time()
IF lSuccess
START HPDFDOC
START HPDFPAGE
FOR nI := 1 TO LEN( aLine)
@ 10 + nI * 5, 10 HPDFPRINT aLine[ nI] FONT cFontname
NEXT
END HPDFPAGE
END HPDFDOC
MsgInfo( "Pdf Printed !")
ELSE
MsgInfo( "Error Printing Pdf !")
ENDIF
RETURN NIL
Re: HPDFPRINT with Font cannot be loaded
Posted: Tue May 20, 2014 3:36 am
by andyglezl
Hola hmgchang
Pudiera ser esta la razon ?
viewtopic.php?f=5&t=3422&p=31430#p31430
-------------------------------------------------------------------------------
Hello hmgchang
Could this be the reason ?
viewtopic.php?f=5&t=3422&p=31430#p31430
Re: HPDFPRINT with Font cannot be loaded
Posted: Tue May 20, 2014 4:33 am
by hmgchang
Hi Andy,
I actually tried to load the Courier font ( Cour.TTF).
I dont know if i hv done something wrong, pls advise
thks n rgds
Chang
Re: HPDFPRINT with Font cannot be loaded
Posted: Tue May 20, 2014 5:14 am
by Rathinagiri
There is a fix in the next version of HMG. I am sure it will solve this problem.
For the time being, try to give the full path of the font file.
HPDFPRINT with Font cannot be loaded
Posted: Tue May 20, 2014 10:56 am
by Pablo César
Rathinagiri wrote:For the time being, try to give the full path of the font file.
Yeah, as I have already told him...
Only in the new version is going to find the ttf file. Is necessary to know where the file is. If is not in current folder, will not find. And I think even been in current, will need the fullpath of ttf file.
Re: HPDFPRINT with Font cannot be loaded
Posted: Tue May 20, 2014 2:13 pm
by EduardoLuis
Hi Chang:
I use this procedure to load ttf fonts, and all works fine.-
1) First define at the begining of the function pdf_create include these variables
function pdf_create
local lSuccess := .f.
local cLB := chr( 10 )
local cTTFFName, cFontName, qPDF
2) Before each line HPDFPRINT where you want an special font put:
qPDF := _HMG_SYSDATA[ 150, 1 ]
cTTFFName := "C:\VEGANO\KUNSTLER.ttf"
cFontName := HPDF_LoadTTFontFromFile( qPDF, cTTFFName, .F. )
@ 235, 200 HPDFPRINT "This is right aligned text" FONT cFontName SIZE 30 RIGHT
Notes:
cTTFFName stores folder where is the font file.-
cFontName stores the full name of the font
For simplicity i keep the fonts i use on the principal folder of my develope.-
I hope this will let you solve your problem.-
With regards.
Eduardo