spacemacs icon indicating copy to clipboard operation
spacemacs copied to clipboard

Floating-point font size interpreted incorrectly on macOS

Open bcc32 opened this issue 3 years ago • 10 comments

Description :octocat:

Floating-point font sizes, according to the help text for font-spec, specify the size of the font in points, unlike integers, which specify them in pixels. E.g., 13 pixels should be equivalent to 10.0 points.

The default font size in Spacemacs, 10.0, was set by #12515 to a floating-point value. But, it gets interpreted as a pixel size rather than a point size on macOS.

Reproduction guide :beetle:

Set dotspacemacs-default-font:

   dotspacemacs-default-font `("Anonymous Pro"
                               :size 10.0
                               :weight normal
                               :width normal)
  • Start Emacs

Observed behaviour: :eyes: :broken_heart: The font is tiny. I measure the distance between the bottom of two consecutive lines of xxx to be 0.075 inch apart on my screen.

Expected behaviour: :heart: :smile: The font should be bigger! With the font size set to 13 (as an integer, which is supposedly equivalent to 10.0 as a floating-point value), I measure the distance between the bottom of two consecutive lines of xxx to be 0.10 inch on my screen.

System Info :computer:

  • OS: darwin
  • Emacs: 27.1
  • Spacemacs: 0.300.0
  • Spacemacs branch: wip-ocamlformat-in-ocaml-layer (rev. 0c6f7fe68)
  • Graphic display: t
  • Distribution: spacemacs-base
  • Editing style: hybrid
  • Completion: ivy
  • Layers:
(spell-checking
 (syntax-checking :variables syntax-checking-use-original-bitmaps t)
 (auto-completion :variables auto-completion-idle-delay 1.0)
 (ivy :variables ivy-enable-advanced-buffer-information t)
 helpful ibuffer
 (org :variables org-projectile-file "TODO.org" org-want-todo-bindings t)
 (unicode-fonts :variables unicode-fonts-enable-ligatures t unicode-fonts-ligature-modes
                '(prog-mode))
 autohotkey c-c++ csv nil emacs-lisp nil nil html
 (javascript :variables javascript-fmt-tool 'prettier javascript-fmt-on-save t)
 json markdown
 (ocaml :variables ocaml-format-before-save t)
 perl5 python ruby rust scheme shell-scripts sql
 (typescript :variables typescript-fmt-tool 'prettier typescript-fmt-on-save t)
 yaml nixos osx git
 (version-control :variables version-control-diff-tool nil)
 spacemacs-completion spacemacs-layouts spacemacs-editing spacemacs-editing-visual spacemacs-evil spacemacs-language spacemacs-misc spacemacs-modeline spacemacs-navigation spacemacs-org spacemacs-project spacemacs-purpose spacemacs-visual command-log fasd finance
 (shell :variables shell-enable-smart-eshell t)
 spotify bcc32-org)
  • System configuration features: NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS JSON PDUMPER

bcc32 avatar Oct 10 '20 04:10 bcc32

It might be helpful to include some screenshots. Then someone else with a mac can confirm if they are seeing the same thing.

duianto avatar Oct 10 '20 05:10 duianto

Ah, indeed. Here's some screenshots taken at full screen (2560 x 1600 on my MacBook Air)

Font size 10.0: Screen Shot 2020-10-10 at 01 28 33

Font size 13: Screen Shot 2020-10-10 at 01 28 53

bcc32 avatar Oct 10 '20 05:10 bcc32

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

github-actions[bot] avatar Oct 10 '21 05:10 github-actions[bot]

With the font size set to 13 (as an integer, which is supposedly equivalent to 10.0 as a floating-point value)

@bcc32

Nope. macbook pro is likely to have DPI 225 So 10 * 225 / 72 = 31.25

lebensterben avatar Oct 15 '21 02:10 lebensterben

With the font size set to 13 (as an integer, which is supposedly equivalent to 10.0 as a floating-point value)

@bcc32

Nope. macbook pro is likely to have DPI 225 So 10 * 225 / 72 = 31.25

Those numbers were based on a previous MacBook Air which I don't have access to anymore, so I wouldn't be able to check. I'd believe you that the numbers might be different, but in any case, once set to a floating-point size, it should render as the same physical size on the screen regardless of device, according to the documentation.

bcc32 avatar Nov 08 '21 21:11 bcc32

according to xft specification you can optionally specify dpi. so point size + manually specified dpi should give you best result

lebensterben avatar Nov 08 '21 22:11 lebensterben

Specifying dpi in the font name, or some other config var? That seems unfortunate, because it wouldn't be reusable across machines. Ideally, we'd be able to detect the appropriate DPI and interpret the point size accordingly, but maybe that is not possible.

bcc32 avatar Nov 09 '21 18:11 bcc32

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

github-actions[bot] avatar Nov 09 '22 18:11 github-actions[bot]

This is still an issue. The same floating-point font size (10.5) renders as significantly different physical sizes on macOS vs. other platforms.

bcc32 avatar Nov 13 '22 23:11 bcc32

It seems the font size is ignored 🤔 image

rinconjc avatar Oct 25 '23 05:10 rinconjc