G'day all,

I've just hit a nasty one on Carbon.

I have a custom .ttf installed on my system. It was copied from a Windows 
system and it's apparently 
broken (though it works on Gtk/Gtk2 and Windows). I can fix the font by loading 
it into fontforge 
and re-building it. No problem.

The problem is when the font is selected for the TSynEdit component it crashes 
with a divide by zero 
error. (The font charheight registers as zero).

The obvious solution is not to use a broken font, but something tells me we 
should perhaps check the 
charheight when we set fTextHeight in synedit.pp and ensure it is never set to 
zero.

I've tested this under Wine, WindowsXP and gtk2 and it does not appear as a 
problem. Only on OSX 
Carbon (Intel or PPC). I guess it's something to do with the way the .ttf is 
built and OSX font 
rendering system.

I've worked around it by creating a synedit, assigning it this font name and 
measuring the 
lineheight. If it's less than 2 then I select another font prior to any paint 
events.

Any ideas on the correct way to prevent this from occurring ?

For interest, here is the backtrace that explodes.

CarbonFontIDToFontName Error: ATSUFindFontName Length failed with result -8905
CarbonFontIDToFontName Error: ATSUFindFontName Length failed with result -8905
CarbonFontIDToFontName Error: ATSUFindFontName Length failed with result -8905
TCarbonWindow.SetScrollInfo TODO
TCarbonWindow.SetScrollInfo TODO
TApplication.HandleException Division by zero
   Stack trace:
   $00152213  TCUSTOMSYNEDIT__PAINT,  line 2840 of synedit.pp
   $000AD4F7  TCUSTOMCONTROL__PAINTWINDOW,  line 127 of 
./include/customcontrol.inc
   $0009D3E6  TWINCONTROL__PAINTHANDLER,  line 4239 of ./include/wincontrol.inc
   $000A08ED  TWINCONTROL__WMPAINT,  line 6044 of ./include/wincontrol.inc
   $000AD442  TCUSTOMCONTROL__WMPAINT,  line 107 of ./include/customcontrol.inc
   $0000A719  TOBJECT__DISPATCH,  line 459 of 
/home/brad/devel/fpc/svn/fixes/fpc/rtl/inc/objpas.inc
   $0009E384  TWINCONTROL__WNDPROC,  line 4749 of ./include/wincontrol.inc
   $0015B9DE  TCUSTOMSYNEDIT__WNDPROC,  line 7008 of synedit.pp
   $0011EF61  DELIVERMESSAGE,  line 103 of lclmessageglue.pas
   $0011F25C  LCLSENDPAINTMSG,  line 830 of lclmessageglue.pas
   $00133077  CARBONCOMMON_DRAW,  line 73 of carbonprivatecommon.inc
   $95F26303
   $95F2573D
   $95F255A2
   $95F48FC5
   $95F48AB2
   $95F48C16
TApplication.HandleException: there was another exception during showing the 
first exception
   Stack trace:
   $00152213  TCUSTOMSYNEDIT__PAINT,  line 2840 of synedit.pp
   $000AD4F7  TCUSTOMCONTROL__PAINTWINDOW,  line 127 of 
./include/customcontrol.inc
   $0009D3E6  TWINCONTROL__PAINTHANDLER,  line 4239 of ./include/wincontrol.inc
   $000A08ED  TWINCONTROL__WMPAINT,  line 6044 of ./include/wincontrol.inc
   $000AD442  TCUSTOMCONTROL__WMPAINT,  line 107 of ./include/customcontrol.inc
   $0000A719  TOBJECT__DISPATCH,  line 459 of 
/home/brad/devel/fpc/svn/fixes/fpc/rtl/inc/objpas.inc
   $0009E384  TWINCONTROL__WNDPROC,  line 4749 of ./include/wincontrol.inc
   $0015B9DE  TCUSTOMSYNEDIT__WNDPROC,  line 7008 of synedit.pp
   $0011EF61  DELIVERMESSAGE,  line 103 of lclmessageglue.pas
   $0011F25C  LCLSENDPAINTMSG,  line 830 of lclmessageglue.pas
   $00133077  CARBONCOMMON_DRAW,  line 73 of carbonprivatecommon.inc
   $95F26303
   $95F2573D
   $95F255A2
   $95F48FC5
   $95F48AB2
   $95F48C16

Regards,
Brad
-- 
Dolphins are so intelligent that within a few weeks they can
train Americans to stand at the edge of the pool and throw them
fish.
_______________________________________________
Lazarus mailing list
[email protected]
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to