2009-01-02 Colin D Bennett <colin@gibibit.com>
New font engine. Additional changes by Vesa Jääskeläinen <chaac@nic.fi> to adapt to build system and fixed gfxterm.c to work with different sized fonts. * configure.ac: Changed UNIFONT_HEX to UNIFONT_BDF. * configure: Re-generated. * DISTLIST: Removed font/manager.c. Added font/font.c. Added font/font_cmd.c. * Makefile.in: Changed UNIFONT_HEX to UNIFONT_BDF. Added Font tool compilation. * include/grub/misc.h (grub_utf8_to_ucs4): Changed prototype. Changed users. * kern/misc.c (grub_utf8_to_ucs4): Changed prototype. * kern/term.c: Changed users of grub_utf8_to_ucs4. * normal/menu.c: Likewise. * conf/common.rmk (font_mod_SOURCES): Removed font/manager.c. (font_mod_SOURCES): Added font/font_cmd.c, font/font.c. * include/grub/font.h: Replaced with new file. * include/grub/video.h (GRUB_VIDEO_MODE_TYPE_ALPHA): Changed value. (GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED): Likewise. (GRUB_VIDEO_MODE_TYPE_COLOR_MASK): Likewise. (GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP): Added. (grub_video_blit_format): Added GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED. (grub_video_mode_info): Added bg_red, bg_green, bg_blue, bg_alpha, fg_red, fg_green, fg_blue, fg_alpha. (grub_video_adapter): Removed blit_glyph. (grub_video_blit_glyph): Removed. * font/manager.c: Removed file. * font/font.c: New file. * font/font_cmd.c: Likewise. * video/video.c (grub_video_blit_glyph): Removed. * video/i386/pc/vbe.c (grub_video_vbe_map_rgb): Added 1-bit support. (grub_video_vbe_map_rgba): Likewise. (grub_video_vbe_unmap_color_int): Likewise. (grub_video_vbe_blit_glyph): Removed. (grub_video_vbe_adapter): Removed blit_glyph. * video/i386/pc/vbeutil.c (get_data_ptr): Added 1-bit support. (get_pixel): Likewise. (set_pixel): Likewise. * commands/videotest.c (grub_cmd_videotest): Added more tests for fonts. * term/gfxterm.c: Adapted to new font engine. * term/i386/pc/vesafb.c: Marked as deprecated. Made it compile. * term/i386/pc/vga.c: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/BDFLoader.java: New file. * util/fonttool/src/org/gnu/grub/fonttool/CharDefs.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/CharacterRange.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/CharacterRange.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/Converter.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/Font.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/Glyph.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/PFF2Sections.java: Likewise. * util/fonttool/src/org/gnu/grub/fonttool/PFF2Writer.java: Likewise. * util/grub.d/00_header.in: Changed to use new loadfont command. * util/grub-mkconfig_lib.in: Changed font extension.
This commit is contained in:
parent
278922e80b
commit
1e901a7573
34 changed files with 2859 additions and 543 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -26,7 +26,6 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/bitmap.h>
|
||||
|
@ -710,6 +709,16 @@ grub_video_vbe_map_rgb (grub_uint8_t red, grub_uint8_t green,
|
|||
|
||||
return minindex;
|
||||
}
|
||||
else if ((render_target->mode_info.mode_type
|
||||
& GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0)
|
||||
{
|
||||
if (red == render_target->mode_info.fg_red
|
||||
&& green == render_target->mode_info.fg_green
|
||||
&& blue == render_target->mode_info.fg_blue)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_uint32_t value;
|
||||
|
@ -740,6 +749,17 @@ grub_video_vbe_map_rgba (grub_uint8_t red, grub_uint8_t green,
|
|||
/* No alpha available in index color modes, just use
|
||||
same value as in only RGB modes. */
|
||||
return grub_video_vbe_map_rgb (red, green, blue);
|
||||
else if ((render_target->mode_info.mode_type
|
||||
& GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0)
|
||||
{
|
||||
if (red == render_target->mode_info.fg_red
|
||||
&& green == render_target->mode_info.fg_green
|
||||
&& blue == render_target->mode_info.fg_blue
|
||||
&& alpha == render_target->mode_info.fg_alpha)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_uint32_t value;
|
||||
|
@ -802,6 +822,24 @@ grub_video_vbe_unmap_color_int (struct grub_video_i386_vbeblit_info * source,
|
|||
*alpha = framebuffer.palette[color].a;
|
||||
return;
|
||||
}
|
||||
else if ((mode_info->mode_type
|
||||
& GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP) != 0)
|
||||
{
|
||||
if (color & 1)
|
||||
{
|
||||
*red = mode_info->fg_red;
|
||||
*green = mode_info->fg_green;
|
||||
*blue = mode_info->fg_blue;
|
||||
*alpha = mode_info->fg_alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
*red = mode_info->bg_red;
|
||||
*green = mode_info->bg_green;
|
||||
*blue = mode_info->bg_blue;
|
||||
*alpha = mode_info->bg_alpha;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_uint32_t tmp;
|
||||
|
@ -925,76 +963,6 @@ grub_video_vbe_fill_rect (grub_video_color_t color, int x, int y,
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
// TODO: Remove this method and replace with bitmap based glyphs
|
||||
static grub_err_t
|
||||
grub_video_vbe_blit_glyph (struct grub_font_glyph * glyph,
|
||||
grub_video_color_t color, int x, int y)
|
||||
{
|
||||
struct grub_video_i386_vbeblit_info target;
|
||||
unsigned int width;
|
||||
unsigned int charwidth;
|
||||
unsigned int height;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
unsigned int x_offset = 0;
|
||||
unsigned int y_offset = 0;
|
||||
|
||||
/* Make sure there is something to do. */
|
||||
if (x >= (int)render_target->viewport.width)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
if (y >= (int)render_target->viewport.height)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
/* Calculate glyph dimensions. */
|
||||
width = ((glyph->width + 7) / 8) * 8;
|
||||
charwidth = width;
|
||||
height = glyph->height;
|
||||
|
||||
if (x + (int)width < 0)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
if (y + (int)height < 0)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
/* Do not allow drawing out of viewport. */
|
||||
if (x < 0)
|
||||
{
|
||||
width += x;
|
||||
x_offset = (unsigned int)-x;
|
||||
x = 0;
|
||||
}
|
||||
if (y < 0)
|
||||
{
|
||||
height += y;
|
||||
y_offset = (unsigned int)-y;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
if ((x + width) > render_target->viewport.width)
|
||||
width = render_target->viewport.width - x;
|
||||
if ((y + height) > render_target->viewport.height)
|
||||
height = render_target->viewport.height - y;
|
||||
|
||||
/* Add viewport offset. */
|
||||
x += render_target->viewport.x;
|
||||
y += render_target->viewport.y;
|
||||
|
||||
/* Use vbeblit_info to encapsulate rendering. */
|
||||
target.mode_info = &render_target->mode_info;
|
||||
target.data = render_target->data;
|
||||
|
||||
/* Draw glyph. */
|
||||
for (j = 0; j < height; j++)
|
||||
for (i = 0; i < width; i++)
|
||||
if ((glyph->bitmap[((i + x_offset) / 8)
|
||||
+ (j + y_offset) * (charwidth / 8)]
|
||||
& (1 << ((charwidth - (i + x_offset) - 1) % 8))))
|
||||
set_pixel (&target, x+i, y+j, color);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
/* NOTE: This function assumes that given coordinates are within bounds of
|
||||
handled data. */
|
||||
static void
|
||||
|
@ -1619,7 +1587,6 @@ static struct grub_video_adapter grub_video_vbe_adapter =
|
|||
.map_rgba = grub_video_vbe_map_rgba,
|
||||
.unmap_color = grub_video_vbe_unmap_color,
|
||||
.fill_rect = grub_video_vbe_fill_rect,
|
||||
.blit_glyph = grub_video_vbe_blit_glyph,
|
||||
.blit_bitmap = grub_video_vbe_blit_bitmap,
|
||||
.blit_render_target = grub_video_vbe_blit_render_target,
|
||||
.scroll = grub_video_vbe_scroll,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -52,6 +52,12 @@ get_data_ptr (struct grub_video_i386_vbeblit_info *source,
|
|||
+ y * source->mode_info->pitch
|
||||
+ x;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
/* For 1-bit bitmaps, addressing needs to be done at the bit level
|
||||
and it doesn't make sense, in general, to ask for a pointer
|
||||
to a particular pixel's data. */
|
||||
break;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
@ -86,6 +92,17 @@ get_pixel (struct grub_video_i386_vbeblit_info *source,
|
|||
color = *(grub_uint8_t *)get_data_ptr (source, x, y);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED)
|
||||
{
|
||||
int bit_index = y * source->mode_info->width + x;
|
||||
grub_uint8_t *ptr = (grub_uint8_t *)source->data
|
||||
+ bit_index / 8;
|
||||
int bit_pos = 7 - bit_index % 8;
|
||||
color = (*ptr >> bit_pos) & 0x01;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -143,6 +160,17 @@ set_pixel (struct grub_video_i386_vbeblit_info *source,
|
|||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (source->mode_info->blit_format == GRUB_VIDEO_BLIT_FORMAT_1BIT_PACKED)
|
||||
{
|
||||
int bit_index = y * source->mode_info->width + x;
|
||||
grub_uint8_t *ptr = (grub_uint8_t *)source->data
|
||||
+ bit_index / 8;
|
||||
int bit_pos = 7 - bit_index % 8;
|
||||
*ptr = (*ptr & ~(1 << bit_pos)) | ((color & 0x01) << bit_pos);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -336,17 +336,6 @@ grub_video_fill_rect (grub_video_color_t color, int x, int y,
|
|||
return grub_video_adapter_active->fill_rect (color, x, y, width, height);
|
||||
}
|
||||
|
||||
/* Blit glyph to screen using specified color. */
|
||||
grub_err_t
|
||||
grub_video_blit_glyph (struct grub_font_glyph *glyph,
|
||||
grub_video_color_t color, int x, int y)
|
||||
{
|
||||
if (! grub_video_adapter_active)
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "No video mode activated");
|
||||
|
||||
return grub_video_adapter_active->blit_glyph (glyph, color, x, y);
|
||||
}
|
||||
|
||||
/* Blit bitmap to screen. */
|
||||
grub_err_t
|
||||
grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue