TPostScriptPrinterCanvas lazarus / 31-LCL ---------------------------------------------------------------------- timppl · 2012-12-06 11:39 Hi all Laz version svn 39445M , fpc version 2.7.1 on Mandriva Linux 2001 I am trying to implement the textRect function in the TPostScriptPrinterCanvas. I dont know if my approach is correct: I copied the TextRect code from TCanvas and am trying to modify it to suit. Note that TPostScriptPrinterCanvas uses a dummy handle ( ie Handle := 1 ); I have tried the following: Using the default DC for TPostScriptPrinterCanvas, I get a segmentation fault in TGtk2WidgetSet.SetBkMode in gtk2winapi.inc with the code Code: [Select]  Result := DevCtx.BkMode; Debugger tells me that this is because DevCtx is at address 0xd9. This seems reasonable because it has no valid handle, so I then tried getting a valid handle and using that. Code: [Select]DC := CreateCompatibleDC( Self.Handle ); BMHandle := CreateCompatibleBitmap( DC,Self.Width,Self.Height ); SelectObject ( DC, BMHandle ); This seems to satisfy the SetBkMode, but  then DrawText is called and now a segmentation fault is produced in  gtk2/gtk2winapi.inc at line 2558: Code: [Select]    Result := (TGtkDeviceContext(DC).CurrentFont^.LogFont.lfOrientation <> 0) and Here the debugger tells me that CurrentFont is nil. So I have now got stuck.  I suspect that the DC is not correct but I do not know where to go from here. Has anyone got any comments , pointers or advice ( preferably good  ) Regards Tim ---------------------------------------------------------------------- jesusr · 2012-12-06 20:14 There is simply no DeviceContext in PostscriptPrinterCanvas all graphic operations should "emit" or "translate to" the corresponding postscript code ---------------------------------------------------------------------- timppl · 2012-12-07 06:22 Thanks. I was starting to come to that conclusion. I will do it all within the unit. Regards Tim