T168_111\appl\Text文件:2个文件

Text.c   。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

/******************************************************************************
 *                                                                            *
 *                         M O D U L E   D E F I N E                          *
 *                                                                            *
 ******************************************************************************/

#define TEXT_C

/******************************************************************************
 *                                                                            *
 *        C O M P I L E R   D E F I N E D   I N C L U D E   F I L E S         *
 *                                                                            *
 ******************************************************************************/

#include <stdlib.h>
#include <string.h>

/******************************************************************************
 *                                                                            *
 *            U S E R   D E F I N E D   I N C L U D E   F I L E S             *
 *                                                                            *
 ******************************************************************************/

#include "Common.h"
#include "XCore.h"
#include "BMF\Thai.h"
#include "BMF\BMF.h"
#include "Text.h"

#if defined(__HITACHI__)
#pragma section Font
#endif

#include "FontData\EanFont.c"

#if defined(TSPL) && defined(TSPL_VER_1)
#include "FontData\TsplFontOCR.c"
#include "FontData\TsplFontV1.c"
#include "FontData\Bf2Big5Half.c"
#include "FontData\OCRA36.c"
#endif

#if defined(TSPL) && defined(TSPL_VER_2)
#include "FontData\TsplFontOCR.c"
#include "FontData\TsplFontV2.c"
#endif

#if defined(EPL2)
#include "FontData\EplFont.c"
#endif

#if defined(ZPL2)
#include "FontData\ZplFont.c"
#endif

#if defined(DPL)
#include "FontData\DplFont.c"
#endif

#if defined(FREETYPE_TTF)
#include "FontData\PHEI00H-3.c"
#endif

#if defined(__HITACHI__)
#pragma section 
#endif

/******************************************************************************
 *                                                                            *
 *                         L O C A L   D E F I N E S                          *
 *                                                                            *
 ******************************************************************************/

#define THAI_CHARSET                    222

#define FONT_HEAD_LEN                    32
#define FONT_HEAD_LEN_V1_BF1            6
#define FONT_HEAD_LEN_V1_BF1_2            8
#define FONT_HEAD_LEN_V1_VF1            5
#define FONT_HEAD_LEN_V1_VF1_2            7

#define FONT_HEAD_LEN_V1_BF2            10
#define FONT_HEAD_LEN_V1_BF2_KOREA        0
#define FONT_HEAD_LEN_V1_BF2_JAPAN24    0x100
#define BF2_DECODE_V1_TOTAL                (sizeof(DecodeV1) / sizeof(_FontDecodeV1))

#define MCARD_FONT_ADDR                    0x400000

#define DIS_MODE1                        1
#define DIS_MODE2                        2

#define IS_AGFA_TYPE(type)    (            \
    type == AGFA_FONT_TYPE_CGT ||        \
    type == AGFA_FONT_TYPE_CGT_BOLD ||    \
    type == AGFA_FONT_TYPE_DOWNLOAD )

#define IS_TTF_TYPE(type)    (            \
    type == TTF_FONT_TYPE ||            \
    type == AGFA_FONT_TYPE_CGT ||        \
    type == AGFA_FONT_TYPE_CGT_BOLD ||    \
    type == AGFA_FONT_TYPE_DOWNLOAD )

/******************************************************************************
 *                                                                            *
 *                        L O C A L   T Y P E D E F S                         *
 *                                                                            *
 ******************************************************************************/

typedef struct
{
    CONST CHAR *FontName;        // Font Name
    CONST BYTE *FontAddr;        // Font Addr
    INT         FontSize;        // Font Size, K L font is offset, AGFA TTF is font height
    WORD        Distance;        // Font Distance, K L font is size, AGFA TTF is font width
    WORD        BaseLine;        // Font Baseline, 0 = 3 x height/4
    _eFontType  FontType;        // Font Type
    INT         DecodeType;        // Decode Type
}_FontInfo;

typedef struct
{
    CHAR *DecodeName;
    BYTE DecodeType;
}_FontDecodeV1;

/******************************************************************************
 *                                                                            *
 *             L O C A L   F U N C T I O N   P R O T O T Y P E S              *
 *                                                                            *
 ******************************************************************************/

/* None */

/******************************************************************************
 *                                                                            *
 *    L O C A L   I N I T I A L I Z E D   D A T A   D E F I N I T I O N S     *
 *                                                                            *
 ******************************************************************************/

// DPL Font Info.
#if defined(DPL)

#if defined(TPH_DPI_200)
STATIC CONST _FontInfo DplFontInfo[]=
{
    {"0DMX.BMF", DplFont0, sizeof(DplFont0), 1, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"1DMX.BMF", DplFont1, sizeof(DplFont1), 2, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"2DMX.BMF", DplFont2, sizeof(DplFont2), 2, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"3DMX.BMF", DplFont3, sizeof(DplFont3), 2, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"4DMX.BMF", DplFont4, sizeof(DplFont4), 3, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"5DMX.BMF", DplFont5, sizeof(DplFont5), 3, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"6DMX.BMF", DplFont6, sizeof(DplFont6), 4, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"7DMX.BMF", DplFont7, sizeof(DplFont7), 5, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"8DMX.BMF", DplFont8, sizeof(DplFont8), 5, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

#elif defined(TPH_DPI_300) || defined(TPH_DPI_600)
STATIC CONST _FontInfo DplFontInfo[]=
{
    {"0DMX.BMF", DplFont0, sizeof(DplFont0), 1, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"1DMX.BMF", DplFont1, sizeof(DplFont1), 3, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"2DMX.BMF", DplFont2, sizeof(DplFont2), 2, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"3DMX.BMF", DplFont3, sizeof(DplFont3), 2, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"4DMX.BMF", DplFont4, sizeof(DplFont4), 3, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"5DMX.BMF", DplFont5, sizeof(DplFont5), 3, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"6DMX.BMF", DplFont6, sizeof(DplFont6), 5, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"7DMX.BMF", DplFont7, sizeof(DplFont7), 7, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {"8DMX.BMF", DplFont8, sizeof(DplFont8), 7, 0, BF4_FONT_TYPE, DECODE_DATAMAX},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

#endif

STATIC CONST _FontInfo DplAgfaFontInfo[]=
{
    {"00DMX.TTF", _NULL, 0, 0, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},
    {"01DMX.TTF", _NULL, 0, 0, 0, AGFA_FONT_TYPE_CGT,      0},
    {"A0DMX.TTF", _NULL, 0, 0, 0, AGFA_FONT_TYPE_CGT,      0},
    {"A1DMX.TTF", _NULL, 0, 0, 0, AGFA_FONT_TYPE_CGT,      0},
    {"A2DMX.TTF", _NULL, 0, 0, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},
    {"A3DMX.TTF", _NULL, 0, 0, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

#endif

// ZPL Font Info.
#if defined(ZPL2)
STATIC CONST _FontInfo ZplFontInfo[]=
{
    {"A.FNT",   ZplFontA,   sizeof(ZplFontA),   1,  7, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"B.FNT",   ZplFontB,   sizeof(ZplFontB),   2, 11, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"D.FNT",   ZplFontD,   sizeof(ZplFontD),   2, 14, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"E8.FNT",  ZplFontE8,  sizeof(ZplFontE8),  5, 23, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"E12.FNT", ZplFontE12, sizeof(ZplFontE12), 6, 31, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"F.FNT",   ZplFontF,   sizeof(ZplFontF),   3, 21, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"G.FNT",   ZplFontG,   sizeof(ZplFontG),   8, 48, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"H8.FNT",  ZplFontH8,  sizeof(ZplFontH8),  6, 21, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"H12.FNT", ZplFontH12, sizeof(ZplFontH12), 6, 29, BF4_FONT_TYPE, DECODE_ZEBRA},
    {"GS.FNT",  ZplFontGS,  sizeof(ZplFontGS),  2,  0, BF1_FONT_TYPE, 0},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

STATIC CONST _FontInfo ZplAgfaFontInfo[]=
{
    {"0.TTF", _NULL,  0,  0, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},    // 0  x 0
    {"P.TTF", _NULL, 20, 18, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},    // 20 x 18
    {"Q.TTF", _NULL, 28, 24, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},    // 28 x 24
    {"R.TTF", _NULL, 35, 31, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},    // 35 x 31
    {"S.TTF", _NULL, 40, 35, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},    // 40 x 35
    {"T.TTF", _NULL, 48, 42, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},    // 48 x 42
    {"U.TTF", _NULL, 59, 53, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},    // 59 x 53
    {"V.TTF", _NULL, 80, 71, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},    // 80 x 71
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};
#endif

// EPL Font Info.
#if defined(EPL2)

#if defined(TPH_DPI_200)
STATIC CONST _FontInfo EplFontInfo[]=
{
    {"1.EFT", EplFont1, sizeof(EplFont1), 2, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {"2.EFT", EplFont2, sizeof(EplFont2), 2, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {"3.EFT", EplFont3, sizeof(EplFont3), 2, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {"4.EFT", EplFont4, sizeof(EplFont4), 2, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {"5.EFT", EplFont5, sizeof(EplFont5), 4, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

#elif defined(TPH_DPI_300) || defined(TPH_DPI_600)
STATIC CONST _FontInfo EplFontInfo[]=
{
    {"1.EFT", EplFont1, sizeof(EplFont1), 0, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {"2.EFT", EplFont2, sizeof(EplFont2), 0, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {"3.EFT", EplFont3, sizeof(EplFont3), 0, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {"4.EFT", EplFont4, sizeof(EplFont4), 0, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {"5.EFT", EplFont5, sizeof(EplFont5), 0, 0, BF4_FONT_TYPE, DECODE_ELTRON},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

#endif

#endif

// TSPL Font Info.
#if defined(TSPL_VER_2)
STATIC CONST _FontInfo TsplFontInfo[]=
{
    {"1", TsplFont1, sizeof(TsplFont1), DIS_MODE2, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"2", TsplFont2, sizeof(TsplFont2), DIS_MODE2, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"3", TsplFont3, sizeof(TsplFont3), DIS_MODE1, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"4", TsplFont4, sizeof(TsplFont4), DIS_MODE1, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"5", TsplFont5, sizeof(TsplFont5), DIS_MODE1, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"6", OCRBFont14x19, sizeof(OCRBFont14x19), 0, 0, BF1_FONT_TYPE, 0},
    {"7", OCRBFont21x27, sizeof(OCRBFont21x27), 0, 0, BF1_FONT_TYPE, 0},
    {"8", OCRAFont14x25, sizeof(OCRAFont14x25), 0, 0, BF1_FONT_TYPE, 0},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

#elif defined(TSPL_VER_1)
STATIC CONST _FontInfo TsplFontInfo[]=
{
    {"1", TsplFont1, sizeof(TsplFont1), 2, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"2", TsplFont2, sizeof(TsplFont2), 2, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"3", TsplFont3, sizeof(TsplFont3), 0, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"4", TsplFont4, sizeof(TsplFont4), 0, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"5", TsplFont5, sizeof(TsplFont5), 4, 0, BF4_FONT_TYPE, DECODE_TSC},
    {"6", OCRBFont14x19, sizeof(OCRBFont14x19), 0, 0, BF1_FONT_TYPE, 0},
    {"7", OCRBFont21x27, sizeof(OCRBFont21x27), 0, 0, BF1_FONT_TYPE, 0},
    {"8", OCRAFont14x25, sizeof(OCRAFont14x25), 0, 0, BF1_FONT_TYPE, 0},
    {"OCRA36.VF1", OCRA36, sizeof(OCRA36), 0, 0, VF1_FONT_TYPE_V1, 0},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

#endif

// Ean Font Info.
STATIC CONST _FontInfo EanFontInfo[]=
{
    {"@0", EanFont7x10,   sizeof(EanFont7x10),   0, 0, BF1_FONT_TYPE, 0},
    {"@1", EanFont14x22,  sizeof(EanFont14x22),  0, 0, BF1_FONT_TYPE, 0},
    {"@2", EanFont21x33,  sizeof(EanFont21x33),  0, 0, BF1_FONT_TYPE, 0},
    {"@3", EanFont28x43,  sizeof(EanFont28x43),  0, 0, BF1_FONT_TYPE, 0},
    {"@4", EanFont35x52,  sizeof(EanFont35x52),  0, 0, BF1_FONT_TYPE, 0},
    {"@5", EanFont42x64,  sizeof(EanFont42x64),  0, 0, BF1_FONT_TYPE, 0},
    {"@6", EanFont49x74,  sizeof(EanFont49x74),  0, 0, BF1_FONT_TYPE, 0},
    {"@7", EanFont56x85,  sizeof(EanFont56x85),  0, 0, BF1_FONT_TYPE, 0},
    {"@8", EanFont63x97,  sizeof(EanFont63x97),  0, 0, BF1_FONT_TYPE, 0},
    {"@9", EanFont70x107, sizeof(EanFont70x107), 0, 0, BF1_FONT_TYPE, 0},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};

// TTF Font Info.
#if defined(FREETYPE_TTF)
STATIC CONST _FontInfo TTFFontInfo[]=
{
           {"0", AR_Gothic3_Heavy, sizeof(AR_Gothic3_Heavy), 0, 0, TTF_FONT_TYPE, 0},
    {"ROMAN.TTF", AR_Gothic3_Heavy, sizeof(AR_Gothic3_Heavy), 0, 0, TTF_FONT_TYPE, 0},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};
#endif

#if defined(AGFA_TTF) && defined(TSPL)
STATIC CONST _FontInfo TsplAgfaFontInfo[]=
{
#if !defined(NO_BUILT_IN_AGFA_FONT)
    {"0",         _NULL, 0, 0, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},
    {"ROMAN.TTF", _NULL, 0, 0, 0, AGFA_FONT_TYPE_CGT_BOLD, 0},
#endif
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};
#endif

// TTP243 Memory Card Font Info.
#if defined(DEFAULT_MCARD_MODEL)
STATIC CONST _FontInfo MCardFontInfo[]=
{
    {"K", (BYTE *)MCARD_FONT_ADDR, 0,       0, 0, BF2_FONT_TYPE_V1, 0},
    {"L", (BYTE *)MCARD_FONT_ADDR, 0x8C800, 0, 0, BF2_FONT_TYPE_V1, 0},
    {_NULL, _NULL, 0, 0, 0, ERR_FONT_TYPE, 0},
};
#endif

STATIC CONST _FontDecodeV1 DecodeV1[]=
{
    {"BIG5", DECODE_BIG5},
    {"GB",   DECODE_GB},
    {"GX",   DECODE_GX},
};

/******************************************************************************
 *                                                                            *
 *    L O C A L   U N I T I A L I Z E D   D A T A   D E F I N I T I O N S     *
 *                                                                            *
 ******************************************************************************/

STATIC BYTE *pTsplCodePage, *pTsplRemap;
STATIC BYTE *pEplCodePage, *pEplRemap;
STATIC BYTE *pZplCodePage, *pZplRemap;
STATIC BYTE *pDplCodePage, *pDplRemap;

STATIC WORD *pSymbolSet;

STATIC _FileHandle *pFontFileHandle;
STATIC BYTE *pFontStartPtr;
STATIC BYTE *pFontNowPtr;
STATIC INT FontFileSize;
STATIC _FontAttr sExtFontAttr;

/******************************************************************************
 *
 * Function:
 *    
 *
 * Description: 
 *        
 *
 * Input:
 *      None
 *
 * Output:
 *      None.
 *
 ******************************************************************************/
STATIC _FontInfo *CheckBuildFontName(CHAR *pString , _FontInfo *pFontInfo)
{
    while (pFontInfo->FontName != _NULL)
    {
        if (strcmp(pString , pFontInfo->FontName) == 0)
            return (_FontInfo *)pFontInfo;
        pFontInfo++;
    }
    return _NULL;
}

/******************************************************************************
 *
 * Function:
 *    GetBuildData
 *
 * Description: 
 *        This function use to get data for build font.
 *
 * Input:
 *      None
 *
 * Output:
 *      data
 *
 ******************************************************************************/
STATIC INT GetBuildData(BYTE *pString, INT Length)
{
    memcpy(pString, pFontNowPtr, Length);
    pFontNowPtr += Length;
    return _SUCCESS;
}

/******************************************************************************
 *
 * Function:
 *    MoveBuildDataPtr
 *
 * Description: 
 *        This function use to move build font data point.
 *
 * Input:
 *      None
 *
 * Output:
 *      data
 *
 ******************************************************************************/
STATIC VOID MoveBuildDataPtr(INT Offset)
{
    pFontNowPtr = pFontStartPtr + Offset;
}

STATIC LONG GetBuildDataPtr(VOID)
{
    return (pFontNowPtr - pFontStartPtr);
}

STATIC LONG GetBuildSize(VOID)
{
    return FontFileSize;
}

STATIC LONG GetBuildAddr(VOID)
{
    return (LONG)pFontNowPtr;
}

/******************************************************************************
 *
 * Function:
 *    GetDownloadData
 *
 * Description: 
 *        This function use to get data for download font.
 *
 * Input:
 *      None
 *
 * Output:
 *      data
 *
 ******************************************************************************/
STATIC INT GetDownloadData(BYTE *pString, INT Length)
{
    return Fread(pString, sizeof(BYTE), Length, pFontFileHandle);
}

/******************************************************************************
 *
 * Function:
 *    MoveDownloadDataPtr
 *
 * Description: 
 *        This function use to move download font data point.
 *
 * Input:
 *      None
 *
 * Output:
 *      data
 *
 ******************************************************************************/
STATIC VOID MoveDownloadDataPtr(INT Offset)
{
    Fseek(pFontFileHandle, Offset, SEEK_SET);
}

STATIC LONG GetDownloadDataPtr(VOID)
{
    return Ftell(pFontFileHandle);
}

STATIC LONG GetDownloadSize(VOID)
{
    return FileLength(FileNo(pFontFileHandle));
}

STATIC LONG GetDownloadAddr(VOID)
{
#if defined(AGFA_FS)
    return (LONG)pFontNowPtr;
#elif defined(TSCFS)
    return pFontFileHandle->TscFile.CurrAddr;
#endif
}

STATIC VOID ReadFontHead(_FontAttr *pFontAttr, BYTE *Pitch, BYTE *CharSize, BYTE *DecodeWay, WORD *Lang)
{
    BYTE Data;
    WORD wData;

    pFontAttr->lpSetDataPoint(0);

    // 0: font ID B->Bitmap font
    pFontAttr->lpGetData((BYTE *)&Data, 1);

    // 1: 0->Fixed pitch 1->Variable Pitch
    pFontAttr->lpGetData((BYTE *)Pitch, 1);

    // 2: 0->Singed Byte Decode 1->Double Byte Decode
    pFontAttr->lpGetData((BYTE *)CharSize, 1);

    // 3: decode by table
    pFontAttr->lpGetData((BYTE *)DecodeWay, 1);

    // 4: style 0-> None  1->Italic
    pFontAttr->lpGetData((BYTE *)&Data, 1);
    pFontAttr->iStyle = Data;

    // 5-6: font Height
    pFontAttr->lpGetData((BYTE *)&wData, 2);
    pFontAttr->iRealHeight = le16_to_cpu(wData);

    // 7-8: font Width
    pFontAttr->lpGetData((BYTE *)&wData, 2);
    pFontAttr->iFontWidth = pFontAttr->iRealWidth = le16_to_cpu(wData);

    pFontAttr->iFontByteWidth = (pFontAttr->iRealWidth + 7) / 8;

    // 9-10: font decode start
    pFontAttr->lpGetData((BYTE *)&wData, 2);
    pFontAttr->iFirstChar = le16_to_cpu(wData);

    // 11-12: font decode end
    pFontAttr->lpGetData((BYTE *)&wData, 2);
    pFontAttr->iLastChar = le16_to_cpu(wData);

    // 13: font decode type
    pFontAttr->lpGetData((BYTE *)&Data, 1);
    pFontAttr->iDecodeType = Data;

    // 14: Rotation Support
    pFontAttr->lpGetData((BYTE *)&Data, 1);
    pFontAttr->iRotationSupport = Data;

    // 15-16: font character total
    pFontAttr->lpGetData((BYTE *)&wData, 2);
    pFontAttr->iTotalChar = le16_to_cpu(wData);

    // 17-18: Italic Width Variable
    pFontAttr->lpGetData((BYTE *)&wData, 2);
    pFontAttr->iItalicWidth = le16_to_cpu(wData);

    // 19-20: VF6 RealHeight
    pFontAttr->lpGetData((BYTE *)&wData, 2);

    // 21-22: Language
    pFontAttr->lpGetData((BYTE *)&wData, 2);
    *Lang = le16_to_cpu(wData);

    // 23-24: Base Line of ZPL
    pFontAttr->lpGetData((BYTE *)&wData, 2);
    pFontAttr->iBaseLineZ = le16_to_cpu(wData);
}

STATIC INT ReadFontHeadV1(_FontAttr *pFontAttr)
{
    BYTE Data;
    WORD wData;
    CHAR DecodeID[10];
    INT i;

    if (pFontAttr->iFontType == BF1_FONT_TYPE_V1)
    {
        pFontAttr->lpSetDataPoint(0);

        // font ID
        pFontAttr->lpGetData((BYTE *)&Data, 1);

        // get font height
        pFontAttr->lpGetData((BYTE *)&Data, 1);
        pFontAttr->iRealHeight = Data;

        // get font width
        pFontAttr->lpGetData((BYTE *)&Data, 1);
        pFontAttr->iFontWidth = pFontAttr->iRealWidth = Data;

        pFontAttr->iFontByteWidth = (pFontAttr->iRealWidth + 7) / 8;

        pFontAttr->lpGetData((BYTE *)&Data, 1);
        // single byte
        if (Data == 1)
        {
            pFontAttr->lpGetData((BYTE *)&Data, 1);
            pFontAttr->iFirstChar = Data;
            pFontAttr->lpGetData((BYTE *)&Data, 1);
            pFontAttr->iLastChar = Data;
            if (pFontAttr->iLastChar < pFontAttr->iFirstChar)
                return FALSE;
            pFontAttr->iTotalChar = pFontAttr->iLastChar - pFontAttr->iFirstChar + 1;
            pFontAttr->iHeadLen = FONT_HEAD_LEN_V1_BF1;
        }
        else if (Data == 2)
        {
            pFontAttr->lpGetData((BYTE *)&wData, 2);
            pFontAttr->iFirstChar = le16_to_cpu(wData);

            pFontAttr->lpGetData((BYTE *)&wData, 2);
            pFontAttr->iLastChar = le16_to_cpu(wData);

            if (pFontAttr->iLastChar < pFontAttr->iFirstChar)
                return FALSE;
            pFontAttr->iTotalChar = pFontAttr->iLastChar - pFontAttr->iFirstChar + 1;
            pFontAttr->iHeadLen = FONT_HEAD_LEN_V1_BF1_2;
            pFontAttr->iFontType = BF1_2_FONT_TYPE_V1;
        }
        else
            return FALSE;
        pFontAttr->iDecodeType = 0;
    }
    else if (pFontAttr->iFontType == VF1_FONT_TYPE_V1)
    {
        pFontAttr->lpSetDataPoint(0);

        // font ID
        pFontAttr->lpGetData((BYTE *)&Data, 1);

        // get font height
        pFontAttr->lpGetData((BYTE *)&Data, 1);
        pFontAttr->iRealHeight = Data;
        pFontAttr->iFontWidth  = pFontAttr->iRealWidth = Data;

        pFontAttr->iFontByteWidth = (pFontAttr->iRealWidth + 7) / 8;

        pFontAttr->lpGetData((BYTE *)&Data, 1);
        // single byte
        if (Data == 1)
        {
            pFontAttr->lpGetData((BYTE *)&Data, 1);
            pFontAttr->iFirstChar = Data;
            pFontAttr->lpGetData((BYTE *)&Data, 1);
            pFontAttr->iLastChar = Data;
            if (pFontAttr->iLastChar < pFontAttr->iFirstChar)
                return FALSE;
            pFontAttr->iTotalChar = pFontAttr->iLastChar - pFontAttr->iFirstChar + 1;
            pFontAttr->iHeadLen   = FONT_HEAD_LEN_V1_VF1;
        }
        else if (Data == 2)
        {
            pFontAttr->lpGetData((BYTE *)&wData, 2);
            pFontAttr->iFirstChar = le16_to_cpu(wData);

            pFontAttr->lpGetData((BYTE *)&wData, 2);
            pFontAttr->iLastChar = le16_to_cpu(wData);

            if (pFontAttr->iLastChar < pFontAttr->iFirstChar)
                return FALSE;
            pFontAttr->iTotalChar = pFontAttr->iLastChar - pFontAttr->iFirstChar + 1;
            pFontAttr->iHeadLen   = FONT_HEAD_LEN_V1_VF1_2;
            pFontAttr->iFontType  = VF1_2_FONT_TYPE_V1;
        }
        else
            return FALSE;
        pFontAttr->iDecodeType = 0;
    }
    else if (pFontAttr->iFontType == BF2_FONT_TYPE_V1)
    {
        pFontAttr->lpSetDataPoint(0);

        // font ID
        pFontAttr->lpGetData((BYTE *)&Data, 1);

        // get font height
        pFontAttr->lpGetData((BYTE *)&Data, 1);
        pFontAttr->iRealHeight = Data;

        // get font width
        pFontAttr->lpGetData((BYTE *)&Data, 1);
        pFontAttr->iFontWidth     = pFontAttr->iRealWidth = Data;
        pFontAttr->iFontByteWidth = (pFontAttr->iRealWidth + 7) / 8;

        pFontAttr->lpGetData((BYTE *)&Data, 1);
        if (Data != 2)
            return FALSE;

        pFontAttr->lpGetData((BYTE *)&DecodeID, 6);

        pFontAttr->iDecodeType = 0;

        for (i = 0; i < BF2_DECODE_V1_TOTAL; i++)
        {
            if (strncmp(DecodeID, DecodeV1[i].DecodeName, strlen(DecodeV1[i].DecodeName)) == 0)
            {
                pFontAttr->iDecodeType = DecodeV1[i].DecodeType;
                break;
            }
        }
        if (pFontAttr->iDecodeType == 0)
            return FALSE;

#if defined(TSPL_VER_1)
        if (pFontAttr->iDecodeType == DECODE_BIG5 && pFontAttr->iRealWidth == 24)
        {
            pFontNowPtr = pFontStartPtr = (BYTE *)Big5Half;
            FontFileSize = sizeof(Big5Half);

            // set get data function
            sExtFontAttr.lpGetData      = GetBuildData;
            sExtFontAttr.lpSetDataPoint = MoveBuildDataPtr;
            sExtFontAttr.lpGetDataPoint = GetBuildDataPtr;
            sExtFontAttr.lpGetSize      = GetBuildSize;
            sExtFontAttr.lpGetAddrPoint = GetBuildAddr;
            sExtFontAttr.iRealHeight    = 16;
            sExtFontAttr.iRealWidth     = 16;
            sExtFontAttr.iHeadLen       = 0;
            SetExtFontAttr(&sExtFontAttr);
        }
#endif
        pFontAttr->iHeadLen = FONT_HEAD_LEN_V1_BF2;
    }
    pFontAttr->iStyle       = 0;
    pFontAttr->iItalicWidth = 0;
    return TRUE;
}

STATIC VOID SwapFontMultiXY(_FontAttr *pFontAttr)
{
    if (pFontAttr->iRotation == 90 || pFontAttr->iRotation == 270)
    {
        INT Temp = pFontAttr->iHoriMulti;
        pFontAttr->iHoriMulti = pFontAttr->iVertMulti;
        pFontAttr->iVertMulti = Temp;
    }
}

STATIC VOID CaculateZplFontMulti(_FontAttr *pFontAttr)
{
    INT Xmul, Ymul;

    // check bitmap horimulti
    // if font 0 realwidth = 0
    Xmul = pFontAttr->iHoriMulti;
    Ymul = pFontAttr->iVertMulti;

    if (pFontAttr->iRealWidth)
    {
        Xmul = (Xmul + pFontAttr->iRealWidth / 2) / pFontAttr->iRealWidth;
        if (Xmul <= 0)
            Xmul = 1;
        if (Xmul > 10)
            Xmul = 10;

        // Zebra P Q R S T U V Font
        if (pFontAttr->iFontType == AGFA_FONT_TYPE_CGT_BOLD)
            Xmul *= pFontAttr->iRealWidth * 0.92;
    }
    // check bitmap horimulti
    // if font 0 realwidth = 0
    if (pFontAttr->iRealHeight)
    {
        Ymul = (Ymul + pFontAttr->iRealHeight / 2) / pFontAttr->iRealHeight;
        if (Ymul <= 0)
            Ymul = 1;
        if (Ymul > 10)
            Ymul = 10;

        // Zebra P Q R S T U V Font
        if (pFontAttr->iFontType == AGFA_FONT_TYPE_CGT_BOLD)
        {
            Ymul *= pFontAttr->iRealHeight * 0.85;

            // FIXME: Image buffer area for serialization should be erased
            if (pFontAttr->iDirection == 0)
                pFontAttr->sCoord.iY += Ymul * 0.15;
            else if (pFontAttr->iDirection == 90)
                pFontAttr->sCoord.iX -= Ymul * 0.15;
            else if (pFontAttr->iDirection == 180)
                pFontAttr->sCoord.iY -= Ymul * 0.15;
            else if (pFontAttr->iDirection == 270)
                pFontAttr->sCoord.iX += Ymul * 0.15;
        }
    }
    // set multi
    pFontAttr->iHoriMulti = Xmul;
    pFontAttr->iVertMulti = Ymul;
}

STATIC VOID CaculateTsplDistance(_FontInfo *pFontInfo, _FontAttr *pFontAttr)
{
#if defined(TSPL_VER_1)
    if (pFontAttr->iHoriMulti > 1)
        pFontAttr->iDistance = pFontInfo->Distance * (pFontAttr->iHoriMulti - 1);
    else
        pFontAttr->iDistance = pFontInfo->Distance;

#elif defined(TSPL_VER_2)
    if (pFontInfo->Distance == DIS_MODE1)
        pFontAttr->iDistance = pFontAttr->iHoriMulti - 1;
    else if (pFontInfo->Distance == DIS_MODE2)
        pFontAttr->iDistance = 2 * pFontAttr->iHoriMulti;
    else
        pFontAttr->iDistance = 0;

#endif
}

STATIC VOID CaculateEplDistance(_FontInfo *pFontInfo, _FontAttr *pFontAttr)
{
    pFontAttr->iDistance = pFontInfo->Distance * pFontAttr->iHoriMulti;
}

STATIC VOID CaculateZplDistance(_FontInfo *pFontInfo, _FontAttr *pFontAttr)
{
    pFontAttr->iDistance = pFontInfo->Distance * pFontAttr->iHoriMulti;
}

STATIC VOID CaculateDplDistance(_FontInfo *pFontInfo, _FontAttr *pFontAttr)
{
    pFontAttr->iDistance = pFontInfo->Distance * pFontAttr->iHoriMulti;
}

STATIC VOID SizePointToDot(_FontAttr *pFontAttr)
{
    pFontAttr->iHoriMulti = (FLOAT)pFontAttr->iHoriMulti * TPH_DPI / 72;
    pFontAttr->iVertMulti = (FLOAT)pFontAttr->iVertMulti * TPH_DPI / 72;
}

STATIC VOID CopyTextToFont(_FontAttr *pFontAttr, _TextAttr *psTextAttr)
{
    pFontAttr->psImageBuffer = psTextAttr->psImageBuffer;
    pFontAttr->sCoord        = psTextAttr->sCoord;
    pFontAttr->iDirection    = psTextAttr->iDirection;
    pFontAttr->iRotation     = psTextAttr->iRotation;

    pFontAttr->iHoriMulti    = psTextAttr->iHoriMulti;
    pFontAttr->iVertMulti    = psTextAttr->iVertMulti;
    pFontAttr->ExpLength     = psTextAttr->ExpLength;

    pFontAttr->iSymbolSet    = psTextAttr->iSymbolSet;
    pFontAttr->pFont         = psTextAttr->pFont;
    pFontAttr->pExp          = psTextAttr->pExp;
    pFontAttr->eLanguage     = psTextAttr->eLanguage;
    pFontAttr->ePutWay       = psTextAttr->ePutWay;

    pFontAttr->iFontType     = ERR_FONT_TYPE;
}

STATIC _FontInfo *CheckTsplBuildFont(CHAR *pString)
{
    _FontInfo *pFontInfo;

#if defined(TSPL)
    // check TSPL build BMF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)TsplFontInfo))
        return pFontInfo;
#endif

#if defined(EPL2)
    // check EPL build BMF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)EplFontInfo))
        return pFontInfo;
#endif

#if defined(ZPL2)
    // check ZPL build BMF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)ZplFontInfo))
        return pFontInfo;
#endif

#if defined(DPL)
    // check DPL build BMF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)DplFontInfo))
        return pFontInfo;
#endif

    // check EAN font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)EanFontInfo))
        return pFontInfo;

#if defined(AGFA_TTF) && defined(TSPL)
    // check TTF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)TsplAgfaFontInfo))
        return pFontInfo;
#endif

#if defined(FREETYPE_TTF)
    // check TTF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)TTFFontInfo))
        return pFontInfo;
#endif

    return _NULL;
}

STATIC _FontInfo *CheckEplBuildFont(CHAR *pString)
{
    _FontInfo *pFontInfo;

#if defined(EPL2)
    // check EPL build BMF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)EplFontInfo))
        return pFontInfo;
#endif

    // check EAN font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)EanFontInfo))
        return pFontInfo;

#if defined(AGFA_TTF) && defined(TSPL)
    // check TTF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)TsplAgfaFontInfo))
        return pFontInfo;
#endif

#if defined(FREETYPE_TTF)
    // check TTF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)TTFFontInfo))
        return pFontInfo;
#endif

    return _NULL;
}

STATIC _FontInfo *CheckZplBuildFont(CHAR *pString)
{
    _FontInfo *pFontInfo;

#if defined(ZPL2)
    // check ZPL build BMF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)ZplFontInfo))
        return pFontInfo;
#endif

#if defined(AGFA_TTF) && defined(ZPL2)
    // check ZPL build BMF font    
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)ZplAgfaFontInfo))
        return pFontInfo;
#endif

    // check EAN font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)EanFontInfo))
        return pFontInfo;

    return _NULL;
}

STATIC _FontInfo *CheckDplBuildFont(CHAR *pString)
{
    _FontInfo *pFontInfo;

#if defined(DPL)
    // check DPL build BMF font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)DplFontInfo))
        return pFontInfo;
#endif

#if defined(AGFA_TTF) && defined(DPL)
    // check DPL build BMF font    
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)DplAgfaFontInfo))
        return pFontInfo;
#endif

    // check EAN font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)EanFontInfo))
        return pFontInfo;

    return _NULL;
}

STATIC INT CheckDownloadFont(BYTE *pFileName, _FontAttr *pFontAttr)
{
    CHAR FontID;
    INT Len;
    BYTE Pitch,    CharSize, DecodeWay;
    WORD Lang;

    // check download font
    if ((pFontFileHandle = Fopen(DRAM_DEVICE,  (CHAR *)pFileName, "r")) == _NULL)
    if ((pFontFileHandle = Fopen(FLASH_DEVICE, (CHAR *)pFileName, "r")) == _NULL)
    if ((pFontFileHandle = Fopen(CARD_DEVICE,  (CHAR *)pFileName, "r")) == _NULL)
        return FALSE;

    pFontAttr->lpGetData      = GetDownloadData;
    pFontAttr->lpSetDataPoint = MoveDownloadDataPtr;
    pFontAttr->lpGetDataPoint = GetDownloadDataPtr;
    pFontAttr->lpGetSize      = GetDownloadSize;
    pFontAttr->lpGetAddrPoint = GetDownloadAddr;
    pFontAttr->iLocate        = DOWNLOAD_FONT;

    // get font name length
    Len = strlen((CHAR *)pFileName);

    // check download true type font
    if (strncmp((CHAR *)(pFileName + Len - 4), ".TTF", 4) == 0 ||
        strncmp((CHAR *)(pFileName + Len - 4), ".TTC", 4) == 0)
    {
//        pFontAttr->iFontType   = TTF_FONT_TYPE;
        pFontAttr->iFontType   = AGFA_FONT_TYPE_DOWNLOAD;
        pFontAttr->iRealHeight = 0;
        pFontAttr->iRealWidth  = 0;
#if defined(AGFA_FS)
        Fclose(pFontFileHandle);
#endif
        return TRUE;
    }

    // check download font
    pFontAttr->lpSetDataPoint(0);
    pFontAttr->lpGetData((BYTE *)&FontID, 1);

    // check TTP245 download font
    if (FontID == 'B')
    {
        ReadFontHead(pFontAttr, &Pitch, &CharSize, &DecodeWay, &Lang);

        pFontAttr->iDistance = 0;
        pFontAttr->iHeadLen = FONT_HEAD_LEN;
        if (Pitch == 1 && CharSize == 0 && DecodeWay == 0 && Lang == THAI_CHARSET)
            pFontAttr->iFontType = THAI_FONT_TYPE;
        else if (Pitch == 0 && CharSize == 0 && DecodeWay == 0)
            pFontAttr->iFontType = BF1_FONT_TYPE;
        else if (Pitch == 0 && CharSize == 1 && DecodeWay == 0)
            pFontAttr->iFontType = BF2_FONT_TYPE;
        else if (Pitch == 0 && CharSize == 0 && DecodeWay == 1)
            pFontAttr->iFontType = BF3_FONT_TYPE;
        else if (Pitch == 0 && CharSize == 1 && DecodeWay == 1)
            pFontAttr->iFontType = BF4_FONT_TYPE;
        else if (Pitch == 1 && CharSize == 0 && DecodeWay == 0)
            pFontAttr->iFontType = VF1_FONT_TYPE;
        else if (Pitch == 1 && CharSize == 1 && DecodeWay == 0)
            pFontAttr->iFontType = VF2_FONT_TYPE;
        else if (Pitch == 1 && CharSize == 0 && DecodeWay == 1)
            pFontAttr->iFontType = VF3_FONT_TYPE;
        else if (Pitch == 1 && CharSize == 1 && DecodeWay == 1)
            pFontAttr->iFontType = VF4_FONT_TYPE;
        return TRUE;
    }

    if (FontID == 'E')
    {
        ReadFontHead(pFontAttr, &Pitch, &CharSize, &DecodeWay, &Lang);

        pFontAttr->iDistance = 0;
        pFontAttr->iHeadLen  = FONT_HEAD_LEN;
        pFontAttr->iFontType = EPL_FONT_TYPE;
        return TRUE;
    }

    // check ZPL download true type font
    if (strncmp((CHAR *)(pFileName + Len - 4), ".FNT", 4) == 0 && pFontAttr->eLanguage == LANG_ZPL)
    {
        pFontAttr->iFontType   = AGFA_FONT_TYPE_DOWNLOAD;
        pFontAttr->iRealHeight = 0;
        pFontAttr->iRealWidth  = 0;
#if defined(AGFA_FS)
        Fclose(pFontFileHandle);
#endif
        return TRUE;
    }

    // check 243 download font
    if (strncmp((CHAR *)(pFileName + Len - 4), ".BF1", 4) == 0 && FontID == 0)
    {
        pFontAttr->iFontType = BF1_FONT_TYPE_V1;
        pFontAttr->iDistance = 0;
        if (ReadFontHeadV1(pFontAttr))
            return TRUE;
    }
    else if (strncmp((CHAR *)(pFileName + Len - 4), ".VF1", 4) == 0 && FontID == 0)
    {
        pFontAttr->iFontType = VF1_FONT_TYPE_V1;
        pFontAttr->iDistance = 0;
        if (ReadFontHeadV1(pFontAttr))
            return TRUE;
    }
    else if (strncmp((CHAR *)(pFileName + Len - 4), ".BF2", 4) == 0 && FontID == 0)
    {
        pFontAttr->iFontType = BF2_FONT_TYPE_V1;
        pFontAttr->iDistance = 0;
        if (ReadFontHeadV1(pFontAttr))
            return TRUE;
    }
    else if (strcmp((CHAR *)pFileName , "K") == 0 && FontID == 0)
    {
        // korea Font
        pFontAttr->iFontType      = BF2_FONT_TYPE_V1;
        pFontAttr->iFontWidth     = pFontAttr->iRealWidth = pFontAttr->iRealHeight = 24;
        pFontAttr->iFontByteWidth = (pFontAttr->iRealWidth + 7) / 8;

        pFontAttr->iStyle       = 0;
        pFontAttr->iItalicWidth = 0;
        pFontAttr->iHeadLen     = FONT_HEAD_LEN_V1_BF2_KOREA;
        pFontAttr->iDecodeType  = DECODE_KOREA;
        pFontAttr->iDistance    = 0;
        pFontAttr->iFirstChar   = 0;
        pFontAttr->iLastChar    = 0;
        return TRUE;
    }

    Fclose(pFontFileHandle);
    return FALSE;
}

STATIC _FontInfo *CheckTsplMCardFont(CHAR *pString)
{
    _FontInfo *pFontInfo;

#if defined(DEFAULT_MCARD_MODEL)
    // check 243 Memory Card font
    if (pFontInfo = CheckBuildFontName((CHAR *)pString, (_FontInfo *)MCardFontInfo))
    {
        if (*(pFontInfo->FontAddr + 1) == 0 && *(pFontInfo->FontAddr + 2) == 0)
            return pFontInfo;
    }
#endif

    return _NULL;
}

STATIC INT GetBuildFontInfo(_FontInfo *pFontInfo, _FontAttr *pFontAttr)
{
    CHAR Data;
    BYTE Pitch,    CharSize, DecodeWay;
    WORD Lang;

    // set font address
    pFontStartPtr = (BYTE *)pFontInfo->FontAddr;
    pFontNowPtr   = (BYTE *)pFontInfo->FontAddr;
    FontFileSize  = pFontInfo->FontSize;

    pFontAttr->iFontType = pFontInfo->FontType;

    // set get data function
    pFontAttr->lpGetData      = GetBuildData;
    pFontAttr->lpSetDataPoint = MoveBuildDataPtr;
    pFontAttr->lpGetDataPoint = GetBuildDataPtr;
    pFontAttr->lpGetSize      = GetBuildSize;
    pFontAttr->lpGetAddrPoint = GetBuildAddr;

    pFontAttr->iLocate = BUILD_FONT;

#if defined(AGFA_TTF)
    if (IS_AGFA_TYPE(pFontAttr->iFontType))
    {
        pFontAttr->iRealHeight = pFontInfo->FontSize;
        pFontAttr->iRealWidth = pFontInfo->Distance;
        return TRUE;
    }
#endif

    // if freetype font        
#if defined(FREETYPE_TTF)
    if (IS_TTF_TYPE(pFontAttr->iFontType))
        return TRUE;
#endif

    // if 243 korea font or japan font
    if (pFontAttr->iFontType == BF2_FONT_TYPE_V1)
    {
        pFontAttr->iDistance = 0;
        pFontAttr->lpGetData((BYTE *)&Data, 1);
        if (Data == 'J')
        {
            if (*pFontInfo->FontName == 'K')
                pFontAttr->iFontWidth = pFontAttr->iRealWidth = pFontAttr->iRealHeight = 24;
            else
                pFontAttr->iFontWidth = pFontAttr->iRealWidth = pFontAttr->iRealHeight = 16;

            pFontAttr->iFontByteWidth = (pFontAttr->iRealWidth + 7) / 8;

            pFontAttr->iStyle       = 0;
            pFontAttr->iItalicWidth = 0;
            pFontAttr->iHeadLen     = pFontInfo->FontSize + FONT_HEAD_LEN_V1_BF2_JAPAN24;
            pFontAttr->iDecodeType  = DECODE_SJIS;
            pFontAttr->iFirstChar   = 0;
            pFontAttr->iLastChar    = 0;
            return TRUE;
        }
        else if (Data == 0)
        {
            pFontAttr->iFontWidth     = pFontAttr->iRealWidth = pFontAttr->iRealHeight = 24;
            pFontAttr->iFontByteWidth = (pFontAttr->iRealWidth + 7) / 8;
    
            pFontAttr->iStyle       = 0;
            pFontAttr->iItalicWidth = 0;
            pFontAttr->iHeadLen     = FONT_HEAD_LEN_V1_BF2_KOREA;
            pFontAttr->iDecodeType  = DECODE_KOREA;
            pFontAttr->iFirstChar   = 0;
            pFontAttr->iLastChar    = 0;
            return TRUE;
        }
    }
    else if (pFontAttr->iFontType == VF1_FONT_TYPE_V1)
    {
        pFontAttr->iDistance = 0;
        ReadFontHeadV1(pFontAttr);
        return TRUE;
    }
    else
    {
        ReadFontHead(pFontAttr, &Pitch, &CharSize, &DecodeWay, &Lang);
        pFontAttr->iDecodeType = pFontInfo->DecodeType;
        pFontAttr->iHeadLen    = FONT_HEAD_LEN;
        return TRUE;
    }
    return TRUE;
}

/*----------------------------------------------------------------------------------
Function name:
    GetTsplFontInfo
Description:
    Get font information 
    font high
    font width
    font total
    font data point 
    font locate
    font codeedbyte
    font firstchar
    font lastchar
    font type
Input:
    psFontAttr: Font Attrible
    psTextAtrr: Text Attrible
output:
   font type
----------------------------------------------------------------------------------*/
STATIC INT GetTsplFontInfo(BYTE *pFileName, _FontAttr *pFontAttr, _TextAttr *psTextAttr)
{
    _FontInfo *pFontInfo;

    // copy text struct data to font struct
    CopyTextToFont(pFontAttr, psTextAttr);

    // build font
    if (pFontInfo = CheckTsplBuildFont((CHAR *)pFileName))
    {
        if (GetBuildFontInfo(pFontInfo, pFontAttr))
        {
            if (!IS_TTF_TYPE(pFontInfo->FontType))
            {
                SwapFontMultiXY(pFontAttr);

                if (pFontInfo->DecodeType == DECODE_DATAMAX)
                    CaculateDplDistance(pFontInfo, pFontAttr);
                else if (pFontInfo->DecodeType == DECODE_ZEBRA)
                    CaculateZplDistance(pFontInfo, pFontAttr);
                else if (pFontInfo->DecodeType == DECODE_ELTRON)
                    CaculateEplDistance(pFontInfo, pFontAttr);
                else
                    CaculateTsplDistance(pFontInfo, pFontAttr);
            }
            if (IS_AGFA_TYPE(pFontAttr->iFontType))
                SizePointToDot(pFontAttr);
            return TRUE;
        }
    }

    // download font
    else if (CheckDownloadFont(pFileName, pFontAttr))
    {
        if (!IS_TTF_TYPE(pFontAttr->iFontType))
            SwapFontMultiXY(pFontAttr);
        if (IS_AGFA_TYPE(pFontAttr->iFontType))
            SizePointToDot(pFontAttr);
        return TRUE;
    }

    // memory card font
    else if (pFontInfo = CheckTsplMCardFont((CHAR *)pFileName))
    {
        if (GetBuildFontInfo(pFontInfo, pFontAttr))
        {
            if (!IS_TTF_TYPE(pFontInfo->FontType))
            {
                SwapFontMultiXY(pFontAttr);
                CaculateTsplDistance(pFontInfo, pFontAttr);
            }
            return TRUE;
        }
    }

    return FALSE;
}

STATIC INT GetEplFontInfo(BYTE *pFileName, _FontAttr *pFontAttr, _TextAttr *psTextAttr)
{
    _FontInfo *pFontInfo;

    // copy text struct data to font struct
    CopyTextToFont(pFontAttr, psTextAttr);

    // build font
    if (pFontInfo = CheckEplBuildFont((CHAR *)pFileName))
    {
        if (GetBuildFontInfo(pFontInfo, pFontAttr))
        {
            if (!IS_TTF_TYPE(pFontInfo->FontType))
            {
                SwapFontMultiXY(pFontAttr);
                CaculateEplDistance(pFontInfo, pFontAttr);
            }
            return TRUE;
        }
    }

    // download font
    else if (CheckDownloadFont(pFileName, pFontAttr))
    {
        if (!IS_TTF_TYPE(pFontAttr->iFontType))
            SwapFontMultiXY(pFontAttr);
        return TRUE;
    }

    return FALSE;
}

STATIC INT GetZplFontInfo(BYTE *pFileName, _FontAttr *pFontAttr, _TextAttr *psTextAttr)
{
    _FontInfo *pFontInfo;

    // copy text struct data to font struct
    CopyTextToFont(pFontAttr, psTextAttr);

    // build font
    if (pFontInfo = CheckZplBuildFont((CHAR *)pFileName))
    {
        if (GetBuildFontInfo(pFontInfo, pFontAttr))
        {
            CaculateZplFontMulti(pFontAttr);
            CaculateZplDistance(pFontInfo, pFontAttr);

            psTextAttr->iBaseLine = pFontInfo->BaseLine * pFontAttr->iVertMulti;
            return TRUE;
        }
    }

    // download font
    else if (CheckDownloadFont(pFileName, pFontAttr))
    {
        CaculateZplFontMulti(pFontAttr);
        return TRUE;
    }

    return FALSE;
}

STATIC INT GetDplFontInfo(BYTE *pFileName, _FontAttr *pFontAttr, _TextAttr *psTextAttr)
{
    _FontInfo *pFontInfo;

    // copy text struct data to font struct
    CopyTextToFont(pFontAttr, psTextAttr);

    // build font
    if (pFontInfo = CheckDplBuildFont((CHAR *)pFileName))
    {
        if (GetBuildFontInfo(pFontInfo, pFontAttr))
        {
            CaculateDplDistance(pFontInfo, pFontAttr);
            return TRUE;
        }
    }

    // download font
    else if (CheckDownloadFont(pFileName, pFontAttr))
        return TRUE;

    return FALSE;
}

STATIC VOID CheckFontMulti(_FontAttr *pFontAttr)
{
    if (pFontAttr->iHoriMulti < 1)
        pFontAttr->iHoriMulti = 1;
    if (pFontAttr->iHoriMulti > 10)
        pFontAttr->iHoriMulti = 10;

    if (pFontAttr->iVertMulti < 1)
        pFontAttr->iVertMulti = 1;
    if (pFontAttr->iVertMulti > 10)
        pFontAttr->iVertMulti = 10;
}

/*----------------------------------------------------------------------------------
Function name:
    OutText
Description:
    Draw Text
Input:
    psTextAtrr: Text Attrible
output:
    TRUE or FALSE
----------------------------------------------------------------------------------*/
INT OutText(_TextAttr* pTextAttr)
{
    _FontAttr sFontAttr;

    pTextAttr->iBaseLine   = 0;
    pTextAttr->iAdjustLine = 0;
    pTextAttr->iRealHeight = 0;
    pTextAttr->iRealWidth  = 0;

    if (pTextAttr->sCoord.iX < 0 || pTextAttr->sCoord.iY < 0)
        return FALSE;

    memset(&sFontAttr, 0, sizeof(sFontAttr));

    if (pTextAttr->eLanguage == LANG_DPL)
    {
           sFontAttr.iCodePage = *pDplCodePage;
        sFontAttr.pRemapChar = pDplRemap;
        if (!GetDplFontInfo(pTextAttr->pFont, &sFontAttr, pTextAttr))
            return FALSE;
    }
    else if (pTextAttr->eLanguage == LANG_ZPL)
    {
           sFontAttr.iCodePage = *pZplCodePage;
        sFontAttr.pRemapChar = pZplRemap;
        if (!GetZplFontInfo(pTextAttr->pFont, &sFontAttr, pTextAttr))
            return FALSE;
    }
    else if (pTextAttr->eLanguage == LANG_EPL)
    {
           sFontAttr.iCodePage = *pEplCodePage;
        sFontAttr.pRemapChar = pEplRemap;
        if (!GetEplFontInfo(pTextAttr->pFont, &sFontAttr, pTextAttr))
            return FALSE;
    }
    else
    {
           sFontAttr.iCodePage = *pTsplCodePage;
        sFontAttr.pRemapChar = pTsplRemap;
        if (!GetTsplFontInfo(pTextAttr->pFont, &sFontAttr, pTextAttr))
            return FALSE;
    }

    switch (sFontAttr.iFontType)
    {
#if defined(AGFA_TTF)
        case AGFA_FONT_TYPE_CGT:
        case AGFA_FONT_TYPE_CGT_BOLD:
        case AGFA_FONT_TYPE_DOWNLOAD:
            AgfaOutText(&sFontAttr);
            break;
#endif

#if defined(FREETYPE_TTF)
        case TTF_FONT_TYPE:
            TTOutText(pTextAttr, &sFontAttr);
            break;
#endif
        case BF1_FONT_TYPE:
        case BF2_FONT_TYPE:
        case BF3_FONT_TYPE:
        case BF4_FONT_TYPE:
        case BF1_FONT_TYPE_V1:
        case BF1_2_FONT_TYPE_V1:
        case BF2_FONT_TYPE_V1:
            if (sFontAttr.iRealHeight > 0 && sFontAttr.iRealWidth > 0)
            {
                CheckFontMulti(&sFontAttr);
                OutFont(sFontAttr.pExp, &sFontAttr);
            }
            break;

        case VF1_FONT_TYPE:
        case VF3_FONT_TYPE:
        case VF2_FONT_TYPE:
        case VF4_FONT_TYPE:
        case VF1_FONT_TYPE_V1:
        case VF1_2_FONT_TYPE_V1:
        case EPL_FONT_TYPE:
            if (sFontAttr.iRealHeight > 0)
            {
                CheckFontMulti(&sFontAttr);
                OutFont(sFontAttr.pExp, &sFontAttr);
            }
            break;

        case THAI_FONT_TYPE:
            sFontAttr.iDirection = sFontAttr.iRotation;
            if (sFontAttr.iRealHeight > 0)
            {
                CheckFontMulti(&sFontAttr);
                OutFont(sFontAttr.pExp, &sFontAttr);
            }
            break;

        default:
            return FALSE;
    }
    if (sFontAttr.iLocate == DOWNLOAD_FONT)
        Fclose(pFontFileHandle);

    if (pTextAttr->iBaseLine == 0)
    {
        if (IS_TTF_TYPE(sFontAttr.iFontType))
            pTextAttr->iBaseLine = (sFontAttr.iVertMulti * 3) >> 2;
        else
            pTextAttr->iBaseLine = (sFontAttr.iRealHeight * sFontAttr.iVertMulti * 3) >> 2;
    }
    // for ZPL download bitmap font
    if (sFontAttr.eLanguage == LANG_ZPL && sFontAttr.iBaseLineZ)
    {
        pTextAttr->iBaseLine   = sFontAttr.iBaseLineZ;
        pTextAttr->iAdjustLine = (sFontAttr.iRealHeight / 2) - sFontAttr.iBaseLineZ;
    }
    pTextAttr->iRealHeight = sFontAttr.iTextHeight;
    pTextAttr->iRealWidth  = sFontAttr.iTextWidth;
    return TRUE;
}

/*----------------------------------------------------------------------------------
Function name:
    PreviewText
Description:
    Get Text Expression width and high
    high put in TextAttr.iRealHigh
    width put in TextAttr.IRealWidth
Input:
    psTextAtrr: Text Attrible
output:
   0: ok
   1: error
----------------------------------------------------------------------------------*/
INT PreviewText(_TextAttr *pTextAttr)
{
    _FontAttr sFontAttr;

    pTextAttr->iBaseLine   = 0;
    pTextAttr->iAdjustLine = 0;
    pTextAttr->iRealHeight = 0;
    pTextAttr->iRealWidth  = 0;

    memset(&sFontAttr, 0, sizeof(sFontAttr));

    if (pTextAttr->eLanguage == LANG_DPL)
    {
           sFontAttr.iCodePage = *pDplCodePage;
        sFontAttr.pRemapChar = pDplRemap;
        if (!GetDplFontInfo(pTextAttr->pFont, &sFontAttr, pTextAttr))
            return FALSE;
    }
    else if (pTextAttr->eLanguage == LANG_ZPL)
    {
           sFontAttr.iCodePage = *pZplCodePage;
        sFontAttr.pRemapChar = pZplRemap;
        if (!GetZplFontInfo(pTextAttr->pFont, &sFontAttr, pTextAttr))
            return FALSE;
    }
    else if (pTextAttr->eLanguage == LANG_EPL)
    {
           sFontAttr.iCodePage = *pEplCodePage;
        sFontAttr.pRemapChar = pEplRemap;
        if (!GetEplFontInfo(pTextAttr->pFont, &sFontAttr, pTextAttr))
            return FALSE;
    }
    else
    {
           sFontAttr.iCodePage = *pTsplCodePage;
        sFontAttr.pRemapChar = pTsplRemap;
        if (!GetTsplFontInfo(pTextAttr->pFont, &sFontAttr, pTextAttr))
            return FALSE;
    }

    switch (sFontAttr.iFontType)
    {
#if defined(AGFA_TTF)
        case AGFA_FONT_TYPE_CGT:
        case AGFA_FONT_TYPE_CGT_BOLD:
        case AGFA_FONT_TYPE_DOWNLOAD:
            PreviewAcfaFont(&sFontAttr);
            break;
#endif

#if defined(FREETYPE_TTF)
        case TTF_FONT_TYPE:
            PreviewTTOutText(pTextAttr, &sFontAttr);
            break;
#endif
        case BF1_FONT_TYPE:
        case BF3_FONT_TYPE:
        case BF2_FONT_TYPE:
        case BF4_FONT_TYPE:
        case BF1_FONT_TYPE_V1:
        case BF1_2_FONT_TYPE_V1:
        case BF2_FONT_TYPE_V1:
            if (sFontAttr.iRealHeight > 0 && sFontAttr.iRealWidth > 0)
            {
                CheckFontMulti(&sFontAttr);
                PreviewFont(sFontAttr.pExp, &sFontAttr);
            }
            break;

        case VF1_FONT_TYPE:
        case VF3_FONT_TYPE:
        case VF2_FONT_TYPE:
        case VF4_FONT_TYPE:
        case VF1_FONT_TYPE_V1:
        case VF1_2_FONT_TYPE_V1:
        case EPL_FONT_TYPE:
            if (sFontAttr.iRealHeight > 0)
            {
                CheckFontMulti(&sFontAttr);
                PreviewFont(sFontAttr.pExp, &sFontAttr);
            }
            break;

        case THAI_FONT_TYPE:
            sFontAttr.iDirection = sFontAttr.iRotation;
            if (sFontAttr.iRealHeight > 0)
            {
                BYTE abString[1024];
                CheckFontMulti(&sFontAttr);
                ThaiStringRegulator(abString, sFontAttr.pExp);
                PreviewFont(abString, &sFontAttr);
            }
            break;

        default:
            return FALSE;
    }
    if (sFontAttr.iLocate == DOWNLOAD_FONT)
        Fclose(pFontFileHandle);

    if (pTextAttr->iBaseLine == 0)
    {
        if (IS_TTF_TYPE(sFontAttr.iFontType))
            pTextAttr->iBaseLine = (sFontAttr.iVertMulti * 3) >> 2;
        else
            pTextAttr->iBaseLine = (sFontAttr.iRealHeight * sFontAttr.iVertMulti * 3) >> 2;
    }
    // for ZPL download bitmap font
    if (sFontAttr.eLanguage == LANG_ZPL && sFontAttr.iBaseLineZ)
    {
        pTextAttr->iBaseLine   = sFontAttr.iBaseLineZ;
        pTextAttr->iAdjustLine = (sFontAttr.iRealHeight / 2) - sFontAttr.iBaseLineZ;
    }
    pTextAttr->iRealHeight = sFontAttr.iTextHeight;
    pTextAttr->iRealWidth  = sFontAttr.iTextWidth;
    return TRUE;
}

/*----------------------------------------------------------------------------------
Function name:
    PreviewFontSize
Description:
    Get Font Expression width and high
    high put in TextAttr.iRealHigh
    width put in TextAttr.IRealWidth
Input:
    psTextAtrr: Text Attrible
output:
   0: ok
   1: error
----------------------------------------------------------------------------------*/
BOOL GetFontSize(CHAR *FontName, _eLanguage Lang, SHORT *Width, SHORT *Height)
{
    _FontAttr sFontAttr;
    _TextAttr sTextAttr;

    if (Lang == LANG_DPL)
    {
        if (!GetDplFontInfo((BYTE *)FontName, &sFontAttr, &sTextAttr))
            return FALSE;
    }
    else if (Lang == LANG_ZPL)
    {
        if (!GetZplFontInfo((BYTE *)FontName, &sFontAttr, &sTextAttr))
            return FALSE;
    }
    else if (Lang == LANG_EPL)
    {
        if (!GetEplFontInfo((BYTE *)FontName, &sFontAttr, &sTextAttr))
            return FALSE;
    }
    else
    {
        if (!GetTsplFontInfo((BYTE *)FontName, &sFontAttr, &sTextAttr))
            return FALSE;
    }

    if (sFontAttr.iLocate == DOWNLOAD_FONT)
        Fclose( pFontFileHandle ); 

    *Width  = sFontAttr.iRealWidth;
    *Height = sFontAttr.iRealHeight;
    return TRUE;
}

VOID SetCodePageCross(_eLanguage Lang, BYTE *pPage, BYTE *pRemap)
{
    switch (Lang)
    {
        case LANG_TSPL:
            pTsplCodePage = pPage;
            pTsplRemap    = pRemap;
            break;
        case LANG_EPL:
            pEplCodePage  = pPage;
            pEplRemap     = pRemap;
            break;
        case LANG_ZPL:
            pZplCodePage  = pPage;
            pZplRemap     = pRemap;
            break;
        case LANG_DPL:
            pDplCodePage = pPage;
            pDplRemap    = pRemap;
            break;
    }
}

Text.h   。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

#ifndef TEXT_H

/******************************************************************************
 *                                                                            *
 *                         M O D U L E   D E F I N E                          *
 *                                                                            *
 ******************************************************************************/

#define TEXT_H

/******************************************************************************
 *                                                                            *
 *        C O M P I L E R   D E F I N E D   I N C L U D E   F I L E S         *
 *                                                                            *
 ******************************************************************************/

/* None */

/******************************************************************************
 *                                                                            *
 *            U S E R   D E F I N E D   I N C L U D E   F I L E S             *
 *                                                                            *
 ******************************************************************************/

#include "XGraphic.h"
#include "XImgMgr.h"
#include "XFileSys.h"

#ifdef __cplusplus
extern "C" {            /* Assume C declarations for C++ */
#endif    /* __cplusplus */

/******************************************************************************
 *                                                                            *
 *                        G L O B A L   D E F I N E S                         *
 *                                                                            *
 ******************************************************************************/

typedef enum
{
    BF1_FONT_TYPE,
    BF2_FONT_TYPE,
    BF3_FONT_TYPE,
    BF4_FONT_TYPE,
    VF1_FONT_TYPE,
    VF2_FONT_TYPE,
    VF3_FONT_TYPE,
    VF4_FONT_TYPE,
    VF5_FONT_TYPE,
    VF6_FONT_TYPE,
    THAI_FONT_TYPE,
    BF1_FONT_TYPE_V1,
    BF2_FONT_TYPE_V1,
    VF1_FONT_TYPE_V1,
    BF1_2_FONT_TYPE_V1,
    VF1_2_FONT_TYPE_V1,
    EPL_FONT_TYPE,
    TTF_FONT_TYPE,                // Free Type TTF
    AGFA_FONT_TYPE_CGT,            // USFT TTF
    AGFA_FONT_TYPE_CGT_BOLD,    // USFT TTF
    AGFA_FONT_TYPE_DOWNLOAD,    // USFT TTF
    ERR_FONT_TYPE,                // Error Font Name
}_eFontType;

typedef enum
{
    BUILD_FONT,
    DOWNLOAD_FONT,
}_eFontLocate;

typedef enum
{
    LANG_TSPL,
    LANG_EPL,
    LANG_ZPL,
    LANG_DPL,
}_eLanguage;

/******************************************************************************
 *                                                                            *
 *                 S T R U C T U R E   D E F I N I T I O N S                  *
 *                                                                            *
 ******************************************************************************/

typedef struct
{
    DWORD    dwOffset;        //    0-3:    Font Data Offset
    WORD    wTotalWidth;    //    4-5:    Font Total Width
    WORD    wActualWidth;    //    6-7:    Font Actual Width
    WORD    wDrawPoint;        //    8-9:    Font Draw Point
    WORD    wReversed;        //    10-11:    Reversed
}_ThaiTable;

typedef struct
{
    _ImgBuf            *psImageBuffer;
    _Coord            sCoord;
    SHORT            iDirection;
    SHORT            iRotation;
    SHORT            iDistance;
    SHORT            iBaseLine;
    SHORT            iAdjustLine;    // For ZPL download bitmap fonts.
    SHORT            iRealHeight;
    SHORT            iRealWidth;
    SHORT            iHoriMulti;     // Used to describe point size too.
    SHORT            iVertMulti;     // Used to describe style too.
    SHORT            iReverse;
    SHORT            iSymbolSet;
    SHORT            ExpLength;
    BYTE            *pExp;
    BYTE            *pFont;
    _eLanguage        eLanguage;
    _ePutWay        ePutWay;
}_TextAttr;

typedef struct
{
    INT                (*lpGetData)(BYTE *, INT);    // Get Data Function
    VOID            (*lpSetDataPoint)(INT);        // Set Data Point Function
    LONG            (*lpGetDataPoint)(VOID);
    LONG            (*lpGetSize)(VOID);
    LONG            (*lpGetAddrPoint)(VOID);
    _ImgBuf            *psImageBuffer;
    _Coord            sCoord;
    SHORT            iDirection;
    SHORT            iRotation;
    SHORT            iHoriMulti;                 // Used to describe point size too.
    SHORT            iVertMulti;                 // Used to describe style too.
    SHORT            iFontType;                    // ttf, bf1, bf2, etc.
    SHORT            iPointSize;
    SHORT            iFontWidth;
    SHORT            iRealWidth;
    SHORT            iRealHeight;
    SHORT            iFontByteWidth;
    SHORT            iTextWidth;
    SHORT            iTextHeight;
    SHORT            iFirstChar;
    SHORT            iLastChar;
    SHORT             iTotalChar;
    SHORT            iDecodeType;
    SHORT            iSymbolSet;
    SHORT             iLocate;
    SHORT            iStyle;
    SHORT            iDistance;
    SHORT             iItalicWidth;
    SHORT             iCodePage;
    SHORT            iRotationSupport;            // Rotation of EPL
    SHORT            iBaseLineZ;                    // Bsae line of ZPL
    INT                iHeadLen;
    SHORT            ExpLength;
    BYTE            *pExp;
    BYTE            *pFont;
    BYTE            *pRemapChar;
    _ThaiTable        sThaiTable;
    _eLanguage        eLanguage;
    _ePutWay        ePutWay;
}_FontAttr;

typedef struct
{        
    BYTE    bManufacturer;    //    0:        B->Bitmap font
    BYTE    bPitch;            //    1:        0->Fixed pitch 1->Variable Pitch
    BYTE    bCharSize;        //    2:        0->Singed Byte Decode 1->Double Byte Decode
    BYTE    bDecodeTable;    //    3:        decode by table 0->without 1->with
    BYTE    bStyle;            //    4:        0-> None  1->Italic
    WORD    wHeight;        //    5-6:    font Height
    WORD    wWidth;            //    7-8:    font Width
    WORD    wFirstChar;        //    9-10:    font decode start
    WORD    wLastChar;        //    11-12:    font decode end
    BYTE    bDecodeType;    //    13:        font decode type
    BYTE    bReversed;        //    14:        Reversed epl:rotation
    WORD    wTotalChar;        //    15-16:    font character total
    WORD    wItalicWidth;    //    17-18:    Italic Width Variable
    WORD    wVF6RealHeight;    //    19-20:    VF6 RealHeight
    WORD    wLanguage;        //    21-22:    Language
    BYTE    abDummy[9];        //    23-31:    Reversed
}_FontHeader;

/*----------------------------------------------------------------------------------
font file head
locate 0:         B->Bitmap font
locate 1:         0->Fixed pitch 1->Variable Pitch
locate 2:         0->Singed Byte Decode 1->Double Byte Decode
locate 3:         decode by table
locate 4:         0-> None  1->Italic
locate 5-6:     font Height
locate 7-8:     font Width
locate 9-10:    font decode start
locate 11-12:    font decode end
locate 13:        font decode type
locate 14:        Rotation Support     //Reversed
locate 15-16:    font character total
locate 17-18:    Italic Width Variable
locate 19-20:   VF6 RealHeight
locate 21-22:   Language
----------------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------------------------------
       fixed pitch | variabled pitch |  singed byte | doubled byte | decoded by Table | font table
BF1       x                                 x 
BF2       x                                               x
BF3       x                                 x                                x
BF4       x                                               x                  x
VF1                        x                x 
VF2                        x                              x 
VF3                        x                x                                x  
VF4                        x                              x                  x
VF7                        x                x                                               x
-------------------------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------
thai font table structure

locate 0-3:        Font Data Offset
locate 4-5:        Font Total Width
locate 6-7:        Font Actual Width
locate 8-9:        Font Draw Point
----------------------------------------------------------------------------------*/

/******************************************************************************
 *                                                                            *
 *    G L O B A L   V A R I A B L E S   -   N O   I N I T I A L I Z E R S     *
 *                                                                            *
 ******************************************************************************/
 
/* None */

/******************************************************************************
 *                                                                            *
 *       G L O B A L   V A R I A B L E S   -   I N I T I A L I Z E R S        *
 *                                                                            *
 ******************************************************************************/

/* None */

/******************************************************************************
 *                                                                            *
 *                   F U N C T I O N   P R O T O T Y P E S                    *
 *                                                                            *
 ******************************************************************************/

/* Text.c */

INT OutText(_TextAttr *);
INT PreviewText(_TextAttr *);
BOOL GetFontSize(CHAR *, _eLanguage, SHORT *, SHORT *);
VOID SetCodePageCross(_eLanguage, BYTE *, BYTE *);

/* Ttextout.c */

#if defined(FREETYPE_TTF)
INT TTOutText(_TextAttr *, _FontAttr *);
INT PreviewTTOutText(_TextAttr *, _FontAttr *);
#endif

/* AgfaText.c */

#if defined(AGFA_TTF)
INT InitUFST(VOID);
INT AgfaOutText(_FontAttr *);
INT PreviewAcfaFont(_FontAttr *);
#endif

VOID *InstallEncodingTable(VOID *, INT);

#ifdef __cplusplus
}                       /* End of extern "C" { */
#endif    /* __cplusplus */

#endif

  • 13
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值