Which magic numbers?  The 0.5 above in lines 636-637?  This is just trying to place the accidental bbox's relative to the staff, since they are relative to the individual notes themselves.  Using bbox's make the code less dependent on the specific font.  Now, the overlap and undercut amounts below where you've quoted - those are indeed somewhat font-specific.  They should be good for any font that has a "normal" size & shape for accidentals.  Getting this kind of info from font metrics somewhow would be preferable, but I don't know if that's possible.  Is it?