Refactor title calculation in drawing