{"id":60,"date":"2009-04-21T11:04:33","date_gmt":"2009-04-21T11:04:33","guid":{"rendered":""},"modified":"2009-04-21T11:04:33","modified_gmt":"2009-04-21T11:04:33","slug":"font-problems-with-the-pdf-generation-te","status":"publish","type":"post","link":"http:\/\/www.icetips.com\/blog_wp\/2009\/04\/21\/font-problems-with-the-pdf-generation-te\/","title":{"rendered":"Font problems with the PDF generation templates"},"content":{"rendered":"<p>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.  <\/p>\n<p>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.  <\/p>\n<p>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.  <\/p>\n<p>This involves adding a single method to the PDFGeneratorClass class in ABPRPDF.INC and ABPRPDF.CLW:<\/p>\n<p>Add to class declaration in ABPRPDF.INC (I put it in at the top of the<br \/>\nmethod list, around line 195):<\/p>\n<div style=\"border: 1px solid gray;padding: 2px;background:#FBFFE8\">\n<pre>AdjustDPIValues   PROCEDURE(Long pValue),Long \r\n!! AB 2009-02-19  Adjusts DPI values\r\n<\/pre>\n<\/div>\n<p>In the classfile, ABPRPDF.clw, I added this:<\/p>\n<div style=\"border: 1px solid gray;padding: 2px;background:#FBFFE8\">\n<pre>PDFGeneratorClass.AdjustDPIValues   PROCEDURE(Long pValue)!!,Long \r\n!! AB 2009-02-19  Adjusts DPI values\r\nHDcScreen  UNSIGNED\r\nIDPI       Long\r\nR          Real\r\nL          Long\r\n Code\r\n R = 1\r\n HDcScreen = GetDC(0)\r\n If HDcScreen <> 0\r\n   IDPI = GetDeviceCaps(HDcScreen, 88)\r\n   L = ReleaseDC(0, HDcScreen)\r\n   R = IDPI\/96\r\n End\r\n Return (pValue \/ R)\r\n<\/pre>\n<\/div>\n<p>In PDFGeneratorClass.AddFontDescriptor method, you have code like this:<\/p>\n<div style=\"border: 1px solid gray;padding: 2px;background:#FBFFE8\">\n<pre>!SET the fonts Width\r\nLOOP LOC:I=SELF.FontsNames.FirstChar TO SELF.FontsNames.LastChar\r\n   LOC:CharToTest=CHR(LOC:I)\r\n   IF GetTextExtentPoint32(LOC:DC,LOC:CharToTest, 1,LOC:CharSize)<>0 THEN\r\n      IF LOC:Subclasing THEN\r\n         IF SELF.FontsNames.CharWidth[LOC:I] THEN\r\n            SELF.FontsNames.CharWidth[LOC:I] = LOC:CharSize.eW\r\n         END\r\n      ELSE\r\n         SELF.FontsNames.CharWidth[LOC:I] = LOC:CharSize.eW\r\n      END\r\n   END\r\nEND\r\n<\/pre>\n<\/div>\n<p>I changed both of the assignments to the CharWidth to:<\/p>\n<div style=\"border: 1px solid gray;padding: 2px;background:#FBFFE8\">\n<pre>SELF.FontsNames.CharWidth[LOC:I] = |\r\n           SELF.AdjustDPIValues(LOC:CharSize.eW)<\/pre>\n<\/div>\n<p>\nIn PDFGeneratorClass.GetTextWidth method, you have code like this:<\/p>\n<div style=\"border: 1px solid gray;padding: 2px;background:#FBFFE8\">\n<pre> IF SelectObject(LOC:DC, LOC:HFont) THEN\r\n    RV = GetTextExtentPoint32(LOC:DC,pText, LEN(pText),LOC:CharSize)\r\n    LOC:OLDMAPMODE=SetMapMode(LOC:DC,LOC:OLDMAPMODE)\r\n    DeleteObject(LOC:HFont)\r\n    RETURN LOC:CharSize.eW + (LOC:CharSize.eW\/20)\r\n END\r\n<\/pre>\n<\/div>\n<p>I changed the RETURN to adjust the value:<\/p>\n<div style=\"border: 1px solid gray;padding: 2px;background:#FBFFE8\">\n<pre>RETURN SELF.AdjustDPIValues(LOC:CharSize.eW + (LOC:CharSize.eW\/20))\r\n<\/pre>\n<\/div>\n<p>\nThis takes care of the font sizing problem in any DPI combination that I<br \/>\nthrew at it:)<\/p>\n<p>Arnor Baldvinsson<\/p>\n<\/p>\n<\/p>\n<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_60\" class=\"pvc_stats all  \" data-element-id=\"60\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"http:\/\/www.icetips.com\/blog_wp\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 <a href=\"http:\/\/www.icetips.com\/blog_wp\/2009\/04\/21\/font-problems-with-the-pdf-generation-te\/\" class=\"more-link\">...continue reading <span class=\"screen-reader-text\">Font problems with the PDF generation templates<\/span><\/a><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_60\" class=\"pvc_stats all  \" data-element-id=\"60\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"http:\/\/www.icetips.com\/blog_wp\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-technical"],"_links":{"self":[{"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":0,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.icetips.com\/blog_wp\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}