⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpcfont.c

📁 一个操作系统源代码 用于嵌入式设备 在Vc++环境下仿真 成功移植到多款处理器上
💻 C
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////////////
//
//        Copyright (C) 2001 SHANGHAI EPSON Corp.
//        All Rights Reserved
//
//        File name :gpc.h
//        Function  :
//            This is a GPC33 header file
//        Revision history
//            Ver 0.10 2001/01/11  Stella Yuan          Start
//            Ver 1.90 2001/06/01  CYu                  customize to plus version
//
///////////////////////////////////////////////////////////////////////////////////
#include <string.h>
#include <sys\gpc.h>
#include <sys\taskdsp.h>
#include <sys\systsk.h>

BYTE	CHINESE_CHAR_HEIGHT = 12;
BYTE	CHINESE_CHAR_WIDTH  = 12;
BYTE	ENGLISH_CHAR_WIDTH	= 6;
BYTE	ENGLISH_CHAR_HEIGHT	= 12;

PBYTE	ENGLISH_CHAR_ENTRY;
PBYTE	CHINESE_CHAR_ENTRY;

// 1999.12.02 By Shin :: Add Font2 Table Entry
//static DWORD gTableEntry[100];

#ifdef _GB2312_
/*
STATUS SysInitFont(  )	// longn_qi 2001/11/28 create this function
{
	PFONTHEADER pFontHead;
	
	pFontHead = ( PFONTHEADER )GPCFONT11A;
	if( strncmp( pFontHead->symbol, "FONTX2", 6 ) != 0 )
		return GPC_ERR_FONT;
	ENGLISH_CHAR_WIDTH = pFontHead->width;
	ENGLISH_CHAR_HEIGHT = pFontHead->height;
	ENGLISH_CHAR_ENTRY = ((PBYTE) GPCFONT11A) + sizeof( FONTHEADER );
	
	pFontHead = ( PFONTHEADER )GPCFONT11K;
	if( strncmp( pFontHead->symbol, "FONTX2", 6 ) != 0 )
		return GPC_ERR_FONT;
	CHINESE_CHAR_WIDTH = pFontHead->width;
	CHINESE_CHAR_HEIGHT = pFontHead->height;
	CHINESE_CHAR_ENTRY = ((PBYTE) GPCFONT11K) + sizeof( FONTHEADER );
	
	return GPC_ERR_OK;
}
*/

//-------------------------------------------------------------------------
//    SysSetFont()
//
//  Set Font .
//
//  Parameters:
//      font1    - Points to  1byte font .
//      font2    - Points to  2byte font .
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
STATUS SysSetFont( DWORD hGC, PBYTE font1, PBYTE font2 )
{
	GC *pGC;
	PFONTHEADER pFontHead;

	pGC = ( GC* )hGC;
	if ( pGC == NULL )//by zl 2002.4.3
		return GPC_ERR_FAILED;

	// 2000.04.20 Add by Shin :: Initialize Fonts
//    pGC->font->Font1 = NULL;   // Set Null to point for Font1
//    pGC->font->Font2 = NULL;   // Set Null to point for Font2
    
    if( font1 != NULL )
    {
/*        // 2000.02.28 Update By Shin : Check FONT2X Font 
        if(strncmp( font1, "FONTX2", 6) != 0 )
            return GPC_ERR_FONT;
        pGC->font->Font1 = font1 + 16;				// 16 means header size
        pGC->font->Font1Width  = *(font1 + 14);		// 14 means offset of width
        pGC->font->Font1Height = *(font1 + 15);		// 15 means offset of height
*/
		// longn_qi 2001/11/28 replaced above (5) with follow (6)
		pFontHead = ( PFONTHEADER )font1;
		if( strncmp( pFontHead->symbol, "FONTX2", 6 ) != 0 )
			return GPC_ERR_FONT;
		pGC->font->Font1Width = pFontHead->width;
		pGC->font->Font1Height = pFontHead->height;
		pGC->font->Font1 = font1 + sizeof( FONTHEADER );
	}

    // 1999.12.03 By Shin :: Add 2Byte Font GPCFONT11K(ZENNKAKU)
    if( font2 != NULL )
    {
/*        // 2000.02.28 Update By Shin : Check FONT2X Font 
        if( strncmp(font2, "FONTX2", 6) != 0 )
            return GPC_ERR_FONT;
        //hGC->font->TableSize  = 0x0;//(*(font2 + 17));   // 17 means Entry size
        //hGC->font->TableEntry = 0x0;//font2 + 18;      // 18 means offset of Table Entry
        pGC->font->Font2 = font2 + 16;//font2 + gpcGC.GCTableSize*4 + 18 ;  // Font patten Start Point
        pGC->font->Font2Width  = *(font2 + 14);   // 14 means offset of width
        pGC->font->Font2Height = *(font2 + 15);   // 15 means offset of height
        
        // Process 2Byte Font Table Entry
        //gpcMakeFont2TableEntry(gpcGC.GCTableEntry, gpcGC.GCTableSize);
*/
		// longn_qi 2001/11/28 replaced above (5) with follow (6)
		pFontHead = ( PFONTHEADER )font2;
		if( strncmp( pFontHead->symbol, "FONTX2", 6 ) != 0 )
			return GPC_ERR_FONT;
		pGC->font->Font2Width = pFontHead->width;
		pGC->font->Font2Height = pFontHead->height;
		pGC->font->Font2 = font2 + sizeof( FONTHEADER );

    }
    return GPC_ERR_OK;
}

#endif
//-------------------------------------------------------------------------
//    SysGetFont()
//
//  Get Font .
//
//  Parameters:
//      font1    - Points to  1byte font .
//      font2    - Points to  2byte font .
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
STATUS SysGetFont( DWORD hGC, PBYTE font1, PBYTE font2)
{
    GC *pGC;

	pGC = ( GC* )hGC;
	if ( pGC == NULL )//by zl 2002.4.3
		return GPC_ERR_FAILED;

	if( font1 != NULL )
        font1 = pGC->font->Font1;

    if( font2 != NULL )
        font2 = pGC->font->Font2;

    return GPC_ERR_OK;
}

//-------------------------------------------------------------------------
//    SysGetFontSize()
//
//  Get Font Size.
//
//  Parameters:
//      font1_W    - English character width.
//      font1_H    - English character height.
//      font2_W    - Chinese character width.
//      font2_H    - Chinese character height.
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
STATUS SysGetFontSize( DWORD hGC, PBYTE font1_W, PBYTE font1_H, PBYTE font2_W, PBYTE font2_H )
{
    GC *pGC;

	pGC = ( GC* )hGC;
	if ( pGC == NULL )//by zl 2002.4.3
		return GPC_ERR_FAILED;
	
	*font1_W = pGC->font->Font1Width;
	*font1_H = pGC->font->Font1Height;
	*font2_W = pGC->font->Font2Width;
	*font2_H = pGC->font->Font2Height;

    return GPC_ERR_OK;
}

//-------------------------------------------------------------------------
//    SysDrawText()
//
//  Draw text in the x, y with text's length.
//
//  Parameters:
//    Returns:
//      GPC_ERR_OK
//-------------------------------------------------------------------------
STATUS SysDrawText(DWORD gc, DWORD rgb, WORD xSrc, WORD ySrc, WORD xDes, WORD yDes, PBYTE text, WORD style)
{
    GC		*pGC;
	PBYTE	str;
	WORD	x, y;
    DWORD	ulFont2Start, font1size, font2size;
    PHYIMAGEINFO pii;
	PIXEL	frtcolor;//, bkcolor;
	WORD	quit = 0;

	pGC = ( GC* )gc;

	if ( pGC == NULL || pGC->symbol != GPC_GC_SYMBOL )	
	    return GPC_ERR_FAILED;		

	if ( text == NULL )
		return GPC_ERR_FAILED;

    if ( xDes <= xSrc || yDes <= ySrc )	//if ( xDes < xSrc || yDes < ySrc )	//by zhuli 2002.2.2
		return GPC_ERR_FAILED;
    if ( xDes > (pGC->width - 1) || yDes > (pGC->height - 1) )	//if ( xDes >= pGC->width || yDes >= pGC->height )	//by zhuli 2002.2.2
		return GPC_ERR_FAILED;
	
	if ( pGC->font->Font1 != NULL )
		font1size = pGC->font->Font1Height * ( ( pGC->font->Font1Width + 7 )>>3 );
	else
		font1size = 0;
	if ( pGC->font->Font2 != NULL )
		font2size = pGC->font->Font2Height * ( ( pGC->font->Font2Width + 7 )>>3 );
	else
		font2size = 0;	

	if ( !font1size && !font2size )
		return GPC_ERR_FAILED;
//	if ( xSrc + pGC->font->Font2Width > xDes + 1 || ySrc + pGC->font->Font2Height > yDes + 1 )
//		return GPC_ERR_FAILED;

//	if( style < GPC_MIN_STYLE || style > GPC_MAX_STYLE )
//		return GPC_ERR_FAILED;



    pii.method = style;
	pii.mode = GPC_TRANSPARENT_STYLE;
	pii.width = pGC->font->Font2Width;
	pii.height = pGC->font->Font2Height;

	seRGBtoIndex( (DWORD)(rgb), &frtcolor );
	//seRGBtoIndex( (DWORD)(gc->bk_color), &bkcolor );
    pii.ColorIndex = frtcolor;
    //pii.BkColorIndex = bkcolor;
	
	x = xSrc;
	y = ySrc;
	str = text;
    while ( *str != '\0' && quit != 1 )
    {
		pii.x = x;
        pii.y = y;
        // Check Font Byte ( 1:1Byte, 2:2Byte )
        switch ( gpcCheckFontByte( str ) )
        {
            case 1:
                // 2000.04.20 Add by Shin :: Check No Font
                if ( font1size == 0 )
                {
					str++;
					continue;
				}
                pii.buffer = pGC->font->Font1 + font1size * ( *str - ' ' );
                pii.width = pGC->font->Font1Width;
                pii.height = pGC->font->Font1Height;
				break;
            case 2:
                // 2000.04.20 Add by Shin :: Check No Font
                str++;
				if( *str & 0x80 == 0x00 )
				{
					quit = 1;
					continue;
				}
				if ( font2size == 0 )
                {
					str++;
					continue;
				}
                // Count Font2 patten Start Point
				if( *str == '\0' ) 
				{
					str++;
					continue;
				}
				ulFont2Start = ( *(str - 1) - 161 )*94 + ( *str - 161 );
                //if( ulFont2Start )
				//	continue;
				pii.buffer = pGC->font->Font2 + ulFont2Start * font2size; 
                pii.width = pGC->font->Font2Width;
                pii.height = pGC->font->Font2Height;
                break;
            default:
				switch ( *str )
				{
					case 0x0a:
						str++;
						x = xSrc;
						y += pii.height;
						if ( y > yDes+1 ) 
							quit = 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -