
I'm too much tired. Time to start weekend

-10 deg C outside - so time to start winter swimming - water is so hot at this time

Moderator: Rathinagiri
Tu może być pewien problem, bo w moim Windows 10 PL nazwy fontów w rejestrze są w jęz. polskim, np.mol wrote: ↑Fri Mar 02, 2018 5:41 pm We can use such a code to find font file name:Code: Select all
if lBold FontName += " Bold" endif if lItalic FontName += " Italic" endif cRet := RegistryRead( 'HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\' + FontName + ' (TrueType)' )
Code: Select all
Function _HMG_HPDF_SeekEquivalences(FontName,lBold,lItalic)
Local cFldWindows := GetSpecialFolder(CSIDL_FONTS)
Local cRet:=""
Default lBold := .f., lItalic := .f.
Do Case
Case "COUR" $ HMG_Upper(FontName)
cRet:="cour"
Case "TIMES" $ HMG_Upper(FontName)
cRet:="times"
Case "ARIAL NARROW" $ HMG_Upper(FontName)
cRet:="arialn"
Case "ARIAL" $ HMG_Upper(FontName)
cRet:="arial"
Case "VERDANA" $ HMG_Upper(FontName)
cRet:="verdana"
EndCase
If !Empty(cRet)
//cRet := cFldWindows + "\" + cRet
If lBold .and. lItalic
cRet := cRet + 'bi.ttf'
ElseIf lBold
If cRet="arialn"
cRet := cRet + 'b.ttf'
Else
cRet := cRet + 'bd.ttf'
Endif
ElseIf lItalic
cRet := cRet + 'i.ttf'
Else
cRet := cRet + '.ttf'
Endif
cRet := cFldWindows + "\" + cRet
cRet := _HMG_HPDF_ExistInLocal(cRet)
Endif
Return cRet
Code: Select all
typedef struct tagLOGFONT {
LONG lfHeight;
LONG lfWidth;
LONG lfEscapement;
LONG lfOrientation;
LONG lfWeight;
BYTE lfItalic;
BYTE lfUnderline;
BYTE lfStrikeOut;
BYTE lfCharSet;
BYTE lfOutPrecision;
BYTE lfClipPrecision;
BYTE lfQuality;
BYTE lfPitchAndFamily;
TCHAR lfFaceName[LF_FACESIZE];
} LOGFONT, *PLOGFONT;
Code: Select all
#include "hmg.ch"
#include "harupdf.ch"
Function Main()
SELECT HPDFDOC "sample.pdf" PAPERLENGTH 300 PAPERWIDTH 300 LOG
START HPDFDOC
START HPDFPAGE
SET HPDFDOC ENCODING TO "WinAnsiEncoding"
@ 5, 10 HPDFPRINT "Default font and size." UNDERLINE
@ 10,100 HPDFPRINT "This is a sample Text CENTER." CENTER
@ 15,200 HPDFPRINT "This is a sample Text in BOLD RIGHT." BOLD RIGHT
@ 20, 10 HPDFPRINT "This is a sample Text in ITALIC." ITALIC
SET HPDFDOC FONT SIZE TO 8
SET HPDFDOC FONT NAME TO "Arial Narrow"
@ 30, 10 HPDFPRINT "Arial Narrow 8" FONT "Helvetica" SIZE 12 UNDERLINE IF .T.
@ 35, 10 HPDFPRINT "This is a sample Text."
@ 40, 10 HPDFPRINT "This is a sample Text in BOLD IF .T." BOLD IF .T.
@ 45, 10 HPDFPRINT "This is a sample Text in ITALIC IF .T. " ITALIC IF .T.
SET HPDFDOC FONT SIZE TO 10
SET HPDFDOC FONT NAME TO "Courier"
@ 55, 10 HPDFPRINT "Courier 10" FONT "Helvetica" SIZE 12 UNDERLINE
@ 60, 10 HPDFPRINT "This is a sample Text."
@ 65, 10 HPDFPRINT "This is a sample Text in BOLD IF .F." BOLD IF .F.
@ 70, 10 HPDFPRINT "This is a sample Text in ITALIC IF .F." ITALIC IF .F.
SET HPDFDOC FONT SIZE TO 18
SET HPDFDOC FONT NAME TO "Times-Roman"
lBold := .T.
@ 85, 10 HPDFPRINT "Times-Roman (built-in) 18" FONT "Helvetica" SIZE 12 UNDERLINE STRIKEOUT IF .F.
@ 90, 10 HPDFPRINT "This is a sample Text BOLD IF lBold ITALIC UNDERLINE STRIKEOUT" BOLD IF lBold ITALIC UNDERLINE STRIKEOUT
SET HPDFDOC FONT NAME TO "Times"
@ 115, 10 HPDFPRINT "Times 18" FONT "Helvetica" SIZE 12 UNDERLINE
@ 120, 10 HPDFPRINT "This is a sample Text baseline................................................................"
@ 120, 150 HPDFPRINT "Sample Text BOLD IF .T. ANGLE 90" BOLD IF .T. COLOR {255,0,0} ANGLE 90
@ 120, 150 HPDFPRINT "Sample Text BOLD IF .F. ANGLE -90" BOLD IF .F. COLOR {255,0,0} ANGLE -90
@ 120, 170 HPDFPRINT "Sample Text UNDERLINE ANGLE 90 TOP" UNDERLINE COLOR {0,255,0} ANGLE 90 TOP
@ 120, 190 HPDFPRINT "Sample Text ITALIC IF .T. STRIKEOUT ANGLE 90 MIDDLE" ITALIC IF .T. STRIKEOUT COLOR {0,0,255} ANGLE 90 MIDDLE
SET HPDFDOC FONT SIZE TO 13
SET HPDFDOC FONT NAME TO "Symbol"
@ 135, 10 HPDFPRINT "Symbol 13" FONT "Helvetica" SIZE 12 UNDERLINE
@ 140, 10 HPDFPRINT "This is a sample Text."
SET HPDFDOC FONT SIZE TO 6
SET HPDFDOC FONT NAME TO "ZapfDingbats"
@ 150, 10 HPDFPRINT "ZapfDingbats 6" FONT "Helvetica" SIZE 12 UNDERLINE
@ 155, 10 HPDFPRINT "This is a sample Text."
SET HPDFDOC FONT SIZE TO 22
SET HPDFDOC FONT NAME TO "MAIAN.TTF"
@ 170, 10 HPDFPRINT "MAIAN.TTF 22" FONT "Helvetica" SIZE 12 UNDERLINE
@ 175, 10 HPDFPRINT "This is a sample Text."
SET HPDFDOC FONT SIZE TO
SET HPDFDOC FONT NAME TO
@ 190, 10 HPDFPRINT "Back to Defaults"
END HPDFPAGE
END HPDFDOC
Execute File 'sample.pdf'
Return Nil
Code: Select all
#include "hmg.ch"
Function Main()
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE 'Test' ;
MAIN
@ 50, 50 BUTTON Button_1 CAPTION "Test" ACTION PrintTest()
END WINDOW
CENTER WINDOW Win_1
ACTIVATE WINDOW Win_1
Return
*------------------------------------------------------------------------------*
Procedure PrintTest
*------------------------------------------------------------------------------*
LOCAL lSuccess, IsPreview, xTab := 50, aList:={ {"Code","000001"} , {"Description","#PEPPER MARMALADE"} , {"Price", 2.35} , {"Code","000002"} , {"Description","!NEW"} , {"Price", 123.45} }, i, xRow := 20
SELECT PRINTER DIALOG TO lSuccess PREVIEW
If lSuccess == .F.
MsgInfo('Print Error')
Return
EndIf
START PRINTDOC
START PRINTPAGE
FOR i=1 TO LEN(aList)
@ xRow,20 PRINT aList[i][1] + REPLICATE(".", 100) TO xRow + 5, xTab + .5 ;
FONT "Arial" ;
SIZE 10
@ xRow,xTab PRINT ": " + ALLTRIM(hb_ValToStr( aList [i][2] )) ;
FONT "Arial" ;
SIZE 10 BOLD IF ALLTRIM(hb_ValToStr( aList [i][2] ))='!' STRIKEOUT IF ALLTRIM(hb_ValToStr( aList [i][2] ))='#'
xRow += 5
Next i
END PRINTPAGE
END PRINTDOC
Return
Code: Select all
#include "hmg.ch"
Function Main()
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 400 ;
TITLE 'Test' ;
MAIN
@ 50, 50 BUTTON Button_1 CAPTION "Test" ACTION PrintTest()
END WINDOW
CENTER WINDOW Win_1
ACTIVATE WINDOW Win_1
Return
*------------------------------------------------------------------------------*
Procedure PrintTest
*------------------------------------------------------------------------------*
LOCAL lSuccess
SELECT PRINTER PDF "test.pdf" TO lSuccess
If lSuccess == .F.
MsgInfo('Print Error')
Return
EndIf
START PRINTDOC
START PRINTPAGE
@ 5, 10 PRINT "Default font and size." UNDERLINE
@ 10,100 PRINT "This is a sample Text CENTER." CENTER
@ 15,200 PRINT "This is a sample Text in BOLD RIGHT." BOLD RIGHT
@ 20, 10 PRINT "This is a sample Text in ITALIC." ITALIC
SET HPDFDOC FONT SIZE TO 8
SET HPDFDOC FONT NAME TO "Arial Narrow"
@ 30, 10 PRINT "Arial Narrow 8" FONT "Helvetica" SIZE 12 UNDERLINE IF .T.
@ 35, 10 PRINT "This is a sample Text."
@ 40, 10 PRINT "This is a sample Text in BOLD IF .T." BOLD IF .T.
@ 45, 10 PRINT "This is a sample Text in ITALIC IF .T. " ITALIC IF .T.
SET HPDFDOC FONT SIZE TO 10
SET HPDFDOC FONT NAME TO "Courier"
@ 55, 10 PRINT "Courier 10" FONT "Helvetica" SIZE 12 UNDERLINE
@ 60, 10 PRINT "This is a sample Text."
@ 65, 10 PRINT "This is a sample Text in BOLD IF .F." BOLD IF .F.
@ 70, 10 PRINT "This is a sample Text in ITALIC IF .F." ITALIC IF .F.
SET HPDFDOC FONT SIZE TO 18
SET HPDFDOC FONT NAME TO "Times-Roman"
lBold := .T.
@ 85, 10 PRINT "Times-Roman (built-in) 18" FONT "Helvetica" SIZE 12 UNDERLINE STRIKEOUT IF .F.
@ 90, 10 PRINT "This is a sample Text BOLD IF lBold ITALIC UNDERLINE STRIKEOUT" BOLD IF lBold ITALIC UNDERLINE STRIKEOUT
SET HPDFDOC FONT NAME TO "Times"
@ 115, 10 PRINT "Times 18" FONT "Helvetica" SIZE 12 UNDERLINE
@ 120, 10 PRINT "This is a sample Text baseline................................................................"
@ 120, 150 PRINT "Sample Text BOLD IF .T. ANGLE 90" BOLD IF .T. COLOR {255,0,0} ANGLE 90
@ 120, 150 PRINT "Sample Text BOLD IF .F. ANGLE -90" BOLD IF .F. COLOR {255,0,0} ANGLE -90
@ 120, 170 PRINT "Sample Text UNDERLINE ANGLE 90 TOP" UNDERLINE COLOR {0,255,0} ANGLE 90 TOP
@ 120, 190 PRINT "Sample Text ITALIC IF .T. STRIKEOUT ANGLE 90 MIDDLE" ITALIC IF .T. STRIKEOUT COLOR {0,0,255} ANGLE 90 MIDDLE
SET HPDFDOC FONT SIZE TO 13
SET HPDFDOC FONT NAME TO "Symbol"
@ 135, 10 PRINT "Symbol 13" FONT "Helvetica" SIZE 12 UNDERLINE
@ 140, 10 PRINT "This is a sample Text."
SET HPDFDOC FONT SIZE TO 6
SET HPDFDOC FONT NAME TO "ZapfDingbats"
@ 150, 10 PRINT "ZapfDingbats 6" FONT "Helvetica" SIZE 12 UNDERLINE
@ 155, 10 PRINT "This is a sample Text."
SET HPDFDOC FONT SIZE TO 22
SET HPDFDOC FONT NAME TO "MAIAN.TTF"
@ 170, 10 PRINT "MAIAN.TTF 22" FONT "Helvetica" SIZE 12 UNDERLINE
@ 175, 10 PRINT "This is a sample Text."
SET HPDFDOC FONT SIZE TO
SET HPDFDOC FONT NAME TO
@ 190, 10 PRINT "Back to Defaults"
END PRINTPAGE
END PRINTDOC
Return