Page 1 of 1

How to print character sigma in Haru?

PostPosted: Wed Aug 16, 2023 5:22 am
by hua
After defining font in Haru
Code: Select all  Expand view
oFont := oPrn:DefineFont("Symbol", 9)

How to print the sigma symbol? Image

I was printing it this way in TPrinter
Code: Select all  Expand view
oPrn:say(nRow, nCol, "S", oFont)

But this doesn't work under Haru

I am not using unicode.

Actually, how to inspect the attributes of a font used in Haru e.g. typeface name, bold or not, etc
TIA

Re: How to print character sigma in Haru?

PostPosted: Wed Aug 16, 2023 10:44 am
by hua
Tested using SAMPLES\pdfh.prg
The font Symbol is not loaded eventhough it should be amongst the Base14

Image

Image

Re: How to print character sigma in Haru?

PostPosted: Wed Aug 16, 2023 10:58 am
by nageswaragunupudi
This is working for me
Code: Select all  Expand view
function printSigma

   local oPrn, oFont, nRow := 1

   FW_SetUnicode( .t. )

   TPrinter():lUseHaruPDF := .t.

   PRINT oPrn PREVIEW file "sigma.pdf"
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-30 OF oPrn
   PAGE
   @ nRow,1 PRINT TO oPrn TEXT "Print Sigma separately" SIZE 5,0.5 INCHES ;
      FONT oFont LASTROW nRow
   @ nRow,1 PRINT TO oPrn TEXT hb_utf8chr( 0x03a3 ) SIZE 5,0.5 INCHES ;
      FONT oFont LASTROW nRow
   @ nRow,1 PRINT TO oPrn TEXT "Like This" SIZE 5,1 INCHES ;
      FONT oFont
   ENDPAGE
   ENDPRINT
   RELEASE FONT oFont

return nil


Image

Re: How to print character sigma in Haru?

PostPosted: Wed Aug 16, 2023 11:07 am
by nageswaragunupudi
Sumbol font is not working with Haru.
Without Haru, using the default PDF generation of TPrinter, we can have the Symbol fonts in pdf.

Let us keep trying.

Re: How to print character sigma in Haru?

PostPosted: Wed Aug 16, 2023 2:00 pm
by cnavarro
Have you tried this way?
Code: Select all  Expand view

     TPrinter():lUseHaruPDF  := .T.

      GetHaruFontList( , .F. )
      // For use fonts not installed
      HaruAddFont( 'Arial Black', '.\ariblk.ttf', , .F. )
      HaruAddFont( 'EAN-13', '.\EAN13_0.ttf', .T., .F. )

      oPrn := THaruPDF():New()
      oFontTitle  := oPrn:DefineFont( 'Arial Black', 15 )
      oFontBold   := oPrn:DefineFont( 'Arial Black',  9 )
      oFontText   := oPrn:DefineFont( 'Verdana', 8 )
      oFontText1  := oPrn:DefineFont( 'Arial', 8 )
      oFontBar    := oPrn:DefineFont( 'EAN-13', 20, .T. )
 

Re: How to print character sigma in Haru?

PostPosted: Wed Aug 16, 2023 5:32 pm
by nageswaragunupudi
Mr. Cristobal

So, are you able to print Σ ?
If so, by using which font and which character please?

Re: How to print character sigma in Haru?

PostPosted: Wed Aug 16, 2023 7:45 pm
by nageswaragunupudi
PDF's internal Symbol font is different from Windows Symbol font.
We are working on how to make our FWPDF class to use Windows Symbol font, though it seems difficult as of now.
For now, the immediate solution is to use HB_UTF8CHR(0x03A3) and setting FW_SetUnicode() to .T., atleast temporarily.

Re: How to print character sigma in Haru?

PostPosted: Wed Aug 16, 2023 8:12 pm
by nageswaragunupudi
Some notes for information:
FWH does not provide THaruPDF class.
Instead we have FWPDF class derived from TPDF class.

PDF internal font list:
Code: Select all  Expand view

Courier
Courier-Bold
Courier-Oblique
Courier-BoldOblique
Helvetica
Helvetica-Bold
Helvetica-Oblique
Helvetica-BoldOblique
Times-Roman
Times-Bold
Times-Italic
Times-BoldItalic
Symbol
ZapfDingbats
 


Instead of GetHaruFontList(..) you may use
oPdf:aTTFFontList
Initially, FWPdf is loaded with this list
Code: Select all  Expand view

+-----------+----------------------------+
|Arial      |C:\WINDOWS\Fonts\arial.ttf  |
|Verdana    |C:\WINDOWS\Fonts\verdana.ttf|
|Courier New|C:\WINDOWS\Fonts\cour.ttf   |
|Calibri    |C:\WINDOWS\Fonts\calibri.ttf|
|Tahoma     |C:\WINDOWS\Fonts\tahoma.ttf |
|Impact     |C:\WINDOWS\Fonts\impact.ttf |
|Segoe UI   |C:\WINDOWS\Fonts\segoeui.ttf|
+-----------+----------------------------+
 


Instead of HaruAddFont()
we can use oPdf:AddFont( cFontname, cTtfFileName )

We have not added EAN font in the default list, because this font is not installed on all computers bu default and we prefer to generate bar codes on our own than using barcode fonts.

Re: How to print character sigma in Haru?

PostPosted: Thu Aug 17, 2023 3:50 am
by hua
nageswaragunupudi wrote:For now, the immediate solution is to use HB_UTF8CHR(0x03A3) and setting FW_SetUnicode() to .T., atleast temporarily.


Thanks Rao, for the time being I adopted this workaround