firenvim icon indicating copy to clipboard operation
firenvim copied to clipboard

Font size too big or too small

Open glacambre opened this issue 3 years ago • 16 comments

If the font is too big or too small you can use :set guifont=... to change the size. See :help guifont.

glacambre avatar Mar 03 '21 13:03 glacambre

After several hours spent trying to understand the help menu, here's what worked for me in nvim in Vivaldi on a Mac.

:set guifont=Fira_Code:h18

For what it's worth, in the font name you can replace spaces with underscores.

caseymandell avatar Mar 12 '21 23:03 caseymandell

Thanks @caseymandell you saved me a few hours.

@glacambre Maybe this should be a part of README.md or TROUBLESHOOTING.md?

For the record, this scales up the entire iframe and not just the size of the font inside the textarea so it isn't very elegant. Not sure if there's a better way to fix it? The extension works flawlessly on my linux desktop.

devanshuDesai avatar Mar 21 '21 07:03 devanshuDesai

Just saw your email. Thanks! To me it should definitely be part of one of those files. The help entry itself they referred us to said it was a "confusing entry,:" Referring people looking for an answer to it was kind of like saying eat shit.

Casey

On Mar 21, 2021, at 3:52 AM, Devanshu Desai @.***> wrote:

Thanks @caseymandell https://github.com/caseymandell you saved me a few hours.

@glacambre https://github.com/glacambre Maybe this should be a part of README.md or TROUBLESHOOTING.md?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/glacambre/firenvim/issues/972#issuecomment-803527582, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOGACDFLKRHBJ4LFYA7R4ETTEWQURANCNFSM4YRHOPYA.

caseymandell avatar Mar 27 '21 23:03 caseymandell

@caseymandell

The help entry itself they referred us to said it was a "confusing entry,:" Referring people looking for an answer to it was kind of like saying eat shit.

I'm not sure I understand what you mean. I'm not seeing any instances of "confusing" in :help guifont's documentation. Could you expand on that?

Also, if you can think of ways to improve the documentation, please send pull requests to Vim. The problem of documentation is that it's often written by experts, who by definition have a hard time imagining the hurdles the non-experts have to go through. If you don't contribute, things won't get better.

@devanshuDesai

For the record, this scales up the entire iframe and not just the size of the font inside the textarea so it isn't very elegant. Not sure if there's a better way to fix it?

You can resize the frame afterwards with :set lines=... columns=... (unfortunately you can't use both :set lines=... columns=... and :set guifont=... at the same time, you have to first let firenvim adapt the font and then ask for the resize. See https://github.com/glacambre/firenvim/issues/800 for more info).

glacambre avatar Mar 28 '21 05:03 glacambre

I'm not sure if these emails are going to a mailing list or not. If it had occurred to me they were going to a mailing list I never would have used that kind of language and for that I apologize. I REALLY like firenvim and wouldn't want to do anything to damage it's reputation. In fact the example was an attempt to help out, and as things turned out it did..

I wish you the best of luck, but having said that, for better or worse, the larger point is that the reference wasn't very helpful. A simple example would have saved me hours of work. And I have to say it seems kind of contradictory for you to say "the problem of documentation is that it's often written by experts, who by definition have a hard time imagining the hurdles the non-experts have to go through. If you don't contribute, things won't get better," with reference to a help entry you referred people to without any other elaboration such as an example. Especially since I did in fact post a comment that improved upon your own help entry.

I spent a few minutes looking for the entry saying it was confusing but couldn't find it. Who knows, maybe I just imagined it.

I don't know how big a deal this is to you, but it's not really a big deal to me. I think the larger point is that if your help item had been helpful we wouldn't even be having this discussion.

I enjoy your product and am sorry to have the start of our relationship get off on the wrong foot like this.

Sincerely, Casey

On Mar 28, 2021, at 1:30 AM, Ghjuvan Lacambre @.***> wrote:

@caseymandell https://github.com/caseymandell The help entry itself they referred us to said it was a "confusing entry,:" Referring people looking for an answer to it was kind of like saying eat shit.

I'm not sure I understand what you mean. I'm not seeing any instances of "confusing" in :help guifont's documentation. Could you expand on that?

Also, if you can think of ways to improve the documentation, please send pull requests to Vim. The problem of documentation is that it's often written by experts, who by definition have a hard time imagining the hurdles the non-experts have to go through. If you don't contribute, things won't get better.

@devanshuDesai https://github.com/devanshuDesai For the record, this scales up the entire iframe and not just the size of the font inside the textarea so it isn't very elegant. Not sure if there's a better way to fix it?

You can resize the frame afterwards with :set lines=... columns=... (unfortunately you can't use both :set lines=... columns=... and :set guifont=... at the same time, you have to first let firenvim adapt the font and then ask for the resize. See #800 https://github.com/glacambre/firenvim/issues/800 for more info).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/glacambre/firenvim/issues/972#issuecomment-808849905, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOGACDD2WZZCNDCVELUYHNTTF3EJZANCNFSM4YRHOPYA.

caseymandell avatar Mar 28 '21 18:03 caseymandell

A simple example would have saved me hours of work.

:help guifont already contains multiple examples. Here is guifont's help page:

This is a list of fonts which will be used for the GUI version of Vim.
In its simplest form the value is just one font name.  When
the font cannot be found you will get an error message.  To try other
font names a list can be specified, font names separated with commas.
The first valid font is used.

Spaces after a comma are ignored.  To include a comma in a font name
precede it with a backslash.  Setting an option requires an extra
backslash before a space and a backslash.  See also
option-backslash.  For example:
    :set guifont=Screen15,\ 7x13,font\\,with\\,commas
will make Vim try to use the font "Screen15" first, and if it fails it
will try to use "7x13" and then "font,with,commas" instead.

If none of the fonts can be loaded, Vim will keep the current setting.
If an empty font list is given, Vim will try using other resource
settings (for X, it will use the Vim.font resource), and finally it
will try some builtin default which should always be there ("7x13" in
the case of X).  The font names given should be "normal" fonts.  Vim
will try to find the related bold and italic fonts.

For Win32 and Mac OS:
    :set guifont=*
will bring up a font requester, where you can pick the font you want.

The font name depends on the GUI used.

For Mac OSX you can use something like this:
    :set guifont=Monaco:h10
                                                        E236
Note that the fonts must be mono-spaced (all characters have the same
width).

To preview a font on X11, you might be able to use the "xfontsel"
program.  The "xlsfonts" program gives a list of all available fonts.

For the Win32 GUI                                       E244 E245
- takes these options in the font name:
        hXX - height is XX (points, can be floating-point)
        wXX - width is XX (points, can be floating-point)
        b   - bold
        i   - italic
        u   - underline
        s   - strikeout
        cXX - character set XX.  Valid charsets are: ANSI, ARABIC,
              BALTIC, CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK,
              HANGEUL, HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS,
              SYMBOL, THAI, TURKISH, VIETNAMESE ANSI and BALTIC.
              Normally you would use "cDEFAULT".

  Use a ':' to separate the options.
- A '_' can be used in the place of a space, so you don't need to use
  backslashes to escape the spaces.
- Examples:
    :set guifont=courier_new:h12:w5:b:cRUSSIAN
    :set guifont=Andale_Mono:h7.5:w4.5

In particular, the example you gave seems very similar to the :set guifont=Monaco:h10 example. In fact, I don't see the difference between your example and the one provided by Vim's help pages. This is why I recommend you send a PR to Vim to make this easier to understand for end users. I don't know how to improve things, but you, as a person who encountered an issue and solved it, know exactly what would have helped you figure things out faster.

The documentation for guifont is available here: https://github.com/vim/vim/blob/fa79be6b10e1d34fd697a56e85f6c0ce101f3d62/runtime/doc/gui.txt#L1056 . If you don't know how to send pull requests to github projects, the process is described here: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request .

glacambre avatar Mar 28 '21 19:03 glacambre

I am curious if there is an easy way to use a bigger font without resizing the textbox. Has this been resolved? I have tried this and that but without any luck.

dit7ya avatar Apr 02 '21 14:04 dit7ya

@dit7ya You can create a shortcut for increasing and decreasing the font size, something like this:

function! OnUIEnter(event) abort
  if s:IsFirenvimActive(a:event)
    nnoremap <space> :set lines=28 columns=110 <CR>

    let s:fontsize = 14
    function! AdjustFontSizeF(amount)
      let s:fontsize = s:fontsize+a:amount
      execute "set guifont=SauceCodePro\\ Nerd\\ Font:h" . s:fontsize
      call rpcnotify(0, 'Gui', 'WindowMaximized', 1)
    endfunction

    noremap  <C-=> :call AdjustFontSizeF(1)<CR>
    noremap  <C--> :call AdjustFontSizeF(-1)<CR>
    inoremap <C-=> :call AdjustFontSizeF(1)<CR>
    inoremap <C--> :call AdjustFontSizeF(-1)<CR>
endif
endfunction
autocmd UIEnter * call OnUIEnter(deepcopy(v:event))

matheusfillipe avatar May 19 '21 04:05 matheusfillipe

I was trying to change the font style using :set guifont=CaskaydiaCove_Nerd_Font_Mono:h20 but it gives me the same result as :set guifont=monospace:h20 is there something I need to do to embed the font for the browser to render it? I have it installed on my system.

vito-c avatar Jul 04 '21 18:07 vito-c

is there something I need to do to embed the font for the browser to render it

No, Firenvim should be able to use any font your browser can use. I think the problem here is that you're not using the right font name and your browser can't find it.

What you can try to do in order to figure out what the name of the font should be is create a small HTML document, open it in your browser and then try to make it use the font you want to use. Once you've found the right name for the font, you can use it with guifont.

glacambre avatar Jul 04 '21 19:07 glacambre

In case anyone stumbles across this and is having issues the trick is to escape the spaces. set guifont=Caskaydia\ Cove\ Nerd\ Font\ Mono:h18

vito-c avatar Jul 05 '21 19:07 vito-c

Wow now it works! I put this in my configs and the firenvim window expands the whole browser window in width:

set guifont=FiraCode_Nerd_Font_Mono:h23

molleweide avatar Aug 09 '21 20:08 molleweide

I tried this, it works and do increases the size of the guifont, however, the window exceed the original text area like this: image

So this might not be a good solution... BTW, I'm using brave browser. And I tried this under firefox, and sometimes I can reproduce it.

glyh avatar Nov 19 '21 10:11 glyh

I was having trouble with this issue, as well as #869 and #1006.

What found works best is simply adding a mapping for setting the guifont, rather than setting it directly in my init.nvim or .vimrc. This avoids running into #1006, while providing an immediate easy fix to #869 whenever I'm in the "wrong monitor". Basically, in my .vimrc i have the following:

if exists('g:started_by_firenvim')
  nnoremap <leader>font :set guifont=Monaco:h18<CR>
endif

That way, when I'm on my built in display where the font is too small, I can just hit <leader>font and the font will be resized to the right size, without running into the issue of the frame being resized too like in #1006, as explained here

thesofakillers avatar Feb 20 '22 14:02 thesofakillers

I have a hacky fix for this, which uses an autocmd, and requires no manual intervention

    autocmds = {
    	set_font = {
    		{ 'UIEnter', '*', "call timer_start(200, { tid -> execute('if exists(''g:started_by_firenvim'')\nset guifont=FiraCode\\ Nerd\\ Font:h18\nendif')})"}
    	}
    },

That's some lua. I'm a vimscript newb but I believe all fo those elements concatenated together (with whitespce in between) should work

quarkw avatar Feb 22 '22 21:02 quarkw

I personnally settled on a setting a fixed sized font with the set guifont option and I was glad to learn to about the lines and columns option but this does feel like since this an issue that potentially every user will encounter, the README should mention it. It took me some time to find this issue because I have looking for "zooming" options and found nothing to address in the README

Thank you so much for making this extension. I had been looking for something like that for quite some time. It's a joy to use.

cassepipe avatar Dec 15 '22 14:12 cassepipe