Fix bug in character measurement

Issue #1617