Do you mean something like this ?:
- Bez tytułu1.png (14.83 KiB) Viewed 4682 times
Replace the HPDF_CircleText function with this one
(by the way, I corrected the rims color error if the color was not defined.):
Code: Select all
Function HPDF_CircleText( nRow, nCol, cFontName, nFontSize, nRColor, nGColor, nBColor, cText, lBold, lItalic, lColor, lFont, lSize, nRadial, lCircle, cAlign)
/* text along a circle */
/* nRow, nCol wspolrzedne srodka */
Local nAngle1, nAngle2, nRlen
Local i, nRad1, nRad2, x, y
Local oFont := Nil
Local cFont := ''
Local hPdf := _HMG_SYSDATA[ 150 ][ 1 ]
Local hPage := _HMG_SYSDATA[ 150 ][ 7 ]
*Local nWidth := _HMG_SYSDATA[ 150 ][ 4 ]
Local nHeight := _HMG_SYSDATA[ 150 ][ 5 ]
Local nxPos := _HMG_HPDF_MM2Pixel( nCol )
Local nyPos := nHeight - _HMG_HPDF_MM2Pixel( nRow )
Local nPxAng
Local nRange := 360
DEFAULT lCircle := .F.
DEFAULT nRadial := 15
default cFontName := ''
default nFontSize := _HMG_SYSDATA[ 150 ][ 9 ]
default nRColor := 0
default nGColor := 0
default nBColor := 0
default lBold := .f.
default lItalic := .f.
default lColor := .f.
default lFont := .f.
default lSize := .f.
DEFAULT cText := ""
DEFAULT cAlign :=""
IF !HB_IsNumeric( nRadial )
nRadial := 15
ENDIF
IF !HB_IsString( cAlign )
cAlign := ""
ENDIF
nRLen:= _HMG_HPDF_MM2Pixel( nRadial )
// set color
If lColor
HPDF_Page_SetRGBFill( hPage, nRColor/255, nGColor/255, nBColor/255 )
else
HPDF_Page_SetRGBFill( hPage, 0.0, 0.0, 0.0 )
endIf
IF lCircle
If lColor
HPDF_Page_SetRGBSTROKE( hPage, nRColor/255, nGColor/255, nBColor/255 )
else
HPDF_Page_SetRGBSTROKE( hPage, 0.0, 0.0, 0.0 )
endIf
HPDF_Page_SetLineWidth (hPage, 1.5)
HPDF_Page_Circle ( hPage, nxPos, nyPos, nRlen + nFontSize)
HPDF_Page_Circle ( hPage, nxPos, nyPos, nRlen - (nFontSize /3))
HPDF_Page_Stroke ( hPage )
HPDF_Page_SetLineWidth (hPage, 1)
ENDIF
// set font
cFontName := AllTrim(_HMG_HPDF_SetFont( cFontName, lBold, lItalic ))
if HMG_UPPER (cFileExt (cFontName)) == '.TTF' // load ttf font
cFont := HPDF_LOADTTFONTFROMFILE( hPdf, cFontName, .t. )
If HMG_LEN( alltrim( cFont ) ) == 0
_HMG_HPDF_Error( 6 , cFontName )
Return Nil
endif
oFont := HPDF_GetFont( hPdf, cFont, _HMG_SYSDATA[ 150 ][ 10 ] )
else
If HMG_UPPER( alltrim( cFontName ) ) == "SYMBOL" .or. HMG_UPPER( alltrim( cFontName ) ) == "ZAPFDINGBATS"
oFont := HPDF_GetFont( hPdf, cFontName, Nil )
else
oFont := HPDF_GetFont( hPdf, cFontName, _HMG_SYSDATA[ 150 ][ 10 ] )
endIf
endif
If oFont == Nil
_HMG_HPDF_Error( 6 , cFontName )
Return Nil
EndIF
HPDF_Page_SetFontAndSize( hPage, oFont, nFontSize )
SWITCH HMG_UPPER( alltrim( cAlign ) )
CASE "TOP" ; nRange := 180 ; EXIT //Uppper
CASE "BOTTOM" ; nRange := 180 ; EXIT //Bottom
ENDSWITCH
nAngle1 := nRange / Len( cText ) //monospaced fonts
nAngle2 := 180
//A better solution for non monospaced fonts.
nPxAng := nRange / HPDF_Page_TextWidth( hPage, cText )
HPDF_Page_BeginText ( hPage)
FOR i=1 TO LEN(cText)
nRad1 := ( nAngle2 - Int((HPDF_Page_TextWidth( hPage, SUBSTR(cText, i, 1) ) * nPxAng) / 2) - 90) / 180 * 3.141592
nRad2 := nAngle2 / 180 * 3.141592
SWITCH HMG_UPPER( alltrim( cAlign ) )
CASE "BOTTOM"
x := nxPos + cos(nRad2) * (nRlen + nFontSize*(2/3))
y := nyPos - sin(nRad2) * (nRlen + nFontSize*(2/3))
HPDF_Page_SetTextMatrix( hPage, cos(nRad1), -sin(nRad1), sin(nRad1), cos(nRad1), x, y)
EXIT
OTHERWISE
x := nxPos + cos(nRad2) * nRlen
y := nyPos + sin(nRad2) * nRlen
HPDF_Page_SetTextMatrix( hPage, cos(nRad1), sin(nRad1), -sin(nRad1), cos(nRad1), x, y)
ENDSWITCH
HPDF_Page_ShowText ( hPage, SUBSTR(cText, i, 1) )
//nAngle2 -= nAngle1 //monospaced fonts
//A better solution for non monospaced fonts.
nAngle2 -= (HPDF_Page_TextWidth( hPage, SUBSTR(cText, i, 1) ) * nPxAng)
NEXT i
HPDF_Page_EndText ( hPage )
RETURN Nil
Replace #xcommand @ <Row>, <Col> HPDFPRINT CIRCLED TEXT with this one:
Code: Select all
#xcommand @ <Row> , <Col> HPDFPRINT CIRCLED TEXT <cText> ;
[ <lfont : FONT> <cFontName> ] ;
[ <lsize : SIZE> <nFontSize> ] ;
[ <bold : BOLD> [ IF <lBold> ] ] ;
[ <italic : ITALIC> [ IF <lItalic> ] ] ;
[ <lcolor : COLOR> <aColor> ] ;
[ <lrad : RADIUS> <nRad> ] ;
[ <lrims: RIMS> ] ;
[ <align : TOP, BOTTOM> ] ;
=> ;
HPDF_CircleText ( <Row> , <Col> , <cFontName> , <nFontSize> , <aColor>\[1\] , <aColor>\[2\] , <aColor>\[3\] , <cText> ,;
<.bold.> .AND. iif( HB_IsLogical(<lBold>), <lBold>, HB_IsNil(<lBold>) ) ,;
<.italic.> .AND. iif( HB_IsLogical(<lItalic>), <lItalic>, HB_IsNil(<lItalic>) ) ,;
<.lcolor.> , <.lfont.> , <.lsize.> , <nRad> , <.lrims.> , <"align">)
In your source, use the commands:
Code: Select all
@ 230 , 160 HPDFPRINT CIRCLED TEXT "TIPSQUIRREL" FONT "Times" SIZE 20 BOLD RADIUS 20 RIMS TOP
@ 230 , 160 HPDFPRINT CIRCLED TEXT " "+chr(149)+" PS NUTS "+chr(149)+" " SIZE 20 BOLD RADIUS 20 BOTTOM
where:
TOP - prints the text in the upper half of the circle
BOTTOM - prints the text in the bottom half of the circle
Edward.