[fpc-pascal] How does TFPImageCanvas draw TextOut?

David Emerson dle3ab at angelbase.com
Sun Mar 1 02:04:17 CET 2009


I've started with the fontdraw example at the bottom of 
http://wiki.freepascal.org/Developing_with_Graphics

Somewhere in the middle, there's a call to ImgCanvas.TextOut, which 
seems to work just fine -- the png file has the text, and if I create a 
cracker class I can call TFPImageCanvasCracker.GetColor and find where 
the text has been drawn, without the writer, memory stream, or file 
stream. I don't understand how it works, though.


In the fontdraw program,
  var ImgCanvas: TFPImageCanvas;

In unit fpimgcanv,
  type TFPImageCanvas = class (TFPPixelCanvas)
but it doesn't have a TextOut method.

In unit fppixlcanv,
  type TFPPixelCanvas = class (TFPCustomCanvas)
and it doesn't have a TextOut method, either.

and in unit fpcanvas,
  type TFPCustomCanvas = class(TPersistent)
    public procedure TextOut (x,y:integer;text:string);

Okay, so I see that in the fontdraw example program, ImgCanvas inherits 
TextOut from TFPCustomCanvas; and it's not overridden in TFPPixelCanvas 
or TFPImageCanvas.

TFPCustomCanvas.TextOut simply calls DoTextOut, however 
TFPCustomCanvas.DoTextOut is virtual; abstract;

In TFPPixelCanvas, I see protected procedure DoTextOut 
(x,y:integer;text:string); override;

However, the procedure only makes a call to "NotImplemented;"

And TFPImageCanvas does not override DoTextOut, either.

So what on earth is going on here? I don't see any place where a 
procedure is being called that actually draws the text.

I do see that in ftfont, a DrawText procedure exists -- and it seems 
pretty clear that that's the procedure that's actually drawing the 
text. But how is it being called?

Puzzled,
~David.




More information about the fpc-pascal mailing list