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

Getting the default font sometimes fails #122

Open
meskarune opened this issue Aug 7, 2018 · 4 comments
Open

Getting the default font sometimes fails #122

meskarune opened this issue Aug 7, 2018 · 4 comments
Labels
Projects

Comments

@meskarune
Copy link
Owner

Oh my system I have Noto Sans Regular as my default. However when I run this:

convert -list font | awk "{ a[NR] = \$2 } /family: $(fc-match sans -f "%{family}\n")/ { print a[NR-1]; exit }"

I get "Noto-Sans-Adlam-Regular" which is incorrect. It should be "Noto-Sans-Regular"

The bug in the awk script needs to get figured out.

@PandorasFox
Copy link
Contributor

oof, fontconfig stuff

I imagine that it's probably something related to fontconfig 2.13, since that's been... buggy, at times.

@meskarune meskarune added this to High priority in bugs Aug 8, 2018
@meskarune
Copy link
Owner Author

@PandorasFox yes, it actually did turn out to be an annoying font config issues lmao.

After some investigation it turns out it the problem is fc-match having very liberal matching and will return things that even partially match. I'm honestly not sure how to get around that. I have "Noto Sans" set as my default font, but fc-match returns "Noto Sans Adlam" as the first match, rather than an exact match.

@AladW AladW added the bug label Jun 25, 2020
@CRTified
Copy link

CRTified commented Jul 8, 2023

I have a similar problem. fc-match returns too much:

$ fc-match sans -f "%{family}\n"                                                                                
NotoSans Nerd Font,NotoSans NF

Running the subsequent command with only one of these is fine:

$ convert -list font | awk "{ a[NR] = \$2 } /family: NotoSans Nerd Font/ { print a[NR-1]; exit }"
NotoSans-NF-Cond

But the original command, where both values are used, remains empty.
This might be a bit more robust:

fc-match sans -f "%{family}\n" | tr ',' '\n' | while read fontLine; do convert -list font | awk "{ a[NR] = \$2 } /family: $fontLine/ { print a[NR-1]; exit }"; done | head -n1

It essentially tries all comma-separated font families that fc-match returned.

Here's a patch, should I open a PR for it?

diff --git a/i3lock-fancy b/i3lock-fancy
index d35b977..36cc583 100755
--- a/i3lock-fancy
+++ b/i3lock-fancy
@@ -6,7 +6,7 @@ set -o errexit -o noclobber -o nounset
 hue=(-level "0%,100%,0.6")
 effect=(-filter Gaussian -resize 20% -define "filter:sigma=1.5" -resize 500.5%)
 # default system sans-serif font
-font=$(convert -list font | awk "{ a[NR] = \$2 } /family: $(fc-match sans -f "%{family}\n")/ { print a[NR-1]; exit }")
+font=$(fc-match sans -f "%{family}\n" | tr ',' '\n' | while read fontLine; do convert -list font | awk "{ a[NR] = \$2 } /family: $fontLine/ { print a[NR-1]; exit }"; done | head -n1)
 image=$(mktemp --suffix=.png)
 shot=(import -silent -window root)
 desktop=""
@@ -22,7 +22,7 @@ options="Options:
 
     -p, --pixelate   Pixelate the background instead of blur, runs faster.
 
-    -f <fontname>, --font <fontname>  Set a custom font.
+    -f <fontname>, --font <fontname>  Set a custom font. (Default: ${font})
 
     -t <text>, --text <text> Set a custom text prompt.

@CRTified
Copy link

CRTified commented Jul 8, 2023

I just noticed that this is a different problem than the original one.

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

No branches or pull requests

4 participants