Re: [Lazarus] PDF generator: please test

2016-04-14 Thread Graeme Geldenhuys
On 2016-04-14 00:04, Ondrej Pokorny wrote:
> You've got a bug in the font height functions. They must not be scaled 
> with ToNatural.

Well done Ondrey, you are indeed correct. Amazing, because the example
code I posted was tested with four other fonts. Incidently they all had
the same UnitsPerEm, so the issue went unnoticed.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-13 Thread Ondrej Pokorny
You've got a bug in the font height functions. They must not be scaled 
with ToNatural.


Try e.g. the Tahoma font from Windows or any other font where 
FHead.UnitsPerEm<>1000. You'll see wrong results.


Your example works because FHead.UnitsPerEm is 1000 for your version of 
FreeSans. If you use an old FreeSans where UnitsPerEm is 2048, you get 
wrong box height.


I needed about 2 hours to find it :(

See http://mantis.freepascal.org/view.php?id=30008

Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-11 Thread Graeme Geldenhuys
On 2016-04-11 02:17, Dmitry Boyarintsev wrote:
> I always assumed it represents text as a sequence of glyphs, rather than
> sequence of characters. But it seems like both options are possible.

No, your first assumption is correct. When it comes to PDF, there is NO
notion of text strings (sequence of characters). PDF only understands
graphical elements (lines, rectangles, curves etc). The PDF creator
breaks text down into character ID's (something like Unicode codepoints
- but again PDF's know nothing about Unicode either). Those character
ID's are used to look up Glyph ID's in the font file. The Glyph ID's are
what are stored inside the PDF. When viewed, those glyph ID's are used
to retrieve the vector graphic instructions from the font file to render
a glyph.

You might view a PDF with a text editor and see text strings. It might
look like text strings to you (eg: ASCII range), but PDF doesn't
consider them text, but rather ID's. It is pure coincidence that they
happen to look like text in a text editor.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-11 Thread Graeme Geldenhuys
On 2016-04-10 09:23, Michael Van Canneyt wrote:
> Font substitution is a potentially huge subject. 
> I would not want this in the initial low-level API.

Indeed. The *nix libXft.so library with combination of FontConfig does
this for general desktop applications, but it is a huge task. Windows
doesn't do font substitution at all for desktop applications.

As for PDFs, the problem is handled in two ways as per the official PDF
spec.

 1) if you embed a font, but the character glyphs do not exist for that
font, you use GlyphID 0, which should draw a rectangle in place of
the glyph.

 2) if you don't embed a TTF font, all the font information will still
be written to the PDF. The PDF viewer (no matter the platform) can
then try and use the exact font, if it is available on the current
system. If not, the PDF viewer uses the font information to
substitute it with a font from the same family.

Both cases are already implemented in fpPDF.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-10 Thread Dmitry Boyarintsev
On Sun, Apr 10, 2016 at 4:23 AM, Michael Van Canneyt  wrote:
>
>
> No, why ? One is about encoding of the supplied text.
>
> The other about whether the current font has the necessary glyphs to render
> the text.


I see the issue now. It's in my perception of PDF format.
I always assumed it represents text as a sequence of glyphs, rather than
sequence of characters. But it seems like both options are possible.

thanks,
Dmitry
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-10 Thread Michael Van Canneyt



On Sun, 10 Apr 2016, Graeme Geldenhuys wrote:


On 2016-04-10 08:15, Michael Van Canneyt wrote:

Wow, let me interfere here before we go in a wrong direction:

The public API should not depend on the selected font.


I know. The current implementation gravitated towards the situation we
have now, but that is definitely not how it is going to end up. Like I
mentioned in one of my earlier replies, we will end up with overloaded
WriteText() calls only, and internally the fpPDF code will sort out what
font code to generate. Up to now, one of my high priority was figuring
out font embedding and handling of ASCII and Unicode text - this task
seems complete (except for the Unicode range above BMP which still needs
some minor attention).

These should all be addressed in the next round of updates.


OK, seems we are of the same mind, I just wanted to make sure of that :-)

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-10 Thread Graeme Geldenhuys
On 2016-04-10 08:15, Michael Van Canneyt wrote:
> Wow, let me interfere here before we go in a wrong direction:
> 
> The public API should not depend on the selected font.

I know. The current implementation gravitated towards the situation we
have now, but that is definitely not how it is going to end up. Like I
mentioned in one of my earlier replies, we will end up with overloaded
WriteText() calls only, and internally the fpPDF code will sort out what
font code to generate. Up to now, one of my high priority was figuring
out font embedding and handling of ASCII and Unicode text - this task
seems complete (except for the Unicode range above BMP which still needs
some minor attention).

These should all be addressed in the next round of updates.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-10 Thread Michael Van Canneyt



On Sun, 10 Apr 2016, Dmitry Boyarintsev wrote:


On Sun, Apr 10, 2016 at 3:15 AM, Michael Van Canneyt 

Re: [Lazarus] PDF generator: please test

2016-04-10 Thread Dmitry Boyarintsev
On Sun, Apr 10, 2016 at 3:15 AM, Michael Van Canneyt  wrote:

It feels like, these two paragraphs:

>
> The user of the API should not have to care what font is used.
> the API should do whatever is necessary to emit correct PDF for the
> current font.
>
> If internally there are different calls needed for different fonts, then
> that is OK, but they should not be exposed to the user, at the best they
> should be made protected.
> (if need be, we can expose them later)
>

contradict to:


> If the currently used font does not contain the necessary glyphs to
> represent
> the text, we will not check it, that is the responsability of the user.


The APIs should either do the font-substitution  (with whatever level  of
control from the user side). (something what graphic APIs are doing for
text rendering)
or should not do them at all (leaving full font-substitution to the user)

Then there should be some cross-platform APIs provided (not necessary part
of PDF package) that would perform font substitution by the (unicode) text
and the desired font (font-size).

Eventually, someone would provide  WriteUTF8TextSmart() function, that
would split the text into parts (by fonts used) and would populate the PDF
accordingly, if PDF library doesn't the font-substitution itself.

For example, rendering a text with mix of latin letters and hieroglyphs,
using Times New Roman font. Typically for hieroglyphs one of system default
CJK fonts are used.

thanks,
Dmitry
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-10 Thread Michael Van Canneyt



On Sun, 10 Apr 2016, Graeme Geldenhuys wrote:


On 2016-04-09 09:09, Ondrej Pokorny wrote:

   P.WriteText(25, 0, 'Sample Text'); // DOESN'T WORK !!!


Indeed. As I mentioned, the Write*Text() names are a bit inaccurate and
will be improved. At the moment WriteText() is meant for the Standard
PDF Fonts, and WriteUTF8Text() for any TTF fonts used.


Wow, let me interfere here before we go in a wrong direction:

The public API should not depend on the selected font.

WriteText() is meant for Ansi text - whatever the current font.
WriteUTF8Text() is meant for UTF8 encoded unicode text, whatever the current 
font.

The user of the API should not have to care what font is used.
the API should do whatever is necessary to emit correct PDF for the current 
font.

If internally there are different calls needed for different fonts, then
that is OK, but they should not be exposed to the user, at the best they should 
be made protected.
(if need be, we can expose them later)

If the currently used font does not contain the necessary glyphs to represent
the text, we will not check it, that is the responsability of the user.

Michael.


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-10 Thread Ondrej Pokorny

On 10.04.2016 1:02, Graeme Geldenhuys wrote:

   P.WriteUTF8Text(25, 20, 'Sample Text');
>
>xFontCache := TFPFontCacheList.Create;
>try
>  xFont := TFPFontCacheItem.Create('fonts\FreeSans.ttf');
>  xFontCache.Add(xFont);
>  xWidth := xFont.TextWidth('Sample Text', cFontSize) * 25.4 / 72; //
>25.4 / 72 = conversion PDFTomm (?)

I believe here is your mistake. Your system is probably 96 DPI, not 72.


IMO it's not about my system DPI (fppdf is headless and doesn't use the 
GUI DPI). It's the default value in TFPFontCacheList.DPI. Correct?
I expected fpttf it to use 72 DPI which is the default for PDF 
(cDefaultDPI in fppdf.pas). My mistake.



If you use gTTFontCache.DPI it would have given you the correct result.


Indeed, thanks!


At the moment the FontCache object defaults to the most common desktop
DPI, which is 96, but in your actual application you can query it with
whatever GUI you have and set the value yourself.


Great, thanks Graeme for the code and clarifying, it works!
(IMO it would be great to update the example code with "box around text" 
code. It is a usual task to get text width/height and so you spare your 
time to clarify it to another person who needs it in the future.)


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

On 08.04.2016 23:35, Graeme Geldenhuys wrote:

As note: If I compile with -Cr, I got a Runerror 201 in unit fpparsettf
>on line 810.

I made a note of that, thanks.


The attached patch fixes the range error.

Ondrej
Index: fpparsettf.pp
===
--- fpparsettf.pp   (revision 33453)
+++ fpparsettf.pp   (working copy)
@@ -807,7 +807,8 @@
   FMissingWidth := Widths[Chars[CharCodes^[32]]].AdvanceWidth;  // Char(32) - 
Space character
   for I:=0 to 255 do
 begin
-if (Widths[Chars[CharCodes^[i]]].AdvanceWidth> 0) and (CharNames^[i]<> 
'.notdef') then
+if (CharCodes^[i]>=0) and (CharCodes^[i]<=High(Chars))
+and (Widths[Chars[CharCodes^[i]]].AdvanceWidth> 0) and (CharNames^[i]<> 
'.notdef') then
   CharWidth[I]:= ToNatural(Widths[Chars[CharCodes^[I]]].AdvanceWidth)
 else
   CharWidth[I]:= FMissingWidth;
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
On 2016-04-10 00:02, Graeme Geldenhuys wrote:
> Here is verbosely commented code that draws a rectangle around the Page
> Title text.

Apologies, here is the correct code.

=
  { Page title }
  P.SetFont(FtText1, 23);
  P.SetColor(clBlack, false);
  P.WriteUTF8Text(25, 20, 'Sample Text');

  { draw a rectangle around the Page Title text }
  lPt1.X := 25;  // units in MM
  lPt1.Y := 20;  // units in MM
  lFntPtSize := 23;

  lFC := gTTFontCache.Find('FreeSans', False, False);
  if not Assigned(lFC) then
raise Exception.Create('FreeSans font not found');
  lFntInfo := lFC.GetFontData;

  { result is in pixels }
  lHeight := lFntInfo.CapHeight * lFntPtSize * gTTFontCache.DPI /
  (72 * lFntInfo.Head.UnitsPerEm);
  { convert pixels to mm as our PDFPage.UnitOfMeasure is set to mm. }
  lTextHeightInMM :=  (lHeight * 25.4) / gTTFontCache.DPI;

  lWidth := lFC.TextWidth('Sample Text', lFntPtSize);
  { convert the Font Units to Millimeters }
  lTextWidthInMM := (lWidth * 25.4) / gTTFontCache.DPI;

  { result is in pixels }
  lHeight := Abs(lFntInfo.Descender) * lFntPtSize * gTTFontCache.DPI /
  (72 * lFntInfo.Head.UnitsPerEm);
  { convert pixels to mm as you PDFPage.UnitOfMeasure is set to mm. }
  lDescenderHeightInMM :=  (lHeight * 25.4) / gTTFontCache.DPI;

  { adjust the Y coordinate for the font Descender, because
WriteUTF8Text draws on the baseline. Also adjust the TextHeight
because CapHeight doesn't take into account the Descender. }
  P.SetColor(clRed, true);
  P.DrawRect(lPt1.X, lPt1.Y+lDescenderHeightInMM, lTextWidthInMM,
  lTextHeightInMM+lDescenderHeightInMM, 1, false, true);
  lFntInfo.Free;

=


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
On 2016-04-09 09:09, Ondrej Pokorny wrote:
>P.WriteText(25, 0, 'Sample Text'); // DOESN'T WORK !!!

Indeed. As I mentioned, the Write*Text() names are a bit inaccurate and
will be improved. At the moment WriteText() is meant for the Standard
PDF Fonts, and WriteUTF8Text() for any TTF fonts used.


>P.WriteUTF8Text(25, 20, 'Sample Text');
> 
>xFontCache := TFPFontCacheList.Create;
>try
>  xFont := TFPFontCacheItem.Create('fonts\FreeSans.ttf');
>  xFontCache.Add(xFont);
>  xWidth := xFont.TextWidth('Sample Text', cFontSize) * 25.4 / 72; // 
> 25.4 / 72 = conversion PDFTomm (?)

I believe here is your mistake. Your system is probably 96 DPI, not 72.
If you use gTTFontCache.DPI it would have given you the correct result.
At the moment the FontCache object defaults to the most common desktop
DPI, which is 96, but in your actual application you can query it with
whatever GUI you have and set the value yourself.


Here is verbosely commented code that draws a rectangle around the Page
Title text. Screenshot of the output is attached.

==
  { draw a rectangle around the Page Title text }
  lPt1.X := 25;  // units in MM
  lPt1.Y := 20;  // units in MM
  lFntPtSize := 23;

  { a rough calculation but not 100% accurate for a specific font. }
//  lTextHeightInMM := ((gTTFontCache.PointSizeInPixels(lFntPtSize) *
25.4) / 72) / 2;

  lFC := gTTFontCache.Find('FreeSans', False, False);
  if not Assigned(lFC) then
raise Exception.Create('FreeSans font not found');
  lFntInfo := lFC.GetFontData;

  { result is in pixels }
  lHeight := lFntInfo.CapHeight * lFntPtSize * gTTFontCache.DPI / (72 *
lFntInfo.Head.UnitsPerEm);
  { convert pixels to mm as our PDFPage.UnitOfMeasure is set to mm. }
  lTextHeightInMM :=  (lHeight * 25.4) / 72;

  lWidth := lFC.TextWidth('Sample Text', lFntPtSize);
  { convert the Font Units to Millimeters }
  lTextWidthInMM := (lWidth * 25.4) / gTTFontCache.DPI;

  { result is in pixels }
  lHeight := Abs(lFntInfo.Descender) * lFntPtSize * gTTFontCache.DPI /
(72 * lFntInfo.Head.UnitsPerEm);
  { convert pixels to mm as you PDFPage.UnitOfMeasure is set to mm. }
  lDescenderHeightInMM :=  (lHeight * 25.4) / 72;

  { adjust the Y coordinate for the font Descender, because
WriteUTF8Text draws on the baseline. }
  lPt1.Y := lPt1.Y + lDescenderHeightInMM;

  P.SetColor(clRed, true);
  P.DrawRect(lPt1.X, lPt1.Y, lTextWidthInMM, lTextHeightInMM, 1, false,
true);
  lFntInfo.Free;
==



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
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Michael Van Canneyt



On Sat, 9 Apr 2016, Graeme Geldenhuys wrote:


On 2016-04-09 18:27, Ondrej Pokorny wrote:

As is the
text width function (for right/center alignment support).


That is already implemented in fpReport (Standard PDF built-in fonts and
TTF fonts). What I haven't implemented yet is Font Kerning to make the
width calculation even more accurate, but the width difference will be
very minor. I can take a look and see if it makes sense to move that
code to fpPDF. I'm pretty sure it shouldn't be a problem.


Graeme,

If that can be moved to unit fpttf instead of fppdf, then that would be even 
better.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Michael Van Canneyt



On Sat, 9 Apr 2016, Ondrej Pokorny wrote:


I think I'll develop a TPDFDocument->TCanvas renderer for
previewing created PDF documents.

Great. I should then be able to plug that into fpReport too. I want to
implement a PDF & fpReport -> AggPas renderer too.


We should then try to omit unnecessary double work. I see that AggPas should 
be able to render TTF fonts already. Why do you need fpTTF and fpParseTTF 
then?


Because one of the requirements is not to depend on external libraries.
AggPas uses the freetype library to render TTF.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

On 09.04.2016 19:42, Graeme Geldenhuys wrote:

On 2016-04-09 18:27, Ondrej Pokorny wrote:

As is the
text width function (for right/center alignment support).

That is already implemented in fpReport (Standard PDF built-in fonts and
TTF fonts). What I haven't implemented yet is Font Kerning to make the
width calculation even more accurate, but the width difference will be
very minor. I can take a look and see if it makes sense to move that
code to fpPDF. I'm pretty sure it shouldn't be a problem.


Please take a look at the code in my email from today 10:09. When I use 
TFPFontCacheItem.TextWidth, I get this:



(The red rectangle visualizes the textwidth/textheight calculation). The 
text height is correct, but text width is very different.



If there is a possibility to render text with custom TTF font in Lazarus
(I found easylazfreetype, but I couldn't make it work with my first

I'm not sure if we are talking about the same unit, but the freetype
pascal implementation in Lazarus is based on a very old FreeType v1. It
also misses tons of features found in the commonly used FreeType v2 library.

I once tried to use the Pascal based FreeType code to reduce
dependencies for AggPas text rendering. The Pascal FreeType simply
wasn't up to the task and lacked functionality I needed. The fpTTF (font
cache) and fpParseTTF (actual TTF data extraction) is much more likely
to be successful with my AggPas goal.



I think I'll develop a TPDFDocument->TCanvas renderer for
previewing created PDF documents.

Great. I should then be able to plug that into fpReport too. I want to
implement a PDF & fpReport -> AggPas renderer too.


We should then try to omit unnecessary double work. I see that AggPas 
should be able to render TTF fonts already. Why do you need fpTTF and 
fpParseTTF then? Nevertheless IMO it's good to have as little 
dependencies as possible, so if the TTF functionality from fp-pdf can be 
extended to render TTF characters without AggPas, that would be great.


Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
On 2016-04-09 16:51, Giuliano Colla wrote:
> I'd say that Здравствуйте 
> мир! is to be preferred, because it has a higher number of characters!


Good point. :)


Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
On 2016-04-09 18:33, Ondrej Pokorny wrote:
> What PDF documentation do you use? (Where can I find information on PDF 
> creating?)

I used the official PDF v1.3 specification document. All 700 pages of
it, which I've probably read a 100 times over now.  :)

 http://partners.adobe.com/public/developer/en/pdf/PDFReference13.pdf


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
On 2016-04-09 18:27, Ondrej Pokorny wrote:
> As is the 
> text width function (for right/center alignment support).

That is already implemented in fpReport (Standard PDF built-in fonts and
TTF fonts). What I haven't implemented yet is Font Kerning to make the
width calculation even more accurate, but the width difference will be
very minor. I can take a look and see if it makes sense to move that
code to fpPDF. I'm pretty sure it shouldn't be a problem.


> If there is a possibility to render text with custom TTF font in Lazarus 
> (I found easylazfreetype, but I couldn't make it work with my first

I'm not sure if we are talking about the same unit, but the freetype
pascal implementation in Lazarus is based on a very old FreeType v1. It
also misses tons of features found in the commonly used FreeType v2 library.

I once tried to use the Pascal based FreeType code to reduce
dependencies for AggPas text rendering. The Pascal FreeType simply
wasn't up to the task and lacked functionality I needed. The fpTTF (font
cache) and fpParseTTF (actual TTF data extraction) is much more likely
to be successful with my AggPas goal.


> I think I'll develop a TPDFDocument->TCanvas renderer for 
> previewing created PDF documents.

Great. I should then be able to plug that into fpReport too. I want to
implement a PDF & fpReport -> AggPas renderer too.



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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Michael Van Canneyt



On Sat, 9 Apr 2016, Ondrej Pokorny wrote:


On 09.04.2016 19:00, Michael Van Canneyt wrote:

On Sat, 9 Apr 2016, Ondrej Pokorny wrote:

I see that the PDF generator doesn't support image compression. This is a 
no-go in my eyes. Is anybody working on that or should I try to study it?


We are not yet working on this, it was on the TODO list, but not very high
priority.



AFAIR SynPDF uses JPEG compression for images.


Patches will gladly be accepted.


Great, I'll take a look into it. It is high priority for me. As is the text 
width function (for right/center alignment support).


Maybe Graeme can comment on the latter, as far as I know, that should work ?



If there is a possibility to render text with custom TTF font in Lazarus (I 
found easylazfreetype, but I couldn't make it work with my first attempts), I 
think I'll develop a TPDFDocument->TCanvas renderer for previewing created 
PDF documents.


That would be really awesome !

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

On 09.04.2016 19:28, Graeme Geldenhuys wrote:

On 2016-04-09 17:27, Ondrej Pokorny wrote:

I see that the PDF generator doesn't support image compression. This is
a no-go in my eyes. Is anybody working on that or should I try to study it?

It's on the todo list, as is Text Compression, Font Subset Embedding and
many more. You are welcome to tackle parts you deem urgent for your needs.


What PDF documentation do you use? (Where can I find information on PDF 
creating?)


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
On 2016-04-09 17:27, Ondrej Pokorny wrote:
> I see that the PDF generator doesn't support image compression. This is 
> a no-go in my eyes. Is anybody working on that or should I try to study it?

It's on the todo list, as is Text Compression, Font Subset Embedding and
many more. You are welcome to tackle parts you deem urgent for your needs.

Reducing the size of generated PDF's are high on the priority list, but
what was even higher was actually getting a working PDF. Based on the
latest round of feedback, the latter goal has finally been reached. So
the next goals will be ticked off one by one.


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

On 09.04.2016 19:00, Michael Van Canneyt wrote:

On Sat, 9 Apr 2016, Ondrej Pokorny wrote:

I see that the PDF generator doesn't support image compression. This 
is a no-go in my eyes. Is anybody working on that or should I try to 
study it?


We are not yet working on this, it was on the TODO list, but not very 
high

priority.



AFAIR SynPDF uses JPEG compression for images.


Patches will gladly be accepted.


Great, I'll take a look into it. It is high priority for me. As is the 
text width function (for right/center alignment support).


If there is a possibility to render text with custom TTF font in Lazarus 
(I found easylazfreetype, but I couldn't make it work with my first 
attempts), I think I'll develop a TPDFDocument->TCanvas renderer for 
previewing created PDF documents.


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Michael Van Canneyt



On Sat, 9 Apr 2016, Ondrej Pokorny wrote:

I see that the PDF generator doesn't support image compression. This is a 
no-go in my eyes. Is anybody working on that or should I try to study it?


We are not yet working on this, it was on the TODO list, but not very high
priority.



AFAIR SynPDF uses JPEG compression for images.


Patches will gladly be accepted.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread wkitty42

On 04/09/2016 10:57 AM, Ondrej Pokorny wrote:

On 09.04.2016 15:44, wkitt...@windstream.net wrote:

On 04/09/2016 04:30 AM, Ondrej Pokorny wrote:

Please don't take it as an offence, there is no.
I just first opened the PDF, saw the typo and then I had to check in the source
code if it is really a typo or the library picks up the wrong character for the
PDF. It is a typo, so everything is OK.
It would be still great if you corrected it ;)
Correct is "Здравствуйте" (I missed a character in the first email as well :D)


interesting in what determines "correct"...

Алло мир!
Привет мир!
Здравствуйте мир!


"Correct" as I used it was about a typo in one of the words you presented. It
wasn't about word choice.


oh! in that case, carry on! :) O:)

--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list* unless
   private contact is specifically requested and granted.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Лагунов Алексей
Correct - Привет мир!16:44, 9 апреля 2016 г., "wkitt...@windstream.net" :On 04/09/2016 04:30 AM, Ondrej Pokorny wrote: Please don't take it as an offence, there is no. I just first opened the PDF, saw the typo and then I had to check in the source code if it is really a typo or the library picks up the wrong character for the PDF. It is a typo, so everything is OK. It would be still great if you corrected it ;) Correct is "Здравствуйте" (I missed a character in the first email as well :D)interesting in what determines "correct"...Алло мир!Привет мир!Здравствуйте мир!--   NOTE: No off-list assistance is given without prior approval.*Please keep mailing list traffic on the list* unlessprivate contact is specifically requested and granted.-- ___Lazarus mailing listLazarus@lists.lazarus.freepascal.orghttp://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny
I see that the PDF generator doesn't support image compression. This is 
a no-go in my eyes. Is anybody working on that or should I try to study it?


AFAIR SynPDF uses JPEG compression for images.

Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Giuliano Colla

Il 09/04/2016 16:47, Graeme Geldenhuys ha scritto:

On 2016-04-09 14:44, wkitt...@windstream.net wrote:

interesting in what determines "correct"...

Алло мир!
Привет мир!
Здравствуйте мир!


That's my point exactly. I've seen the same thing in fpGUI's translation
files. Many different terms, all apparently meaning the same thing. Some
were considered "old style language" others "modern language usage",
some based on Context.


Given the context, which is to test a PDF generator, and not to find the 
best way to greet the world in Russian :-) , I'd say that Здравствуйте 
мир! is to be preferred, because it has a higher number of characters!

Even better would be Электро́нная вычисли́тельная маши́на, meaning "Computer".

Giuliano*
*

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

On 09.04.2016 10:40, Michael Van Canneyt wrote:

Fixed in rev. 33456.


Thanks :)

Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

On 09.04.2016 15:44, wkitt...@windstream.net wrote:

On 04/09/2016 04:30 AM, Ondrej Pokorny wrote:

Please don't take it as an offence, there is no.
I just first opened the PDF, saw the typo and then I had to check in 
the source
code if it is really a typo or the library picks up the wrong 
character for the

PDF. It is a typo, so everything is OK.
It would be still great if you corrected it ;)
Correct is "Здравствуйте" (I missed a character in the first email as 
well :D)


interesting in what determines "correct"...

Алло мир!
Привет мир!
Здравствуйте мир!


"Correct" as I used it was about a typo in one of the words you 
presented. It wasn't about word choice.


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
On 2016-04-09 14:44, wkitt...@windstream.net wrote:
> interesting in what determines "correct"...
> 
> Алло мир!
> Привет мир!
> Здравствуйте мир!


That's my point exactly. I've seen the same thing in fpGUI's translation
files. Many different terms, all apparently meaning the same thing. Some
were considered "old style language" others "modern language usage",
some based on Context.

I'm no language or translation expert - thank goodness. Trying to teach
my son the rules of the English language and all its "exceptions to the
rule" is enough! :)

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread wkitty42

On 04/09/2016 04:30 AM, Ondrej Pokorny wrote:

Please don't take it as an offence, there is no.
I just first opened the PDF, saw the typo and then I had to check in the source
code if it is really a typo or the library picks up the wrong character for the
PDF. It is a typo, so everything is OK.
It would be still great if you corrected it ;)
Correct is "Здравствуйте" (I missed a character in the first email as well :D)


interesting in what determines "correct"...

Алло мир!
Привет мир!
Здравствуйте мир!


--
 NOTE: No off-list assistance is given without prior approval.
   *Please keep mailing list traffic on the list* unless
   private contact is specifically requested and granted.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Лагунов Алексей
This text on russian:"Привет мир!"12:05, 9 апреля 2016 г., Graeme Geldenhuys :On 2016-04-09 09:19, Ondrej Pokorny wrote: You should learn how to use Google Translate :)I use it a lot. The page you link here shows you  the typo explicitely just below the original text...Okay, but clicking on the second link below the one you are referringto, and you still get "Hello World". I don't know Russian at all, so Ireally don't know if it is correct or not. My point is, I know you get aton of slight variations in language terms (no matter the language) andoften related to context. Such terms often translate to the same Englishterm.Anyway, no offence taken, I'll update the text.[...seconds later...]Ah, I see Michael already fixed it. Thanks M.Regards,  - Graeme --- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascalhttp://fpgui.sourceforge.net/My public PGP key: http://tinyurl.com/graeme-pgp-- ___Lazarus mailing listLazarus@lists.lazarus.freepascal.orghttp://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
Hi,

I'm on my way out, so can't comment on all parts right now.

There is still quite a few improvements that need to be made to fpPDF -
features and  some tweaks to the API.

As for WriteText() versus WriteUTF8Text(). These grew from the fact that
Standard built-in PDF Fonts were implemented first, then TTF. The API
stuck around, but needs improving. There really should be overloaded
WriteText(), then internally the current font should be queried and then
decide which internal text processing methods to call. Standard PDF
Fonts and TTF Fonts have very different text and font info handling.

More accurate API names would have been WriteStdFontText() and
WriteTTFFontText(), but that looks hideous too. ;-)



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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Graeme Geldenhuys
On 2016-04-09 09:19, Ondrej Pokorny wrote:
> You should learn how to use Google Translate :)

I use it a lot.

> The page you link here shows you 
> the typo explicitely just below the original text...

Okay, but clicking on the second link below the one you are referring
to, and you still get "Hello World". I don't know Russian at all, so I
really don't know if it is correct or not. My point is, I know you get a
ton of slight variations in language terms (no matter the language) and
often related to context. Such terms often translate to the same English
term.

Anyway, no offence taken, I'll update the text.

[...seconds later...]

Ah, I see Michael already fixed it. Thanks M.



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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Michael Van Canneyt



On Sat, 9 Apr 2016, Ondrej Pokorny wrote:


Please don't take it as an offence, there is no.
I just first opened the PDF, saw the typo and then I had to check in the 
source code if it is really a typo or the library picks up the wrong 
character for the PDF. It is a typo, so everything is OK.

It would be still great if you corrected it ;)
Correct is "Здравствуйте" (I missed a character in the first email as 
well :D)


Well, I thought so too, but I am not a native Russian speaker, so it is not my 
place
to make comments :-)

Fixed in rev. 33456.

Michael.--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

On 09.04.2016 10:09, Ondrej Pokorny wrote:
4. I cannot make TFPFontCacheItem.TextWidth work. (I was able to make 
"TextWidth" work, though.)


That should read: (I was able to make "*TextHeight*" work, though.)

Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

Please don't take it as an offence, there is no.
I just first opened the PDF, saw the typo and then I had to check in the 
source code if it is really a typo or the library picks up the wrong 
character for the PDF. It is a typo, so everything is OK.

It would be still great if you corrected it ;)
Correct is "Здравствуйте" (I missed a character in the first email as 
well :D)


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

On 08.04.2016 23:34, Graeme Geldenhuys wrote:

On 2016-04-08 19:55, Ondrej Pokorny wrote:

Btw. you have a typo in the Russian "Hello, word". The first word should
be "Здравстуйте".

Not according to Google Translate. :)

[https://translate.google.com/#auto/en/%D0%97%D0%B4%D1%80%D0%B0%D0%B2%D1%81%D1%82%D0%B2%D1%83%D0%BB%D1%82%D0%B5%20%D0%BC%D0%B8%D1%80]


You should learn how to use Google Translate :) The page you link here 
shows you the typo explicitely just below the original text...




Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-09 Thread Ondrej Pokorny

I started testing.

1. Why does TFPFontCacheItem.GetFontData create and load TTFFileInfo 
every time it is called? As a result TTFFileInfo is created and loaded 
every time TextWidth is called - there's no way to go around this. The 
TTFFileInfo should be cached IMO.

Please consider the attached patch.

2. Is gTTFontCache/uFontCacheList really needed? fcl-pdf doesn't use it. 
The user should create such a variable by himself, IMO.


3. WriteText in combination with custom TTF font doesn't print anything. 
There should be an exception when calling WriteText with custom TTF font 
or the call should be redirected to WriteUTF8Text automatically. (See 
demo code below.)


4. I cannot make TFPFontCacheItem.TextWidth work. (I was able to make 
"TextWidth" work, though.) Could you please check the code below to see 
what I am doing wrong? I want to draw a rectangle around text. (I just 
added a procedure to the example project):


procedure TPDFTestApp.TextBox(D: TPDFDocument; APage: integer);
var
  P : TPDFPage;
  FtTitle: integer;
  xFontCache: TFPFontCacheList;
  xFont: TFPFontCacheItem;
  xWidth, xHeight, xDesc: Extended;
const
  cFontSize = 50;
begin
  P := D.Pages[APage];

  FtTitle := D.AddFont('FreeSans.ttf', 'FreeSans', clGreen);

  P.SetFont(FtTitle, cFontSize);
  P.SetColor(clBlack, false);
  P.WriteText(25, 0, 'Sample Text'); // DOESN'T WORK !!!
  P.WriteUTF8Text(25, 20, 'Sample Text');

  xFontCache := TFPFontCacheList.Create;
  try
xFont := TFPFontCacheItem.Create('fonts\FreeSans.ttf');
xFontCache.Add(xFont);
xWidth := xFont.TextWidth('Sample Text', cFontSize) * 25.4 / 72; // 
25.4 / 72 = conversion PDFTomm (?)
xHeight := xFont.GetFontData.CapHeight * cFontSize * xFontCache.DPI 
/ (72 * xFont.GetFontData.Head.UnitsPerEm) * 25.4 / 72;
xDesc := xFont.GetFontData.Descender * cFontSize * xFontCache.DPI / 
(72 * xFont.GetFontData.Head.UnitsPerEm) * 25.4 / 72;

  finally
xFontCache.Free;
  end;

  P.SetColor(clRed, true);
  P.SetColor($37b344, false); // some green color
  P.SetPenStyle(ppsDashDot);
  P.DrawRect(25, 20-xDesc, xWidth, xHeight, 1, False, True);
end;

Ondrej
Index: fpttf.pp
===
--- fpttf.pp(revision 33453)
+++ fpttf.pp(working copy)
@@ -43,11 +43,13 @@
 FFamilyName: String;
 FFileName: String;
 FStyleFlags: LongWord;
+FFileInfo: TTFFileInfo;
 FOwner: TFPFontCacheList; // reference to FontCacheList that owns this 
instance
 functionGetIsBold: boolean;
 functionGetIsFixedWidth: boolean;
 functionGetIsItalic: boolean;
 functionGetIsRegular: boolean;
+procedure   SetFileName(const AFileName: String);
 procedure   SetIsBold(AValue: boolean);
 procedure   SetIsFixedWidth(AValue: boolean);
 procedure   SetIsItalic(AValue: boolean);
@@ -54,11 +56,12 @@
 procedure   SetIsRegular(AValue: boolean);
   public
 constructor Create(const AFilename: String);
-{ Returns the actual TTF font file information. Caller needs to free the 
returned instance. }
+destructor  Destroy; override;
+{ Returns the actual TTF font file information. }
 functionGetFontData: TTFFileInfo;
 { Result is in pixels }
 functionTextWidth(AStr: string; APointSize: single): single;
-propertyFileName: String read FFileName write FFileName;
+propertyFileName: String read FFileName write SetFileName;
 propertyFamilyName: String read FFamilyName write FFamilyName;
 { A bitmasked value describing the full font style }
 propertyStyleFlags: LongWord read FStyleFlags write FStyleFlags;
@@ -147,6 +150,14 @@
   Result := (FStyleFlags and FP_FONT_STYLE_REGULAR) <> 0;
 end;
 
+procedure TFPFontCacheItem.SetFileName(const AFileName: String);
+begin
+  if FFileName = AFileName then Exit;
+  FFileName := AFileName;
+  if FFileInfo<>nil then
+FreeAndNil(FFileInfo);
+end;
+
 procedure TFPFontCacheItem.SetIsBold(AValue: boolean);
 begin
   if AValue then
@@ -192,14 +203,25 @@
   FStyleFlags := FP_FONT_STYLE_REGULAR;
 end;
 
+destructor TFPFontCacheItem.Destroy;
+begin
+  FFileInfo.Free;
+
+  inherited Destroy;
+end;
+
 function TFPFontCacheItem.GetFontData: TTFFileInfo;
 begin
+  if FFileInfo <> nil then
+Exit(FFileInfo);
+
   if FileName = '' then
 raise ETTF.Create(rsNoFontFileName);
   if FileExists(FileName) then
   begin
-Result := TTFFileInfo.Create;
-Result.LoadFromFile(FileName);
+FFileInfo := TTFFileInfo.Create;
+FFileInfo.LoadFromFile(FileName);
+Result := FFileInfo;
   end
   else
 Result := nil;
@@ -262,25 +284,21 @@
 sl.Free;
   {$ENDIF}
 
-  try
-lWidth := 0;
-for i := 1 to Length(AStr) do
-begin
-  c := AStr[i];
-  lGIndex := lFntInfo.GetGlyphIndex(Ord(c));
-  lWidth := lWidth + lFntInfo.GetAdvanceWidth(lGIndex);
-end;
+  lWidth := 0;
+  for i := 1 to Length(AStr) do
+  begin
+c := AStr[i];
+lGIndex := 

Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Graeme Geldenhuys
On 2016-04-08 20:22, Michael W. Vogel wrote:
> (60mm,100mm) Times-BoldItalic: Big text at absolute position
> Languages: English: Hello, World!
> Greek: Γειά σου κόσμος

If you could copy the text out of the displayed PDF, that means I got
the ToUnicode structure correct too. Nice. I forgot to test that one. :)


> As note: If I compile with -Cr, I got a Runerror 201 in unit fpparsettf 
> on line 810.

I made a note of that, thanks.


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Graeme Geldenhuys
On 2016-04-08 19:55, Ondrej Pokorny wrote:
> Btw. you have a typo in the Russian "Hello, word". The first word should 
> be "Здравстуйте".

Not according to Google Translate. :)

[https://translate.google.com/#auto/en/%D0%97%D0%B4%D1%80%D0%B0%D0%B2%D1%81%D1%82%D0%B2%D1%83%D0%BB%D1%82%D0%B5%20%D0%BC%D0%B8%D1%80]

Anyway, I got that text from somewhere on the Internet, and used it for
various Unicode text handling. I never really checked how accurate the
non-English text was.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Ondrej Pokorny

On 08.04.2016 21:29, Graeme Geldenhuys wrote:

On 2016-04-08 20:27, Ondrej Pokorny wrote:

Correct, when I took the font from Lazarus\components\aggpas as Michael
W. Vogel did, everything looks good!

Awesome!

Just curious. What is your Windows locale set at?


Currently Czech (+Windows 10).

Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Graeme Geldenhuys
On 2016-04-08 19:55, Ondrej Pokorny wrote:
> (Still it would be fine to provide links where compatible versions of 
> the fonts can be found.)

Our internal SVN repo had such a file - albeit not 100% complete.

As Michael mentioned, the unit tests will definitely be dependent on the
exact font version. I'll make sure the README file is updated, and try
and improve the unit tests to report more sensible errors (if font
versions don't match).

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Graeme Geldenhuys
On 2016-04-08 20:27, Ondrej Pokorny wrote:
> Correct, when I took the font from Lazarus\components\aggpas as Michael 
> W. Vogel did, everything looks good!

Awesome!

Just curious. What is your Windows locale set at?

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Graeme Geldenhuys
On 2016-04-08 20:13, Michael Van Canneyt wrote:
>> > Some Vietnamese characters and box drawing characters aren't rendered on 
>> > my 
>> > system.
> That probably depends on the font, Graeme will be able to say more about it.

Sjoe, that first PDF got me worried! :-)

It does look like a DejaVu Sans font version mismatch. These open source
font files get updated regularly, and I used the latest I could find.

I'll post the exact font files I have. Size and Version. I'll also
update that README file I mentioned.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Ondrej Pokorny

On 08.04.2016 21:13, Michael Van Canneyt wrote:
Some Vietnamese characters and box drawing characters aren't rendered 
on my system.


That probably depends on the font, Graeme will be able to say more 
about it.


Correct, when I took the font from Lazarus\components\aggpas as Michael 
W. Vogel did, everything looks good!


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Michael W. Vogel

Am 08.04.2016 um 20:22 schrieb Michael Van Canneyt:


Hello,

Graeme has fixed a number of errors that should hopefully solve the 
problems with
codepages;  Changes have been tested on windows/linux/bsd but on 
Windows only

with a system that has an english locale.

These changes have been committed to FPC svn. (rev 33453)

We would appreciate it if someone could test the PDF generating demo 
on a Windows with non-english locale, and report whether the first 
page of

the generated PDF looks OK.

Michael.


I've tested it too. Thank you very much for your work!

I've just copied the font FreeSans.ttf from Lazarus\components\aggpas to 
FPC\packages\fcl-pdf\examples\fonts. It looks fine (Windows 7, 64bit, 
Lazarus 1.7 r52149 FPC 3.1.1 r33453 i386-win32-win32/win64 German locale):


(60mm,100mm) Times-BoldItalic: Big text at absolute position
Languages: English: Hello, World!
Greek: Γειά σου κόσμος
Polish: Witaj świecie
Portuguese: Olá mundo
Russian: Здравствулте мир
Vietnamese: Xin chào thế giới
Box Drawing: ╠ ╣ ╦ ╩ ├ ┤ ┬ ┴
Typography: “What’s wrong?”
£17.99 vs £17·99
€17.99 vs €17·99
OK then… êçèûÎÐð£¢ß
B субботу двадцать третьего мая приезжает твоя любимая теща.


As note: If I compile with -Cr, I got a Runerror 201 in unit fpparsettf 
on line 810.



Kind regards

Michl

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Michael Van Canneyt



On Fri, 8 Apr 2016, Ondrej Pokorny wrote:


On 08.04.2016 20:57, Ondrej Pokorny wrote:

Sorry, I missed the latest revision. I'll update and report back!


I updated and now SetMultiByteConversionCodePage(CP_UTF8) isn't needed. The 
files are exactly the same (=the same byte contents) as before with 
SetMultiByteConversionCodePage(CP_UTF8).


https://drive.google.com/open?id=0Bx-flYubOTroemdJWG5Pb0xCcWc


Good to hear that, this is what we were aiming for :-)



Some Vietnamese characters and box drawing characters aren't rendered on my 
system.


That probably depends on the font, Graeme will be able to say more about it.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Ondrej Pokorny

On 08.04.2016 20:57, Ondrej Pokorny wrote:

Sorry, I missed the latest revision. I'll update and report back!


I updated and now SetMultiByteConversionCodePage(CP_UTF8) isn't needed. 
The files are exactly the same (=the same byte contents) as before with 
SetMultiByteConversionCodePage(CP_UTF8).


https://drive.google.com/open?id=0Bx-flYubOTroemdJWG5Pb0xCcWc

Some Vietnamese characters and box drawing characters aren't rendered on 
my system.





Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Ondrej Pokorny

Sorry, I missed the latest revision. I'll update and report back!

Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Ondrej Pokorny

On 08.04.2016 20:43, Michael Van Canneyt wrote:
The test program to use to generate a PDF, is however 
"examples/testfppdf.lpi"


I should maybe have mentioned that more explicitly.


No problem. Thanks :)
(Still it would be fine to provide links where compatible versions of 
the fonts can be found.)


Here you go. Win 10, Czech locale.
Original file:
https://drive.google.com/open?id=0Bx-flYubOTroenRQcTRTYTQtYVk

If I set SetMultiByteConversionCodePage(CP_UTF8):
https://drive.google.com/open?id=0Bx-flYubOTroemdJWG5Pb0xCcWc

Btw. you have a typo in the Russian "Hello, word". The first word should 
be "Здравстуйте".


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Michael Van Canneyt



On Fri, 8 Apr 2016, Ondrej Pokorny wrote:


On 08.04.2016 20:22, Michael Van Canneyt wrote:
We would appreciate it if someone could test the PDF generating demo on a 
Windows with non-english locale, and report whether the first page of the 
generated PDF looks OK.


I am now testing it. The unittests_console.lpr test fails with:

#0 fpc_raiseexception(0x1a099a4, 0x1, 0x19f6ae0) at 
P:\software\FPC\trunk_src\rtl\inc\except.inc:158
#1 TASSERT__FAIL(0x1a099a4 '"Failed on Numtables" expected: <19> but was: 
<18>', 0x433990, 0x5beea4) at .\fcl-fpcunit\src\fpcunit.pp:564
#2 TASSERT__ASSERTTRUE(0x1a099a4 '"Failed on Numtables" expected: <19> but 
was: <18>', false, 0x433990, 0x5beea4) at .\fcl-fpcunit\src\fpcunit.pp:591
#3 TASSERT__ASSERTEQUALS(0x5c15dc 'Failed on Numtables', 19, 18, 
0x5beea4) at .\fcl-fpcunit\src\fpcunit.pp:675
#4 TTESTLIBERATIONFONT__TESTDIRECTORY_NUMTABLES() at 
fpparsettf_test.pas:421
#5 TTESTCASE__RUNTEST() at 
.\fcl-fpcunit\src\fpcunit.pp:1039
#6 TTESTCASE__RUNBARE() at 
.\fcl-fpcunit\src\fpcunit.pp:1006

#7 PROTECTTEST(0x198ab70, 0x19f9fd8) at .\fcl-fpcunit\src\fpcunit.pp:1453
#8 TTESTRESULT__RUNPROTECTED(0x198ab70, 0x4456e0 , reading variable>) at .\fcl-fpcunit\src\fpcunit.pp:1471
#9 TTESTRESULT__RUN(0x198ab70, ) at 
.\fcl-fpcunit\src\fpcunit.pp:1462
#10 TTESTCASE__RUN(0x19f9fd8, ) at 
.\fcl-fpcunit\src\fpcunit.pp:996
#11 TTESTSUITE__RUNTEST(0x198ab70, 0x19f9fd8, ) at 
.\fcl-fpcunit\src\fpcunit.pp:1318
#12 TTESTSUITE__RUN(0x19f9fd8, ) at 
.\fcl-fpcunit\src\fpcunit.pp:1308
#13 TTESTSUITE__RUNTEST(0x196aa28, 0x19f9fd8, ) at 
.\fcl-fpcunit\src\fpcunit.pp:1318
#14 TTESTSUITE__RUN(0x19f9fd8, ) at 
.\fcl-fpcunit\src\fpcunit.pp:1308
#15 TTESTRUNNER__DOTESTRUN(0x196a6c8, ) at 
.\fcl-fpcunit\src\consoletestrunner.pas:179
#16 TTESTRUNNER__DORUN() at 
.\fcl-fpcunit\src\consoletestrunner.pas:429
#17 TCUSTOMAPPLICATION__RUN() at 
.\fcl-base\src\custapp.pp:343

#18 main at unittests_console.lpr:28

I downloaded all needed fonts. What am I doing wrong?


Probably the version of the font differs from what Graeme is using.
(I also have several errors because of too much font files etc, these are
known)

But those are the unit tests.

The test program to use to generate a PDF, is however "examples/testfppdf.lpi"

I should maybe have mentioned that more explicitly.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator: please test

2016-04-08 Thread Ondrej Pokorny

On 08.04.2016 20:22, Michael Van Canneyt wrote:
We would appreciate it if someone could test the PDF generating demo 
on a Windows with non-english locale, and report whether the first 
page of the generated PDF looks OK.


I am now testing it. The unittests_console.lpr test fails with:

#0 fpc_raiseexception(0x1a099a4, 0x1, 0x19f6ae0) at 
P:\software\FPC\trunk_src\rtl\inc\except.inc:158
#1 TASSERT__FAIL(0x1a099a4 '"Failed on Numtables" expected: <19> but 
was: <18>', 0x433990, 0x5beea4) at .\fcl-fpcunit\src\fpcunit.pp:564
#2 TASSERT__ASSERTTRUE(0x1a099a4 '"Failed on Numtables" expected: <19> 
but was: <18>', false, 0x433990, 0x5beea4) at 
.\fcl-fpcunit\src\fpcunit.pp:591
#3 TASSERT__ASSERTEQUALS(0x5c15dc 'Failed on Numtables', 19, 18, 
0x5beea4) at .\fcl-fpcunit\src\fpcunit.pp:675
#4 TTESTLIBERATIONFONT__TESTDIRECTORY_NUMTABLES(variable>) at fpparsettf_test.pas:421
#5 TTESTCASE__RUNTEST() at 
.\fcl-fpcunit\src\fpcunit.pp:1039
#6 TTESTCASE__RUNBARE() at 
.\fcl-fpcunit\src\fpcunit.pp:1006

#7 PROTECTTEST(0x198ab70, 0x19f9fd8) at .\fcl-fpcunit\src\fpcunit.pp:1453
#8 TTESTRESULT__RUNPROTECTED(0x198ab70, 0x4456e0 , reading variable>) at .\fcl-fpcunit\src\fpcunit.pp:1471
#9 TTESTRESULT__RUN(0x198ab70, ) at 
.\fcl-fpcunit\src\fpcunit.pp:1462
#10 TTESTCASE__RUN(0x19f9fd8, ) at 
.\fcl-fpcunit\src\fpcunit.pp:996
#11 TTESTSUITE__RUNTEST(0x198ab70, 0x19f9fd8, ) 
at .\fcl-fpcunit\src\fpcunit.pp:1318
#12 TTESTSUITE__RUN(0x19f9fd8, ) at 
.\fcl-fpcunit\src\fpcunit.pp:1308
#13 TTESTSUITE__RUNTEST(0x196aa28, 0x19f9fd8, ) 
at .\fcl-fpcunit\src\fpcunit.pp:1318
#14 TTESTSUITE__RUN(0x19f9fd8, ) at 
.\fcl-fpcunit\src\fpcunit.pp:1308
#15 TTESTRUNNER__DOTESTRUN(0x196a6c8, ) at 
.\fcl-fpcunit\src\consoletestrunner.pas:179
#16 TTESTRUNNER__DORUN() at 
.\fcl-fpcunit\src\consoletestrunner.pas:429
#17 TCUSTOMAPPLICATION__RUN() at 
.\fcl-base\src\custapp.pp:343

#18 main at unittests_console.lpr:28

I downloaded all needed fonts. What am I doing wrong?

Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] PDF generator: please test

2016-04-08 Thread Michael Van Canneyt


Hello,

Graeme has fixed a number of errors that should hopefully solve the problems 
with
codepages;  Changes have been tested on windows/linux/bsd but on Windows only
with a system that has an english locale.

These changes have been committed to FPC svn. (rev 33453)

We would appreciate it if someone could test the PDF generating demo 
on a Windows with non-english locale, and report whether the first page of

the generated PDF looks OK.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Sven Barth
Am 07.04.2016 14:58 schrieb "Martin Schreiber" :
>
> On Thursday 07 April 2016 13:49:06 Graeme Geldenhuys wrote:
> > I was about to mention that. This was discussed before, and there was a
> > reason (which eludes me now) why FillChar() will not be changed.
>
> Because out parameters are finalised on caller side:

Ah, yes, that was the subtle point I mentioned :)

Regards,
Sven
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Martin Schreiber
On Thursday 07 April 2016 13:49:06 Graeme Geldenhuys wrote:
> I was about to mention that. This was discussed before, and there was a
> reason (which eludes me now) why FillChar() will not be changed.

Because out parameters are finalised on caller side:

"
Procedure FillChar1(out x;count:SizeInt;Value:Byte);
begin
 fillchar(x,count,value);
end;

procedure tmainfo.exe(const sender: TObject);
type
 testty = record
  a: int32;
  b: string;
 end;
 ptestty = ^testty;
var
 po1: ptestty;
begin
 getmem(po1,sizeof(testty));
 pointer(po1^.b):= pointer(123467); //random value
// fillchar(po1^,sizeof(testty),0); //OK
 fillchar1(po1^,sizeof(testty),0); //crash because out paramters are 
   //finalized on caller side
 po1^.b:= 'abc';
 finalize(po1^);
 freemem(po1);
end;
"

Martin

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Sven Barth
Am 07.04.2016 13:49 schrieb "Graeme Geldenhuys" <
mailingli...@geldenhuys.co.uk>:
>
> On 2016-04-07 12:25, Martok wrote:
> > If Move+FillChar would use out instead of var (as they should - they
don't read
> > the dest value, that's the whole point), that would be fixed once and
for all.
> > But I remember having this discussion before and apparently it was like
this for
> > some compatibility reason...
>
> I was about to mention that. This was discussed before, and there was a
> reason (which eludes me now) why FillChar() will not be changed. And
> that is also when I came up with the FillMem() solution.
>

"out" and "var" behave different in rather subtle points and thus code that
would currently work with FillChar would no longer work then or have subtle
errors.

> If FPC starts nagging about uninitialised pointer parameters (as in the
> usage by FillMem(...) ), then I am afraid there is *no solution* to get
> rid of that compiler hint for FPC 2.6.4.

There is no warning/hint/whatever because a parameter is always assumed to
be initialized (except it's am "out" one).

> I haven't looked at what FPC 3.0's Default() function does yet, but
> maybe FPC could implement a FillMem() exactly like FillChar() but with
> an out parameter instead. So then FillChar() is there for whatever
> backward compatibility, and FillMem() could be used going forward to get
> rid of that compiler hint.  Then again, I probably made this suggestion
> in our previous discussions on this topic. ;-)

Default() essentially creates a variable of the given type and sets it to
zero (there are optimizations for simple types).

Regards,
Sven
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Graeme Geldenhuys
On 2016-04-07 12:25, Martok wrote:
> If Move+FillChar would use out instead of var (as they should - they don't 
> read
> the dest value, that's the whole point), that would be fixed once and for all.
> But I remember having this discussion before and apparently it was like this 
> for
> some compatibility reason...

I was about to mention that. This was discussed before, and there was a
reason (which eludes me now) why FillChar() will not be changed. And
that is also when I came up with the FillMem() solution.

If FPC starts nagging about uninitialised pointer parameters (as in the
usage by FillMem(...) ), then I am afraid there is *no solution* to get
rid of that compiler hint for FPC 2.6.4.

I haven't looked at what FPC 3.0's Default() function does yet, but
maybe FPC could implement a FillMem() exactly like FillChar() but with
an out parameter instead. So then FillChar() is there for whatever
backward compatibility, and FillMem() could be used going forward to get
rid of that compiler hint.  Then again, I probably made this suggestion
in our previous discussions on this topic. ;-)

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Martok
>> You will get the hint here then, no  ?
>
> No.  Seems the compiler is more lenient with pointer types.
That's a bug then, isn't it? After all, it's about the var parameter, not what
is passed into it... The variable that is passed into FillChar is not yet
initialized, but it could be read inside FillChar, which is why the compiler 
nags.

If Move+FillChar would use out instead of var (as they should - they don't read
the dest value, that's the whole point), that would be fixed once and for all.
But I remember having this discussion before and apparently it was like this for
some compatibility reason...

There are a few places in API imports as well where a "_Out_ FOO * pBar" was
imported as "var bar: FOO" but it is actually only used for output, with the
same technically useless hints. But that's getting off-topic, sorry.


Regards,
Martok


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Graeme Geldenhuys
On 2016-04-07 11:37, Michael Van Canneyt wrote:
> You will get the hint here then, no  ?

No.  Seems the compiler is more lenient with pointer types.

Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Michael Van Canneyt



On Thu, 7 Apr 2016, Graeme Geldenhuys wrote:


On 2016-03-31 16:48, silvioprog wrote:

+{$IFDEF VER3}
+  Buffer := Default(TBuffer)
+{$ELSE}
+  FillChar(Buffer,SizeOf(TBuffer),0)
+{$ENDIF};



Just thought I would mention, I've seen the above code listed a few
times now to remove the famous "Local variable does not seem to be
initialized" compiler hint.

Well, it might work on FPC 3.0 (not test), but it does nothing for FPC
2.6.4 - the hint is always there. I know it is a harmless hint, if the
code was correct to start work.

Either way, I found a solution for that, which I used in fpGUI's DocView
help viewer application too.

Implement the following:

procedure FillMem(Dest: pointer; Size: longint; Data: Byte );
begin
 FillChar(Dest^, Size, Data);
end;


You will get the hint here then, no  ?

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Graeme Geldenhuys
On 2016-03-31 16:48, silvioprog wrote:
> +{$IFDEF VER3}
> +  Buffer := Default(TBuffer)
> +{$ELSE}
> +  FillChar(Buffer,SizeOf(TBuffer),0)
> +{$ENDIF};


Just thought I would mention, I've seen the above code listed a few
times now to remove the famous "Local variable does not seem to be
initialized" compiler hint.

Well, it might work on FPC 3.0 (not test), but it does nothing for FPC
2.6.4 - the hint is always there. I know it is a harmless hint, if the
code was correct to start work.

Either way, I found a solution for that, which I used in fpGUI's DocView
help viewer application too.

Implement the following:

procedure FillMem(Dest: pointer; Size: longint; Data: Byte );
begin
  FillChar(Dest^, Size, Data);
end;

Then write your code as follows:

  FillMem(@Buffer, SizeOf(TBuffer), 0);


Now the compiler hint is gone under both FPC 2.6.4 and FPC 3.0 - and no
ugly IFDEF's required.  And as a bonus the name FillMem() is more
descriptive and technically accurate of what the code does than FillChar()


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Graeme Geldenhuys
On 2016-04-07 07:36, Michael Van Canneyt wrote:
> 
> This should not exist to begin with, I think. 
> The UTF8Decode function of the system unit performs the same function.

Indeed, you are correct. I'll make the change.


Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-07 Thread Michael Van Canneyt



On Thu, 7 Apr 2016, Sven Barth wrote:



the SetMultiByteConversionCodePage(CP_UTF8) call makes

DefaultSystemCodePage=CP_UTF8 which matches UTF8String and so in
fpc_ansistr_to_ansistr no conversion is performed.


And so that is why SetMultiByteConversionCodePage(CP_UTF8) is needed when

compiling in windows

:)


UTF8ToUTF16 should best take a UTF8String then. It would fit the purpose of
the function better anyway...


This should not exist to begin with, I think. 
The UTF8Decode function of the system unit performs the same function.


Jesus, thank you for looking into this, we'll get to work with it !

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Sven Barth
Am 07.04.2016 07:43 schrieb "Jesus Reyes A." :
>
> En Wed, 06 Apr 2016 13:14:49 -0500, Michael Van Canneyt <
mich...@freepascal.org> escribió:
>
>>
>>
>> On Wed, 6 Apr 2016, silvioprog wrote:
>>
>>> On Wed, Apr 6, 2016 at 2:14 PM, Michael Van Canneyt <
mich...@freepascal.org>
>>> wrote:
>>> [...]
>>>
 Why is this patch needed ? It should not be needed at all ?

>>>
>>> Sorry, I sent a wrong patch, please consider this new one in attachment.
>>>
>>> My patch just fix wrong chars in the generated PDF, eg, before the apply
>>> it, I got:
>>
>>
>> I see. I don't understand why this patch fixes it for you.
>>
>> Because it means that somewhere a conversion happens that should not
happen.
>>
>
> Here it fixes the problem too. So I did a small investigation and this is
what I found:
>
> The problem starts with this code:
>
> procedure TPDFPage.AddTextToLookupLists(AText: UTF8String);
> var
>   str: UnicodeString;
> begin
>   if AText = '' then
> Exit;
>   str := UTF8ToUTF16(AText);
>   Document.Fonts[FFontIndex].AddTextToMappingList(str);
> end;
>
> AText (a CP_UTF8 tagged string) is passed away to UTF8ToUTF16(AText)
which expects a mere and mundane ansistring (to be used later as a pchar),
the assembler window shows at what point the conversion is attempted:
>
> C:\ThePathTo\fpctrunk\packages\fcl-pdf\src\fppdf.pp:1583  str :=
UTF8ToUTF16(AText);
> 00435974 8b45fc   mov-0x4(%ebp),%eax
> 00435977 8d4dc8   lea-0x38(%ebp),%ecx
> 0043597A 66ba mov$0x0,%dx
> 0043597E e80d3dfdff   call   0x409690 
> 00435983 8b45c8   mov-0x38(%ebp),%eax
> 00435986 8d55f4   lea-0xc(%ebp),%edx
> 00435989 e8a286   call   0x43e030 
>
> fpc_ansistr_to_ansistr converts AText from the given UTF8String to
ansistring via RawbyteString. And it converts it to whatever
DefaultSystemCodePage says it should. Now this is a problem because in
Windows and according to the wiki this value is "The result of the GetACP
OS call, which returns the Windows ANSI code page". In my case, and I guess
Silvio's too, DefaultSystemCodePage=1252 not CP_UTF8, so in our case if
AText is 'Greek: Γειά σου κόσμος' there will be problems converting that to
CodePage=1252 which is solved by showing the "?" in the problematic
characters
>
> the SetMultiByteConversionCodePage(CP_UTF8) call makes
DefaultSystemCodePage=CP_UTF8 which matches UTF8String and so in
fpc_ansistr_to_ansistr no conversion is performed.
>
> And so that is why SetMultiByteConversionCodePage(CP_UTF8) is needed when
compiling in windows
> :)

UTF8ToUTF16 should best take a UTF8String then. It would fit the purpose of
the function better anyway...

Regards,
Sven
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Jesus Reyes A.
En Wed, 06 Apr 2016 13:14:49 -0500, Michael Van Canneyt  
 escribió:





On Wed, 6 Apr 2016, silvioprog wrote:

On Wed, Apr 6, 2016 at 2:14 PM, Michael Van Canneyt  


wrote:
[...]


Why is this patch needed ? It should not be needed at all ?



Sorry, I sent a wrong patch, please consider this new one in attachment.

My patch just fix wrong chars in the generated PDF, eg, before the apply
it, I got:


I see. I don't understand why this patch fixes it for you.

Because it means that somewhere a conversion happens that should not  
happen.




Here it fixes the problem too. So I did a small investigation and this is  
what I found:


The problem starts with this code:

procedure TPDFPage.AddTextToLookupLists(AText: UTF8String);
var
  str: UnicodeString;
begin
  if AText = '' then
Exit;
  str := UTF8ToUTF16(AText);
  Document.Fonts[FFontIndex].AddTextToMappingList(str);
end;

AText (a CP_UTF8 tagged string) is passed away to UTF8ToUTF16(AText) which  
expects a mere and mundane ansistring (to be used later as a pchar), the  
assembler window shows at what point the conversion is attempted:


C:\ThePathTo\fpctrunk\packages\fcl-pdf\src\fppdf.pp:1583  str :=  
UTF8ToUTF16(AText);

00435974 8b45fc   mov-0x4(%ebp),%eax
00435977 8d4dc8   lea-0x38(%ebp),%ecx
0043597A 66ba mov$0x0,%dx
0043597E e80d3dfdff   call   0x409690 
00435983 8b45c8   mov-0x38(%ebp),%eax
00435986 8d55f4   lea-0xc(%ebp),%edx
00435989 e8a286   call   0x43e030 

fpc_ansistr_to_ansistr converts AText from the given UTF8String to  
ansistring via RawbyteString. And it converts it to whatever  
DefaultSystemCodePage says it should. Now this is a problem because in  
Windows and according to the wiki this value is "The result of the GetACP  
OS call, which returns the Windows ANSI code page". In my case, and I  
guess Silvio's too, DefaultSystemCodePage=1252 not CP_UTF8, so in our case  
if AText is 'Greek: Γειά σου κόσμος' there will be problems converting  
that to CodePage=1252 which is solved by showing the "?" in the  
problematic characters


the SetMultiByteConversionCodePage(CP_UTF8) call makes  
DefaultSystemCodePage=CP_UTF8 which matches UTF8String and so in  
fpc_ansistr_to_ansistr no conversion is performed.


And so that is why SetMultiByteConversionCodePage(CP_UTF8) is needed when  
compiling in windows

:)

Jesus Reyes A.



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Jesus Reyes A.
On Wed, 06 Apr 2016 12:23:12 -0500, Graeme Geldenhuys  
 wrote:



On 2016-04-01 20:16, Jesus Reyes A. wrote:
(it seems currently is not necessary because the matrix is  
auto-adjusted)

and then ...

   P.WriteUTF8Text(15, 120, 'Languages: English: Hello, World!');
   P.WriteUTF8Text(40, 130, 'Greek: %1B-FÃåéÜ óïõ êüóìïò');
   P.WriteUTF8Text(40, 140, 'Polish: Witaj %1B-B¶wiecie');
   P.WriteUTF8Text(40, 150, 'Portuguese: Ol%1B-Aá mundo');

Of course, before DoUnitConversion(p1); there should be a
DoMatrixTransform(p1); etc.



This change has been made and will be available in FPC repo shortly.
Incidently, this drastically reduces the amount of application code and
makes it much neater. Something I like. :)


Regards,
  - Graeme -



;)

Thanks.

Jesus Reyes A.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Michael Van Canneyt



On Wed, 6 Apr 2016, silvioprog wrote:


On Wed, Apr 6, 2016 at 2:14 PM, Michael Van Canneyt 
wrote:
[...]


Why is this patch needed ? It should not be needed at all ?



Sorry, I sent a wrong patch, please consider this new one in attachment.

My patch just fix wrong chars in the generated PDF, eg, before the apply
it, I got:


I see. I don't understand why this patch fixes it for you.

Because it means that somewhere a conversion happens that should not happen.


ps. about the hints/warnings, see the compiler log below:

Compile Project, Target: testfppdf.exe: Success, Warnings: 3, Hints: 4
fppdf.pp(1049,28) Hint: Local variable "Buffer" does not seem to be
initialized
fppdf.pp(1028,3) Note: Local variable "I" not used
fppdf.pp(3194,31) Warning: Implicit string type conversion from
"AnsiString" to "WideString"
fppdf.pp(3195,35) Warning: Implicit string type conversion from
"AnsiString" to "WideString"
fppdf.pp(808,44) Hint: Parameter "EmbeddedFontNum" not used
fppdf.pp(808,70) Hint: Parameter "FontDef" not used
fppdf.pp(3308,37) Warning: Implicit string type conversion with potential
data loss from "WideString" to "AnsiString"


Maybe one of these string conversion warnings are the cause of the error.
I suspect the last one, actually, line 3308.

The other ones will be fixed too, of course.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Wed, Apr 6, 2016 at 2:14 PM, Michael Van Canneyt 
wrote:
[...]

> Why is this patch needed ? It should not be needed at all ?
>

Sorry, I sent a wrong patch, please consider this new one in attachment.

My patch just fix wrong chars in the generated PDF, eg, before the apply
it, I got:

...
English: Hello, World!
Greek: Ge?? s?? ??s
Polish: Witaj swiecie
Portuguese: Ol? mundo
...

After apply it:

...
Languages: English: Hello, World!
Greek: Γειά σου κόσμος
Polish: Witaj świecie
Portuguese: Olá mundo
...

I needed to apply it even after update my FPC to rev. 33428.

In each case it will not be applied, since it assumes use of lazarus, and
> that is not acceptable in the FCL.


Indeed.

ps. about the hints/warnings, see the compiler log below:

Compile Project, Target: testfppdf.exe: Success, Warnings: 3, Hints: 4
fppdf.pp(1049,28) Hint: Local variable "Buffer" does not seem to be
initialized
fppdf.pp(1028,3) Note: Local variable "I" not used
fppdf.pp(3194,31) Warning: Implicit string type conversion from
"AnsiString" to "WideString"
fppdf.pp(3195,35) Warning: Implicit string type conversion from
"AnsiString" to "WideString"
fppdf.pp(808,44) Hint: Parameter "EmbeddedFontNum" not used
fppdf.pp(808,70) Hint: Parameter "FontDef" not used
fppdf.pp(3308,37) Warning: Implicit string type conversion with potential
data loss from "WideString" to "AnsiString"

-- 
Silvio Clécio


0001-fix-wrong-chars.patch
Description: Binary data
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Graeme Geldenhuys
On 2016-04-01 02:21, Jesus Reyes A. wrote:
>> >   // Add your custom page as follows
>> >   P := TMyPDFPage.Create(Doc);
>> >   Doc.Pages.Add(P); // global Page Object list
>> >   lSection.AddPage(P); // which Section our page belongs too
>> >
> Yes that would suffice, thanks.


This change has now been made.


Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Graeme Geldenhuys
On 2016-04-06 18:23, Michael Van Canneyt wrote:
> Patch applied. Rev. 33428.

Thanks Michael.

Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Graeme Geldenhuys
On 2016-04-06 18:18, Michael Van Canneyt wrote:
>>> >> procedure CreateTTFCIDSystemInfo(const {%H-}EmbeddedFontNum:
>>> >> integer;{%H-}FontDef: TFontDef);virtual;
>>> >>
>> >
>> > {$HINTS OFF} instead of it?
> No, fix the hint (if possible).
> 

As I "hinted" (excuse the pun) at before, any reference at TFontDef will
be removed soon. It isn't needed any more.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Michael Van Canneyt



On Wed, 6 Apr 2016, Graeme Geldenhuys wrote:


On 2016-04-06 17:57, silvioprog wrote:

This attached patch definitely fixes this error on Windows. :-)


This was already fixed (plus other changes). I simply forgot to send
Michael the email yesterday to update FPC.


Patch applied. Rev. 33428.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Graeme Geldenhuys
On 2016-04-01 20:16, Jesus Reyes A. wrote:
> (it seems currently is not necessary because the matrix is auto-adjusted)  
> and then ...
> 
>P.WriteUTF8Text(15, 120, 'Languages: English: Hello, World!');
>P.WriteUTF8Text(40, 130, 'Greek: -FÃåéÜ óïõ êüóìïò');
>P.WriteUTF8Text(40, 140, 'Polish: Witaj -B¶wiecie');
>P.WriteUTF8Text(40, 150, 'Portuguese: Ol-Aá mundo');
> 
> Of course, before DoUnitConversion(p1); there should be a  
> DoMatrixTransform(p1); etc.


This change has been made and will be available in FPC repo shortly.
Incidently, this drastically reduces the amount of application code and
makes it much neater. Something I like. :)


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Michael Van Canneyt



On Wed, 6 Apr 2016, silvioprog wrote:


On Thu, Mar 31, 2016 at 1:17 PM, Michael Van Canneyt 

Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Graeme Geldenhuys
On 2016-04-06 17:57, silvioprog wrote:
> This attached patch definitely fixes this error on Windows. :-)

This was already fixed (plus other changes). I simply forgot to send
Michael the email yesterday to update FPC.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread Michael Van Canneyt



On Wed, 6 Apr 2016, silvioprog wrote:


On Thu, Mar 31, 2016 at 1:13 PM, Michael Van Canneyt  wrote:

[...]



Greek: Ge?? s?? ??s

Polish: Witaj swiecie
Portuguese: Ol? mundo
Russian:  ???
Vietnamese: Xin ch?o th? gi?i




This attached patch definitely fixes this error on Windows. :-)


Why is this patch needed ? It should not be needed at all ?

In each case it will not be applied, since it assumes use of lazarus, 
and that is not acceptable in the FCL.


Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Wed, Apr 6, 2016 at 1:57 PM, silvioprog  wrote:

> On Thu, Mar 31, 2016 at 1:13 PM, Michael Van Canneyt <
> mich...@freepascal.org> wrote:
>>
>> On Thu, Mar 31, 2016 at 11:18 AM, silvioprog 
>>> wrote:
>>
>> [...]
>
>> Greek: Ge?? s?? ??s
>>> Polish: Witaj swiecie
>>> Portuguese: Ol? mundo
>>> Russian:  ???
>>> Vietnamese: Xin ch?o th? gi?i
>>
>>
> This attached patch definitely fixes this error on Windows. :-)
>

Oops, I forgot the test using the attached patch result:

https://dl.dropboxusercontent.com/u/135304375/test.pdf

It was generated on Windows 7 (using Arial instead of FreeSans).

Thanks for this awesome and promising library!

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Thu, Mar 31, 2016 at 1:13 PM, Michael Van Canneyt  wrote:
>
> On Thu, Mar 31, 2016 at 11:18 AM, silvioprog  wrote:
>
> [...]

> Greek: Ge?? s?? ??s
>> Polish: Witaj swiecie
>> Portuguese: Ol? mundo
>> Russian:  ???
>> Vietnamese: Xin ch?o th? gi?i
>
>
This attached patch definitely fixes this error on Windows. :-)

-- 
Silvio Clécio


0001-fix-wrong-characters.patch
Description: Binary data
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Thu, Mar 31, 2016 at 1:17 PM, Michael Van Canneyt  wrote:
[...]

> Please, don't do {%H-} etc:
>
> procedure CreateTTFCIDSystemInfo(const {%H-}EmbeddedFontNum:
> integer;{%H-}FontDef: TFontDef);virtual;
>

{$HINTS OFF} instead of it?


> Typecasts like this should also not be done:
>
> +FontDef.FDiffs := WideString(lFontDef.Diffs);
> +FontDef.FCharWidth := WideString(lFontDef.CharWidths);
>

Because the FontDef.FCharWidth is a WideString.


> -  Arr.AddIntArray(FontDef.FCharWidth);
> +  Arr.AddIntArray(string(FontDef.FCharWidth));
>

Because Arr.AddIntArray() is AnsiString (string) and FontDef.FCharWidth
WideString.


> We need to investigate why you think this typecast is needed.
>

It just stop hints/warnings from compiler.


> The buffer initialization is good, though.
>
> I will not apply this patch, this needs deeper investigation.


It just remove unused variables and apply some cast fixes.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Thu, Mar 31, 2016 at 1:26 PM, Graeme Geldenhuys <
mailingli...@geldenhuys.co.uk> wrote:
[...]

> On 2016-03-31 17:13, Michael Van Canneyt wrote:
>
> I had a look at your PDF. I did not extract the embedded FreeSans font
> you have embedded, so don't know the font file version, but based on its
> size (264KB) it is a very old FreeSans.ttf file. The one I tested with
> is 1.56MB in size.
>
> If I must, I can extract your embedded FreeSans font to query it further
> and see the version and glyph count it defines.


Hm... I'll try Arial instead of FreeSans.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-06 Thread silvioprog
On Thu, Mar 31, 2016 at 1:13 PM, Michael Van Canneyt  wrote:
[...]

> No, I have one of ~1Mb. But probably logical if the file is not there ?
>
> It's not quite clear what to think of your report ?
>
> For me
>
> "PDF was succefully generated"
>
> does not compute with
>
> "Unable to open file "fonts\FreeSans.ttf".
>
> :-)


Oops, I meant: "PDF was succefully generated but with some issues". :-D

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-02 Thread Graeme Geldenhuys
On 2016-04-01 20:16, Jesus Reyes A. wrote:
>P.WriteUTF8Text(15, 120, 'Languages: English: Hello, World!');
>P.WriteUTF8Text(40, 130, 'Greek: -FÃåéÜ óïõ êüóìïò');
>P.WriteUTF8Text(40, 140, 'Polish: Witaj -B¶wiecie');
>P.WriteUTF8Text(40, 150, 'Portuguese: Ol-Aá mundo');
> 
> Of course, before DoUnitConversion(p1); there should be a  
> DoMatrixTransform(p1); etc.

That does indeed look much better. The origin of the external matrix
usage is quite simple really... Initially there wasn't a matrix, and
coordinates had to be calculated (PDF's origin point is bottom/left of
the page) manually before passed to drawing routines. Introducing Matrix
was the first step in cleaning up the code.

Your recommendation is the next step and already on my todo list. I'll
make the change and adapt the demos. This will affect the fpReport code
too (hence it wasn't done yet), but the changes really aren't that big.
I'll make the change in this coming week.

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-01 Thread Jesus Reyes A.
On Thu, 31 Mar 2016 18:16:18 -0600, Graeme Geldenhuys  
 wrote:


BTW, out of curiosity, in the sample there is code like this:

  lPt1 := P.Matrix.Transform(15, 120);
  P.WriteUTF8Text(lPt1.X, lPt1.Y, 'Languages: English: Hello, World!');

  lPt1 := P.Matrix.Transform(40, 130);
  P.WriteUTF8Text(lPt1.X, lPt1.Y, 'Greek: -FÃåéÜ óïõ êüóìïò');

  lPt1 := P.Matrix.Transform(40, 140);
  P.WriteUTF8Text(lPt1.X, lPt1.Y, 'Polish: Witaj -B¶wiecie');

  lPt1 := P.Matrix.Transform(40, 150);
  P.WriteUTF8Text(lPt1.X, lPt1.Y, 'Portuguese: Ol-Aá mundo');

and then WriteUTF8Text and practically every other drawing function does  
something like this:


  p1.X := X;
  p1.Y := Y;
  DoUnitConversion(p1);

The question is why isn't the transformation matrix "active"?,

I mean the code above would be simply:

  p.SetTransformationMatrix(paramst o adjust the matrix) // or 
  p.Matrix.SetTransformationMatrix(params to adjust the matrix);

(it seems currently is not necessary because the matrix is auto-adjusted)  
and then ...


  P.WriteUTF8Text(15, 120, 'Languages: English: Hello, World!');
  P.WriteUTF8Text(40, 130, 'Greek: -FÃåéÜ óïõ êüóìïò');
  P.WriteUTF8Text(40, 140, 'Polish: Witaj -B¶wiecie');
  P.WriteUTF8Text(40, 150, 'Portuguese: Ol-Aá mundo');

Of course, before DoUnitConversion(p1); there should be a  
DoMatrixTransform(p1); etc.


One thought is that coordinates could be reused and in such case it might  
help but it doesn't seem to be a very strong reason, is interesting to  
know the real reason.


Jesus Reyes A.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-04-01 Thread Michael Van Canneyt



On Fri, 1 Apr 2016, Ondrej Pokorny wrote:


On 31.03.2016 22:58, Michael Van Canneyt wrote:

I suspect this can be easily implemented.

Synopse pdf is the reason I started fppdf. Synopse is heavily Windows
centric, but otherwise quite capable.


Yes, correct. I was who implemented exact drawing to Synopse PDF (i.e. 
rendering to exact rect) because the font sizes on Canvas and PDF were quite 
different. IIRC you compare the actual text width with the wanted text width 
and you scale the text box with a transformation.


Coordinate transformations are explicitly part of the PDF generator design.

I also implemented underline text and did more enhancements, I don't remember 
exactly any more. It was years ago.


Now I stay before a choice to use Synopse PDF (and to have PDF export 
Windows-only) or create a new bindings to fppdf.


Well, obviously I cannot make this choice for you. 
For me there was no choice: my software runs on headless linux servers. 
So maybe you will profit from my lack of choice :-)



Fppdf is a young library (although it required many months of work)
I am sure many improvements will be made as the reporting library develops.

A canvas descendant that renders to pdf is planned, but not very high
priority.

Patches and suggestions are definitely welcome. The library is intended for
production, so quality is important.


I have to take a look at fppdf. I'll need a PDF export in the next months. If 
I decide for fppdf you can be sure that I'll make you busy with sending 
patches :)


No worries there, they will be very welcome :)

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Ondrej Pokorny

On 31.03.2016 22:58, Michael Van Canneyt wrote:

I suspect this can be easily implemented.

Synopse pdf is the reason I started fppdf. Synopse is heavily Windows
centric, but otherwise quite capable.


Yes, correct. I was who implemented exact drawing to Synopse PDF (i.e. 
rendering to exact rect) because the font sizes on Canvas and PDF were 
quite different. IIRC you compare the actual text width with the wanted 
text width and you scale the text box with a transformation.
I also implemented underline text and did more enhancements, I don't 
remember exactly any more. It was years ago.


Now I stay before a choice to use Synopse PDF (and to have PDF export 
Windows-only) or create a new bindings to fppdf.




Fppdf is a young library (although it required many months of work)
I am sure many improvements will be made as the reporting library 
develops.


A canvas descendant that renders to pdf is planned, but not very high
priority.

Patches and suggestions are definitely welcome. The library is 
intended for

production, so quality is important.


I have to take a look at fppdf. I'll need a PDF export in the next 
months. If I decide for fppdf you can be sure that I'll make you busy 
with sending patches :)


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Jesus Reyes A.
En Thu, 31 Mar 2016 18:16:18 -0600, Graeme Geldenhuys  
 escribió:



On 2016-03-31 22:18, Jesus Reyes A. wrote:
TPDFPage has some basic primitives for drawing: lines, rects, ellipses  
and

images. I don't see a way to add our own (except by patches to fpPDF of
course)



  // Add your custom page as follows
  P := TMyPDFPage.Create(Doc);
  Doc.Pages.Add(P); // global Page Object list
  lSection.AddPage(P); // which Section our page belongs too



Yes that would suffice, thanks.

Jesus Reyes A.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Graeme Geldenhuys
On 2016-03-31 22:18, Jesus Reyes A. wrote:
> TPDFPage has some basic primitives for drawing: lines, rects, ellipses and  
> images. I don't see a way to add our own (except by patches to fpPDF of  
> course)


I like the idea of giving developers the ability to extend TPDFPage with
more drawing functions. Good news is, it is quite possible already, with
one minor modifications - TPDFPages needs to surface a Add(APage:
TPDFPage) procedure.

I just made the change locally and managed to add my own drawing
function as follows:

type
  // page class with new custom drawing methods
  TMyPDFPage = class(TPDFPage)
  public
procedure DrawRoundedRect(...);
  end;


  // Add your custom page as follows
  P := TMyPDFPage.Create(Doc);
  Doc.Pages.Add(P); // global Page Object list
  lSection.AddPage(P); // which Section our page belongs too


  // painting our custom page.  P is a TMyPDFPage type.
  P := TMyPDFPage(FDoc.Pages[5]); // get our page reference
  { call a custom draw function from our custom class }
  P.DrawRoundedRect(...);


I'll send the changes to Michael so he can update fcl-pdf.


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Jesus Reyes A.
On Thu, 31 Mar 2016 14:58:07 -0600, Michael Van Canneyt  
 wrote:




Synopse pdf is the reason I started fppdf. Synopse is heavily Windows
centric, but otherwise quite capable.

Fppdf is a young library (although it required many months of work)
I am sure many improvements will be made as the reporting library  
develops.


A canvas descendant that renders to pdf is planned, but not very high
priority.

Patches and suggestions are definitely welcome. The library is intended  
for

production, so quality is important.

Michael.



TPDFPage has some basic primitives for drawing: lines, rects, ellipses and  
images. I don't see a way to add our own (except by patches to fpPDF of  
course) but it would be nice to have some mechanism for extension, for  
example if a TPdfPageClass=class of TPdfClass is defined, then there could  
be a TPdfPages.AddPage overloaded with an extra argument  
PageClass:TPdfPageClass, and this could be used for implementing  
additional primitives? what you hink?


Regards.

Jesus Reyes A.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Michael Van Canneyt



On Thu, 31 Mar 2016, Ondrej Pokorny wrote:


On 31.03.2016 20:39, Michael Van Canneyt wrote:

On Thu, 31 Mar 2016, Ondrej Pokorny wrote:

A quick question (sorry I haven't tested): is word breaking supported and 
is it possible to get the target rect of multiline and singleline text?


It is possible to get a target rect of a single line; unit fpttf:

function TextWidth(AStr: string; APointSize: single): single;

Word breaking is left to the calling application.
A reporting tool is in the make (well, made, but not released yet)
which will handle this.


Great, thank you!

And is it possible the other way round? I.e. I know the target rect and I 
have to export a single line exactly into that rect? (The text has to be 
scaled to fill the rect.)


I suspect this can be easily implemented.



Why I ask: I need to print my PDFs directly from a Lazarus application. I 
have to render the page on a canvas (monitor for preview, printer for 
printing) and create a PDF from the same source. All three targets (monitor, 
printer, PDF) have to be exactly equal.
I achieved this in Delphi with Synopse PDF. Now I'd like to port my reporting 
solution to Lazarus.



Synopse pdf is the reason I started fppdf. Synopse is heavily Windows
centric, but otherwise quite capable.

Fppdf is a young library (although it required many months of work)
I am sure many improvements will be made as the reporting library develops.

A canvas descendant that renders to pdf is planned, but not very high
priority.

Patches and suggestions are definitely welcome. The library is intended for
production, so quality is important.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Ondrej Pokorny

On 31.03.2016 20:39, Michael Van Canneyt wrote:

On Thu, 31 Mar 2016, Ondrej Pokorny wrote:

A quick question (sorry I haven't tested): is word breaking supported 
and is it possible to get the target rect of multiline and singleline 
text?


It is possible to get a target rect of a single line; unit fpttf:

function TextWidth(AStr: string; APointSize: single): single;

Word breaking is left to the calling application.
A reporting tool is in the make (well, made, but not released yet)
which will handle this.


Great, thank you!

And is it possible the other way round? I.e. I know the target rect and 
I have to export a single line exactly into that rect? (The text has to 
be scaled to fill the rect.)


Why I ask: I need to print my PDFs directly from a Lazarus application. 
I have to render the page on a canvas (monitor for preview, printer for 
printing) and create a PDF from the same source. All three targets 
(monitor, printer, PDF) have to be exactly equal.
I achieved this in Delphi with Synopse PDF. Now I'd like to port my 
reporting solution to Lazarus.


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Michael Van Canneyt



On Thu, 31 Mar 2016, Ondrej Pokorny wrote:

A quick question (sorry I haven't tested): is word breaking supported and is 
it possible to get the target rect of multiline and singleline text?


It is possible to get a target rect of a single line; unit fpttf:

function TextWidth(AStr: string; APointSize: single): single;

Word breaking is left to the calling application.
A reporting tool is in the make (well, made, but not released yet)
which will handle this.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Ondrej Pokorny
A quick question (sorry I haven't tested): is word breaking supported 
and is it possible to get the target rect of multiline and singleline text?


Ondrej

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Graeme Geldenhuys
On 2016-03-31 17:17, Michael Van Canneyt wrote:
> -  Arr.AddIntArray(FontDef.FCharWidth);
> +  Arr.AddIntArray(string(FontDef.FCharWidth));
> 
> We need to investigate why you think this typecast is needed.


Plus the fact that I haven't complete all the code clean-up yet. As far
as I can see all the TFontDef related code is legacy - related to when
the pdf code still used *.fnt files, instead of querying *.ttf files
directly. What does depend on the TFontDef structure can easily be
replaced by finding the info directly from the TTF file.

The TTextDictionary class can be removed as well. That has been replaced
by TTextMappingList & TTextMapping classes.


As you might know [Michael], my last concern was compiler hints. ;-)


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Graeme Geldenhuys
On 2016-03-31 17:13, Michael Van Canneyt wrote:
>> I have some observations:
>>
>> . The demo print a lot of lines if the font is not found:
>>
>> Exception at 0041F4B7: EFOpenError:
>> Unable to open file "fonts\FreeSans.ttf".


I believe the loop is caused by the usage of TCustomApplication (the
previous test app didn't use TCustomApplication).

And yes, the demo requires that TTF file otherwise the text output will
not work.

>> . The PDF was generated with some wrong chars (you can download it here:
>> https://dl.dropboxusercontent.com/u/135304375/test.pdf):
> 
> That is logical, if it cannot find the file which it tries to embed ??

I had a look at your PDF. I did not extract the embedded FreeSans font
you have embedded, so don't know the font file version, but based on its
size (264KB) it is a very old FreeSans.ttf file. The one I tested with
is 1.56MB in size.

If I must, I can extract your embedded FreeSans font to query it further
and see the version and glyph count it defines.

>> Greek: Ge?? s?? ??s
>> Polish: Witaj swiecie

This tells me your version of FreeSans.ttf doesn't have all the glyphs
the demo uses.


> "PDF was succefully generated"
> 
> does not compute with
> 
> "Unable to open file "fonts\FreeSans.ttf".

Indeed. :)


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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Michael Van Canneyt



On Thu, 31 Mar 2016, silvioprog wrote:


On Thu, Mar 31, 2016 at 11:18 AM, silvioprog  wrote:


On Thu, Mar 31, 2016 at 11:02 AM, Michael Van Canneyt <
mich...@freepascal.org> wrote:


Hello

In revision 33401 of FPC subversion, a lot of fixes have been committed
for Font
handling in the PDF generator: e.g. Unicode fonts should now render
correctly.


[...]

Great news! :-)

I'm going to re-test it ...



Finally the PDF was succefully generated on Windows! \o/

I have some observations:

. The demo print a lot of lines if the font is not found:

Exception at 0041F4B7: EFOpenError:
Unable to open file "fonts\FreeSans.ttf".
Exception at 0041F4B7: EFOpenError:
Unable to open file "fonts\FreeSans.ttf".
Exception at 0041F4B7: EFOpenError:
Unable to open file "fonts\FreeSans.ttf".
Exception at 0041F4B7: EFOpenError:
Unable to open file "fonts\FreeSans.ttf".
... infinitely ...

. The PDF was generated with some wrong chars (you can download it here:
https://dl.dropboxusercontent.com/u/135304375/test.pdf):


That is logical, if it cannot find the file which it tries to embed ??



Greek: Ge?? s?? ??s
Polish: Witaj swiecie
Portuguese: Ol? mundo
Russian:  ???
Vietnamese: Xin ch?o th? gi?i

In the previous fppdf version, the PDF was generated about ~650KB, after
update it I get a PDF ~381KB. Is it OK?


No, I have one of ~1Mb. But probably logical if the file is not there ?

It's not quite clear what to think of your report ?

For me

"PDF was succefully generated"

does not compute with

"Unable to open file "fonts\FreeSans.ttf".

:-)


Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread Michael Van Canneyt



On Thu, 31 Mar 2016, silvioprog wrote:


On Thu, Mar 31, 2016 at 12:45 PM, silvioprog  wrote:


On Thu, Mar 31, 2016 at 11:18 AM, silvioprog  wrote:


On Thu, Mar 31, 2016 at 11:02 AM, Michael Van Canneyt <
mich...@freepascal.org> wrote:


Hello

In revision 33401 of FPC subversion, a lot of fixes have been committed
for Font
handling in the PDF generator: e.g. Unicode fonts should now render
correctly.


[...]

Great news! :-)

I'm going to re-test it ...



Finally the PDF was succefully generated on Windows! \o/



The attached patch remove some compile hints/warnings.


Please, don't do {%H-} etc:

procedure CreateTTFCIDSystemInfo(const {%H-}EmbeddedFontNum: 
integer;{%H-}FontDef: TFontDef);virtual;

Typecasts like this should also not be done:

+FontDef.FDiffs := WideString(lFontDef.Diffs);
+FontDef.FCharWidth := WideString(lFontDef.CharWidths);

-  Arr.AddIntArray(FontDef.FCharWidth);
+  Arr.AddIntArray(string(FontDef.FCharWidth));

We need to investigate why you think this typecast is needed.

The buffer initialization is good, though.

I will not apply this patch, this needs deeper investigation.

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] PDF generator, try 2

2016-03-31 Thread silvioprog
On Thu, Mar 31, 2016 at 12:45 PM, silvioprog  wrote:

> On Thu, Mar 31, 2016 at 11:18 AM, silvioprog  wrote:
>
>> On Thu, Mar 31, 2016 at 11:02 AM, Michael Van Canneyt <
>> mich...@freepascal.org> wrote:
>>>
>>> Hello
>>>
>>> In revision 33401 of FPC subversion, a lot of fixes have been committed
>>> for Font
>>> handling in the PDF generator: e.g. Unicode fonts should now render
>>> correctly.
>>
>> [...]
>>
>> Great news! :-)
>>
>> I'm going to re-test it ...
>>
>
> Finally the PDF was succefully generated on Windows! \o/
>

The attached patch remove some compile hints/warnings.

-- 
Silvio Clécio


0001-Remove-hints-warnings.patch
Description: Binary data
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


  1   2   >