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

Always uses Source Code Pro ExtraLight #177

Closed
averms opened this issue Oct 30, 2020 · 11 comments
Closed

Always uses Source Code Pro ExtraLight #177

averms opened this issue Oct 30, 2020 · 11 comments

Comments

@averms
Copy link

averms commented Oct 30, 2020

I am on Arch Linux and I installed the adobe-source-code-pro-fonts package. setting.toml is empty and this is all I have in my init.vim:

set guifont=Source\ Code\ Pro:h11

But when I start goneovim, it chooses Source Code Pro Extra Light instead of Regular. I checked by running like this:

FC_DEBUG=1 ./Goneovim-0.4.8.1-linux/goneovim

The only way I could solve was by deleting Extra Light. But then it chose Light. So in the end I had to delete both and only then it chose the regular style.

@akiyosi
Copy link
Owner

akiyosi commented Oct 30, 2020

Hi
Thanks for this issue report.

Goneovim's font weight should normally be normal size. Here's the part where the font weight is handled.

goneovim/editor/workspace.go

Lines 1672 to 1709 in c66c8b2

func getFontFamilyAndHeightAndWeightAndStretch(s string) (string, float64, gui.QFont__Weight, int) {
parts := strings.Split(s, ":")
height := -1.0
width := -1.0
weight := gui.QFont__Normal
if len(parts) > 1 {
for _, p := range parts[1:] {
if strings.HasPrefix(p, "h") {
// height, err = strconv.Atoi(p[1:])
h, err := strconv.ParseFloat(p[1:], 64)
if err == nil {
height = h
}
} else if strings.HasPrefix(p, "w") {
// width, err := strconv.Atoi(p[1:])
w, err := strconv.ParseFloat(p[1:], 64)
if err == nil {
width = w
}
} else if p == "t" {
weight = gui.QFont__Thin
} else if p == "el" {
weight = gui.QFont__ExtraLight
} else if p == "l" {
weight = gui.QFont__Light
} else if p == "n" {
// default weight, we do nothing
} else if p == "db" || p == "sb" {
weight = gui.QFont__DemiBold
} else if p == "b" {
weight = gui.QFont__Bold
} else if p == "eb" {
weight = gui.QFont__ExtraBold
} else {
weight = gui.QFont__Normal
}
}
}

I didn't specify this in the documentation, but I assume that you could control the weight by using : separator like the following;

set guifont=Source\ Code\ Pro:h11:t
set guifont=Source\ Code\ Pro:h11:el
set guifont=Source\ Code\ Pro:h11:l
set guifont=Source\ Code\ Pro:h11:n
set guifont=Source\ Code\ Pro:h11:db
set guifont=Source\ Code\ Pro:h11:b
set guifont=Source\ Code\ Pro:h11:eb

If you explicitly specify set guifont=Source\ Code\ Pro:h11:n or set guifont=Source\ Code\ Pro:h11:eb, could you confirm which font is being used?

@averms
Copy link
Author

averms commented Oct 30, 2020

If you explicitly specify set guifont=Source\ Code\ Pro:h11:n or set guifont=Source\ Code\ Pro:h11:eb, could you confirm which font is being used?

No matter what I specify for the weight, I still get Source Code Pro
ExtraLight. I also tried monospace:h11:n and it still gives me ExtraLight.

Here is the output of
fc-list : family style | grep 'Source Code Pro':

Source Code Pro,Source Code Pro Semibold:style=Semibold Italic,Italic
Source Code Pro:style=Bold
Source Code Pro,Source Code Pro Semibold:style=Semibold,Regular
Source Code Pro:style=Italic
Source Code Pro,Source Code Pro Light:style=Light Italic,Italic
Source Code Pro,Source Code Pro ExtraLight:style=ExtraLight Italic,Italic
Source Code Pro:style=Bold Italic
Source Code Pro,Source Code Pro Black:style=Black Italic,Italic
Source Code Pro,Source Code Pro Medium:style=Medium,Regular
Source Code Pro,Source Code Pro Black:style=Black,Regular
Source Code Pro,Source Code Pro Light:style=Light,Regular
Source Code Pro:style=Regular
Source Code Pro,Source Code Pro Medium:style=Medium Italic,Italic
Source Code Pro,Source Code Pro ExtraLight:style=ExtraLight,Regular

As you can see, some of them have alternate family names and those work fine.
For example, guifont=Source\ Code\ Pro\ Medium:h11 chooses Source Code Pro
Medium correctly. Unfortunately, the regular style doesn't have a family name
specific to it so it doesn't work.

@akiyosi
Copy link
Owner

akiyosi commented Nov 1, 2020

Sorry for late reply.
I looking into this.

I've checked on my archlinux and the problem seems to be reproduced.
However, since the output of set guifont=Source\ Code\ Pro:h12 when FC_DEBUG=1 is different each time, there is no certainty that the issue is reproduced.
The following is an example of the output for set guifont=Source\ Code\ Pro:hXX command.

https://gist.github.com/akiyosi/d4ca9825c03bb22db78666d3992a5221
https://gist.github.com/akiyosi/317284f8dd72dbd0c232afb242194436

I don't know how to read FC_DEBUG's output, but is it the same in your environment?

@averms
Copy link
Author

averms commented Nov 3, 2020

I've checked on my archlinux and the problem seems to be reproduced.
However, since the output of set guifont=Source\ Code\ Pro:h12 when FC_DEBUG=1 is different each time, there is no certainty that the issue is reproduced.
...
I don't know how to read FC_DEBUG's output, but is it the same in your environment?

I'm not sure what exactly you are asking. Is your output different every time you start up goneovim? For me it is the same. I tried running FC_DEBUG=1 ./Goneovim-0.4.8.1-linux/goneovim &>fc.txt a few different times. Each time I let it start, waited a few seconds, and then :quit.

I ran diff on the fc.txt files but I didn't see any differences. I have uploaded the log. Line 81 actually contains a correct match for Source Code Pro Regular but near the end it starts matching ExtraLight. Our logs will always be different because we probably have different installed fonts and fontconfig configurations. For some reason yours is much longer.

I don't know how to read FC_DEBUG's output, but is it the same in your environment?

I'm don't know a lot about fontconfig myself but I think the general architecture is:

  1. Program sends a request for a font. This is logged in a block with a first line like First font Pattern has ....
  2. Fontconfig configuration modifies request. This is to allow user to alias fonts. This is logged in a block with a first line like Match Pattern has ...
  3. Fontconfig looks for a font file that matches the request. This is logged in a block with a first line like Best score ....

Here is an example FC_DEBUG log for fc-match, which a good program for debugging the matching algorithm.

@akiyosi
Copy link
Owner

akiyosi commented Nov 3, 2020

Thanks for detail.

I'm not sure what exactly you are asking. Is your output different every time you start up goneovim?

My intention is that the output content of FC_DEBUG will be different each time the command set guifont=Source\ Code\ Pro:h12 is executed.
We actually need to execute the font change to occur, so once we specify a different font and change it(set guifont=Hack:h12), we execute set giufont=Source\ Code\ Pro:h12again.

The algorithm inside goneovim is to give the font family names to setfamily() method of qfont object. I think this is probably related to the algorithm inside qfont.

https://doc.qt.io/qt-5/qfont.html#setFamily

I'm continuing to look into it now and will reply here if there is any progress.

@GlassBricks
Copy link

GlassBricks commented Feb 23, 2021

I'm also experiencing this problem with other fonts (Firacode, Jetbrains Mono); the font weight is always at the lightest weight.
Running latest github actions goneovim as of posting on Ubuntu 20.04

Interestingly, I found that, explicitly setting font weight via :n, :b, etc. actually does affect the weight of "bold" syntax highlighting, but not normal text.

Any updates on this?

@akiyosi
Copy link
Owner

akiyosi commented Feb 24, 2021

@enjoydambience
Hi :)
Sorry for the lack of updates for so long. I have not been able to devote enough time to this issue.

One thing I'd like to check is whether changing the following settings will change the behavior related to this issue.

[~/.config/goneovim/settings.toml]

[Editor]
#...

CachedDrawing = false

@GlassBricks
Copy link

GlassBricks commented Feb 24, 2021

Just checked: setting CachedDrawing to false fixed the problem; fonts now appear at their appropriate weight.

@akiyosi
Copy link
Owner

akiyosi commented Feb 25, 2021

Hi
Thank you for your confirmation.
I have found the cause of this problem.
I would appreciate it if you could check the problem has been fixed with the latest package below.

https://github.com/akiyosi/goneovim/actions/runs/599846180

@GlassBricks
Copy link

Seems to have fixed the problem for me; fonts work properly with CachedDrawing=true.

@akiyosi
Copy link
Owner

akiyosi commented Feb 27, 2021

@enjoydambience
Thanks for confirming! I'll close it.

@akiyosi akiyosi closed this as completed Feb 27, 2021
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