Two months ago I implemented the Clarion PDF generation templates in a client project. I was pretty horrified by the results as characters were chopped and spaced very strangely. After posting about this on the Clarion newsgroups, Lee White suggested that this was because I was running Large Fonts on my system.
Since I have had to deal with Large Font issues before simply because I use high resolution and need to be able to seeB) I decided to take a closer look at this and see what was going on.
Sure enough the problem stems from code in the ABPRPDF.CLW file where the width of the characters is calculated. To fix this I made some changes to the files.
This involves adding a single method to the PDFGeneratorClass class in ABPRPDF.INC and ABPRPDF.CLW:
Add to class declaration in ABPRPDF.INC (I put it in at the top of the
method list, around line 195):
AdjustDPIValues PROCEDURE(Long pValue),Long !! AB 2009-02-19 Adjusts DPI values
In the classfile, ABPRPDF.clw, I added this:
PDFGeneratorClass.AdjustDPIValues PROCEDURE(Long pValue)!!,Long !! AB 2009-02-19 Adjusts DPI values HDcScreen UNSIGNED IDPI Long R Real L Long Code R = 1 HDcScreen = GetDC(0) If HDcScreen <> 0 IDPI = GetDeviceCaps(HDcScreen, 88) L = ReleaseDC(0, HDcScreen) R = IDPI/96 End Return (pValue / R)
In PDFGeneratorClass.AddFontDescriptor method, you have code like this:
!SET the fonts Width LOOP LOC:I=SELF.FontsNames.FirstChar TO SELF.FontsNames.LastChar LOC:CharToTest=CHR(LOC:I) IF GetTextExtentPoint32(LOC:DC,LOC:CharToTest, 1,LOC:CharSize)<>0 THEN IF LOC:Subclasing THEN IF SELF.FontsNames.CharWidth[LOC:I] THEN SELF.FontsNames.CharWidth[LOC:I] = LOC:CharSize.eW END ELSE SELF.FontsNames.CharWidth[LOC:I] = LOC:CharSize.eW END END END
I changed both of the assignments to the CharWidth to:
SELF.FontsNames.CharWidth[LOC:I] = | SELF.AdjustDPIValues(LOC:CharSize.eW)
In PDFGeneratorClass.GetTextWidth method, you have code like this:
IF SelectObject(LOC:DC, LOC:HFont) THEN RV = GetTextExtentPoint32(LOC:DC,pText, LEN(pText),LOC:CharSize) LOC:OLDMAPMODE=SetMapMode(LOC:DC,LOC:OLDMAPMODE) DeleteObject(LOC:HFont) RETURN LOC:CharSize.eW + (LOC:CharSize.eW/20) END
I changed the RETURN to adjust the value:
RETURN SELF.AdjustDPIValues(LOC:CharSize.eW + (LOC:CharSize.eW/20))
This takes care of the font sizing problem in any DPI combination that I
threw at it:)
Arnor Baldvinsson
Hi all,
This is now apparently fixed in Clarion 9.1.11129. I thought this had been fixed in Clarion 7, but apparently it never made it in there.
Arnor