Print Page | Close Window

Non-Embedded Fonts not working

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=3601
Printed Date: 29 Apr 24 at 6:16PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Non-Embedded Fonts not working
Posted By: waynefulcher
Subject: Non-Embedded Fonts not working
Date Posted: 25 Aug 18 at 12:02AM
I am using Delphi 7 and QPL version 8.16.
 
I have the following array of Font Names:
aFontNames: array[0..3] of string = ('Arial', 'Arial Bold', 'Arial Italic', 'Arial Bold Italic')

On a form I have a checkbox "chkEmbed" and a button which will create a pdf, add some fonts, draw one line of text per font and render the PDF onto an image which is showing on the form.
As I loop through array of Font Names I save an array of FontIDs to match.
below is a snippet of that code:
...
  setLength(aFontIDs, 0) ;
  if chkEmbed.Checked then
    embedOption := 1
  else
    embedOption := 0;
  setLength(aFontIDs, Length(aFontNames)) ;
  for i := 0 to High(aFontNames) do begin
    aFontIDs := PDF.AddTrueTypeFont(aFontNames, embedOption) ;
    mmo.Lines.Add(aFontNames+': '+IntToStr(aFontIDs));
  end ;
  DrawText(); 
....

procedure TfrmPDFFontUtility.DrawText() ;
var
  i: Integer ;
begin
  for i := 0 to High(aFontNames) do begin
    PDF.SelectFont(aFontIDs) ;
    PDF.SetTextSize(edtFontSize.Value) ;
    PDF.DrawText(1, ((i+1)*0.5), aFontNames+' ABCDEFGHIJKLMN abcdefghijklm');
  end ;
  PDF.SaveToFile('c:\temp\test.pdf');
  RenderPageToImageControl() ;
end ;


So the problem is if I check the box to embed the fonts then the image rendered is correct.
If I un-check the embed option then none of the Bold fonts are bold but other fonts (including italic) are correct.
Why does it matter if I embed the fonts or not? The font still exists on my computer the same. I could understand if I am sending a PDF to another computer that does not have the fonts, but that is not the case.

And this is off topic but.... the test.pdf file I save is like 10k when not embedded and almost 4MB when fonts are embedded. So for my end product I cannot embed the font.

Thanks for any help.



Replies:
Posted By: waynefulcher
Date Posted: 27 Aug 18 at 8:32PM
As a follow up I just downloaded the Trial for version 15.11 and it still has the same bug.... I can't for the life of me find where to go to report bugs.... At one time I saw a link but when I clicked on it it took me somewhere that had nothing to do with reporting bugs.

Anyone know how to communicate with this company?




Posted By: Ingo
Date Posted: 27 Aug 18 at 8:51PM
Hi Wayne,

i hardly can imagine that there's an error regarding fonts inside the library from version 8.16 up to 15.11 ... ;-)
Here you can report a technical problem or a bug:
https://www.foxitsoftware.com/login.php?u=https://tickets.foxitsoftware.com/create.php
First you have to register an foxit account (Debenu is a part of Foxit).



-------------
Cheers,
Ingo



Posted By: Ingo
Date Posted: 27 Aug 18 at 9:28PM
Hi Wayne ... it's me again ;-)

If you don't want to embed but only to select a font, you can use the already inserted standard fonts:
0 = Courier
1 = CourierBold
2 = CourierBoldOblique
3 = CourierOblique
4 = Helvetica
5 = HelveticaBold
6 = HelveticaBoldOblique
7 = HelveticaOblique
8 = TimesRoman
9 = TimesBold
10 = TimesItalic
11 = TimesBoldItalic
12 = Symbol
13 = ZapfDingbats

If you want to use another font you have to add it first with AddTrueTypeFont:
https://www.debenu.com/docs/pdf_library_reference/AddTrueTypeFont.php
This font has to be installed on your system!

If you're calling a font name not known in the system something similar will be used by the library.
BTW: I don't think that there's a font on your system called "Arial Bold".
I've searched inside my windows/fonts-path - the arial font names will be slightly different from the names you're using.

Here you'll get some informations about dealing with fonts from Debenu. Please read the answers from AndrewC:
http://www.quickpdf.org/forum/arial-narrow-font-is-not-displayed-properly_topic2451.html

To use the added font you have to use GetFontID:
https://www.debenu.com/docs/pdf_library_reference/GetFontID.php
Second step is SelectFont:
https://www.debenu.com/docs/pdf_library_reference/SelectFont.php
...then you can use it for example with the drawing syntax.



-------------
Cheers,
Ingo



Posted By: waynefulcher
Date Posted: 27 Aug 18 at 9:47PM
Thanks for your help but I think I have resolved it.
However to understand the reason it seemed such an issues is if I do this:

fontBold := PDF.AddTrueTypeFont('Arial Bold', 1) ;

it works perfectly it will print in Ariel and it will be Bold.
So why does that work may now be the question?
Because if I do this:

fontBold := PDF.AddTrueTypeFont('Arial Bold', 0) ;

It does not work, it will print in Arial, just not bold.
So you can see how this would make me confused and it seems to be a bug.
However after simply re-reading the docs a little closer I found that the alternative way to select the font with attribute and not embed the font was to change it to this:

fontBold := PDF.AddTrueTypeFont('Arial [Bold]', 0) ;

Thanks so much for your help though. I assume you must have been the original developer for this product cause you are the only person I have ever seen give support for the last (IDK) 15 years or more.

I just want to say again, I really appreciate what you do.




Posted By: Ingo
Date Posted: 28 Aug 18 at 10:10PM
Hi Wayne,

i'm only user of the library since a very long time now.
I'm a bit old-fashioned ... so for me as a member of a community it's important to give and to get.
Today most users only enter a forum for few minutes to ask for their problem and then they are again away. That's not my understanding about good cooperation in developer communities...
Perhaps it's my age ;-)
There's an interesting story about this library with a small team of free developers and me in the past ... if you want to know ;-)




-------------
Cheers,
Ingo



Posted By: waynefulcher
Date Posted: 30 Aug 18 at 5:20PM
Actually I would love to hear about it. I am one that enjoys hearing about how developers start something from nothing. My son and I are in the process of doing that same thing now.
I think you can find my email from my profile. Feel free to reach out anytime.




Posted By: Ingo
Date Posted: 30 Aug 18 at 8:30PM
you've got an email... ;-)



-------------
Cheers,
Ingo




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