2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2003,2007,2008,2009 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * GRUB is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#ifndef GRUB_FONT_HEADER
2N/A#define GRUB_FONT_HEADER 1
2N/A
2N/A#include <grub/types.h>
2N/A#include <grub/video.h>
2N/A#include <grub/file.h>
2N/A#include <grub/unicode.h>
2N/A
2N/A/* Forward declaration of opaque structure grub_font.
2N/A Users only pass struct grub_font pointers to the font module functions,
2N/A and do not have knowledge of the structure contents. */
2N/Astruct grub_font;
2N/A
2N/A/* Font type used to access font functions. */
2N/Atypedef struct grub_font *grub_font_t;
2N/A
2N/Astruct grub_font_node
2N/A{
2N/A struct grub_font_node *next;
2N/A grub_font_t value;
2N/A};
2N/A
2N/A/* Global font registry. */
2N/Aextern struct grub_font_node *grub_font_list;
2N/A
2N/Astruct grub_font_glyph
2N/A{
2N/A /* Reference to the font this glyph belongs to. */
2N/A grub_font_t font;
2N/A
2N/A /* Glyph bitmap width in pixels. */
2N/A grub_uint16_t width;
2N/A
2N/A /* Glyph bitmap height in pixels. */
2N/A grub_uint16_t height;
2N/A
2N/A /* Glyph bitmap x offset in pixels. Add to screen coordinate. */
2N/A grub_int16_t offset_x;
2N/A
2N/A /* Glyph bitmap y offset in pixels. Subtract from screen coordinate. */
2N/A grub_int16_t offset_y;
2N/A
2N/A /* Number of pixels to advance to start the next character. */
2N/A grub_uint16_t device_width;
2N/A
2N/A /* Row-major order, packed bits (no padding; rows can break within a byte).
2N/A The length of the array is (width * height + 7) / 8. Within a
2N/A byte, the most significant bit is the first (leftmost/uppermost) pixel.
2N/A Pixels are coded as bits, value 1 meaning of opaque pixel and 0 is
2N/A transparent. If the length of the array does not fit byte boundary, it
2N/A will be padded with 0 bits to make it fit. */
2N/A grub_uint8_t bitmap[0];
2N/A};
2N/A
2N/A/* Part of code field which is really used as such. */
2N/A#define GRUB_FONT_CODE_CHAR_MASK 0x001fffff
2N/A#define GRUB_FONT_CODE_RIGHT_JOINED 0x80000000
2N/A#define GRUB_FONT_CODE_LEFT_JOINED 0x40000000
2N/A
2N/A/* Initialize the font loader.
2N/A Must be called before any fonts are loaded or used. */
2N/Avoid grub_font_loader_init (void);
2N/A
2N/A/* Load a font and add it to the beginning of the global font list.
2N/A Returns: 0 upon success; nonzero upon failure. */
2N/Aint grub_font_load (const char *filename);
2N/A
2N/A/* Get the font that has the specified name. Font names are in the form
2N/A "Family Name Bold Italic 14", where Bold and Italic are optional.
2N/A If no font matches the name specified, the most recently loaded font
2N/A is returned as a fallback. */
2N/Agrub_font_t EXPORT_FUNC (grub_font_get) (const char *font_name);
2N/A
2N/Aconst char *EXPORT_FUNC (grub_font_get_name) (grub_font_t font);
2N/A
2N/Aint EXPORT_FUNC (grub_font_get_max_char_width) (grub_font_t font);
2N/A
2N/Aint EXPORT_FUNC (grub_font_get_max_char_height) (grub_font_t font);
2N/A
2N/Aint EXPORT_FUNC (grub_font_get_ascent) (grub_font_t font);
2N/A
2N/Aint EXPORT_FUNC (grub_font_get_descent) (grub_font_t font);
2N/A
2N/Aint EXPORT_FUNC (grub_font_get_leading) (grub_font_t font);
2N/A
2N/Aint EXPORT_FUNC (grub_font_get_height) (grub_font_t font);
2N/A
2N/Aint EXPORT_FUNC (grub_font_get_xheight) (grub_font_t font);
2N/A
2N/Astruct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph) (grub_font_t font,
2N/A grub_uint32_t code);
2N/A
2N/Astruct grub_font_glyph *EXPORT_FUNC (grub_font_get_glyph_with_fallback) (grub_font_t font,
2N/A grub_uint32_t code);
2N/A
2N/Agrub_err_t EXPORT_FUNC (grub_font_draw_glyph) (struct grub_font_glyph *glyph,
2N/A grub_video_color_t color,
2N/A int left_x, int baseline_y);
2N/A
2N/Aint
2N/AEXPORT_FUNC (grub_font_get_constructed_device_width) (grub_font_t hinted_font,
2N/A const struct grub_unicode_glyph *glyph_id);
2N/Astruct grub_font_glyph *
2N/AEXPORT_FUNC (grub_font_construct_glyph) (grub_font_t hinted_font,
2N/A const struct grub_unicode_glyph *glyph_id);
2N/A
2N/A#endif /* ! GRUB_FONT_HEADER */