More hacks in character measurement to fix cursor at zero-width widget

Issue #1617