Path: blob/main/sys/contrib/edk2/Include/Protocol/HiiFont.h
96339 views
/** @file1The file provides services to retrieve font information.23Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>4SPDX-License-Identifier: BSD-2-Clause-Patent56@par Revision Reference:7This Protocol was introduced in UEFI Specification 2.1.89**/1011#ifndef __HII_FONT_H__12#define __HII_FONT_H__1314#include <Protocol/GraphicsOutput.h>15#include <Protocol/HiiImage.h>1617#define EFI_HII_FONT_PROTOCOL_GUID \18{ 0xe9ca4775, 0x8657, 0x47fc, { 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 } }1920typedef struct _EFI_HII_FONT_PROTOCOL EFI_HII_FONT_PROTOCOL;2122typedef VOID *EFI_FONT_HANDLE;2324///25/// EFI_HII_OUT_FLAGS.26///27typedef UINT32 EFI_HII_OUT_FLAGS;2829#define EFI_HII_OUT_FLAG_CLIP 0x0000000130#define EFI_HII_OUT_FLAG_WRAP 0x0000000231#define EFI_HII_OUT_FLAG_CLIP_CLEAN_Y 0x0000000432#define EFI_HII_OUT_FLAG_CLIP_CLEAN_X 0x0000000833#define EFI_HII_OUT_FLAG_TRANSPARENT 0x0000001034#define EFI_HII_IGNORE_IF_NO_GLYPH 0x0000002035#define EFI_HII_IGNORE_LINE_BREAK 0x0000004036#define EFI_HII_DIRECT_TO_SCREEN 0x000000803738/**39Definition of EFI_HII_ROW_INFO.40**/41typedef struct _EFI_HII_ROW_INFO {42///43/// The index of the first character in the string which is displayed on the line.44///45UINTN StartIndex;46///47/// The index of the last character in the string which is displayed on the line.48/// If this is the same as StartIndex, then no characters are displayed.49///50UINTN EndIndex;51UINTN LineHeight; ///< The height of the line, in pixels.52UINTN LineWidth; ///< The width of the text on the line, in pixels.5354///55/// The font baseline offset in pixels from the bottom of the row, or 0 if none.56///57UINTN BaselineOffset;58} EFI_HII_ROW_INFO;5960///61/// Font info flag. All flags (FONT, SIZE, STYLE, and COLOR) are defined.62/// They are defined as EFI_FONT_INFO_***63///64typedef UINT32 EFI_FONT_INFO_MASK;6566#define EFI_FONT_INFO_SYS_FONT 0x0000000167#define EFI_FONT_INFO_SYS_SIZE 0x0000000268#define EFI_FONT_INFO_SYS_STYLE 0x0000000469#define EFI_FONT_INFO_SYS_FORE_COLOR 0x0000001070#define EFI_FONT_INFO_SYS_BACK_COLOR 0x0000002071#define EFI_FONT_INFO_RESIZE 0x0000100072#define EFI_FONT_INFO_RESTYLE 0x0000200073#define EFI_FONT_INFO_ANY_FONT 0x0001000074#define EFI_FONT_INFO_ANY_SIZE 0x0002000075#define EFI_FONT_INFO_ANY_STYLE 0x000400007677//78// EFI_FONT_INFO79//80typedef struct {81EFI_HII_FONT_STYLE FontStyle;82UINT16 FontSize; ///< character cell height in pixels83CHAR16 FontName[1];84} EFI_FONT_INFO;8586/**87Describes font output-related information.8889This structure is used for describing the way in which a string90should be rendered in a particular font. FontInfo specifies the91basic font information and ForegroundColor and BackgroundColor92specify the color in which they should be displayed. The flags93in FontInfoMask describe where the system default should be94supplied instead of the specified information. The flags also95describe what options can be used to make a match between the96font requested and the font available.97**/98typedef struct _EFI_FONT_DISPLAY_INFO {99EFI_GRAPHICS_OUTPUT_BLT_PIXEL ForegroundColor;100EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackgroundColor;101EFI_FONT_INFO_MASK FontInfoMask;102EFI_FONT_INFO FontInfo;103} EFI_FONT_DISPLAY_INFO;104105/**106107This function renders a string to a bitmap or the screen using108the specified font, color and options. It either draws the109string and glyphs on an existing bitmap, allocates a new bitmap,110or uses the screen. The strings can be clipped or wrapped.111Optionally, the function also returns the information about each112row and the character position on that row. If113EFI_HII_OUT_FLAG_CLIP is set, then text will be formatted only114based on explicit line breaks and all pixels which would lie115outside the bounding box specified by Width and Height are116ignored. The information in the RowInfoArray only describes117characters which are at least partially displayed. For the final118row, the LineHeight and BaseLine may describe pixels that are119outside the limit specified by Height (unless120EFI_HII_OUT_FLAG_CLIP_CLEAN_Y is specified) even though those121pixels were not drawn. The LineWidth may describe pixels which122are outside the limit specified by Width (unless123EFI_HII_OUT_FLAG_CLIP_CLEAN_X is specified) even though those124pixels were not drawn. If EFI_HII_OUT_FLAG_CLIP_CLEAN_X is set,125then it modifies the behavior of EFI_HII_OUT_FLAG_CLIP so that126if a character's right-most on pixel cannot fit, then it will127not be drawn at all. This flag requires that128EFI_HII_OUT_FLAG_CLIP be set. If EFI_HII_OUT_FLAG_CLIP_CLEAN_Y129is set, then it modifies the behavior of EFI_HII_OUT_FLAG_CLIP130so that if a row's bottom-most pixel cannot fit, then it will131not be drawn at all. This flag requires that132EFI_HII_OUT_FLAG_CLIP be set. If EFI_HII_OUT_FLAG_WRAP is set,133then text will be wrapped at the right-most line-break134opportunity prior to a character whose right-most extent would135exceed Width. If no line-break opportunity can be found, then136the text will behave as if EFI_HII_OUT_FLAG_CLIP_CLEAN_X is set.137This flag cannot be used with EFI_HII_OUT_FLAG_CLIP_CLEAN_X. If138EFI_HII_OUT_FLAG_TRANSPARENT is set, then BackgroundColor is139ignored and all 'off' pixels in the character's drawn140will use the pixel value from Blt. This flag cannot be used if141Blt is NULL upon entry. If EFI_HII_IGNORE_IF_NO_GLYPH is set,142then characters which have no glyphs are not drawn. Otherwise,143they are replaced with Unicode character code 0xFFFD (REPLACEMENT144CHARACTER). If EFI_HII_IGNORE_LINE_BREAK is set, then explicit145line break characters will be ignored. If146EFI_HII_DIRECT_TO_SCREEN is set, then the string will be written147directly to the output device specified by Screen. Otherwise the148string will be rendered to the bitmap specified by Bitmap.149150@param This A pointer to the EFI_HII_FONT_PROTOCOL instance.151152@param Flags Describes how the string is to be drawn.153154@param String Points to the null-terminated string to be155156@param StringInfo Points to the string output information,157including the color and font. If NULL, then158the string will be output in the default159system font and color.160161@param Blt If this points to a non-NULL on entry, this points162to the image, which is Width pixels wide and163Height pixels high. The string will be drawn onto164this image and EFI_HII_OUT_FLAG_CLIP is implied.165If this points to a NULL on entry, then a buffer166will be allocated to hold the generated image and167the pointer updated on exit. It is the caller's168responsibility to free this buffer.169170@param BltX, BltY Specifies the offset from the left and top171edge of the image of the first character172cell in the image.173174@param RowInfoArray If this is non-NULL on entry, then on175exit, this will point to an allocated buffer176containing row information and177RowInfoArraySize will be updated to contain178the number of elements. This array describes179the characters that were at least partially180drawn and the heights of the rows. It is the181caller's responsibility to free this buffer.182183@param RowInfoArraySize If this is non-NULL on entry, then on184exit it contains the number of185elements in RowInfoArray.186187@param ColumnInfoArray If this is non-NULL, then on return it188will be filled with the horizontal189offset for each character in the190string on the row where it is191displayed. Non-printing characters192will have the offset ~0. The caller is193responsible for allocating a buffer large194enough so that there is one entry for195each character in the string, not196including the null-terminator. It is197possible when character display is198normalized that some character cells199overlap.200201@retval EFI_SUCCESS The string was successfully updated.202203@retval EFI_OUT_OF_RESOURCES Unable to allocate an output buffer for RowInfoArray or Blt.204205@retval EFI_INVALID_PARAMETER The String or Blt was NULL.206207@retval EFI_INVALID_PARAMETER Flags were invalid combination.208**/209typedef210EFI_STATUS211(EFIAPI *EFI_HII_STRING_TO_IMAGE)(212IN CONST EFI_HII_FONT_PROTOCOL *This,213IN EFI_HII_OUT_FLAGS Flags,214IN CONST EFI_STRING String,215IN CONST EFI_FONT_DISPLAY_INFO *StringInfo,216IN OUT EFI_IMAGE_OUTPUT **Blt,217IN UINTN BltX,218IN UINTN BltY,219OUT EFI_HII_ROW_INFO **RowInfoArray OPTIONAL,220OUT UINTN *RowInfoArraySize OPTIONAL,221OUT UINTN *ColumnInfoArray OPTIONAL222);223224/**225226This function renders a string as a bitmap or to the screen227and can clip or wrap the string. The bitmap is either supplied228by the caller or allocated by the function. The229strings are drawn with the font, size and style specified and230can be drawn transparently or opaquely. The function can also231return information about each row and each character's232position on the row. If EFI_HII_OUT_FLAG_CLIP is set, then233text will be formatted based only on explicit line breaks, and234all pixels that would lie outside the bounding box specified235by Width and Height are ignored. The information in the236RowInfoArray only describes characters which are at least237partially displayed. For the final row, the LineHeight and238BaseLine may describe pixels which are outside the limit239specified by Height (unless EFI_HII_OUT_FLAG_CLIP_CLEAN_Y is240specified) even though those pixels were not drawn. If241EFI_HII_OUT_FLAG_CLIP_CLEAN_X is set, then it modifies the242behavior of EFI_HII_OUT_FLAG_CLIP so that if a character's243right-most on pixel cannot fit, then it will not be drawn at244all. This flag requires that EFI_HII_OUT_FLAG_CLIP be set. If245EFI_HII_OUT_FLAG_CLIP_CLEAN_Y is set, then it modifies the246behavior of EFI_HII_OUT_FLAG_CLIP so that if a row's bottom247most pixel cannot fit, then it will not be drawn at all. This248flag requires that EFI_HII_OUT_FLAG_CLIP be set. If249EFI_HII_OUT_FLAG_WRAP is set, then text will be wrapped at the250right-most line-break opportunity prior to a character whose251right-most extent would exceed Width. If no line-break252opportunity can be found, then the text will behave as if253EFI_HII_OUT_FLAG_CLIP_CLEAN_X is set. This flag cannot be used254with EFI_HII_OUT_FLAG_CLIP_CLEAN_X. If255EFI_HII_OUT_FLAG_TRANSPARENT is set, then BackgroundColor is256ignored and all off" pixels in the character's glyph will257use the pixel value from Blt. This flag cannot be used if Blt258is NULL upon entry. If EFI_HII_IGNORE_IF_NO_GLYPH is set, then259characters which have no glyphs are not drawn. Otherwise, they260are replaced with Unicode character code 0xFFFD (REPLACEMENT261CHARACTER). If EFI_HII_IGNORE_LINE_BREAK is set, then explicit262line break characters will be ignored. If263EFI_HII_DIRECT_TO_SCREEN is set, then the string will be264written directly to the output device specified by Screen.265Otherwise the string will be rendered to the bitmap specified266by Bitmap.267268269@param This A pointer to the EFI_HII_FONT_PROTOCOL instance.270271@param Flags Describes how the string is to be drawn.272273@param PackageList274The package list in the HII database to275search for the specified string.276277@param StringId The string's id, which is unique within278PackageList.279280@param Language Points to the language for the retrieved281string. If NULL, then the current system282language is used.283284@param StringInfo Points to the string output information,285including the color and font. If NULL, then286the string will be output in the default287system font and color.288289@param Blt If this points to a non-NULL on entry, this points290to the image, which is Width pixels wide and291Height pixels high. The string will be drawn onto292this image and EFI_HII_OUT_FLAG_CLIP is implied.293If this points to a NULL on entry, then a buffer294will be allocated to hold the generated image and295the pointer updated on exit. It is the caller's296responsibility to free this buffer.297298@param BltX, BltY Specifies the offset from the left and top299edge of the output image of the first300character cell in the image.301302@param RowInfoArray If this is non-NULL on entry, then on303exit, this will point to an allocated304buffer containing row information and305RowInfoArraySize will be updated to306contain the number of elements. This array307describes the characters which were at308least partially drawn and the heights of309the rows. It is the caller's310responsibility to free this buffer.311312@param RowInfoArraySize If this is non-NULL on entry, then on313exit it contains the number of314elements in RowInfoArray.315316@param ColumnInfoArray If non-NULL, on return it is filled317with the horizontal offset for each318character in the string on the row319where it is displayed. Non-printing320characters will have the offset ~0.321The caller is responsible to allocate322a buffer large enough so that there is323one entry for each character in the324string, not including the325null-terminator. It is possible when326character display is normalized that327some character cells overlap.328329330@retval EFI_SUCCESS The string was successfully updated.331332@retval EFI_OUT_OF_RESOURCES Unable to allocate an output333buffer for RowInfoArray or Blt.334335@retval EFI_INVALID_PARAMETER The String, or Blt, or Height, or336Width was NULL.337@retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.338@retval EFI_INVALID_PARAMETER Flags were invalid combination.339@retval EFI_NOT_FOUND The specified PackageList is not in the Database,340or the stringid is not in the specified PackageList.341342**/343typedef344EFI_STATUS345(EFIAPI *EFI_HII_STRING_ID_TO_IMAGE)(346IN CONST EFI_HII_FONT_PROTOCOL *This,347IN EFI_HII_OUT_FLAGS Flags,348IN EFI_HII_HANDLE PackageList,349IN EFI_STRING_ID StringId,350IN CONST CHAR8 *Language,351IN CONST EFI_FONT_DISPLAY_INFO *StringInfo OPTIONAL,352IN OUT EFI_IMAGE_OUTPUT **Blt,353IN UINTN BltX,354IN UINTN BltY,355OUT EFI_HII_ROW_INFO **RowInfoArray OPTIONAL,356OUT UINTN *RowInfoArraySize OPTIONAL,357OUT UINTN *ColumnInfoArray OPTIONAL358);359360/**361362Convert the glyph for a single character into a bitmap.363364@param This A pointer to the EFI_HII_FONT_PROTOCOL instance.365366@param Char The character to retrieve.367368@param StringInfo Points to the string font and color369information or NULL if the string should use370the default system font and color.371372@param Blt This must point to a NULL on entry. A buffer will373be allocated to hold the output and the pointer374updated on exit. It is the caller's responsibility375to free this buffer.376377@param Baseline The number of pixels from the bottom of the bitmap378to the baseline.379380381@retval EFI_SUCCESS The glyph bitmap created.382383@retval EFI_OUT_OF_RESOURCES Unable to allocate the output buffer Blt.384385@retval EFI_WARN_UNKNOWN_GLYPH The glyph was unknown and was386replaced with the glyph for387Unicode character code 0xFFFD.388389@retval EFI_INVALID_PARAMETER Blt is NULL, or Width is NULL, or390Height is NULL391392393**/394typedef395EFI_STATUS396(EFIAPI *EFI_HII_GET_GLYPH)(397IN CONST EFI_HII_FONT_PROTOCOL *This,398IN CONST CHAR16 Char,399IN CONST EFI_FONT_DISPLAY_INFO *StringInfo,400OUT EFI_IMAGE_OUTPUT **Blt,401OUT UINTN *Baseline OPTIONAL402);403404/**405406This function iterates through fonts which match the specified407font, using the specified criteria. If String is non-NULL, then408all of the characters in the string must exist in order for a409candidate font to be returned.410411@param This A pointer to the EFI_HII_FONT_PROTOCOL instance.412413@param FontHandle On entry, points to the font handle returned414by a previous call to GetFontInfo() or NULL415to start with the first font. On return,416points to the returned font handle or points417to NULL if there are no more matching fonts.418419@param StringInfoIn Upon entry, points to the font to return420information about. If NULL, then the information421about the system default font will be returned.422423@param StringInfoOut Upon return, contains the matching font's information.424If NULL, then no information is returned. This buffer425is allocated with a call to the Boot Service AllocatePool().426It is the caller's responsibility to call the Boot427Service FreePool() when the caller no longer requires428the contents of StringInfoOut.429430@param String Points to the string which will be tested to431determine if all characters are available. If432NULL, then any font is acceptable.433434@retval EFI_SUCCESS Matching font returned successfully.435436@retval EFI_NOT_FOUND No matching font was found.437438@retval EFI_OUT_OF_RESOURCES There were insufficient resources to complete the request.439440**/441typedef442EFI_STATUS443(EFIAPI *EFI_HII_GET_FONT_INFO)(444IN CONST EFI_HII_FONT_PROTOCOL *This,445IN OUT EFI_FONT_HANDLE *FontHandle,446IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn OPTIONAL,447OUT EFI_FONT_DISPLAY_INFO **StringInfoOut,448IN CONST EFI_STRING String OPTIONAL449);450451///452/// The protocol provides the service to retrieve the font informations.453///454struct _EFI_HII_FONT_PROTOCOL {455EFI_HII_STRING_TO_IMAGE StringToImage;456EFI_HII_STRING_ID_TO_IMAGE StringIdToImage;457EFI_HII_GET_GLYPH GetGlyph;458EFI_HII_GET_FONT_INFO GetFontInfo;459};460461extern EFI_GUID gEfiHiiFontProtocolGuid;462463#endif464465466