📄 osdshowfont.c
字号:
#include "global.h"
#include "func.h"
#include "user_init.h"
#if defined( OSD_FONT_API ) && defined( SUPPORT_FONT_UTIL )
#include "LanguageUtil.h"
#include "font_lowercase.c" //display lower letter ,suqiaoli add 2004-4-28
extern void osd_draw_gbfont(BYTE vid, BYTE pFont[], int xStart, int yStart, unsigned int fwidth, unsigned int fhight, BYTE fontcolor,BYTE number);
extern const unsigned char LOWERCASE_FONT_BITMAP[];
#define lowercase_table LOWERCASE_FONT_BITMAP
#define FONT_LEN_EXTERNAL_TWO_BYTE 14
#define FONT_LEN_INTERNAL_OSD 9
#if defined(EUROPE_FOREIGN_LANGUAGES) || defined(MIDDLE_EUROPE_LANGUAGES) || defined (SUPPORT_TURKISH_LANGUAGES) || defined ( USE_CYRILLIC_FONT )
#define FONT_LEN_EXTERNAL_ONE_BYTE 6
#else
#define FONT_LEN_EXTERNAL_ONE_BYTE FONT_LEN_INTERNAL_OSD
#endif
extern void EnlargeFontSizeToDouble( UINT8 *pDest, const UINT8 *pSrc, BYTE uiWidth, BYTE uiHeight );
extern void ResampleWidthFrom12PixelTo16Pixel( UINT8* pDest, const UINT8* pSrc, UINT32 uiHeight );
UINT32 OSD_ShowChar(int x, int y, BYTE c, BYTE fontcolor,BYTE r)
{
BYTE *pFont;
BYTE width,height;
UINT8 font1[48];
int index;
int i;
if ((c >= 'a') && (c <= 'z'))//litter case
{
width = 16;
height = 24;
index = 48 * (c - 97);
//draw a character
for (i = 0; i < 24; i++)
{
UINT8 cc1,cc2;
cc1 = lowercase_table[index+i*2];
cc2 = lowercase_table[index+i*2+1];
font1[i*2]=cc1;
font1[i*2+1]=cc2;
}
osd_draw_gbfont( 0, (UINT8 *)font1, x, y, width, height, fontcolor, r );
}
else
{
pFont = get_font_entry(0,c);
width = pFont[0];
height = pFont[1];
osd_draw_gbfont( 1, (UINT8 *)pFont, x, y, width, height, fontcolor, r );
}
return FONT_LEN_INTERNAL_OSD;
}
UINT32 OSD_FontShowChar(int x, int y, const BYTE* pBmp, BYTE fontcolor,BYTE r )
{ // 2004/09/23 yltseng
UINT8 aFont1[ 24 ];
UINT8 aFont2[ 96 ]; // 24 * 2 * 2
ENUM_FONT_TYPE enType = GetFontType();
if( enType == FONT_BIG5 || enType == FONT_BIG5_COMMON ||
enType == FONT_GB2312 || enType == FONT_JIS ||
enType == FONT_KSC || enType == FONT_RUSSIAN )
{
ResampleWidthFrom12PixelTo16Pixel( aFont1, pBmp, 12 );
EnlargeFontSizeToDouble( (UINT8 *)aFont2, (UINT8 *)aFont1, 16, 12 );
osd_draw_gbfont( 0, (UINT8 *)aFont2, x, y, 32, 24, fontcolor, r );
return FONT_LEN_EXTERNAL_TWO_BYTE;
}
else if( enType == FONT_ISO_8859_1 || enType == FONT_ISO_8859_2 || enType == FONT_ISO_8859_5|| enType == FONT_ISO_8859_9 )
{
ResampleWidthFrom12PixelTo16Pixel( aFont2, pBmp, 24 );
osd_draw_gbfont( 0, (UINT8 *)aFont2, x, y, 16, 24, fontcolor, r );
return FONT_LEN_EXTERNAL_ONE_BYTE;
}
return 0;
//wanghaoying add from 'else' sequence 2005-1-5 15:33
//for this function did nothing while enType = FONT_NONE
//such satuation will happen if undef SUPPORT_FONT_UTIL
//NOTICE: I don't know wheather should return 0
}
void OSD_ShowString( int x, int y, const char *s, BYTE fontcolor, BYTE r )
{
const BYTE* p = s;
while( *p )
{
const UINT8* pBmp = NULL;
UINT32 uiRtnVal = GetCharacterBmp( p, &pBmp );
if( uiRtnVal != FONT_NOT_IN_RANGE )
{
x += OSD_FontShowChar( x, y, pBmp, fontcolor, r ); // 2004/09/23 yltseng
if( uiRtnVal == FONT_ONE_BYTE )
p++;
else
p += 2;
}
else
{
BYTE c = *p;
if ( (c < 32) || (c > 126) )
c = '_';
x += OSD_ShowChar( x, y, c, fontcolor, r);
p++;
}
if( x > region[r].osd_w )
break;
}
}
#ifdef SUPPORT_OSDSRT
/*
*Function:display text to osd,display max line:7,display max chinese font in a line:19
*Parameter:*p:input string
* Size:length of string
*Return:none
*Creator:suqiaoli
*Date:2004-3-17
*Date:2004/09/06 yltseng modify
*/
void ShowOSDText(const char *p, UINT16 size)
{
// 2004/09/03 yltseng
#define MAX_WORD 50
#ifdef SDRAM_16Mb_Mode
#define MAX_LINE 2
#else
#define MAX_LINE 7
#endif
BYTE*pStr = (BYTE *)p;
BYTE c,c1;
BYTE *old_pStr;
int old_i_len;
int show_line = -1;
int show_word = 0;
UINT16 nsize=0;
int i_len;
int len[MAX_LINE];
int i;
int count;
//All char will be put into this str array
//if string long,it will newline
BYTE str[MAX_LINE][MAX_WORD];
osd_tog_region( 3, OSD_ON );
//Read and parse each char,display them on osd
//include function:display more lines,newline,
//when string length>276,it will newline
while(nsize<size)
{
show_word = 0;
i_len = 0;
count = 0;
show_line++;
if( show_line > MAX_LINE - 1 )//most displayed line is 7 line
{
show_line = MAX_LINE - 1;
break;
}
//read string to string buffer,except "return","next line"
while(((*pStr) != '\r')/*&& ((*pStr)!='\n')*/ )
{
c = *pStr;
c1 = *(pStr + 1);
UINT32 uiRtnVal = IsInCharacterSet( pStr );
if(c=='\n')//wangap add 2005/1/25
{ //if '\n' not jump next line just continue
pStr++;
nsize++;
continue;
}
if( uiRtnVal == FONT_NOT_IN_RANGE )
{
if ((c >= 32) && (c <= 126))
uiRtnVal = FONT_ONE_BYTE;
}
if( uiRtnVal == FONT_TWO_BYTE )
{
str[show_line][show_word]=c;
str[show_line][show_word+1]=c1;
show_word+= 2;
i_len+= FONT_LEN_EXTERNAL_TWO_BYTE;
nsize+= 2;
pStr += 2;
if((((i_len-count*9)%2==0)&&(i_len>275))||(((i_len-count*9)%2==0)&&(i_len>276)))
break;
}
else if( uiRtnVal == FONT_ONE_BYTE )
{
old_pStr = pStr;
old_i_len = i_len;
str[show_line][show_word]=c;
show_word += 1;
i_len += FONT_LEN_EXTERNAL_ONE_BYTE;//len
nsize += 1;
pStr += 1;
if(c == 32) //not to cut off a long word,according to space's position
{
do
{
old_pStr ++;
old_i_len += FONT_LEN_EXTERNAL_ONE_BYTE;//len
if((*old_pStr == 32)|| (*old_pStr == '\r')||(old_i_len > 276))
break;
}while(1);
if (old_i_len > 276)
break;
}
else
{
count++;
if (i_len>276)
break;
}
}
else
{
c = '?';
str[show_line][show_word]=c;
show_word+= 1;
nsize+= 1;
i_len+= FONT_LEN_INTERNAL_OSD;
pStr += 1;
count++;
if (i_len>276)
break;
}
}//while(((*pStr) != '\r')&& ((*pStr)!='\n') )
if(((*pStr) == '\r')/*||((*pStr) == '\n')*/)//count nsize,'\r':when "return",'\n':next line is blank
{ //'\n' just count nsize not jump next line wangap add 2005/1/25
pStr++;
nsize++;
}
len[show_line]=i_len;
str[show_line][show_word]='\0';
if( show_word <= 0 )//if blank line,string line will skip
show_line--;
} //while(nsize<size)
int width = (int) region[3].osd_w;
int height = (int) region[3].osd_h/MAX_LINE;
for( i = show_line; i >= 0; i-- )//display each line srt title
{
int xstart = ( width - len[i] ) / 2;
int ystart = height * ( MAX_LINE - ( show_line - i ) - 1 );
OSD_ShowString( xstart, ystart, str[i], 2, 3 );
}
}
#endif //#ifdefSUPPORT_OSDSRT
#endif //#if defined( OSD_FONT_API ) && defined( SUPPORT_FONT_UTIL )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -