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

Extremely small headings when emacs is started as a daemon #8

Closed
Chobbes opened this issue Jan 8, 2019 · 10 comments
Closed

Extremely small headings when emacs is started as a daemon #8

Chobbes opened this issue Jan 8, 2019 · 10 comments

Comments

@Chobbes
Copy link

Chobbes commented Jan 8, 2019

Hi there! When I have poet installed:

(use-package poet-theme
  :ensure t)

AND I start emacs as a daemon and connect with an emacs client, I get really REALLY small headings in org mode:

2019-01-07-193903_802x144_scrot

If I enable variable-pitch-mode it's even worse:

2019-01-07-193755_114x54_scrot

If I start emacs normally this problem goes away for some reason! If I start emacs as a daemon without initializing poet, and then enable the poet theme when I start an emacsclient, everything is fine as well.

Do you have any idea what might be causing this?

@kunalb
Copy link
Owner

kunalb commented Jan 8, 2019

Wow, I haven't experienced that before. If you inspect your font details, does anything interesting show up? (you can hover over a character in your headings and do C-x C-u = to get details about the font used).

Poet picks up the font height externally and then uses that for all future iterations; just in case it's picking up a strange font-height on first start I could imagine this happening.

@Chobbes
Copy link
Author

Chobbes commented Jan 8, 2019

(you can hover over a character in your headings and do C-x C-u = to get details about the font used).

Which command is this? describe-face? I don't seem to have anything bound to C-x C-u =

describe-face gives me:

Face: org-level-1 (sample) (customize this face)

Documentation:
Face used for level 1 headlines.

Defined in ‘org-faces.el’.

           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: 1
           Weight: unspecified
            Slant: unspecified
       Foreground: #770b0b
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
          Inherit: default

Poet picks up the font height externally and then uses that for all future iterations; just in case it's picking up a strange font-height on first start I could imagine this happening.

Yeah, I imagine it's something related to this --- maybe it thinks it's in a terminal or something when started as a daemon? shrug

@Chobbes
Copy link
Author

Chobbes commented Jan 8, 2019

Here's what happens when I start poet after opening an emacs frame.

Face: org-level-1 (sample) (customize this face)

Documentation:
Face used for level 1 headlines.

Defined in ‘org-faces.el’.

           Family: unspecified
          Foundry: unspecified
            Width: unspecified
           Height: 147
           Weight: unspecified
            Slant: unspecified
       Foreground: #770b0b
DistantForeground: unspecified
       Background: unspecified
        Underline: unspecified
         Overline: unspecified
   Strike-through: unspecified
              Box: unspecified
          Inverse: unspecified
          Stipple: unspecified
             Font: unspecified
          Fontset: unspecified
          Inherit: default

@kunalb
Copy link
Owner

kunalb commented Jan 8, 2019

It's basically the height 1, and yes – I inverted the command; C-u C-x = should be describe :). Are you explicitly setting the heights and fonts before enabling poet in your config?

@Chobbes
Copy link
Author

Chobbes commented Jan 8, 2019

Nope, not explicitly setting anything, afaik. Quick search for height shows nothing in my .emacs.

@kunalb
Copy link
Owner

kunalb commented Jan 8, 2019

setting a reasonable height will probably fix it temporarily. emacs -Q seemed to handle it correctly so I'm not sure why it's misinterpreting height, will do some more testing with emacsclient.

@Chobbes
Copy link
Author

Chobbes commented Jan 8, 2019

Cool! Let me know if you can't reproduce it. I can try anything you need me to :).

@alphapapa
Copy link

You may need to use after-make-frame-functions.

@kunalb
Copy link
Owner

kunalb commented Jan 14, 2019

8f06ffd should fix this.

Many more details than anyone asked for: I ended up going down a little bit of a rabbit hole while debugging this;

  • emacs started as a daemon does not initialize the 'default font to non-unspecified values.

  • if you start emacsclient -t (new frame in the terminal), heights will be initialized to 1

  • poet stores the fixed-pitch height it sees the first time around, because

    • all heights are defined with respect to fixed-pitch; for variable pitch fonts to look visually the same size as monospace I need them to be slightly larger - they're defined as 1.23 * fixed-pitch size.
    • emacs has support for relative heights, but once I use face-remap 'default has 'variable-pitch as the base size instead of 'fixed-pitch, which magnifies everything else unnecessarily.
    • which made me save the original 'fixed-pitch size, and then reuse that to be independent of face-remapped values. (I specifically recommend using variable-pitch-mode, so I definitely need to account for it).
  • Now if you do emacsclient -c, it'll use height 1 for anything related to 'variable-pitch. For emacs on Mac, this doesn't show 1px high fonts, which is why I never had an explicit repro (but I could see the height specified as 1).

  • I ended up trying to find ways to solve this by reinitializing the theme when the first frame is created (following alphapapa's comment), or trying to force calculation of the face height from x-based values sooner; spacemacs actually has code around lazily initializing graphical values that depend on one graphical frame being initialized, etc. etc.

  • I ended up reading larger parts of xfaces.c, frame.c, etc. than I would care to admit.

  • The simple solution was to just replace heights with a dynamic function instead that sizes them based off fixed-pitch height instead of base height.

  • Note to self: This solution isn't perfect because it doesn't work well with text-scale-increase, text-scale-decrease; the fix is to make sure fixed-pitch has its height updated correctly, and then to reuse that. (possibly by looking up face-remapping-alist in the :height function).

@kunalb kunalb closed this as completed Jan 14, 2019
@Chobbes
Copy link
Author

Chobbes commented Jan 15, 2019

... Oops. https://www.xkcd.com/356/

Thanks for looking into this, though, it seems like it's working for me now, which I appreciate a lot :). Did not expect this to be so involved!

These themes are really great for paper writing, particularly how source / example / comment blocks show up, so I am really happy to have it all working at a reasonable font size now, haha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants