]> git.proxmox.com Git - grub2.git/commitdiff
* grub-core/font/font.c (grub_font_load): Add support for default
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 24 Feb 2012 10:18:06 +0000 (11:18 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 24 Feb 2012 10:18:06 +0000 (11:18 +0100)
path for fonts ($prefix/fonts).
* grub-core/kern/corecmd.c (grub_core_cmd_insmod): Unify condition
for checking if string is a path.
* grub-core/normal/main.c (features): Add feature_default_font_path.
* util/grub-mkconfig.in: Skip mangling of GRUB_FONT into GRUB_FONT_PATH.
* util/grub.d/00_header.in: Use default directory if possible.
* util/grub-install.in: Install unicode.pf2.

ChangeLog
grub-core/font/font.c
grub-core/kern/corecmd.c
grub-core/normal/main.c
util/grub-install.in
util/grub-mkconfig.in
util/grub.d/00_header.in

index 31962c3ba0517a1580a365d290d93fbb8d70ae9e..35ca74fd712c340bcf8ee8dd94495f5041c2feb0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-02-24  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/font/font.c (grub_font_load): Add support for default
+       path for fonts ($prefix/fonts).
+       * grub-core/kern/corecmd.c (grub_core_cmd_insmod): Unify condition
+       for checking if string is a path.
+       * grub-core/normal/main.c (features): Add feature_default_font_path.
+       * util/grub-mkconfig.in: Skip mangling of GRUB_FONT into GRUB_FONT_PATH.
+       * util/grub.d/00_header.in: Use default directory if possible.
+       * util/grub-install.in: Install unicode.pf2.
+
 2012-02-24  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * po/README: Add de_CH and en@quot to po/LINGUAS generation command.
index e0597ea4552374a7c468c9fa5ac32ee2fa13015f..93fbb710fda92c4b51771aa850bce7904895446d 100644 (file)
@@ -29,6 +29,7 @@
 #include <grub/charset.h>
 #include <grub/unicode.h>
 #include <grub/fontformat.h>
+#include <grub/env.h>
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
@@ -433,7 +434,30 @@ grub_font_load (const char *filename)
   grub_printf ("add_font(%s)\n", filename);
 #endif
 
-  file = grub_buffile_open (filename, 1024);
+  if (filename[0] == '(' || filename[0] == '/' || filename[0] == '+')
+    file = grub_buffile_open (filename, 1024);
+  else
+    {
+      const char *prefix = grub_env_get ("prefix");
+      char *fullname, *ptr;
+      if (!prefix)
+       {
+         grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
+                     "prefix");
+         goto fail;
+       }
+      fullname = grub_malloc (grub_strlen (prefix) + grub_strlen (filename) + 1
+                             + sizeof ("/fonts/") + sizeof (".pf2"));
+      if (!fullname)
+       goto fail;
+      ptr = grub_stpcpy (fullname, prefix);
+      ptr = grub_stpcpy (ptr, "/fonts/");
+      ptr = grub_stpcpy (ptr, filename);
+      ptr = grub_stpcpy (ptr, ".pf2");
+      *ptr = 0;
+      file = grub_buffile_open (fullname, 1024);
+      grub_free (fullname);
+    }
   if (!file)
     goto fail;
 
index b94f199a5391ce0831019f9b6d775ed793f7323e..eec575c05670300feac8329ba3f263b1e008925e 100644 (file)
@@ -79,17 +79,15 @@ static grub_err_t
 grub_core_cmd_insmod (struct grub_command *cmd __attribute__ ((unused)),
                      int argc, char *argv[])
 {
-  char *p;
   grub_dl_t mod;
 
   if (argc == 0)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
 
-  p = grub_strchr (argv[0], '/');
-  if (! p)
-    mod = grub_dl_load (argv[0]);
-  else
+  if (argv[0][0] == '/' || argv[0][0] == '(' || argv[0][0] == '+')
     mod = grub_dl_load_file (argv[0]);
+  else
+    mod = grub_dl_load (argv[0]);
 
   if (mod)
     grub_dl_ref (mod);
index 707917013dc1f4206444145443e0571517dcf7b3..ceeaa794d48764d2422e2f4c1136a400f94a1153 100644 (file)
@@ -474,7 +474,8 @@ static grub_command_t cmd_clear;
 
 static void (*grub_xputs_saved) (const char *str);
 static const char *features[] = {
-  "feature_chainloader_bpb", "feature_ntldr", "feature_platform_search_hint"
+  "feature_chainloader_bpb", "feature_ntldr", "feature_platform_search_hint",
+  "feature_default_font_path"
 };
 
 GRUB_MOD_INIT(normal)
index c76a029bd9d9f51e039133d6da83474b5c343774..cbb37ead2f6248402a24c4fc0d8814612010118a 100644 (file)
@@ -451,6 +451,11 @@ if test -d "${pkgdatadir}"/themes/starfield; then
     cp "${pkgdatadir}"/themes/starfield/* "${grubdir}"/themes/starfield
 fi
 
+if test -f "${pkgdatadir}"/unicode.pf2; then
+    mkdir -p "${grubdir}"/fonts
+    cp "${pkgdatadir}"/unicode.pf2 "${grubdir}"/fonts
+fi
+
 is_path_readable_by_grub "${grubdir}/${target_cpu}-$platform" || (echo "${grubdir}" not readable 1>&2 ; exit 1)
 
 # Write device to a variable so we don't have to traverse /dev every time.
index 9c405053ff84ac00549400ca42cacb40fb9262aa..198bd37a97bb5cbfaf3ea5cbdf33be4569c96131 100644 (file)
@@ -156,41 +156,6 @@ if [ "x${GRUB_TERMINAL_OUTPUT}" = "x" ]; then
     termoutdefault=1;
 fi
 
-for x in ${GRUB_TERMINAL_OUTPUT}; do
-    if [ "x${x}" = "xgfxterm" ]; then
-       if [ -n "$GRUB_FONT" ] ; then
-           if is_path_readable_by_grub ${GRUB_FONT} > /dev/null ; then
-               GRUB_FONT_PATH=${GRUB_FONT}
-           else
-               echo "No such font or not readable by grub: ${GRUB_FONT}" >&2
-               exit 1
-           fi
-       else
-           for dir in ${pkgdatadir} ${GRUB_PREFIX} /usr/share/grub ; do
-               for basename in unicode unifont ascii; do
-                   path="${dir}/${basename}.pf2"
-                   if is_path_readable_by_grub ${path} > /dev/null ; then
-                       GRUB_FONT_PATH=${path}
-                   else
-                       continue
-                   fi
-                   if [ "${basename}" = "ascii" ] ; then
-                       # make sure all our children behave in conformance with ascii..
-                       export LANG=C
-                   fi
-                   break 2
-               done
-           done
-       fi
-       if [ -z "${GRUB_FONT_PATH}" ] ; then
-           if [ "x$termoutdefault" != "x1" ]; then
-               gettext "No font for video terminal found." >&2; echo >&2 ; exit 1
-           fi
-           GRUB_TERMINAL_OUTPUT=
-       fi
-    fi
-done
-
 for x in ${GRUB_TERMINAL_OUTPUT}; do
     case "x${x}" in
        xgfxterm) ;;
@@ -208,7 +173,7 @@ export GRUB_DEVICE \
   GRUB_DEVICE_BOOT \
   GRUB_DEVICE_BOOT_UUID \
   GRUB_FS \
-  GRUB_FONT_PATH \
+  GRUB_FONT \
   GRUB_PRELOAD_MODULES \
   GRUB_PREFIX
 
index 781d7d47eb04fd09219a89d84e45d51b96f7bace..e47d5ba17732fbccd7134d5f1df9e21b7e437603 100644 (file)
@@ -124,11 +124,47 @@ if [ "x$serial" = x1 ]; then
 fi
 
 if [ "x$gfxterm" = x1 ]; then
-    # Make the font accessible
-    prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT_PATH}"`
+    if [ -n "$GRUB_FONT" ] ; then
+       # Make the font accessible
+       prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT}"`
+    cat << EOF
+if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
+EOF
+       else
+           for dir in ${pkgdatadir} ${GRUB_PREFIX} /usr/share/grub ; do
+               for basename in unicode unifont ascii; do
+                   path="${dir}/${basename}.pf2"
+                   if is_path_readable_by_grub ${path} > /dev/null ; then
+                       font_path=${path}
+                   else
+                       continue
+                   fi
+                   break 2
+               done
+           done
+           if [ -n "${font_path}" ] ; then
+    cat << EOF
+if [ x\$feature_default_font_path = xy ] ; then
+   font=unicode
+else
+EOF
+
+                # Make the font accessible
+               prepare_grub_to_access_device `${grub_probe} --target=device "${font_path}"`
+    cat << EOF
+    font="`make_system_path_relative_to_its_root "${font_path}"`"
+fi
+
+if loadfont \$font ; then
+EOF
+           else
+    cat << EOF
+if loadfont unicode ; then
+EOF
+           fi
+       fi
 
     cat << EOF
-if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT_PATH}"` ; then
   set gfxmode=${GRUB_GFXMODE}
   load_video
   insmod gfxterm