blf.dimensions incorrect on Darwin builds
Closed, InvalidPublic

Description

We have created a help text box in python that draws text to 3D viewport when our tools run modal. This help box automatically wraps the text if it is too wide to fit in the space given. Our line breaking code uses blf.dimensions(0,text)[0] to determine the width of the text.

On Linux and Windows machines, this works as expected, but on OSX machine it is off by factor of ~1.2. For example, blf.dimensions(0,text)[0] gives 155.4 on OSX and 186.0 on Linux when text = 'Contours Help (click to hide help):'. Note: it should report 186.0 for both machines.

We have seen this issue since at least Jan 12, but thought it was a bug in our code. We are using the default font at size = 12 with DPI = context.user_preferences.system.dpi, which is 72 on all our test machines (Linux, Windows, OSX).

Details

Type
Bug
Jon Denning (gfxcoder) updated the task description. (Show Details)
Jon Denning (gfxcoder) raised the priority of this task from to Needs Triage.
Jon Denning (gfxcoder) added a project: Python.
Jon Denning (gfxcoder) set Type to Bug.

What are the steps to reproduce this problem, just running this in the python console?

import blf; blf.size(0, 12, 72); blf.dimensions(0, 'Contours Help (click to hide help):')[0]

Does the OS X machine have a retina display? I would expect a 2x factor for that though, not 1.2x.

Are you testing with factory settings on both platforms?

Running import blf; blf.size(0, 12, 72); blf.dimensions(0, 'Contours Help (click to hide help):')[0] gives:

Linux: 186.046875
OSX: ~155.4
Windows: ~186.047

The OSX machine does not have a retina display. Factory settings for Linux and Windows. Fairly certain OSX has factory settings (not my machine), but I'll double-check on this.

Bastien Montagne (mont29) triaged this task as Incomplete priority.Oct 5 2015, 8:13 AM

Testing with Blender 2.75 and 2.76 RC3 on OS X 10.11, I'm seeing 186.046875, both when running Blender in retina and low resolution.

I would expect there's something in the user preferences influencing this. So testing with File > Load Factory Settings would be good to confirm if that's the case. Perhaps something under Themes > Text Style, or a custom interface font under System.

It would seem it is indeed something with my user preferences.

Running with factory settings I get 186.046875 as well.

So, we need to figure out what exactly is causing this. An addon, theme setting, something else? If you can't find it, could you attach your userpref.blend?

Bastien Montagne (mont29) claimed this task.

No news since one week…