Re: [fpc-pascal] fpPDF and support of Latin2 charset
On 28/03/2019 17:39, Bo Berglund wrote: > The link you provided in your signature gets me to a place where > versions are displayed and the last one is 1.4.1 from 2015-09-02. > Is this a final version not in need of any new stuff? Is software ever "finished" Nope! :) I've been a bit lazy making official releases. Instead I've simply been committing fixes to a stable 'maint' branch which will become v1.4.2 at some point. Myself and others have also been pretty busy in the 'develop' branch which will become the next v2.0 release. There are tons of nice improvements in the 'develop' branch - yet still very backwards compatible with v1.4.1 (bar a few minor API changes, all well documented). The 'maint' branch is always in a stable state, so a good place to start with fpGUI if you want. The 'develop' branch is a lot more stable now than it was 6 months ago, but still things can change and improving. > And is it a development IDE or a plugin for Lazarus? > Or something else entirely? fpGUI is primarily just a GUI toolkit - 100% custom drawn and cross-platform. It can be used with any text editor or IDE (eg: Lazarus, MSEide, Geny, FPC's console IDE etc). Because I didn't want to bind fpGUI to a specific IDE, I implemented some support tools too. Like its own stand-alone Visual Forms Designer (uidesigner) and DocView (INF help viewer). There are also plenty of demos and small sample applications - even a experimental IDE called Maximus, but that is more of a "bigger demo" than a real IDE. fpGUI also has 12 language translations and 8 built in themes and the precursor PDF and Reporting engine (to what is now included with FPC). Saying that, Andrew Haines [I think] started some years ago a Lazarus widgetset called LCL-fpGUI, so LCL applications can be compiled to use fpGUI (instead of GTK, Qt etc). I occasionally contribute to it, but that Lazarus code doesn't see many updates and is a lot more incomplete than using the fpGUI Toolkit directly. If you do decide to play around with fpGUI, you are welcome to send any questions to the "fpgui.support" newsgroup. Details on how to connect can be found on the website: http://fpgui.sourceforge.net/support.shtml Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On Fri, 22 Mar 2019 20:48:25 +, Graeme Geldenhuys wrote: >On 22/03/2019 17:04, Martok wrote: >> Especially for tiny teams, the decision of spending 6k or hiring a new >> developer to maintain the toolchain is, sadly, a no-brainer. > >I developed fpGUI before I started working at that company. Same with >tiOPF, not initially developed by me, but existed lng before they >used it. The company spent a ton of money chasing Borland's dream... >Choosing Delphi 7, then the promise of cross platform future with CLX, >so they purchased Kylix 3 for all developers. All that expense (products >and coding time) just to find out that it will be killed off. They >discovered Free Pascal and Lazarus with improved cross-platform support, >but Lazarus was to buggy at the time and no possibility of per app >theming (still not possible to this day - even though Delphi has it >since XE2). > >Anyway, I proposed fpGUI and demoed it with a prototype application. It >had rough edges because fpGUI was just a hobby of mine at the time. They >saw potential and agreed to use it and I could spend _part_ of my time >improving it for their [product] benefit. The company wins as they get >the flexibility they needed and software that will not be abandoned, and >the open source project wins as it gets some paid development and >improvements with commercial backing and testing. > >fpGUI is not an isolated case. I was hired to implement fpPDF and >fpReport among other things. The company benefited as they needed >something that didn't yet exist (PDF and Reporting engine with no GUI >dependencies, implemented in Object Pascal). In return the company >released that code back to the Free Pascal project. > >There are 1000's of cases like this in all kinds of open source projects. > Graeme, this is interesting. The link you provided in your signature gets me to a place where versions are displayed and the last one is 1.4.1 from 2015-09-02. Is this a final version not in need of any new stuff? And is it a development IDE or a plugin for Lazarus? Or something else entirely? -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On 22/03/2019 17:04, Martok wrote: > Especially for tiny teams, the decision of spending 6k€ or hiring a new > developer to maintain the toolchain is, sadly, a no-brainer. I developed fpGUI before I started working at that company. Same with tiOPF, not initially developed by me, but existed lng before they used it. The company spent a ton of money chasing Borland's dream... Choosing Delphi 7, then the promise of cross platform future with CLX, so they purchased Kylix 3 for all developers. All that expense (products and coding time) just to find out that it will be killed off. They discovered Free Pascal and Lazarus with improved cross-platform support, but Lazarus was to buggy at the time and no possibility of per app theming (still not possible to this day - even though Delphi has it since XE2). Anyway, I proposed fpGUI and demoed it with a prototype application. It had rough edges because fpGUI was just a hobby of mine at the time. They saw potential and agreed to use it and I could spend _part_ of my time improving it for their [product] benefit. The company wins as they get the flexibility they needed and software that will not be abandoned, and the open source project wins as it gets some paid development and improvements with commercial backing and testing. fpGUI is not an isolated case. I was hired to implement fpPDF and fpReport among other things. The company benefited as they needed something that didn't yet exist (PDF and Reporting engine with no GUI dependencies, implemented in Object Pascal). In return the company released that code back to the Free Pascal project. There are 1000's of cases like this in all kinds of open source projects. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
> Tell them how much money (£2000+) they save per developer by using FPC > versus Delphi. A small money contribution to get something they need is > a small price to pay. I showed my company the price saving for a 5 > person development team. They couldn’t believe the savings, and allowed > me to develop the open source fpGUI and others during company time, Not to retroactively rain on your parade, but either you cost them less than 30k a year, or that was a lucky case of departmental politics of invest vs. payroll. Especially for tiny teams, the decision of spending 6k€ or hiring a new developer to maintain the toolchain is, sadly, a no-brainer. Unless you already have a strong commitment to open source tools, of course, but then it's more policy and publicity. -- Regards, Martok ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On 22/03/2019 13:29, LacaK wrote: > As far as we are company owned by state we have relative > strong restrictive policy for what we can spend money ;-| Tell them how much money (£2000+) they save per developer by using FPC versus Delphi. A small money contribution to get something they need is a small price to pay. I showed my company the price saving for a 5 person development team. They couldn’t believe the savings, and allowed me to develop the open source fpGUI and others during company time, because they benefited too from using those tools in their commercial products. It’s a win-win situation. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
(I am asking because in future probably in our company we will need generate PDF invoices which should be digitaly signed) I've looked at the documentation and it is quite doable to implement this. Could be a nice task, but it will and somewhere at the bottom of my to-do list until I need it for my work myself. Of course. I understand. If it goes into play may be I will look at details also. As far as we are company owned by state we have relative strong restrictive policy for what we can spend money ;-| L. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On 3/22/19 12:22 PM, LacaK wrote: How complicated would be add support for digital signing of PDF documents? I briefly looked at that when I implemented fpPDF, and that is quite tricky. Plus I don't fully understand all the requirements yet. :-( ok thank you (I am asking because in future probably in our company we will need generate PDF invoices which should be digitaly signed) I've looked at the documentation and it is quite doable to implement this. Could be a nice task, but it will and somewhere at the bottom of my to-do list until I need it for my work myself. If you or others really need this in the future, you might set a bounty or something. Regards, Joost -- http://lazarussupport.com - Your donation helps to push Free Pascal and Lazarus forwards. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
(but looking into PDF there is still in FontDescriptor wrong MissingWidth attribute, which does not goes into play AFAICS) What do you think is wrong with it? Look into test-noembed.pdf which I have attached to prior email. There is: 10 0 obj << /Type /FontDescriptor /FontName /Courier#20New /FontFamily /Courier#20New /Flags 32 /Ascent 1255 /Descent -386 /CapHeight 1170 /FontBBox [-122 -680 623 1021] /ItalicAngle 0 /StemV 70 /MissingWidth 61453 <-- HERE >> endobj On my side it is set to 600, which as far as I can see is correct for cour.ttf subset embedded font. Yes that is correct and I have 600 in: 8 0 obj << /Type /Font /Subtype /CIDFontType2 /BaseFont /Courier#20New /CIDSystemInfo 9 0 R /FontDescriptor 10 0 R /W [ 16 [600] 36 [600] 40 [600] 44 [600] 50 [600] 56 [600] 200 [600] 101 [600] 203 [600] 207 [600] 210 [600] 253 [600] 277 [600] 226 [600] 228 [600]] >> endobj That value is only used by PDF viewers when they need to display a glyph, but the glyph is not defined in the selected font. Yes may be that wrong value will never be used so it will have no negative impact, but it is potential source of problem ... I'll take another look at the spacing issue. Thank you ... In case no font is embedded all is okay, but in case font is embedded something wrong is still there ... Can I ask what is purpose of Sections in PDF structure? Because when I want use more than 1 Section I get exception "Dictionary element "Count" not found." It allows you to be infinitely flexible with the layout of a document. eg: If a report had several sections with different margins, headers, footers, orientation etc. You would use sections to set those. Attached is a very simple PDF showing sections. Note: some had different page layout, page numbering etc. If you have a decent PDF (reporting) viewer that support sections, you can jump between sections like you jump between pages. I ma trying look at PDF document using Adobe Acrobat Reader and Foxit Reader, but I can not see sections (nor any support for jumping between them) ... So in PDF document sections correspond to /Kids [5 0 R 14 0 R 21 0 R] ... fpGUI's "report preview" supports that. I'll take a look at the sections issue you raised. Would you be so kind as to create a Mantis report for that specific bug. https://bugs.freepascal.org/view.php?id=35258 Would it be possible to add "shortcut" AddPage directly to TPDFDocument, which will add Page to last Section or create new section if none exists? Obviously it could be added, but do we? It's comes down to different users with different needs. Plus what Michael said about the Dutch saying. ;-) Of course, but why not make life easier if we can. I think, that 99% of users will use only 1 section and also section concept is not intuitive without explanation (or if is not documented) Same holds for default Options. If now is preset in constructor: FOptions := [poCompressFonts, poCompressImages]; how many users will benefit from?: FOptions := [poCompressFonts, poCompressImages, poPageOriginAtTop, poSubsetFont]; I think that it is useful. (why repeat something which can be preset and gives reasonable default settings) It has also educational effect, which teach users what is optimal. In case of poSubsetFont why someone should not use always poSubsetFont? IMO it is always good choice have smaller sized file than bigger, does not? How complicated would be add support for digital signing of PDF documents? I briefly looked at that when I implemented fpPDF, and that is quite tricky. Plus I don't fully understand all the requirements yet. :-( ok thank you (I am asking because in future probably in our company we will need generate PDF invoices which should be digitaly signed) How complicated would be (in case of embedding fonts) subset only those characters, which are used in document, not a whole font? That is exactly how [poSubsetFont] works. Simple to test. Embed a large font like "DejaVu Sans". With poSubSetFont disabled, a one page PDF with the only text "Hello World" will be a couple of MBs in size. Then enable poSubsetFont and see the massive size reduction. Yes -Laco. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On 22/03/2019 07:16, LacaK wrote: > (but looking into PDF there is still in FontDescriptor wrong > MissingWidth attribute, which does not goes into play AFAICS) What do you think is wrong with it? On my side it is set to 600, which as far as I can see is correct for cour.ttf subset embedded font. That value is only used by PDF viewers when they need to display a glyph, but the glyph is not defined in the selected font. I'll take another look at the spacing issue. > Can I ask what is purpose of Sections in PDF structure? > Because when I want use more than 1 Section I get exception "Dictionary > element "Count" not found." It allows you to be infinitely flexible with the layout of a document. eg: If a report had several sections with different margins, headers, footers, orientation etc. You would use sections to set those. Attached is a very simple PDF showing sections. Note: some had different page layout, page numbering etc. If you have a decent PDF (reporting) viewer that support sections, you can jump between sections like you jump between pages. fpGUI's "report preview" supports that. I'll take a look at the sections issue you raised. Would you be so kind as to create a Mantis report for that specific bug. > Would it be possible to add "shortcut" AddPage directly to TPDFDocument, > which will add Page to last Section or create new section if none exists? Obviously it could be added, but do we? It's comes down to different users with different needs. Plus what Michael said about the Dutch saying. ;-) > How complicated would be add support for digital signing of PDF documents? I briefly looked at that when I implemented fpPDF, and that is quite tricky. Plus I don't fully understand all the requirements yet. > How complicated would be (in case of embedding fonts) subset only those > characters, which are used in document, not a whole font? That is exactly how [poSubsetFont] works. Simple to test. Embed a large font like "DejaVu Sans". With poSubSetFont disabled, a one page PDF with the only text "Hello World" will be a couple of MBs in size. Then enable poSubsetFont and see the massive size reduction. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp MultiSections.pdf Description: Adobe PDF document ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On Fri, 22 Mar 2019, LacaK wrote: I attached 2 patches to the bug tracker which solves the problem for me. 1. I can confirm, that in my case it is fixed for NO-embedded case only. For embedded fonts case there is still small issue (some characters are okay, some are shifted) - see attachments (but looking into PDF there is still in FontDescriptor wrong MissingWidth attribute, which does not goes into play AFAICS) 2. Can I ask what is purpose of Sections in PDF structure? Because when I want use more than 1 Section I get exception "Dictionary element "Count" not found." Try: PDF.Sections.AddSection; PDF.Sections[0].Title := 'Section1'; PDF.Sections[0].AddPage(PDF.Pages.AddPage); PDF.Sections.AddSection; PDF.Sections[1].Title := 'Section2'; PDF.Sections[1].AddPage(PDF.Pages.AddPage); This needs to be looked at... 3. Would it be possible to add "shortcut" AddPage directly to TPDFDocument, which will add Page to last Section or create new section if none exists? (if I guess right there is no big usage of sections in user code, so hide sections from user POV is no issue) I think this is a good idea in each case. 4. How complicated would be add support for digital signing of PDF documents? My guess is that this is not so easy. 5. How complicated would be (in case of embedding fonts) subset only those characters, which are used in document, not a whole font? (or does it works already so?) It aleready works so if you use poSubsetFont. 6. Would it be possible to use as default: FOPtions := [poCompressFonts, poCompressImages, poPageOriginAtTop, poSubsetFont]; (which are IMO most used options) Anything is possible, but IMO it's better to encourage people to think about what they're doing. There is a dutch saying "Laziness is the pillow of the devil."... Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
I attached 2 patches to the bug tracker which solves the problem for me. 1. I can confirm, that in my case it is fixed for NO-embedded case only. For embedded fonts case there is still small issue (some characters are okay, some are shifted) - see attachments (but looking into PDF there is still in FontDescriptor wrong MissingWidth attribute, which does not goes into play AFAICS) 2. Can I ask what is purpose of Sections in PDF structure? Because when I want use more than 1 Section I get exception "Dictionary element "Count" not found." Try: PDF.Sections.AddSection; PDF.Sections[0].Title := 'Section1'; PDF.Sections[0].AddPage(PDF.Pages.AddPage); PDF.Sections.AddSection; PDF.Sections[1].Title := 'Section2'; PDF.Sections[1].AddPage(PDF.Pages.AddPage); 3. Would it be possible to add "shortcut" AddPage directly to TPDFDocument, which will add Page to last Section or create new section if none exists? (if I guess right there is no big usage of sections in user code, so hide sections from user POV is no issue) 4. How complicated would be add support for digital signing of PDF documents? 5. How complicated would be (in case of embedding fonts) subset only those characters, which are used in document, not a whole font? (or does it works already so?) 6. Would it be possible to use as default: FOPtions := [poCompressFonts, poCompressImages, poPageOriginAtTop, poSubsetFont]; (which are IMO most used options) Thank you -Laco. test-noembed.pdf Description: Adobe PDF document test-embed.pdf Description: Adobe PDF document ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
I attached 2 patches to the bug tracker which solves the problem for me. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On 21/03/2019 13:20, LacaK wrote: > I think that problem is related to font parsing. As I wrote in comment > to bug report #35251 there is incorrectly extracted information about > char Widths ... look into attached generated PDF there ... Ah yes, I see what you mean. Apologies, I didn’t read the bug report, only this thread. I am looking at FPC Trunk and ran the ttfdump utility I wrote and it bombs out with a “Range check error” while processing the glyph widths. So that is mostly likely the cause of the problem. I’ll debug that now. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
I am trying work with fpPDF. I can create PDF document, but character out of ASCII range are displayed wrong (in PDF file they are stored as UTF8). First things first... what version of FPC are you using? FPC 3.0.4 or FPC 3.1.1 - just so I know what code to look at. I tried both versions 3.0.4 and also trunk I had a quick look and indeed there is something strange (or different) with the "cour.ttf" font. At closer inspection (using FontForge font editor) the "cour.tff" as supplied by Microsoft is some hybrid TTF+Bitmap font. The "arial.ttf" is a pure truetype font (no bitmap glyphs embedded). Not 100% sure yet if that is the cause or not. Maybe some special processing is needed for hybrid fonts. I'll investigate further. I think that problem is related to font parsing. As I wrote in comment to bug report #35251 there is incorrectly extracted information about char Widths ... look into attached generated PDF there ... Thank you ... -Laco. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On 19/03/2019 08:46, LacaK wrote: > I am trying work with fpPDF. I can create PDF document, but character > out of ASCII range are displayed wrong (in PDF file they are stored as > UTF8). First things first... what version of FPC are you using? FPC 3.0.4 or FPC 3.1.1 - just so I know what code to look at. I had a quick look and indeed there is something strange (or different) with the "cour.ttf" font. At closer inspection (using FontForge font editor) the "cour.tff" as supplied by Microsoft is some hybrid TTF+Bitmap font. The "arial.ttf" is a pure truetype font (no bitmap glyphs embedded). Not 100% sure yet if that is the cause or not. Maybe some special processing is needed for hybrid fonts. I'll investigate further. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
El 19/03/2019 a las 15:00, LacaK escribió: It seems that there is problem specific to CourierNew font (cour.ttf). With Arial (arial.ttf) it works as expected. Attached program which demonstrates problem. Hello, Can you send me by direct mail the pdf result for that program ? I´ll try to spot the differences. The name "CourierNew" while the TTF name is "Courier New" may force a typographic fallback to a standard font. PDF font handling is a mess, design patch over patch, several ways to render the same glyphs, ... It's almost incredible that a program can render successfully any document :-) -- ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
I suspect that the Arial font has unicode glyphs, and courier not. I do not know, but with other fonts: Arial, Verdana, Consolas it works as expected. Do you think, that Courier New is only exception? When I look at https://docs.microsoft.com/en-us/typography/font-list/courier-new I do not see there something special compared to other fonts ... But my knowledge about font structures (and also about PDF internals) is minimal ... I don't know much about TTF, but PDF should simply map characters to glyphs found in the TTF. Because how is the PDF generator supposed to know that it should transcode your text to latin 2 ? I do not know if it is necesssary. I have used FPDF port of PHP PDF library, which I have rewritten to pascal and there I can use "Courier New" font. (in both ways as embedded and also when not embedded) Probably FPDF handles PDF generation bit differently, but when I write into file any text in code page CP1250 and I embedd Courier New font (generated in advance by using makefont.php utility) then I get correct result. So my raw guess was that it must be doable also using fcl-pdf somehow? Possibly. Graeme Geldenhuys wrote 99% of the PDF and TTF support, I suspect he can tell us more. I will ask. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
Is there way how to get correct PDF file WITHOUT embedding full Courier font? You can embed only the needed characters for every font ? Probably yes, but fpPDF will not handle this automatically? AFAIK I can not control this. But why I get unreadable characters? What I am doing wrong ? It seems that there is problem specific to CourierNew font (cour.ttf). With Arial (arial.ttf) it works as expected. Attached program which demonstrates problem. Reported as bug https://bugs.freepascal.org/view.php?id=35251 (probably there is problem in parsing Courier New TTF font?) I am not sure this is the reason. I suspect that the Arial font has unicode glyphs, and courier not. I do not know, but with other fonts: Arial, Verdana, Consolas it works as expected. Do you think, that Courier New is only exception? When I look at https://docs.microsoft.com/en-us/typography/font-list/courier-new I do not see there something special compared to other fonts ... But my knowledge about font structures (and also about PDF internals) is minimal ... Because how is the PDF generator supposed to know that it should transcode your text to latin 2 ? I do not know if it is necesssary. I have used FPDF port of PHP PDF library, which I have rewritten to pascal and there I can use "Courier New" font. (in both ways as embedded and also when not embedded) Probably FPDF handles PDF generation bit differently, but when I write into file any text in code page CP1250 and I embedd Courier New font (generated in advance by using makefont.php utility) then I get correct result. So my raw guess was that it must be doable also using fcl-pdf somehow? -Laco. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On Wed, 20 Mar 2019, LacaK wrote: Is there way how to get correct PDF file WITHOUT embedding full Courier font? You can embed only the needed characters for every font ? Probably yes, but fpPDF will not handle this automatically? AFAIK I can not control this. But why I get unreadable characters? What I am doing wrong ? It seems that there is problem specific to CourierNew font (cour.ttf). With Arial (arial.ttf) it works as expected. Attached program which demonstrates problem. Reported as bug https://bugs.freepascal.org/view.php?id=35251 (probably there is problem in parsing Courier New TTF font?) I am not sure this is the reason. I suspect that the Arial font has unicode glyphs, and courier not. Because how is the PDF generator supposed to know that it should transcode your text to latin 2 ? Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
Is there way how to get correct PDF file WITHOUT embedding full Courier font? You can embed only the needed characters for every font ? Probably yes, but fpPDF will not handle this automatically? AFAIK I can not control this. But why I get unreadable characters? What I am doing wrong ? It seems that there is problem specific to CourierNew font (cour.ttf). With Arial (arial.ttf) it works as expected. Attached program which demonstrates problem. Reported as bug https://bugs.freepascal.org/view.php?id=35251 (probably there is problem in parsing Courier New TTF font?) -Laco. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
Is there way how to get correct PDF file WITHOUT embedding full Courier font? You can embed only the needed characters for every font ? Probably yes, but fpPDF will not handle this automatically? AFAIK I can not control this. But why I get unreadable characters? What I am doing wrong ? It seems that there is problem specific to CourierNew font (cour.ttf). With Arial (arial.ttf) it works as expected. Attached program which demonstrates problem. -Laco. unit test_fpPDF1; {$mode objfpc}{$H+} {$codepage UTF8} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type { TForm1 } TForm1 = class(TForm) Edit1: TEdit; procedure FormShow(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.lfm} uses fpPDF; { TForm1 } procedure TForm1.FormShow(Sender: TObject); var PDF: TPDFDocument; Font1, Font2: integer; begin PDF := TPDFDocument.Create(Self); PDF.Infos.Producer := ''; PDF.Infos.CreationDate := Now; PDF.Options := [poPageOriginAtTop, {poNoEmbeddedFonts,} poSubsetFont, poCompressFonts, poCompressImages]; PDF.DefaultOrientation := ppoPortrait; PDF.DefaultPaperType := ptA4; PDF.DefaultUnitOfMeasure := uomMillimeters; PDF.FontDirectory := 'C:\WINDOWS\FONTS'; PDF.StartDocument; PDF.Sections.AddSection; PDF.Sections[0].AddPage(PDF.Pages.AddPage);; //FontIndex := PDF.AddFont('Courier'); Font1 := PDF.AddFont('cour.ttf', 'CourierNew'); Font2 := PDF.AddFont('arial.ttf', 'Arial'); PDF.Pages[0].SetFont(Font1, 10); PDF.Pages[0].WriteText(10,10,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ'); PDF.Pages[0].WriteText(10,15,''); PDF.Pages[0].WriteText(10,20,Edit1.Text); PDF.Pages[0].SetFont(Font2, 10); PDF.Pages[0].WriteText(10,30,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ'); PDF.Pages[0].WriteText(10,35,''); PDF.SaveToFile('test.pdf'); end; end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpPDF and support of Latin2 charset
Hi, I am trying work with fpPDF. I can create PDF document, but character out of ASCII range are displayed wrong (in PDF file they are stored as UTF8). Probably it is because I use standard Courier font, which is expecting only "Latin characters" ? I use: FontIndex := PDF.AddFont('Courier'); // --> test1.pdf When I want to use TTF font: FontIndex := PDF.AddFont('cour.ttf','CourierNew'); // --> test2.pdf (nothing else this line has changed) I get strange PDF file (I can open it but content is wrong) What I am doing wrong? Is there way how to get correct PDF with characters from Latin2 code page? Not to my knowledge. You must use unicode for characters outside the ASCII range. Seems, that Adobe in https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf in Annex D2: "Latin Character Set and Encodings" specifies exactly which characters are supported (by standard 14 fonts). Characters not listed there are simply replaced by "X" in Adobe Acrobat Reader. But Foxit reader displays them correctly (so I can use full range of characters from CP1250 when I specify appropriate
Re: [fpc-pascal] fpPDF and support of Latin2 charset
On Tue, 19 Mar 2019, LacaK wrote: Hi, I am trying work with fpPDF. I can create PDF document, but character out of ASCII range are displayed wrong (in PDF file they are stored as UTF8). Probably it is because I use standard Courier font, which is expecting only "Latin characters" ? I use: FontIndex := PDF.AddFont('Courier'); // --> test1.pdf When I want to use TTF font: FontIndex := PDF.AddFont('cour.ttf','CourierNew'); // --> test2.pdf (nothing else this line has changed) I get strange PDF file (I can open it but content is wrong) What I am doing wrong? Is there way how to get correct PDF with characters from Latin2 code page? Not to my knowledge. You must use unicode for characters outside the ASCII range. Is there way how to get correct PDF file WITHOUT embedding full Courier font? You can embed only the needed characters for every font ? Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] fpPDF and support of Latin2 charset
Hi, I am trying work with fpPDF. I can create PDF document, but character out of ASCII range are displayed wrong (in PDF file they are stored as UTF8). Probably it is because I use standard Courier font, which is expecting only "Latin characters" ? I use: FontIndex := PDF.AddFont('Courier'); // --> test1.pdf When I want to use TTF font: FontIndex := PDF.AddFont('cour.ttf','CourierNew'); // --> test2.pdf (nothing else this line has changed) I get strange PDF file (I can open it but content is wrong) What I am doing wrong? Is there way how to get correct PDF with characters from Latin2 code page? Is there way how to get correct PDF file WITHOUT embedding full Courier font? Thanks -Laco. Full source code is: var PDF: TPDFDocument; FontIndex: integer; begin PDF := TPDFDocument.Create(Self); PDF.Infos.Producer := ''; PDF.Infos.CreationDate := Now; PDF.Options := [poPageOriginAtTop, {poNoEmbeddedFonts,} poSubsetFont, poCompressFonts, poCompressImages]; PDF.DefaultOrientation := ppoPortrait; PDF.DefaultPaperType := ptA4; PDF.DefaultUnitOfMeasure := uomMillimeters; PDF.FontDirectory := 'C:\WINDOWS\FONTS'; PDF.StartDocument; PDF.Sections.AddSection; PDF.Sections[0].AddPage(PDF.Pages.AddPage);; //FontIndex := PDF.AddFont('Courier'); FontIndex := PDF.AddFont('cour.ttf', 'CourierNew'); PDF.Pages[0].SetFont(FontIndex, 10); PDF.Pages[0].WriteText(10,10,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ'); PDF.Pages[0].WriteText(10,15,''); PDF.Pages[0].WriteText(10,20,'AEIOU-ÁÉÍÓÚ-ČŠŇŽ'); PDF.SaveToFile('test.pdf'); end; test1.pdf Description: Adobe PDF document test2.pdf Description: Adobe PDF document ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal