Used C++ static_cast in favor of C-style cast
Refactored text geometry update into a single function