Fixed code to convert between pixels and units

The code to convert between pixels and units was missing the information
about which window to get font information from, which caused crashes.