📄 msapi_font.c
字号:
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006-2007 MStar Semiconductor, Inc.
// All rights reserved.
//
// Unless otherwise stipulated in writing, any and all information contained
// herein regardless in any format shall remain the sole proprietary of
// MStar Semiconductor Inc. and be kept in strict confidence
// (¨MStar Confidential Information〃) by the recipient.
// Any unauthorized act including without limitation unauthorized disclosure,
// copying, use, reproduction, sale, distribution, modification, disassembling,
// reverse engineering and compiling of the contents of MStar Confidential
// Information is unlawful and strictly prohibited. MStar hereby reserves the
// rights to any and all damages, losses, costs and expenses resulting therefrom.
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
/// @file msAPI_Font.h
/// @brief API for font handling
/// @author MStar Semiconductor, Inc.
//
////////////////////////////////////////////////////////////////////////////////
#define MSAPI_FONT_C
#include <stdio.h>
#include "board.h"
#include "hwreg.h"
#include "DataType.h"
#include "drvge.h"
#include "drvflash.h"
#include "drvmiu.h"
#include "msAPI_Font.h"
#include "msAPI_Miu.h"
/******************************************************************************/
/// API for font header::
/// Read font header on flash
/// @param u16FontBinID \b IN Font ID in the packed binary
/// @param pFontBinHeader \b IN Pointer to returning FONT_BIN_HEADER
/// @param pu32BinBaseAddr \b IN Pointer to returning base address of the specified font ID
/// @return BOOLEAN:
///- TRUE: Success
///- FALSE: Fail
/******************************************************************************/
bool msAPI_Font_ReadBinHeader(U16 u16FontBinID, FONT_BIN_HEADER *pFontBinHeader, U32 *pu32BinBaseAddr)
{
BINFORMAT BinInfo;
BinInfo.B_ID = u16FontBinID;
if (msAPI_MIU_Get_BinInfo(&BinInfo) != PASS)
{
return false;
}
*pu32BinBaseAddr = BinInfo.B_FAddr;
MDrv_Flash_Read(BinInfo.B_FAddr, sizeof(FONT_BIN_HEADER), (U8 *)pFontBinHeader);
return (pFontBinHeader->u32Tag == FONT_HEADER_TAG);
}
/******************************************************************************/
/// API for font header::
/// Get the size of one line in byte
/// @param pFontBinHeader \b IN Pointer to FONT_BIN_HEADER
/// @return U8: Line bytes
/******************************************************************************/
U8 msAPI_Font_GetLineBytes(const FONT_BIN_HEADER *pFontBinHeader)
{
U8 u8PitchBits = pFontBinHeader->u32Pitch * 8;
return ((pFontBinHeader->u32Width+u8PitchBits-1)/u8PitchBits) * pFontBinHeader->u32Pitch * pFontBinHeader->u32BPP;
}
/******************************************************************************/
/// API for font header::
/// Get the size of one character glyph in byte including possible bottom paddings for alignment
/// @param pFontBinHeader \b IN Pointer to FONT_BIN_HEADER
/// @return U16: Character glyph bytes
/******************************************************************************/
U16 msAPI_Font_GetCharGlyphBytes(const FONT_BIN_HEADER *pFontBinHeader)
{
return (U16)pFontBinHeader->u32CharGlyphBytes;
}
/******************************************************************************/
/// API for font header::
/// Get the size in byte of the uncompressed font table
/// @param pFontBinHeader \b IN Pointer to FONT_BIN_HEADER
/// @return U8: Font table bytes
/******************************************************************************/
U32 msAPI_Font_GetFontGlyphBytes(const FONT_BIN_HEADER *pFontBinHeader)
{
return msAPI_Font_GetCharGlyphBytes(pFontBinHeader) * pFontBinHeader->u32CharNum;
}
#undef MSAPI_FONT_C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -