Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

character/message size bug in macOS 10.15.4 and Pd 0.50-2 #988

Closed
porres opened this issue May 6, 2020 · 55 comments
Closed

character/message size bug in macOS 10.15.4 and Pd 0.50-2 #988

porres opened this issue May 6, 2020 · 55 comments
Labels
bug/fix either a bug (for issues) or a bugfix (for pull-requests)

Comments

@porres
Copy link
Contributor

porres commented May 6, 2020

This is a very annoying bug I'm facing now that I upgraded to Catalina.

Using Pd has become a painful task when dealing with comments that have lots of characters, and the same deal with messages or object boxes because the text is smaller!

I hope it's clear from the screen shot that, for instance, the end bar of the comment is a bit far from the actual end of the comment. This is less noticeable if the comment has less characters, so it depends on the number of characters and the difference is larger wit more characters.

This also changes the size of messages and object boxes.

Because of this, when trying to select a text from a message, comment or object, you can easily miss it and grab a couple of characters away from what you wanted. Also, if you're trying to shorten the size of comments/objects/messages by resizing the boxes, the text gets broken in separate lines before you'd expect visually.

Enough said, here's a screenshot.

Screen Shot 2020-05-06 at 20 24 40

Now let's check a screenshot from another computer I have (also with Pd 0.50-2) with an older system (10.10) but I'm sure things were alright in the same computer with (10.14).

Screen Shot 2020-05-06 at 20 25 22

We can see that the sliders and messages are of the same sizes but the text fits better. This is because in the first image, what we have is that the characters are displayed smaller than they should.

EDIT: This is still happening with the latest version from this repository - 285c53f - ping @danomatika

test patch: test.pd.zip

@danomatika
Copy link
Contributor

It's most likely the font sizing returned by TK on macOS 10.15.

(I'm getting really tired of these small TK issues. where Tk doesn't seem to keep up with mac development very well.)

@danomatika
Copy link
Contributor

In pd-gui.tcl, find the fit_font_into_metrics proc and uncomment the for loops which print the measured metrics. In the Pd macOS .app bundle, this file is in Contents/Resources/tcl. Run the app on both systems and copy/paste the metrics info here.

@porres
Copy link
Contributor Author

porres commented May 7, 2020

This if for the mac running Catalina:

::tk::mac::OpenApplication ++++++++++++
Connection from 'pd' to 'pd-gui' on 127.0.0.1:65091
Tk 8.5.19
Detected font: DejaVu Sans Mono
Using font: DejaVu Sans Mono normal
Measured font metrics:
8 5 9
9 6 10
11 7 13
16 10 19
23 14 26
36 22 41
Measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

@porres
Copy link
Contributor Author

porres commented May 7, 2020

YOSEMITE:

Tk 8.5.19
Detected font: DejaVu Sans Mono
Using font: DejaVu Sans Mono normal
Measured font metrics:
9 5 10
10 6 11
12 7 14
16 10 19
23 14 26
36 22 41
Measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

@porres
Copy link
Contributor Author

porres commented May 7, 2020

We can see how when in zoom the font metrics are the same! Also, larger fonts seem to measure the same as well... I tested here the same patch with zoom (which had font size of "12") and it does look the same.

Catalina:
Screen Shot 2020-05-07 at 09 52 37

Yosemite:
Screen Shot 2020-05-07 at 09 53 32

@danomatika
Copy link
Contributor

danomatika commented May 7, 2020

Yes, the metrics are close enough for this probably not to be the source of the problem.

EDIT: Clarify with "probably."

@porres
Copy link
Contributor Author

porres commented May 7, 2020

the metrics are close enough for this not to be the source of the problem.

hmm, did not expect that. Because when the values are the same, the problem doesn't appear, how is this not related?

@danomatika
Copy link
Contributor

Well, it's a 1 pixel horizontal difference at the most which means the the letters should be spaced 1 pixel wider apart between the versions.

@danomatika
Copy link
Contributor

Is the space at the end of object boxes on macOS 10.15 wider when there are more words & characters in the box?

@porres
Copy link
Contributor Author

porres commented May 7, 2020

Is the space at the end of object boxes on macOS 10.15 wider when there are more words & characters in the box?

Yup, as I described in the first comment ;)

@porres
Copy link
Contributor Author

porres commented May 7, 2020

that's also why I used long sentences in the examples

@danomatika
Copy link
Contributor

Ok, the it is the metrics in so far as the extra pixels are added to the object box width, even though the rendered font is actually the same size, horizontally. We've run into this before, @umlaeute do you remember the solution?

@umlaeute
Copy link
Contributor

umlaeute commented May 7, 2020

unfortunately no (i don't remember anything; i think there's a cronjob that regularily purges all occurences of font metrics from my memory... i don't know how to do it otherwise)

(or, what i remember is a completely different situation, where the last character would be eaten and somesuch; that's luckily unrelated to the problem at hand ;-))

@porres
Copy link
Contributor Author

porres commented May 7, 2020

the extra pixels are added to the object box width

and also in the message box and comment.

hmm, the thing now is that I tried with font size 16, which seem to be equal for both systems (if I got things correctly: 16 10 19?), but they still look different. Catalina adds spaces for bot zoomed and not zoomed!

And funny enough, when in Yosemite, using font 16, when I zoomed, I got the same "bad" issue... it looked the same as bad as catalina... where a space has been added

@dizzybanjo
Copy link

dizzybanjo commented Aug 11, 2020

Just adding that Im having a really annoying time with this bug on Catalina also.
I found that setting to 12 does help fix the spacing and the selection problems, but that would be very disruptive to retrospectively do to big projects which have lots of patches laid out to be readable at size 10 :(
So im trying not to do that hoping there will be a fix soon

btw its still occuring in 0.51.0 and I'm on MacOS 10.15.6

@porres
Copy link
Contributor Author

porres commented Aug 11, 2020

I remember having issues with font 12...

@danomatika
Copy link
Contributor

danomatika commented Aug 11, 2020

Does this build have the same problem on 10.15? http://docs.danomatika.com/pdbuilds/0.51/Pd-0.51-0-tk8610.zip

@dizzybanjo
Copy link

Screenshot 2020-08-12 at 14 10 17

Hey @danomatika I get this message trying to open that build

@dizzybanjo
Copy link

This still occurs on 0.51.1

@dizzybanjo
Copy link

Great! In Pd 0.51.3test1 this seems partially resolved on Catalina.

New patches created have font size 12 and the shape of the box is correct ( no extra space at the end ). Additionally highlights appear correct and the cursor is in the right place in text. If I change font size for this new patch, that behaviour continues.

However, if I open patches created before this issue which, afaik, defaulted to font size 10. They still have a space on the end of each object. The highlight and cursor works which is a big improvement. Users could do a work around to manually change the font size of previous patches from 10 to 12 , however this means layout issues / object overlap will occur sometimes, so isn't ideal really. It would also take a lot of fiddling about for migrating complex multi abstraction patches.

@danomatika
Copy link
Contributor

And what if you change the font size to 10?

@dizzybanjo
Copy link

hmm ok testing more I can see the gap issue is still present with new patches

Screenshot 2020-10-16 at 13 09 41

Screenshot 2020-10-16 at 13 10 44

@dizzybanjo
Copy link

additionally the text cursor appears in the correct place when you click at the start of a message text in edit mode, but in the wrong place when you click towards the end

@dizzybanjo
Copy link

Here is a screen recording of the cursor and highlighting behaviour . Starts with 12 then 10

Screen Recording 2020-10-16 at 13.14.58.mov.zip

@danomatika
Copy link
Contributor

To reiterate, the font metrics probably need to be tweaked to better match what Tk 8.6 is giving us and/or it's a possible bug with how Tk and Cocoa report the character / string widths.

Further: I probably won't be looking at this any time soon, in case people are waiting on me.

@dizzybanjo
Copy link

ok cool, thanks for working on it so far @danomatika

This is definitely an improvement on the previous situation

@danomatika
Copy link
Contributor

@dizzybanjo Can you post the font metrics for the Pd versions you are trying? Instructions are in my previous post.

@danomatika
Copy link
Contributor

danomatika commented Oct 18, 2020

On macOS 10.14, I'm not seeing this problem and it's probably because the font metrics are the same between old and new versions of Tk.

Pd 0.50-2

Tk 8.5.19
Detected font: DejaVu Sans Mono
Using font: DejaVu Sans Mono normal
Measured font metrics:
9 5 10
10 6 11
12 7 14
16 10 19
23 14 26
36 22 41
Measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

Pd 0.51-3test1

Tk 8.6.10
detected font: DejaVu Sans Mono
using font: DejaVu Sans Mono normal
measured font metrics:
9 5 10
10 6 11
12 7 14
16 10 19
23 14 26
36 22 41
measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

@dizzybanjo
Copy link

hmm.. ok maybe this is an issue :

canvas font, received from pd in pdtk_pd_startup, set in s_main.c

set font_family "courier"
set font_weight "normal"

sizes of chars for each of the Pd fixed font sizes:

width(pixels) height(pixels)

set font_metrics {
5 11
6 13
7 16
10 19
14 29
22 44
}

sizes as above for zoomed-in view

set font_zoom2_metrics {
10 22
12 26
14 32
20 38
28 58
44 88
}

@danomatika
Copy link
Contributor

Those are base metrics used to compute the character boxes, but what are the reported font metrics when you run the GUI, ie. my previous post?

@dizzybanjo
Copy link

dizzybanjo commented Oct 19, 2020

pd-gui.tcl.zip
I cant seem to see what you refer to in there

@dizzybanjo
Copy link

sorry @danomatika I didn't have much time to look at this yesterday. To explain more, I cant seem to find what you refer to in your previous instructions in my pd-gui.tcl file. Im not sure if Im doing it wrong or if this is something specific to Catalina.

@danomatika
Copy link
Contributor

danomatika commented Oct 20, 2020

I added some test printing for the metrics some years ago, but it's a bit too much info to leave in all the time. Basically, you just need to edit the Tcl file to uncomment the logging lines.

For a macOS app, the procedure is as follows:

  • Close Pd-***.app if it's running
  • Right-click on Pd-***.app and choose "Show Package Contents"
  • Navigate to Contents/Resources/tcl
  • Open pd-gui.tcl in a text editor
  • Uncomment the code section at the end of the fit_font_into_metrics proc, around line 540
  • Open Pd-***.app, choose log level "4 all" to see the measure font metrics in the Pd window

Do this for both versions you are comparing and copy/paste the metrics output here. You can go back and re-comment those lines to return things to normal.

EDIT: Fixed wrong filename.

@dizzybanjo
Copy link

pd_bindings_files.zip

Hey Dan I dont see that in pd_bindings.tcl here either. Those files end at line 441 for me?

@danomatika
Copy link
Contributor

I don't need copies of the files, we have those in the Git repository. I need the Pd window console output when you start each version by following the steps in my previous post. Basically, open the .app bundle, edit the pd-gui.tcl file, close, start Pd, show log level 4, copy/paste the metrics text output to a new post here. It should look like this previous post from porres.

@dizzybanjo
Copy link

yes I understand. When I follow your instructions I don't see those lines in the code, and cannot search and find fit_font_into_metrics. Indeed my pd_bindings.tcl files ( from the releases compiled from MacOS ) finish at line 441. Thats why I posed the files to verify that.

Should I be using a different version?

@danomatika
Copy link
Contributor

danomatika commented Oct 23, 2020 via email

@dizzybanjo
Copy link

Pd 0.51-3test1 :

Tk 8.6.10
detected font: DejaVu Sans Mono
using font: DejaVu Sans Mono normal
measured font metrics:
8 5 9
9 6 10
11 7 13
16 10 19
23 14 26
36 22 41
measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

Pd 0.51-2:

Tk 8.6.10
detected font: DejaVu Sans Mono
using font: DejaVu Sans Mono normal
measured font metrics:
8 5 9
9 6 10
11 7 13
16 10 19
23 14 26
36 22 41
measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

@dizzybanjo
Copy link

Pd 0.50-2 :

Tk 8.5.19
Detected font: DejaVu Sans Mono
Using font: DejaVu Sans Mono normal
Measured font metrics:
8 5 9
9 6 10
11 7 13
16 10 19
23 14 26
36 22 41
Measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

@danomatika
Copy link
Contributor

Ok, since the numbers are the same, this indicates the problem is not with the metrics.

@danomatika
Copy link
Contributor

danomatika commented Oct 28, 2020

Does this problem happen when you disable retina resolution?

  1. Right-click on the Pd-###.app and choose "Get Info"
  2. Check "Open in Low Resolution"
  3. Open Pd-###.app

Are you only seeing it on retina screens (built-in MBP display) or also external monitors?

@porres
Copy link
Contributor Author

porres commented Nov 12, 2020

hi, let me get back in, please, how can I help?

@danomatika
Copy link
Contributor

danomatika commented Nov 12, 2020

@porres Well, you could respond to my previous post.

In any case, I have a MBP 16 here running 10.15.7 and I see:

  • objects are wider with Pd-0.51-3test5 and Pd-0.50-2
  • changing screen resolution makes no difference, including restarting Pd after a change
  • running in low-resolution mode also makes no difference

For Pd-0.51-3test5 I also see similar metrics:

Tk 8.6.10
detected font: DejaVu Sans Mono
using font: DejaVu Sans Mono normal
measured font metrics:
8 5 9
9 6 10
11 7 13
16 10 19
23 14 26
36 22 41
measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

As the character box sizing is the same, the issue may lie elsewhere, as in how Tk draws to the canvas etc.

@danomatika
Copy link
Contributor

OTOH there is clear change from macOS 10.14 on my MBP 13, Pd-0.51-3test5:

Tk 8.6.10
detected font: DejaVu Sans Mono
using font: DejaVu Sans Mono normal
measured font metrics:
9 5 10
10 6 11
12 7 14
16 10 19
23 14 26
36 22 41
measured zoom2 font metrics:
16 10 19
19 12 22
23 14 26
32 20 38
46 28 54
73 44 85

although in this case, the box size is wider on the older platform.

@danomatika
Copy link
Contributor

I've done some additional research and it may have something to do with the font handling / hinting which can render thinner on macOS 10.15, ie. font smoothing defaults changes and a Tk bug report.

Looking at the behavior, if you drag-select text, the positioning of the background highlight & cursor are correct on the left side and start to offset as you go towards the right. Also, the font kerning seems to shift as you highlight stuff. I have a feeling it's an issue with the Tk text widget.

@danomatika
Copy link
Contributor

danomatika commented Nov 14, 2020

If you change the font to Courier, it actually renders and selects fine. This make me wonder why there is a problem with Deja Vu Sans Mono.

UPDATE: Pd 0.51-3test5 on macOS 10.15.7 screenshots:

Deja Vu Sans Mono, default

Screenshot 2020-11-15 at 00 15 17

-font-face Courier

Screenshot 2020-11-15 at 00 14 29

UPDATE2: -font-face Monaco

Screenshot 2020-11-15 at 00 26 31

UPDATE3: -font-face Menlo

Screenshot 2020-11-15 at 00 58 24

@danomatika
Copy link
Contributor

danomatika commented Nov 15, 2020

At this point, at least there is a workaround. I suggest using Menlo as it's based off of Bitstream Vera Mono & DejaVu Sans Mono and is the most similar, except for the different zero chars.

@dizzybanjo
Copy link

Thanks for all the great detective work on this @danomatika . Apologies I haven't tested much over the last week or so I had a crunch on a project.

This sounds like a good workaround. I've switched to Menlo now and I think its solves any usability issues from old patches. Nice one!

@danomatika
Copy link
Contributor

@porres Can you check and compare Menlo with DJSM. If it's "close enough" in sizing, we could simply change the default font as a quick fix for now as people are moving more and more to 10.15 and now 11.0.

@danomatika
Copy link
Contributor

Thanks for all the great detective work on this @danomatika .

@dizzybanjo Well, I ordered a new M1 MBP so I will have to deal with it soon anyway. Better to know now as I cannot stay on 10.14 forever.

@danomatika
Copy link
Contributor

danomatika commented Nov 15, 2020

@millerpuckette I did some quick comparisons on macOS 10.14 and Menlo is almost identical to DejaVu Sans Mono. I will make an image to highlight the differences, but I think we could safely make it the default font for macOS until we can figure out what's going on with DJSM.

@millerpuckette
Copy link
Contributor

millerpuckette commented Nov 15, 2020 via email

@danomatika
Copy link
Contributor

danomatika commented Nov 15, 2020

Here's an image highlighting the differences between the same test patch (Browser -> Pure Data/7.stuff/tools/sizingtest.pd) using either DejaVu Sans Mono or Menlo. I made screenshots on macOS 10.14 using Pd-0.51-3test5 with font size 12 as the character sizing issue only happens on 10.15+, so this should be an accurate comparison.

DejaVuSansMono vs Menlo

As far as I can tell, the sizing and positioning are pretty much the same. The main differences are adjustments to individual characters such as the slashed '0', more leading space on the 'l', lower strike on the 'e', thicker '_' and '-', etc. I don't think most people would notice a change and patch positioning should not break. I like the changes to 'l' and the underscores are easier to read in Menlo.

I will go ahead and make a separate PR implementing this change.

For completeness, here are the individual screenshots:

DejaVu Sans Mono

Screen Shot 2020-11-15 at 6 38 05 PM

Menlo

Screen Shot 2020-11-15 at 6 38 37 PM

@danomatika
Copy link
Contributor

@millerpuckette Font change in #1222.

@danomatika danomatika added the bug/fix either a bug (for issues) or a bugfix (for pull-requests) label Nov 15, 2020
@danomatika
Copy link
Contributor

Closed by #1222

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/fix either a bug (for issues) or a bugfix (for pull-requests)
Projects
None yet
Development

No branches or pull requests

5 participants