All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] Moved font fixup from manager to font converter
@ 2006-03-30 18:41 Vesa Jääskeläinen
  2006-03-31  3:18 ` Yoshinori K. Okuji
  0 siblings, 1 reply; 5+ messages in thread
From: Vesa Jääskeläinen @ 2006-03-30 18:41 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

Hi,

I have made a small patch that moved this temporary hack from font
manager to font converted. At same time I also made some improvements to
converter. I can't say I am proficient on ruby, but at least it _seems_
to work.

Previously ranges were specified like this 0:123 (which would mean 0x0
to 0x123). After this change 0:123 means 0..123 and 0x0:0x123 would mean
0x0 to 0x123. I also added more intuitive range specifier '-' so you
could specify ranges like 0-255.

Also fixed minor error causing ruby error to be printed if there were no
parameters given.

Thanks,
Vesa Jääskeläinen

[-- Attachment #2: grub2-font-fixup.diff --]
[-- Type: text/plain, Size: 3113 bytes --]

Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v
retrieving revision 1.226
diff -u -r1.226 ChangeLog
--- ChangeLog	14 Mar 2006 19:08:33 -0000	1.226
+++ ChangeLog	30 Mar 2006 18:22:37 -0000
@@ -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: font/manager.c
===================================================================
RCS file: /sources/grub/grub2/font/manager.c,v
retrieving revision 1.7
diff -u -r1.7 manager.c
--- font/manager.c	14 Mar 2006 19:08:33 -0000	1.7
+++ font/manager.c	30 Mar 2006 18:22:37 -0000
@@ -184,8 +184,6 @@
       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 @@
 	      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: util/unifont2pff.rb
===================================================================
RCS file: /sources/grub/grub2/util/unifont2pff.rb,v
retrieving revision 1.2
diff -u -r1.2 unifont2pff.rb
--- util/unifont2pff.rb	24 Feb 2004 17:21:53 -0000	1.2
+++ util/unifont2pff.rb	30 Mar 2006 18:22:37 -0000
@@ -15,18 +15,26 @@
 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 @@
       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}"

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-04-02 11:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-30 18:41 [patch] Moved font fixup from manager to font converter Vesa Jääskeläinen
2006-03-31  3:18 ` Yoshinori K. Okuji
2006-04-01 19:39   ` Vesa Jääskeläinen
2006-04-02  0:43     ` Hollis Blanchard
2006-04-02 11:48     ` Marco Gerards

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.