Skip to contentSkip to conversation

look for DejaVu also in /usr/share/fonts/truetype

PATCH In review Andrey Borzenkov 2 participants 11 messages Jan 12, 2014 – Jan 25, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 look for DejaVu also in /usr/share/fonts/truetype

It is installed in this path on openSUSE.

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
index 7c5d080..e80c074 100644
@@ -1375,7 +1375,7 @@ fi
 
 if test x"$starfield_excuse" = x; then
    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
-     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
+     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
         if test -f "$dir/DejaVuSans.$ext"; then
           DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
           break 2
Signature · 1 line
tg: (0776112..) u/dejavu-path (depends on: master)
#1 lore raw

PATCH 1/1 Improve DejaVuSans detection

Look also in /usr/share/fonts/truetype, it is installed in this path on openSUSE.

Prefer DejaVuSansMono if found, on openSUSE DejaVuSans is proportional font.

Add detected path name to summary output.

---
 configure.ac | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
configure.ac +8 -5
index 2e4cf3c..98f6012 100644
@@ -1378,11 +1378,13 @@ fi
 
 if test x"$starfield_excuse" = x; then
    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
-     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
-        if test -f "$dir/DejaVuSans.$ext"; then
-          DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
-          break 2
-        fi
+     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
+	for font in DejaVuSansMono DejaVuSans; do
+	  if test -f "$dir/$font.$ext"; then
+	    DJVU_FONT_SOURCE="$dir/$font.$ext"
+	    break 2
+	  fi
+	done
      done
    done
 
@@ -1805,6 +1807,7 @@ echo grub-mount: No "($grub_mount_excuse)"
 fi
 if [ x"$starfield_excuse" = x ]; then
 echo starfield theme: Yes
+echo With DejaVuSans font from $DJVU_FONT_SOURCE
 else
 echo starfield theme: No "($starfield_excuse)"
 fi
Signature · 1 line
tg: (dcecae1..) u/dejavu-path (depends on: master)
#2 lore raw

Re: [PATCH] Improve DejaVuSans detection

Quoted 5 lines · Andrey Borzenkov

Look also in /usr/share/fonts/truetype, it is installed in this path on openSUSE.

Prefer DejaVuSansMono if found, on openSUSE DejaVuSans is proportional font.

It's not right solution. Proportional fonts must be preffered for themes. Only terminal requires monospace fonts. You need to set gfxterm_font to unifont name.

Quoted 38 lines

Add detected path name to summary output.

---
 configure.ac | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
configure.ac +8 -5
index 2e4cf3c..98f6012 100644
@@ -1378,11 +1378,13 @@ fi
 
 if test x"$starfield_excuse" = x; then
    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
-     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
-        if test -f "$dir/DejaVuSans.$ext"; then
-          DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
-          break 2
-        fi
+     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
+	for font in DejaVuSansMono DejaVuSans; do
+	  if test -f "$dir/$font.$ext"; then
+	    DJVU_FONT_SOURCE="$dir/$font.$ext"
+	    break 2
+	  fi
+	done
      done
    done
 
@@ -1805,6 +1807,7 @@ echo grub-mount: No "($grub_mount_excuse)"
 fi
 if [ x"$starfield_excuse" = x ]; then
 echo starfield theme: Yes
+echo With DejaVuSans font from $DJVU_FONT_SOURCE
 else
 echo starfield theme: No "($starfield_excuse)"
 fi
#3 lore raw

Re: [PATCH] Improve DejaVuSans detection

В Sat, 18 Jan 2014 17:26:16 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 9 lines · Andrey Borzenkov
Quoted 5 lines

Look also in /usr/share/fonts/truetype, it is installed in this path on openSUSE.

Prefer DejaVuSansMono if found, on openSUSE DejaVuSans is proportional font.

It's not right solution. Proportional fonts must be preffered for themes. Only terminal requires monospace fonts. You need to set gfxterm_font to unifont name.

But then not gfxterm_font, but we need to set it in theme definition. gfxterm_font is optional and theme must still work without it.

From: Andrey Borzenkov <[email protected]>
Subject: [PATCH] Improve DejaVuSans detection and fix starfield terminal font

Look also in /usr/share/fonts/truetype, it is installed in this path on openSUSE.

Add detected path name to summary output.

Set terminal font to unifont in starfield; DejaVuSans is proportional and looks bad in terminal window.

---
 configure.ac               | 3 ++-
 themes/starfield/theme.txt | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
configure.ac +2 -1
index cf3de3b..8888c2f 100644
@@ -1389,7 +1389,7 @@ fi
 
 if test x"$starfield_excuse" = x; then
    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
-     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
+     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
         if test -f "$dir/DejaVuSans.$ext"; then
           DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
           break 2
@@ -1816,6 +1816,7 @@ echo grub-mount: No "($grub_mount_excuse)"
 fi
 if [ x"$starfield_excuse" = x ]; then
 echo starfield theme: Yes
+echo With DejaVuSans font from $DJVU_FONT_SOURCE
 else
 echo starfield theme: No "($starfield_excuse)"
 fi
themes/starfield/theme.txt +1 -1
index 5ec871b..b3b8d85 100644
@@ -25,7 +25,7 @@ message-font: "DejaVu Sans Regular 12"
 message-color: "#000"
 message-bg-color: "#fff"
 terminal-box: "terminal_box_*.png"
-terminal-font: "DejaVu Sans Regular 12"
+terminal-font: "Gnu Unifont Mono Regular 16"
 desktop-image: "starfield.png"
 
 #help bar at the bottom
Signature · 1 line
tg: (1ecf96f..) u/dejavu-path (depends on: master)
#4 lore raw

Re: [PATCH] Improve DejaVuSans detection

Quoted 19 lines · Andrey Borzenkov

В Sat, 18 Jan 2014 17:26:16 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 9 lines · Andrey Borzenkov
Quoted 5 lines

Look also in /usr/share/fonts/truetype, it is installed in this path on openSUSE.

Prefer DejaVuSansMono if found, on openSUSE DejaVuSans is proportional font.

It's not right solution. Proportional fonts must be preffered for themes. Only terminal requires monospace fonts. You need to set gfxterm_font to unifont name.

But then not gfxterm_font, but we need to set it in theme definition. gfxterm_font is optional and theme must still work without it.

From: Andrey Borzenkov <[email protected]>
Subject: [PATCH] Improve DejaVuSans detection and fix starfield terminal font

Quoted 8 lines

Look also in /usr/share/fonts/truetype, it is installed in this path on openSUSE.

Add detected path name to summary output.

Set terminal font to unifont in starfield; DejaVuSans is proportional and looks bad in terminal window.

I've misread the patch in my first review. I thought it added a new behaviour of looking for DejaVuSans.

Quoted 10 lines
---
 configure.ac               | 3 ++-
 themes/starfield/theme.txt | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
configure.ac +0 -0
index cf3de3b..8888c2f 100644

configure.ac fi · line 1392

Quoted 5 lines
configure.ac +1 -1
@@ -1389,7 +1389,7 @@ fi
 
 if test x"$starfield_excuse" = x; then
    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
-     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
+     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do

Go ahead for this part.

configure.ac echo grub-mount: No "($grub_mount_excuse)" · line 1819

Quoted 8 lines
configure.ac +1 -0
         if test -f "$dir/DejaVuSans.$ext"; then
           DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
           break 2
@@ -1816,6 +1816,7 @@ echo grub-mount: No "($grub_mount_excuse)"
 fi
 if [ x"$starfield_excuse" = x ]; then
 echo starfield theme: Yes
+echo With DejaVuSans font from $DJVU_FONT_SOURCE

Go ahead for this as well.

Quoted 8 lines
configure.ac +0 -0
 else
 echo starfield theme: No "($starfield_excuse)"
 fi
themes/starfield/theme.txt +0 -0
index 5ec871b..b3b8d85 100644

themes/starfield/theme.txt message-font: "DejaVu Sans Regular 12" · line 30

Quoted 7 lines
themes/starfield/theme.txt +1 -1
@@ -25,7 +25,7 @@ message-font: "DejaVu Sans Regular 12"
 message-color: "#000"
 message-bg-color: "#fff"
 terminal-box: "terminal_box_*.png"
-terminal-font: "DejaVu Sans Regular 12"
+terminal-font: "Gnu Unifont Mono Regular 16"
 desktop-image: "starfield.png"
 

On my system I get name "Unifont Regular 16". Did you check unicode.pf2 to get this string?

Quoted 9 lines
themes/starfield/theme.txt +0 -0
 #help bar at the bottom

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw

Re: [PATCH] Improve DejaVuSans detection

В Tue, 21 Jan 2014 08:40:39 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 4 lines
Quoted 4 lines
themes/starfield/theme.txt +0 -0
@@ -25,7 +25,7 @@ message-font: "DejaVu Sans Regular 12"
 message-color: "#000"
Quoted 8 lines

themes/starfield/theme.txt message-font: "DejaVu Sans Regular 12" · line 30

Quoted 6 lines
themes/starfield/theme.txt +1 -1
 message-bg-color: "#fff"
 terminal-box: "terminal_box_*.png"
-terminal-font: "DejaVu Sans Regular 12"
+terminal-font: "Gnu Unifont Mono Regular 16"
 desktop-image: "starfield.png"
 

On my system I get name "Unifont Regular 16". Did you check unicode.pf2 to get this string?

Of course.

bor@opensuse:~/build/grub> ./build-grub-mkfont -o /tmp/foo.pf2 -v /usr/share/fonts/uni/unifont.pcf.gz Font name: Gnu Unifont Mono Regular 16
Max width: 16
Max height: 16
Font ascent: 14
Font descent: 2
Number of glyph: 34813

But as I said in another mail, this is not quite correct also as we are not guaranteed to have it available.

#6 lore raw

Re: [PATCH] Improve DejaVuSans detection

In reply to Andrey Borzenkov
Quoted 21 lines · Andrey Borzenkov

Look also in /usr/share/fonts/truetype, it is installed in this path on openSUSE.

Prefer DejaVuSansMono if found, on openSUSE DejaVuSans is proportional font.

Add detected path name to summary output.

---
 configure.ac | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
configure.ac +0 -2
index 2e4cf3c..98f6012 100644
@@ -1378,11 +1378,13 @@ fi
 
 if test x"$starfield_excuse" = x; then
    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
-     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
-        if test -f "$dir/DejaVuSans.$ext"; then

configure.ac fi · line 1387

Quoted 10 lines
configure.ac +7 -3
-          DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
-          break 2
-        fi
+     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
+	for font in DejaVuSansMono DejaVuSans; do
+	  if test -f "$dir/$font.$ext"; then
+	    DJVU_FONT_SOURCE="$dir/$font.$ext"
+	    break 2
+	  fi
+	done

It's fine to use SansMono for terminal (I'd prefer unifont though) but this change also changes the way various items in menu are displayed. Monospace fonts are less dense so allow less info in menu on small screens.

Quoted 12 lines
configure.ac +1 -0
      done
    done
 
@@ -1805,6 +1807,7 @@ echo grub-mount: No "($grub_mount_excuse)"
 fi
 if [ x"$starfield_excuse" = x ]; then
 echo starfield theme: Yes
+echo With DejaVuSans font from $DJVU_FONT_SOURCE
 else
 echo starfield theme: No "($starfield_excuse)"
 fi
#7 lore raw

Re: [PATCH] Improve DejaVuSans detection

В Tue, 21 Jan 2014 08:46:41 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 5 lines
Quoted 2 lines

Prefer DejaVuSansMono if found, on openSUSE DejaVuSans is proportional font.

It's fine to use SansMono for terminal (I'd prefer unifont though) but this change also changes the way various items in menu are displayed. Monospace fonts are less dense so allow less info in menu on small screens.

Yes, I realized that. The problem is, unifont may be missing (user is free to override it with GRUB_FONT) and theme must be self-consistent (which is also why my other attempt to set font to Unifont is not quite correct as well). I tried to build fixed width DejaVuSansMono, but I do not like results enough. First, it results in extremely large vertical size using standard parameters; e.g.

bor@opensuse:~/build/grub> ./build-grub-mkfont -o /tmp/foo.pf2 -v -s 12 /usr/share/fonts/truetype/DejaVuSansMono.ttf Unknown gsub font feature 0x63636d70 (ccmp)
Unknown gsub font feature 0x646c6967 (dlig)
Unsupported substitution flag: 0x9
Unsupported substitution flag: 0x9
Unknown gsub font feature 0x6c6f636c (locl)
Unknown gsub font feature 0x6c6f636c (locl)
Unsupported substitution flag: 0x9
Font name: DejaVu Sans Mono Regular 12
Max width: 11
Max height: 22
Font ascent: 14
Font descent: 4
Number of glyph: 3388

22 height for font size 12! Forcing hinting gives something more close to reality

bor@opensuse:~/build/grub> ./build-grub-mkfont -o /tmp/foo.pf2 -v -s 12 -a /usr/share/fonts/truetype/DejaVuSansMono.ttf Unknown gsub font feature 0x63636d70 (ccmp)
Unknown gsub font feature 0x646c6967 (dlig)
Unsupported substitution flag: 0x9
Unsupported substitution flag: 0x9
Unknown gsub font feature 0x6c6f636c (locl)
Unknown gsub font feature 0x6c6f636c (locl)
Unsupported substitution flag: 0x9
Font name: DejaVu Sans Mono Regular 12
Max width: 11
Max height: 16
Font ascent: 13
Font descent: 5
Number of glyph: 3388

But still too high so vertical lines look dashed.

May be the simplest solution would be to follow the same logic as gfxterm - unless terminal-font is explicitly set, use $gfxterm_font by default with fallback to first loaded font.

#8 lore raw

Re: [PATCH] Improve DejaVuSans detection

Quoted 2 lines · Andrey Borzenkov

Yes, I realized that. The problem is, unifont may be missing (user is free to override it with GRUB_FONT)

If user overrides our fonts and gets ugly display it's his fault. You can assume unifont availability.

#9 lore raw

Re: [PATCH] Improve DejaVuSans detection

В Wed, 22 Jan 2014 00:16:44 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 6 lines · Andrey Borzenkov
Quoted 2 lines

Yes, I realized that. The problem is, unifont may be missing (user is free to override it with GRUB_FONT)

If user overrides our fonts and gets ugly display it's his fault. You can assume unifont availability.

Yes, but as we have just seen I cannot be sure about font *name*. The patch below makes it return the very first loaded font which in normal case is Unifont. So removing explicit font from starfield will result in loading unifont but won't depend on particular font name.

From: Andrey Borzenkov <[email protected]>
Subject: [PATCH] Do not set explicit font in starfield theme

DejaVuSans is proportional and looks bad in terminal window. DejaVuSansMono also results in suboptimal display. Unifont is better but apparently font name may be different on different distributions. So simply delete explicit font name for terminal window; this will cause the very first font to be loaded and normally the very first font is Unifont.

---
 grub-core/font/font.c      | 12 +++++++-----
 themes/starfield/theme.txt |  1 -
 2 files changed, 7 insertions(+), 6 deletions(-)
grub-core/font/font.c +7 -5
index 14b93e1..9e92e1f 100644
@@ -861,18 +861,20 @@ grub_font_t
 grub_font_get (const char *font_name)
 {
   struct grub_font_node *node;
+  struct grub_font_node *last_node = NULL;
 
-  for (node = grub_font_list; node; node = node->next)
+  for (node = grub_font_list; node; last_node = node, node = node->next)
     {
       grub_font_t font = node->value;
       if (grub_strcmp (font->name, font_name) == 0)
 	return font;
     }
 
-  /* If no font by that name is found, return the first font in the list
-     as a fallback.  */
-  if (grub_font_list && grub_font_list->value)
-    return grub_font_list->value;
+  /* If no font by that name is found, return the last font in the list
+     as a fallback. Last font is the one loaded first which is Unifont in
+     standard grub.cfg  */
+  if (last_node && last_node->value)
+    return last_node->value;
   else
     /* The null_font is a last resort.  */
     return &null_font;
themes/starfield/theme.txt +0 -1
index 5ec871b..cea799b 100644
@@ -25,7 +25,6 @@ message-font: "DejaVu Sans Regular 12"
 message-color: "#000"
 message-bg-color: "#fff"
 terminal-box: "terminal_box_*.png"
-terminal-font: "DejaVu Sans Regular 12"
 desktop-image: "starfield.png"
 
 #help bar at the bottom
Signature · 1 line
tg: (5ae584c..) u/dejavu-path (depends on: master)
#10 lore raw
In reply to Andrey Borzenkov

Go ahead

Quoted 20 lines · Andrey Borzenkov

It is installed in this path on openSUSE.

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
configure.ac +1 -1
index 7c5d080..e80c074 100644
@@ -1375,7 +1375,7 @@ fi
 
 if test x"$starfield_excuse" = x; then
    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
-     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
+     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
         if test -f "$dir/DejaVuSans.$ext"; then
           DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
           break 2