[Lazarus] fpPDF: set clip rect for text

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Wed Apr 13 19:00:39 CEST 2016


On 2016-04-13 17:36, Ondrej Pokorny wrote:
> 
> I have no idea about graphics state :)

PDF does it all for you really. The idea is that you ask PDF to save the
current graphics state, apply your clip region, do your drawing or text
output, then ask PDF to restore the graphics state (thus remove your
clip region). Trick is just to know where to use the "q" and "Q"
PDF commands.


> Clipping and multi-line text are probably the last 2 features I miss.

So we are getting there. ;-)


> IMO multi-line text support should be added into TFPFontCacheItem. 
> Something like:

My only problem with that, and why TextHeight() and TextWidth() is not
yet in fpTTF.pas unit, is the 14 PDF built-in fonts. The fontcache might
not have actual TTF files for say Helvetica, Times-Roman etc, but you
are still allowed to use those in your PDF.

In fpReport I had to generate metric equivalent data (stored in an
include file) for all 14 PDF built-in fonts. So TextHeight() and
TextWidth() needs to first query if the font in question is a Std PDF
Font or not, then it knows to go to the fontcache or to the lookup
tables for glyph metric information.

I still need to figure out how to get this cleanly into fpTTF.pas. Part
of it (eg: is the font a Std PDF built-in or not) can possibly go into
fpPDF, the rest needs to go into fpTTF.pas.  But then my other issue
with that is that then fpTTF will depend on fpPDF and vice versa. I want
to keep dependencies to a minimum. Hence my struggle. :)


> Do you have some function like this in fpReport? Could it be extracted 
> from fpReport into fpTTF? Or should I create one for myself?

There is similar functionality in fpReport. I'll see if we can move some
of that to 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




More information about the Lazarus mailing list