HPDFPRINT with Font cannot be loaded

Moderator: Rathinagiri

Post Reply
User avatar
hmgchang
Posts: 173
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

HPDFPRINT with Font cannot be loaded

Post by hmgchang » Fri May 16, 2014 3:26 am

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 :)
Attachments
tscparan_TTF.JPG
tscparan_TTF.JPG (115.02 KiB) Viewed 1470 times
Just Hmg It !

User avatar
hmgchang
Posts: 173
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Post by hmgchang » Fri May 16, 2014 3:28 am

this is what i get : error !
Attachments
fontcannotbeloaded.JPG
fontcannotbeloaded.JPG (12.47 KiB) Viewed 1469 times
fontcannotbeloaded.JPG
fontcannotbeloaded.JPG (12.47 KiB) Viewed 1469 times
Just Hmg It !

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Fri May 16, 2014 12:38 pm

It is something quite difficult to guess what is happen without your code ! :mrgreen:

Probably your font file isn't in current folder. Try to put the FULL path.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
hmgchang
Posts: 173
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Post by hmgchang » Tue May 20, 2014 2:50 am

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
Attachments
error.JPG
error.JPG (27.59 KiB) Viewed 1394 times
Just Hmg It !

User avatar
andyglezl
Posts: 848
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 7 times
Been thanked: 24 times
Contact:

Post by andyglezl » Tue May 20, 2014 3:36 am

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
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
hmgchang
Posts: 173
Joined: Tue Aug 13, 2013 4:46 am
Location: Indonesia

Post by hmgchang » Tue May 20, 2014 4:33 am

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
Just Hmg It !

User avatar
Rathinagiri
Posts: 5173
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 136 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Tue May 20, 2014 5:14 am

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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Tue May 20, 2014 10:56 am

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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

EduardoLuis
Posts: 523
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina
Been thanked: 28 times

Post by EduardoLuis » Tue May 20, 2014 2:13 pm

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

Post Reply