📄 gpcfont.c
字号:
///////////////////////////////////////////////////////////////////////////////////
//
// 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 "gpc.h"
// 1999.12.02 By Shin :: Add Font2 Table Entry
static U32 gTableEntry[100];
extern gpcGCValues gpcGC;
#ifndef _GB2312_
//-------------------------------------------------------------------------
// gpcMakeFont2TableEntry()
//
// Make Font to Table Entry.
//
// Parameters:
// TableEntry - Points to Table Entry .
// TableSize - Points to Table Size .
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
static U16 gpcMakeFont2TableEntry( U8 *TableEntry, S16 TableSize)
{
S16 i;
U32 ulTotal = 0;
// 1999.12.03 By Shin :: Add Font2 Table Entry
gTableEntry[0] = 0;
for(i=0; i<TableSize-1; i++)
{
ulTotal += (U32)*(TableEntry+(i*4)+2) - (U32)*(TableEntry+(i*4)) + 1;
gTableEntry[i+1] = ulTotal ;
}
return GPC_ERR_OK;
}
//-------------------------------------------------------------------------
// gpcFont2StartPoint()
//
// Make Font to Table Entry.
//
// Parameters:
// text - Point to text .
// Returns:
// ucStartPoint - Start Point From Font File
//-------------------------------------------------------------------------
U32 gpcFont2StartPoint( U8 *text )
{
S16 i;
U8 *pEntry;
U32 ucStartPoint;
// 1999.12.03 By Shin :: Add Font2 Start Point Count
pEntry = gpcGC.GCTableEntry;
for(i=0; i<gpcGC.GCTableSize; i++)
{
if(*text == *(pEntry+(i*4) + 1))
{
if((*(text+1) >= *(pEntry+(i*4) )) && (*(text+1) <= *(pEntry+(i*4) + 2)))
{
ucStartPoint = gTableEntry[i] + (U32)*(text+1) - (U32)*(pEntry+(i*4));
return ucStartPoint;
}
}
}
return GPC_ERR_OK;
}
//-------------------------------------------------------------------------
// gpcSetFont()
//
// Set Font .
//
// Parameters:
// font1 - Points to 1byte font .
// font2 - Points to 2byte font .
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
U16 gpcSetFont(U8* font1, U8* font2)
{
// 2000.04.20 Add by Shin :: Initialize Fonts
gpcGC.GCFont1 = (U8*)0; // Set Null to point for Font1
gpcGC.GCFont2 = (U8*)0; // Set Null to point for Font2
if(font1)
{
// 2000.02.28 Update By Shin : Check FONT2X Font
if(strncmp(font1, "FONTX2", 6) != 0)
return GPC_ERR_FONT;
gpcGC.GCFont1 = font1 + 17; // 17 means header size
gpcGC.GCFont1Width = *(font1 + 14); // 14 means offset of width
gpcGC.GCFont1Height = *(font1 + 15); // 15 means offset of height
}
// 1999.12.03 By Shin :: Add 2Byte Font GPCFONT11K(ZENNKAKU)
if(font2)
{
// 2000.02.28 Update By Shin : Check FONT2X Font
if(strncmp(font2, "FONTX2", 6) != 0)
return GPC_ERR_FONT;
gpcGC.GCTableSize = *(font2 + 17); // 17 means Entry size
gpcGC.GCTableEntry = font2 + 18; // 18 means offset of Table Entry
gpcGC.GCFont2 = font2 + gpcGC.GCTableSize*4 + 18 ; // Font patten Start Point
gpcGC.GCFont2Width = *(font2 + 14); // 14 means offset of width
gpcGC.GCFont2Height = *(font2 + 15); // 15 means offset of height
// Process 2Byte Font Table Entry
gpcMakeFont2TableEntry(gpcGC.GCTableEntry, gpcGC.GCTableSize);
}
return GPC_ERR_OK;
}
#else
//-------------------------------------------------------------------------
// gpcCheckFontByte(U8* text)
//
// Make Font to Table Entry.
//
// Parameters:
// text - Points to checked character .
// Returns:
// 0:Error 1: 1byte 2:2byte
//-------------------------------------------------------------------------
U16 gpcCheckFontByte(U8* text)
{
if(*text >= 0x20 && *text <=0x7e)
return 1;
else if(*text>=0xa0 && *text<=0xfe)
return 2;
else
return 0;
}
//-------------------------------------------------------------------------
// gpcMakeFont2TableEntry()
//
// Make Font to Table Entry.
//
// Parameters:
// TableEntry - Points to Table Entry .
// TableSize - Points to Table Size .
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
static U16 gpcMakeFont2TableEntry(U8* TableEntry, S16 TableSize)
{
S16 i;
U32 ulTotal=0;
// 1999.12.03 By Shin :: Add Font2 Table Entry
gTableEntry[0] = 0;
for(i=0; i<TableSize-1; i++)
{
ulTotal += (U32)*(TableEntry+(i*4)+2) - (U32)*(TableEntry+(i*4)) + 1;
gTableEntry[i+1] = ulTotal ;
}
return GPC_ERR_OK;
}
//-------------------------------------------------------------------------
// gpcFont2StartPoint()
//
// Make Font to Table Entry.
//
// Parameters:
// text - Point to text .
// Returns:
// ucStartPoint - Start Point From Font File
//-------------------------------------------------------------------------
U32 gpcFont2StartPoint(U8* text){
// int i;
// U8* pEntry;
U32 ucStartPoint;
// 1999.12.03 By Shin :: Add Font2 Start Point Count
/* pEntry = gpcGC.GCTableEntry;
for(i=0; i<gpcGC.GCTableSize; i++){
if(*text == *(pEntry+(i*4) + 1)) {
if((*(text+1) >= *(pEntry+(i*4) )) && (*(text+1) <= *(pEntry+(i*4) + 2))) {
ucStartPoint = gTableEntry[i] + (U32)*(text+1) - (U32)*(pEntry+(i*4));
return ucStartPoint;
}
}
}
*/
ucStartPoint = (*text-160-1)*94 +(*(text+1)-160-1);
return ucStartPoint;
//
// return GPC_ERR_OK;
}
//-------------------------------------------------------------------------
// gpcSetFont()
//
// Set Font .
//
// Parameters:
// font1 - Points to 1byte font .
// font2 - Points to 2byte font .
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
U16 gpcSetFont(U8* font1, U8* font2){
// 2000.04.20 Add by Shin :: Initialize Fonts
gpcGC.GCFont1 = (U8*)0; // Set Null to point for Font1
gpcGC.GCFont2 = (U8*)0; // Set Null to point for Font2
if(font1)
{
// 2000.02.28 Update By Shin : Check FONT2X Font
if(strncmp(font1, "FONTX2", 6) != 0)
return GPC_ERR_FONT;
gpcGC.GCFont1 = font1 + 17; // 17 means header size
gpcGC.GCFont1Width = *(font1 + 14); // 14 means offset of width
gpcGC.GCFont1Height = *(font1 + 15); // 15 means offset of height
}
// 1999.12.03 By Shin :: Add 2Byte Font GPCFONT11K(ZENNKAKU)
if(font2)
{
// 2000.02.28 Update By Shin : Check FONT2X Font
if(strncmp(font2, "FONTX2", 6) != 0)
return GPC_ERR_FONT;
gpcGC.GCTableSize = 0x0;//*(font2 + 17); // 17 means Entry size
gpcGC.GCTableEntry = 0x0;//font2 + 18; // 18 means offset of Table Entry
gpcGC.GCFont2 = font2+17;//font2 + gpcGC.GCTableSize*4 + 18 ; // Font patten Start Point
gpcGC.GCFont2Width = *(font2 + 14); // 14 means offset of width
gpcGC.GCFont2Height = *(font2 + 15); // 15 means offset of height
// Process 2Byte Font Table Entry
//gpcMakeFont2TableEntry(gpcGC.GCTableEntry, gpcGC.GCTableSize);
}
return GPC_ERR_OK;
}
#endif
//-------------------------------------------------------------------------
// gpcGetFont()
//
// Get Font .
//
// Parameters:
// font1 - Points to 1byte font .
// font2 - Points to 2byte font .
// Returns:
// GPC_ERR_OK
//-------------------------------------------------------------------------
U16 gpcGetFont( U8* font1, U8* font2)
{
if(*font1)
font1 = gpcGC.GCFont1;
if(*font2)
font2 = gpcGC.GCFont2;
return GPC_ERR_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -