]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2006-03-30 Vesa Jaaskelainen <chaac@nic.fi>
authorchaac <chaac@localhost>
Fri, 31 Mar 2006 13:32:52 +0000 (13:32 +0000)
committerchaac <chaac@localhost>
Fri, 31 Mar 2006 13:32:52 +0000 (13:32 +0000)
        * font/manager.c (grub_font_get_glyph): Removed font fixup from
        here...

        * util/unifont2pff.rb: ... and moved it to here.  Improved argument
        parsing to support both hex and dec ranges.  If filename was missing
        show usage information.

ChangeLog
font/manager.c
util/unifont2pff.rb

index 03bd04c523c389b0e32899e73de7d1e8053aa2ff..8ac2d7186c498267aacb944dfb2cad9672954575 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-03-30  Vesa Jaaskelainen  <chaac@nic.fi>
+
+       * font/manager.c (grub_font_get_glyph): Removed font fixup from
+       here...
+
+       * util/unifont2pff.rb: ... and moved it to here.  Improved argument
+       parsing to support both hex and dec ranges.  If filename was missing
+       show usage information.
+
 2006-03-14  Vesa Jaaskelainen  <chaac@nic.fi>
 
        * DISTLIST: Added include/grub/video.h, term/gfxterm.c,
index 1bde6c16fa86b854c47131d403d63e1feb95e51c..9b3dc91a5d7df913b0a512cc2911d02223c948ca 100644 (file)
@@ -184,8 +184,6 @@ grub_font_get_glyph (grub_uint32_t code,
       if (offset)
        {
          grub_uint32_t w;
-         unsigned int x;
-         unsigned int y;
          int len;
 
           /* Make sure we can find glyphs for error messages.  Push active
@@ -215,11 +213,9 @@ grub_font_get_glyph (grub_uint32_t code,
              remove_font (font);
              goto restart;
            }
-           
-          /* Temporary workaround, fix font bitmap.  */
-          for (y = 0; y < 16; y++)
-            for (x = 0; x < w; x++)
-              glyph->bitmap[y * w + x] = bitmap[x * 16 + y];
+
+          /* Fill glyph with information.  */      
+          grub_memcpy (glyph->bitmap, bitmap, w * 16);
           
          glyph->char_width = w;
          glyph->width = glyph->char_width * 8;
index b3b1b1b55883883bae0f5762769d3c32ce221cb1..b746f5cf7bf61c6e384cc124a64ae0b7c291e71f 100644 (file)
 MAGIC = "PPF\x7f"
 
 def usage(status = 0)
-  puts "Usage: ruby unifont2pff.rb [RANGE...] FILE"
+  puts "Usage: ruby unifont2pff.rb [RANGE ...] FILE"
   exit(status)
 end
 
+if ARGV.length == 0
+  usage(1)
+end
+
 file = ARGV.pop
 
 ranges = []
 ARGV.each do |range|
-  if /\A([0-9a-fA-F]+):([0-9a-fA-F]+)\z/ =~ range
+  if /\A0x([0-9a-fA-F]+)[:-]0x([0-9a-fA-F]+)\z/ =~ range
     ranges << [$1.hex, $2.hex]
-  elsif /\A([0-9a-fA-F]+)\z/ =~ range
+  elsif /\A0x([0-9a-fA-F]+)\z/ =~ range
     ranges << [$1.hex, $1.hex]
+  elsif /\A([0-9]+)[:-]([0-9]+)\z/ =~ range
+    ranges << [$1.to_i, $2.to_i]
+  elsif /\A([0-9]+)\z/ =~ range
+    ranges << [$1.to_i, $1.to_i]
   else
     usage(1)
   end
@@ -54,6 +62,17 @@ IO.foreach(file) do |line|
       raise "invalid bitmap size: #{bitmap}"
     end
 
+    # Fix byte ordering
+    w = (bitmap.size / 32)
+    temp = Array.new
+    for y in 0...16
+      for x in 0...w
+        temp[(y * w + x) * 2 + 0] = bitmap[(x * 16 + y) * 2 + 0].chr
+        temp[(y * w + x) * 2 + 1] = bitmap[(x * 16 + y) * 2 + 1].chr
+      end
+    end
+    bitmap = temp.to_s
+
     fonts << [code, bitmap]
   else
     raise "invalid line format: #{line}"