Print Page | Close Window

Arial Narrow font is not displayed properly

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2451
Printed Date: 07 May 24 at 3:29AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Arial Narrow font is not displayed properly
Posted By: hmofaz@pentagon2000.
Subject: Arial Narrow font is not displayed properly
Date Posted: 14 Nov 12 at 9:54AM
Hello,
 
The width of text with Arial Narrow font and size 10 is different from the same text displayed in Notepad.
 
see code:

QuickPDF = new PDFLibrary(@dllName)QuickPDF.UnlockKey(LicenseKey);

QuickPDF.SetMeasurementUnits(1);QuickPDF.SetOrigin(1); 

QuickPDF.CompressImages(1);

QuickPDF.SetPageDimensions(215, 279)int fontId = QuickPDF.AddTrueTypeFont("Arial Narrow", 0);

QuickPDF.SelectFont(fontId);

QuickPDF.SetTextColor(0f, 0f, 0f);

QuickPDF.SetTextSize(10);

string printedText = "1ttttttttttttttttttttttttttttt";QuickPDF.DrawText(10, 10, printedText);QuickPDF.CompressContent();                  

QuickPDF.SaveToFile("FontTest.pdf")

 
the width of text with QuickPDF is 25mm but Notepad displays 17mm.
Why there is a difference?

Is any way to draw text with QuickPDF as Notepad?

Thanks




Replies:
Posted By: AndrewC
Date Posted: 15 Nov 12 at 10:39AM
Here is some test code that I used and the Narrow version of the font is definitely being selected properly.  I assume this is some problem to do with Notepad.

Windows has two different ways of selecting pointsizes as it has two ways of measuring the point size.  Windows can either use the font cell height whereas Adobe fonts are based on the leading value which is based on ascent + descent + leading.

You might be better off comparing 10pt fonts with something like photoshop or a proper drawing package.  Notepad is most likely using the cell height version.

            string printedText = "1ttttttttttttttttttttttttttttt";
            double y = 10;
            int id;

            QP.SetPageDimensions(215, 279);
            QP.SetMeasurementUnits(1);
            QP.SetOrigin(1);

            id = QP.AddTrueTypeFont("Arial Narrow", 0);
            QP.SelectFont(id);
            QP.SetTextSize(10);
            QP.DrawText(10, y, printedText + ":" + QP.FontName());
            y += 6;

            id = QP.AddTrueTypeFont("Arial Narrow", 1);
            QP.SelectFont(id);
            QP.SetTextSize(10);
            QP.DrawText(10, y, printedText + ":" + QP.FontName());
            y += 6;

            id = QP.AddStandardFont(4);      // Arial
            QP.SelectFont(id);
            QP.SetTextSize(10);
            QP.DrawText(10, y, printedText + ":" + QP.FontName());
            y += 6;

            id = QP.AddTrueTypeFont("Arial", 0);
            QP.SelectFont(id);
            QP.SetTextSize(10);
            QP.DrawText(10, y, printedText + ":" + QP.FontName());
            y += 6;

            id = QP.AddTrueTypeFont("Arial", 1);
            QP.SelectFont(id);
            QP.SetTextSize(10);
            QP.DrawText(10, y, printedText + ":" + QP.FontName());
            y += 6;

            QP.SaveToFile("out.pdf");
            Process.Start("out.pdf");



Posted By: hmofaz@pentagon2000.
Date Posted: 15 Nov 12 at 2:14PM
Hello,
 
I'm comparing to Notepad because we were drawing on Delphi canvas which displays text exactly as Notepad does.
I'm aware that the text shown on QuickPDF is identical to .NET Graphics and MS Word.
What do you mean when you state that the text format shown on PDF is true but shown on Notepad and delphi is old and not correct?
 
Thanks


Posted By: AndrewC
Date Posted: 19 Nov 12 at 5:39AM
This is a Microsoft created problem.   QPL will render the same as .NET, postscript, Photoshop etc..  

To calculate the size that you need you will need some type of function to convert from the Microsoft measurement to the Adobe version.  This link below should be helpful

http://stackoverflow.com/questions/2944149/converting-logfont-height-to-font-size-in-points

Andrew.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk