T168_111\appl\Text\BMF:总共4个文件

BMF.c    /

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

#define BMF_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 <ctype.h>
#include <stdio.h>
#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 "XGraphic.h"
#include "XCodePage.h"
#include "Thai.h"
#include "BMF.h"

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

#define FONT_AREA_SIZE                    0x10000

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

typedef enum
{
    BF2_V1_NORMAL,
    BF2_V1_BIG5_FULL,
    BF2_V1_BIG5_HALF,
    BF2_V1_KOREA_FULL,
    BF2_V1_KOREA_HALF,
    BF2_V1_JAPAN_FULL,
    BF2_V1_JAPAN_HALF,
}_eBF2FontTypeV1;

/******************************************************************************
 *                                                                            *
 *             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     *
 *                                                                            *
 ******************************************************************************/

#if defined(HALF2FULL)
CONST WORD FullDigit[] =
//  '0'    '1'    '2'    '3'    '4'    '5'    '6'    '7'    '8'    '9'
{ 0xA2AF,0xA2B0,0xA2B1,0xA2B2,0xA2B3,0xA2B4,0xA2B5,0xA2B6,0xA2B7,0xA2B8 };
                        
CONST WORD FullUpper[] =
//  'A'    'B'    'C'    'D'    'E'    'F'    'G'    'H'    'I'    'J'    'K'    'L'    'M'
{ 0xA2CF,0xA2D0,0xA2D1,0xA2D2,0xA2D3,0xA2D4,0xA2D5,0xA2D6,0xA2D7,0xA2D8,0xA2D9,0xA2DA,0xA2DB,
//  'N'    'O'    'P'    'Q'    'R'    'S'    'T'    'U'    'V'    'W'    'X'    'Y'    'Z'
  0xA2DC,0xA2DD,0xA2DE,0xA2DF,0xA2E0,0xA2E1,0xA2E2,0xA2E3,0xA2E4,0xA2E5,0xA2E6,0xA2E7,0xA2E8 };
                        
CONST WORD FullLower[] =
//  'a'    'b'    'c'    'd'    'e'    'f'    'g'    'h'    'i'    'j'    'k'    'l'    'm'
{ 0xA2E9,0xA2EA,0xA2EB,0xA2EC,0xA2ED,0xA2EE,0xA2EF,0xA2F0,0xA2F1,0xA2F2,0xA2F3,0xA2F4,0xA2F5,
//  'n'    'o'    'p'    'q'    'r'    's'    't'    'u'    'v'    'w'    'x'    'y'    'z'
  0xA2F6,0xA2F7,0xA2F8,0xA2F9,0xA2FA,0xA2FB,0xA2FC,0xA2FD,0xA2FE,0xA340,0xA341,0xA342,0xA343 };

#endif


CONST WORD Big5HalfToFull[]=
{
    0,  9,    70,    75,    160,165, 76, 74, 29, 30, 77,109, 13,110, 15,158,
    234,235,236,237,238,239,240,241,242,243, 10,  6,115,117,116,  8,
    166,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,
    281,282,283,284,285,286,287,288,289,290,291, 37,159, 38,328, 26,
    73, 292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,
    307,308,309,310,311,312,313,314,315,316,317,033,213, 34,129,321,
};

#if defined(TSPL_VER_1)
CONST BYTE Big5HalfFontMap[]=
{    
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x7C,0x7D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x50,0x51,0x2C,0x2D,0x2E,0x01,0x52,0x53,0x54,0x55,0x02,0x2F,0x03,0x04,0x30,
    0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x56,0x57,0x58,0x59,0x5A,
    0x5B,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,
    0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x5C,0x34,0x5D,0x5E,0x5F,
    0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
    0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0xA6,0x00,0xA7,0xA0,0x00,
    0x35,0x7F,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x36,0x37,
    0x38,0x8C,0x39,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x3A,0x3B,0x33,0x31,0xA4,0x00,0x32,
    0x94,0x95,0x96,0x97,0x98,0x3D,0x99,0x9A,0x9B,0x00,0x00,0x2A,0x2B,0x9C,0x00,0x00,
    0xC3,0xC3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x4A,0x00,0x00,0x00,0x00,0x9F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0xA1,0x00,0x00,0x00,0x00,0xA8,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#endif

/******************************************************************************
 *                                                                            *
 *    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     *
 *                                                                            *
 ******************************************************************************/

_FontAttr *pExtFontAttr;

/******************************************************************************
 *
 * Function:
 *    
 *
 * Description: 
 *        
 *
 * Input:
 *      None
 *
 * Output:
 *      None.
 *
 ******************************************************************************/

VOID SetExtFontAttr(_FontAttr* pFontAttr)
{
    // for special 243 Tranditional chinese 24 * 24
    pExtFontAttr = pFontAttr;
}

VOID EplDownloadFontRotation(INT Offset, _FontAttr* pFontAttr)
{
    _ImgBuf sSourceImg;
    BYTE *bFontArea;
    BYTE LineBuffer[256];
    INT Width, Height;
    INT HoriMulti, VertMulti;
    INT Rotation;
    INT LineSize;
    INT Shift;
    INT Delta;
    INT TargetOffset;
    INT i, j;

    if (pFontAttr->iRotationSupport == 1)    // 90 degree
    {
        Width = pFontAttr->iRealHeight;
        Height = pFontAttr->iFontByteWidth;
        HoriMulti = pFontAttr->iVertMulti;
        VertMulti = pFontAttr->iHoriMulti;
        Rotation = (pFontAttr->iRotation - 90 + 360) % 360;

        LineSize = (Width + 7) >> 3;
        Shift = (LineSize << 3) - Width;
    }
    else
    {
        Width = pFontAttr->iRealWidth;
        Height = pFontAttr->iRealHeight;
        HoriMulti = pFontAttr->iHoriMulti;
        VertMulti = pFontAttr->iVertMulti;
        Rotation = pFontAttr->iRotation;

        LineSize = pFontAttr->iFontByteWidth;
        Shift = 0;
    }

    Delta = ((Width * HoriMulti + pFontAttr->iDistance + 7) >> 3) - ((Width * HoriMulti + 7) >> 3);

    if ((bFontArea = (BYTE *)malloc(FONT_AREA_SIZE)) == _NULL)
        return;

    TargetOffset = 0;
    pFontAttr->lpSetDataPoint(Offset);
    for (i = 0; i < Height; i++)
    {
        memset(LineBuffer, 0, ((Width + 7) >> 3));
        pFontAttr->lpGetData(LineBuffer, LineSize);
        if (Shift)
        {
            for (j = 0; j < LineSize; j++)
                LineBuffer[j] = (LineBuffer[j] << Shift) | (LineBuffer[j+1] >> (8 - Shift));
        }
        TargetOffset += LineMultiple(LineBuffer, bFontArea + TargetOffset, Width, HoriMulti, VertMulti, Delta);
    }

    sSourceImg.iWidth = Width * HoriMulti + pFontAttr->iDistance;
    sSourceImg.iHeight = Height * VertMulti;
    sSourceImg.iByteWidth = (Width * HoriMulti + 7) >> 3;
    sSourceImg.pBuffer = bFontArea;

    PutImage(pFontAttr->psImageBuffer, &sSourceImg, pFontAttr->sCoord.iX,
        pFontAttr->sCoord.iY, Rotation, pFontAttr->ePutWay);

    free(bFontArea);
}

VOID FontRotation(INT Offset, _FontAttr* pFontAttr)
{
    INT i, j;
    INT TLineSize, SLineSize;
    INT TargetOffset;
    _ImgBuf sSourceImg;
    BYTE *bFontArea;
    BYTE LineBuffer[256];
    INT Delta;

    if (pFontAttr->iLocate == DOWNLOAD_FONT && pFontAttr->iFontType == EPL_FONT_TYPE && pFontAttr->eLanguage == LANG_EPL)
    {
        EplDownloadFontRotation(Offset, pFontAttr);
        return;
    }

    if ((bFontArea = (BYTE *)malloc(FONT_AREA_SIZE)) == _NULL)
        return;

    TargetOffset = 0;
    SLineSize = (pFontAttr->iRealWidth + 7) / 8;
    TLineSize = (pFontAttr->iRealWidth * pFontAttr->iHoriMulti + pFontAttr->iDistance + 7) / 8;
    i = (pFontAttr->iRealWidth * pFontAttr->iHoriMulti + 7) / 8;
    Delta = TLineSize - i;

    pFontAttr->lpSetDataPoint(Offset);
    for (i = 0; i < pFontAttr->iRealHeight; i++)
    {
        if (pFontAttr->iHoriMulti == 1)
        {
            pFontAttr->lpGetData( bFontArea + TargetOffset, SLineSize );
            memset(bFontArea + TargetOffset + SLineSize, 0, Delta);                
            for (j = 1; j < pFontAttr->iVertMulti; j++)
                memcpy(bFontArea + TargetOffset + j * TLineSize, bFontArea + TargetOffset, TLineSize);
            TargetOffset += TLineSize * pFontAttr->iVertMulti;
        }
        else
        {
            pFontAttr->lpGetData(LineBuffer, SLineSize);
            LineMultiple(LineBuffer, bFontArea + TargetOffset, pFontAttr->iRealWidth, pFontAttr->iHoriMulti, pFontAttr->iVertMulti, Delta);
            TargetOffset += TLineSize * pFontAttr->iVertMulti;
        }
    }

    sSourceImg.iWidth = pFontAttr->iRealWidth * pFontAttr->iHoriMulti + pFontAttr->iDistance;
    sSourceImg.iHeight = pFontAttr->iRealHeight * pFontAttr->iVertMulti;
    sSourceImg.iByteWidth = (sSourceImg.iWidth + 7) / 8;
    sSourceImg.pBuffer = bFontArea;

    PutImage(pFontAttr->psImageBuffer, &sSourceImg, pFontAttr->sCoord.iX,
        pFontAttr->sCoord.iY, pFontAttr->iRotation, pFontAttr->ePutWay);

    free(bFontArea);
}

INT GetUTF8Decode(BYTE *string, INT *bytes)
{
    INT unicode = 0;

    if (*string < 0x80)
    {
        unicode= *string;
        *bytes = 1;
    }
    else if (*string >= 192 && *string <= 223)
    {
        unicode  = (INT)(*(string + 0) - 192) * 64;
        unicode += (INT)(*(string + 1) - 128);
        *bytes = 2;
    }
    else if (*string >= 224 && *string <= 239)
    {
        unicode  = (INT)(*(string + 0) - 224) * 4096;
        unicode += (INT)(*(string + 1) - 128) * 64;
        unicode += (INT)(*(string + 2) - 128);
        *bytes = 3;
    }
    else if (*string >= 240 && *string <= 247)
    {
        unicode  = (INT)(*(string + 0) - 240) * 262144;
        unicode += (INT)(*(string + 1) - 128) * 4096;
        unicode += (INT)(*(string + 2) - 128) * 64;
        unicode += (INT)(*(string + 3) - 128);
        *bytes = 4;
    }
    else if (*string >= 248 && *string <= 251)
    {
        unicode  = (INT)(*(string + 0) - 248) * 16777216;
        unicode += (INT)(*(string + 1) - 128) * 262144;
        unicode += (INT)(*(string + 2) - 128) * 4096;
        unicode += (INT)(*(string + 3) - 128) * 64;
        unicode += (INT)(*(string + 4) - 128);
        *bytes = 5;
    }
    else if (*string == 252 && *string == 253)
    {
        unicode  = (INT)(*(string + 0) - 252) * 1073741824;
        unicode += (INT)(*(string + 1) - 128) * 16777216;
        unicode += (INT)(*(string + 2) - 128) * 262144;
        unicode += (INT)(*(string + 3) - 128) * 4096;
        unicode += (INT)(*(string + 4) - 128) * 64;
        unicode += (INT)(*(string + 5) - 128);
        *bytes = 6;
    }

    // There is something wrong
    else
        *bytes = 1;

    // Does not support unicode over 0x10000
    if (unicode > 0xFFFF)
        unicode = 0;

    return unicode;
}

WORD GetTSCDecode(BYTE *pTextString, SHORT *len)
{
    WORD Data;

    if ((*pTextString < 0x80) && (*pTextString >= 0x20))
    {
#if defined(HALF2FULL)
        INT cByte = *pTextString;
        Data = cByte - 0x20;

        if (isdigit(cByte))
        {
            cByte -= '0';
            Data = ((FullDigit[cByte] >> 8) - 0xA1) * 157;
            Data += ((FullDigit[cByte] & 0xff) - 0xA1) + 63;
        }
        else if (isupper(cByte))
        {
            cByte -= 'A';
            Data = ((FullUpper[cByte] >> 8) - 0xA1) * 157;
            Data += ((FullUpper[cByte] & 0xff) - 0xA1) + 63;
        }
        else if (islower(cByte))
        {
            cByte -= 'a';
            Data = ((FullLower[cByte] >> 8) - 0xA1) * 157;
            if ((FullLower[cByte] & 0xff) > 0xA1)
                Data += ((FullLower[cByte] & 0xff) - 0xA1) + 63;
            else
                Data += (FullLower[cByte] & 0xff) - 0x40;
        }
        *len = 1;
        return Data;
#else
        //
        *len = 1;
        return (*pTextString - 0x20);        
#endif
    }
    if (((*pTextString > 0x80) && (*pTextString < 0xA1)) || (*pTextString < 0x20))
    {
        *len = 1;
        return 0;
    }

    Data = (*pTextString - 0xA1) * 157;
    if (*(pTextString + 1) >= 0xA1)
        Data += (*(pTextString + 1) - 0xA1) + 63;
    else
        Data += (*(pTextString + 1) - 0x40);

    *len = 2;
    return Data;
}

/*----------------------------------------------------------------------------------
Function name:
    GetTSSBF2Decode
Description:
    get bitmap font 2 with simpled chinese decode
    BF2: bitmap font with fixed pitch ,doubled byte 
Input:
    pTextString : Text Expression    
    len: will return full font or half font
output:
   font number
----------------------------------------------------------------------------------*/
WORD GetTSSDecode(BYTE *pTextString, SHORT *len)
{
    WORD Data;

    if ((*pTextString < 0x80) && (*pTextString >= 0x20))
    {
        *len = 1;
        return (*pTextString - 0x20);
    }
    if (((*pTextString > 0x80) && (*pTextString < 0x81)) || (*pTextString < 0x20))
    {
        *len = 1;
        return 0;
    }

    Data = (*pTextString - 0x81) * 191;
    Data += (*(pTextString + 1) - 0x40);
    *len = 2;
    return Data;
}

/*----------------------------------------------------------------------------------
Function name:
    GetJapanBF2Decode
Description:
    get bitmap font 2 with Japan decode
    BF2: bitmap font with fixed pitch ,doubled byte 
Input:
    pTextString : Text Expression    
    len: will return full font or half font
output:
   font number
----------------------------------------------------------------------------------*/
WORD GetJapanDecode(BYTE *pTextString, SHORT *len)
{
    WORD Data;

    if ((*pTextString < 0x80) && (*pTextString >= 0x20))
    {
        *len = 1;
        return (*pTextString - 0x20);
    }
    if (((*pTextString > 0x80) && (*pTextString < 0x81)) || (*pTextString < 0x20))
    {
        *len = 1;
        return 0;
    }
    if ((*pTextString >= 0xA0) && (*pTextString <= 0xdf))
    {
        *len = 1;
        return (*pTextString - 0x40);
    }
    if (*pTextString < 0xa0)
    {
        Data = (*pTextString - 0x81) * 189;
        Data += (*(pTextString + 1) - 0x40);
    }
    else
    {
        Data = (*pTextString - 0x81 - 0x40) * 189;
        Data += (*(pTextString + 1) - 0x40);
    }
    *len = 2;
    return Data;
}

/*----------------------------------------------------------------------------------
Function name:
    GetKoreanBF2Decode
Description:
    get bitmap font 2 with Korean decode
    BF2: bitmap font with fixed pitch ,doubled byte 
Input:
    pTextString : Text Expression    
    len: will return full font or half font
output:
   font number

HIGH BYTE :     A1    ~    FD
LOW BYTE:       A0    ~    FE   
----------------------------------------------------------------------------------*/
WORD GetKoreanDecode(BYTE *pTextString, SHORT *len)
{
    WORD Data;

    if ((*pTextString < 0x80) && (*pTextString >= 0x20))
    {
        *len = 1;
        return (*pTextString - 0x20);
    }
    if (((*pTextString > 0x80) && (*pTextString < 0xA1)) || (*pTextString < 0x20))
    {
        *len = 1;
        return 0;
    }

    Data = (*pTextString - 0xA1) * 95;        // where 95 = 0xFE-0xA0 + 1
    Data += (*(pTextString + 1) - 0xA0);
    *len = 2;
    return Data;
}

WORD GetTSCDecodeV1(BYTE *pTextString, SHORT *len, _eBF2FontTypeV1 *FontStyle, INT FontWidth)
{
    WORD Data;
    WORD Index;

#if defined(TSPL_VER_1)
    if ((*pTextString < 0x80) && (*pTextString >= 0x20) && FontWidth == 24)
    {
        *len = 1;
        *FontStyle = BF2_V1_BIG5_HALF;
        return Big5HalfFontMap[*pTextString];
    }
#endif

    *FontStyle = BF2_V1_BIG5_FULL;
    if ((*pTextString < 0x80) && (*pTextString >= 0x20))
    {
        *len = 1;
        Data = Big5HalfToFull[*pTextString - ' '] + 13094;
        return Data;        
    }

    Index = *pTextString;
    Index <<= 8;
    Index += *(pTextString + 1);

    if (*(pTextString + 1) > 0x7f)
        Data = *(pTextString + 1) - 98;
    else
        Data = *(pTextString + 1) - 64;

    if (Index < 0xA440)
        Data = (*pTextString - 161) * 157 + Data + 13094;
    else if (Index < 0xC6A1)
        Data = (*pTextString - 164) * 157 + Data;
    else if (Index < 0xC940)
        Data = (*pTextString - 198) * 157 + Data + 13094 + 408 - 63;
    else if (Index <= 0xF9D6)
        Data = (*pTextString - 201) * 157 + Data + 5401;
    else
        Data = (*pTextString & 0xff) + 12839;
    *len = 2;

    return Data;
}

WORD GetTSSDecodeV1(BYTE *pTextString, SHORT *len)
{
    WORD Data;

    Data = 0;
    if (*pTextString < 0xA1)
    {
        *len = 1;
        if (*pTextString == ' ')
            return 0;
        Data = (0xA3 - 0xA1) * 94 + ((*pTextString | 0x80) - 0xA1);
        return Data;
    }
    else
    {
        Data = (*pTextString - 0xA1) * 94;
        Data +=(*(pTextString + 1) - 0xA1);
        *len = 2;
    }
    return Data;
}

WORD GetTSS2DecodeV1(BYTE *pTextString ,SHORT *len)
{
    WORD Data;

    Data = 0;
    if (*pTextString < 0xA1)
    {
        *len = 1;
        if (*pTextString == ' ')
            return 0;
        Data = (0xA3 - 0xA1) * 161 + ((*pTextString | 0x80) - 0x40);
        return Data;
    }
    else
    {
        Data = (*pTextString - 0xA1) * 161;
        Data +=(*(pTextString + 1) - 0x40);
        *len = 2;
    }
    return Data;
}

WORD GetSJISDecodeV1(BYTE *pTextString ,SHORT *len, _eBF2FontTypeV1 *FontStyle)
{
    WORD Data;

    if (*pTextString < 0x81)
        Data = (*pTextString + 752 -  0x21);

    else if ((*pTextString >= 0xa1) && (*pTextString < 0xe0))
        Data = (*pTextString + 846 -  0xa1);
    else
    {
        if (*pTextString < 0xe0)
            Data = *pTextString - 0x81;
        else
            Data = *pTextString - 64 - 0x81;
        Data *= 94 * 2;
        if (*(pTextString + 1) < 0x80)
            Data += *(pTextString + 1) - 0x40;
        else
            Data += *(pTextString + 1) - 0x41;
    }

    if (Data >= 752 && Data <= 1034)
    {
        *FontStyle = BF2_V1_JAPAN_HALF;
        *len = 1;
    }
    else
    {
        *FontStyle = BF2_V1_JAPAN_FULL;
        *len = 2;
    }

    return Data;
}

WORD GetJISDecodeV1(BYTE *pTextString ,SHORT *len, _eBF2FontTypeV1 *FontStyle)
{
    WORD Data;

    if (*pTextString < 0x81)
        Data = (*pTextString + 752 -  0x21);

    else if ((*pTextString >= 0xa1) &&  (*pTextString < 0xe0))
        Data = (*pTextString + 846 -  0xa1);
    else
    {
        if  (*pTextString < 0xe0)
            Data = *pTextString - 0x81;
        else
            Data = *pTextString - 64 - 0x81;
        Data *= 94 * 2;
        if (*(pTextString + 1 ) < 0x80)
            Data += *(pTextString + 1) - 0x40;
        else
            Data += *(pTextString + 1) - 0x41;
    }

    if (Data >= 752 && Data <= 1034)
    {
        *FontStyle = BF2_V1_JAPAN_HALF;
        *len = 1;
    }
    else
    {
        *FontStyle = BF2_V1_JAPAN_FULL;
        *len = 2;
    }

    return Data;
}

WORD GetKoreanDecodeV1(BYTE *pTextString ,SHORT *len, _eBF2FontTypeV1 *FontStyle)
{
    WORD Data;

    *FontStyle = BF2_V1_KOREA_FULL;

    if (*pTextString < 0xA1)
    {
        *FontStyle = BF2_V1_KOREA_HALF;
        *len = 1;
        return *pTextString;
    }

    Data = (*pTextString - 0xA1) * 96;
    Data += (*(pTextString + 1) - 0xA0);
    *len = 2;
    return Data;
}

INT GetBFontTableDecode(BYTE *pTextString, _FontAttr* pFontAttr)
{
    INT i;
    LONG Offset;
    BYTE SourceData[2], TargetData[2];

    if (pFontAttr->iFontType == BF3_FONT_TYPE)
    {
        SourceData[0] = *pTextString;
        SourceData[1] = 0;
    }
    else if (pFontAttr->iFontType == BF4_FONT_TYPE)
    {
        SourceData[0] = *pTextString;
        SourceData[1] = *(pTextString + 1);
    }

    Offset = pFontAttr->iHeadLen;

    for (i = 0; i < pFontAttr->iTotalChar; i++)
    {
        pFontAttr->lpSetDataPoint(Offset);
        pFontAttr->lpGetData(TargetData, 2);
        if (strncmp((CHAR *)SourceData, (CHAR *)TargetData, 2) == 0)
        {
            pFontAttr->lpGetData((BYTE *)&Offset, 4);
            Offset = le32_to_cpu(Offset);
            return Offset;
        }
        Offset += 6;
    }
    return 0;
}

INT GetBF2Decode(BYTE *pTextString ,_FontAttr* pFontAttr, INT *DecodeByte)
{
    SHORT ByteLen;
    INT LineSize;
    WORD iChar;
    INT Offset;
    INT SingleByte;

    switch (pFontAttr->iDecodeType)
    {
        case DECODE_BIG5:
            iChar = GetTSCDecode(pTextString, &ByteLen);
            SingleByte = 96;
#if defined(HALF2FULL)
            if (*pTextString < 0x80 && *pTextString >= 0x20 && iChar >= 0x60)
            {
                Offset = (pFontAttr->iRealWidth / 2 + 7) / 8;
                Offset = Offset * pFontAttr->iRealHeight * SingleByte;
                LineSize = (pFontAttr->iRealWidth + 7) / 8;
                Offset += pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
                *DecodeByte = ByteLen;
                return Offset;
            }
#endif
            break;
        case DECODE_GB:    
            iChar = GetTSSDecode(pTextString, &ByteLen);
            SingleByte = 96;
            break;
        case DECODE_SJIS:
            iChar = GetJapanDecode(pTextString, &ByteLen);
            SingleByte = 160;
            break;
        case DECODE_KOREA:
            iChar = GetKoreanDecode(pTextString, &ByteLen);
            SingleByte = 96;
            break;
        default:
            iChar = ((*pTextString) * 256 + *(pTextString + 1)) - pFontAttr->iFirstChar;
            ByteLen = 2;
            LineSize = (pFontAttr->iRealWidth + 7) / 8;
            Offset = pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
            *DecodeByte = 2;
            return Offset;
    }

    if (ByteLen == 1)
    {
        pFontAttr->iRealWidth /= 2;
        LineSize = (pFontAttr->iRealWidth + 7) / 8;
        Offset = pFontAttr->iHeadLen +(iChar * LineSize * (pFontAttr->iRealHeight));
        *DecodeByte = ByteLen;
    }
    else
    {
        Offset = (pFontAttr->iRealWidth / 2 + 7) / 8;
        Offset = Offset * pFontAttr->iRealHeight * SingleByte;
        LineSize = (pFontAttr->iRealWidth + 7) / 8;
        Offset += pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
        *DecodeByte = ByteLen;
    }

    return Offset;
}

INT GetBF2DecodeV1(BYTE *pTextString ,_FontAttr* pFontAttr, INT *DecodeByte, _eBF2FontTypeV1 *FontStyle)
{
    SHORT ByteLen;
    INT LineSize;
    WORD iChar;
    INT Temp;
    INT Offset;

    pFontAttr->iRealWidth = pFontAttr->iFontWidth;
    *FontStyle = BF2_V1_NORMAL;

    switch (pFontAttr->iDecodeType)
    {
        case DECODE_BIG5:    
            iChar = GetTSCDecodeV1(pTextString, &ByteLen, FontStyle, pFontAttr->iFontWidth);
            if (*FontStyle == BF2_V1_BIG5_HALF)
            {
                pFontAttr->iRealWidth = pExtFontAttr->iRealWidth;
                LineSize = (pFontAttr->iRealWidth + 7) / 8;
                Offset = (iChar * LineSize * (pFontAttr->iRealHeight));
                *DecodeByte = ByteLen;
            }
            else
            {
                LineSize = (pFontAttr->iRealWidth + 7) / 8;
                Offset = pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
                *DecodeByte = ByteLen;
            }
            break;
        case DECODE_GB:    
            iChar = GetTSSDecodeV1(pTextString, &ByteLen);
            LineSize = (pFontAttr->iRealWidth + 7) / 8;
            Offset = pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
            *DecodeByte = ByteLen;
            break;
        case DECODE_GX:    
            iChar = GetTSS2DecodeV1(pTextString, &ByteLen);
            LineSize = (pFontAttr->iRealWidth + 7) / 8;
            Offset = pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
            *DecodeByte = ByteLen;
            break;
        case DECODE_SJIS:
            iChar = GetSJISDecodeV1(pTextString, &ByteLen, FontStyle);
            LineSize = (pFontAttr->iRealWidth + 7) / 8;
            Offset = pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
            *DecodeByte = ByteLen;
            if (*FontStyle == BF2_V1_JAPAN_HALF)
                pFontAttr->iRealWidth /= 2;
            break;
        case DECODE_JIS:
            iChar = GetJISDecodeV1(pTextString, &ByteLen, FontStyle);
            LineSize = (pFontAttr->iRealWidth + 7) / 8;
            Offset = pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
            *DecodeByte = ByteLen;
            if (*FontStyle == BF2_V1_JAPAN_HALF)
                pFontAttr->iRealWidth /= 2;
            break;
        case DECODE_KOREA:
            iChar = GetKoreanDecodeV1(pTextString, &ByteLen, FontStyle);
            if (*FontStyle == BF2_V1_KOREA_HALF)
            {
                pFontAttr->iRealWidth /= 2;
                LineSize = (pFontAttr->iRealWidth + 7) / 8;
                Offset = (iChar * LineSize * (pFontAttr->iRealHeight));
                *DecodeByte = ByteLen;
            }
            else
            {
                LineSize = (pFontAttr->iRealWidth + 7) / 8;
                Temp = (pFontAttr->iRealWidth / 2 + 7) / 8 * pFontAttr->iRealHeight;
                Offset = 256 * Temp;
                Offset += pFontAttr->iHeadLen + (iChar * LineSize * pFontAttr->iRealHeight);
                *DecodeByte = ByteLen;
            }
            break;
        default:
            *DecodeByte = 2;
            return 0;
    }
    return Offset;
}

LONG GetVFontOffset(WORD Number, _FontAttr* pFontAttr)
{
    WORD Width;
    LONG Offset;
    INT i;

    Offset = pFontAttr->iHeadLen;
    for (i = 0; i < Number; i++)
    {
        pFontAttr->lpSetDataPoint(Offset);
        pFontAttr->lpGetData((BYTE *)&Width, 2);
        Width = le16_to_cpu(Width);
        Offset += (2 + ((Width + 7) / 8 * pFontAttr->iRealHeight));
    }

    pFontAttr->lpSetDataPoint(Offset);
    pFontAttr->lpGetData((BYTE *)&Width, 2);
    pFontAttr->iRealWidth = le16_to_cpu(Width);
    return Offset + 2;
}

LONG GetVFontOffsetV1(WORD Number, _FontAttr* pFontAttr)
{
    BYTE Width;
    LONG Offset;
    INT i;

    // caculate address table offset
    i = pFontAttr->iHeadLen + Number * 3;
    pFontAttr->lpSetDataPoint(i);
    Offset = 0;
    pFontAttr->lpGetData((BYTE *)&Offset, 3);
    Offset = le32_to_cpu(Offset);
    
    // move to font data
    pFontAttr->lpSetDataPoint(Offset);
    pFontAttr->lpGetData((BYTE *)&Width, 1);

    pFontAttr->iRealWidth = Width;

    return Offset + 1;
}

INT GetVF2Decode(BYTE *pTextString ,_FontAttr* pFontAttr, INT *DecodeByte)
{
    SHORT ByteLen;
    WORD iChar;
    INT Offset;

    switch (pFontAttr->iDecodeType)
    {
        case DECODE_BIG5:    
            iChar = GetTSCDecode(pTextString, &ByteLen);
            *DecodeByte = ByteLen;
            iChar += 96;
            break;
        case DECODE_GB:    
            iChar = GetTSSDecode(pTextString, &ByteLen);
            *DecodeByte = ByteLen;
            iChar += 96;
            break;
        case DECODE_SJIS:
            iChar = GetJapanDecode(pTextString, &ByteLen);
            *DecodeByte = ByteLen;
            iChar += 160;
            break;
        case DECODE_KOREA:
            iChar = GetKoreanDecode(pTextString, &ByteLen);
            *DecodeByte = ByteLen;
            iChar += 96;
            break;
        default:
            iChar = ((*pTextString) * 256 + *(pTextString + 1)) - pFontAttr->iFirstChar;
            *DecodeByte = 2;
            break;
    }

    Offset = GetVFontOffset(iChar, pFontAttr);
    return Offset;
}

INT GetVF2DecodeV1(BYTE *pTextString ,_FontAttr* pFontAttr, INT *DecodeByte)
{
    WORD iChar = ((*pTextString) * 256 + *(pTextString + 1)) - pFontAttr->iFirstChar;
    *DecodeByte = 2;
    return GetVFontOffsetV1(iChar, pFontAttr);
}

INT GetBuildFontDecode(BYTE *pTextString ,_FontAttr* pFontAttr, INT *DecodeByte)
{
    INT charcode = *(pFontAttr->pRemapChar + *pTextString);

    *DecodeByte = 1;

#if defined(DPL)
    if (pFontAttr->iDecodeType == DECODE_DATAMAX)
    {
        if (pFontAttr->eLanguage == LANG_DPL)
            return DplCodePageTable[pFontAttr->iCodePage][charcode];
        return DplCodePageTable[0][charcode];
    }
#endif

#if defined(ZPL2)
    if (pFontAttr->iDecodeType == DECODE_ZEBRA)
    {
        // UCS-2 and UTF-8 encoding
        if ((pFontAttr->eLanguage == LANG_ZPL  && pFontAttr->iCodePage == 17) ||
            (pFontAttr->eLanguage == LANG_ZPL  && pFontAttr->iCodePage == 28) ||
            (pFontAttr->eLanguage == LANG_TSPL && pFontAttr->iCodePage == 43))
        {
            INT unicode = GetUTF8Decode(pTextString, DecodeByte);
            for (charcode = 0; charcode < 256; charcode++)
            {
                if (ZFontToUnicode[charcode] == unicode)
                    return charcode;
            }
        }
        else if (pFontAttr->eLanguage == LANG_ZPL && pFontAttr->iCodePage <= 13)
            return ZplCodePageTable[pFontAttr->iCodePage][charcode];
        else
            return ZplCodePageTable[13][charcode];
    }
#endif

#if defined(EPL2)
    if (pFontAttr->iDecodeType == DECODE_ELTRON)
    {
        if (pFontAttr->eLanguage == LANG_EPL)
            return EplCodePageTable[pFontAttr->iCodePage][charcode];
        if (pFontAttr->eLanguage == LANG_TSPL && pFontAttr->iCodePage < 29)
            return EplCodePageTable[pFontAttr->iCodePage][charcode];
        // default codepage 437
        return EplCodePageTable[9][charcode];
    }
#endif

#if defined(TSPL) && defined(TSPL_VER_2)
    if (pFontAttr->iDecodeType == DECODE_TSC)
    {
        // 7 bit codepage
        if (pFontAttr->eLanguage == LANG_TSPL && pFontAttr->iCodePage < 9)
            return ((charcode < 0x80) ? CodePageTable7Bit[pFontAttr->iCodePage][charcode] : 0);
        // 8 bit codepage
        if (pFontAttr->eLanguage == LANG_TSPL && pFontAttr->iCodePage < 43)
            return CodePageTable8Bit[pFontAttr->iCodePage - 9][charcode];
        // UTF-8 encoding
        if (pFontAttr->eLanguage == LANG_TSPL && pFontAttr->iCodePage == 43)
            return GetUTF8Decode(pTextString, DecodeByte);
        // Other codepage
        return CodePage850ToUnicode[charcode];
    }
#elif defined(TSPL) && defined(TSPL_VER_1)
    if (pFontAttr->iDecodeType == DECODE_TSC)
    {
        if (pFontAttr->eLanguage == LANG_TSPL && pFontAttr->iCodePage < 16)
            return CodePageTable[pFontAttr->iCodePage][charcode];
        // default codepage 850
        return CodePageTable[10][charcode];
    }
#endif

    return 0;
}

INT GetVFontTableOffset(BYTE *pTextString, _FontAttr* pFontAttr)
{
    INT i;
    LONG Offset;
    WORD Width;
    BYTE SourceData[2], TargetData[2];

    if (pFontAttr->iFontType == VF3_FONT_TYPE)
    {
        SourceData[0] = *pTextString;
        SourceData[1] = 0;
    }
    else if (pFontAttr->iFontType == VF4_FONT_TYPE)
    {
        SourceData[0] = *pTextString;
        SourceData[1] = *(pTextString + 1);
    }

    Offset = pFontAttr->iHeadLen;

    for(i = 0; i < pFontAttr->iTotalChar; i++)
    {
        pFontAttr->lpSetDataPoint(Offset);
        pFontAttr->lpGetData(TargetData, 2);
        if (strncmp((CHAR *)SourceData, (CHAR *)TargetData, 2) == 0)
        {
            pFontAttr->lpGetData((BYTE *)&Offset, 4);
            Offset = le32_to_cpu(Offset);
            pFontAttr->lpSetDataPoint(Offset);
            pFontAttr->lpGetData((BYTE *)&Width, 2);
            pFontAttr->iRealWidth = le16_to_cpu(Width);
            return Offset + 2;
        }
        Offset += 6;
    }
    return 0;
}

INT GetThaiFontOffset(BYTE *pTextString, _FontAttr* pFontAttr)
{
    ULONG Offset;
    WORD TotalWidth, ActualWidth, DrawPoint;

    pFontAttr->lpSetDataPoint(pFontAttr->iHeadLen + *pTextString * sizeof(_ThaiTable));

    pFontAttr->lpGetData((BYTE *)&Offset, 4);
    pFontAttr->sThaiTable.dwOffset = le32_to_cpu(Offset);

    pFontAttr->lpGetData((BYTE *)&TotalWidth, 2);
    pFontAttr->sThaiTable.wTotalWidth = le16_to_cpu(TotalWidth);

    pFontAttr->lpGetData((BYTE *)&ActualWidth, 2);
    pFontAttr->sThaiTable.wActualWidth = le16_to_cpu(ActualWidth);

    pFontAttr->lpGetData((BYTE *)&DrawPoint, 2);
    pFontAttr->sThaiTable.wDrawPoint = le16_to_cpu(DrawPoint);

    pFontAttr->iRealWidth = pFontAttr->sThaiTable.wTotalWidth;
    return pFontAttr->sThaiTable.dwOffset;
}

INT GetEplFontOffset(BYTE *pTextString, _FontAttr* pFontAttr)
{
    INT i;
    LONG Offset;
    BYTE Data;
    INT Width, Height;
    BYTE TargetData[2];

    Offset = pFontAttr->iHeadLen;

    for (i = 0; i < pFontAttr->iTotalChar; i++)
    {
        pFontAttr->lpSetDataPoint(Offset);
        pFontAttr->lpGetData(TargetData, 1);

        pFontAttr->lpGetData(&Data, 1);
        pFontAttr->iRealWidth = Data;
        pFontAttr->lpGetData(&Data, 1);
        pFontAttr->iFontByteWidth = Data;

        Width = pFontAttr->iFontByteWidth;
        Height = pFontAttr->iRealHeight;
        if (pFontAttr->iRotationSupport == 1)    // 90 degree
            Height = (Height + 7) >> 3;

        if (*pTextString == *TargetData)
            return Offset + 3;
        Offset += Width * Height + 3;
    }
    return 0;
}

INT BFontOffset(BYTE *pTextString, _FontAttr* pFontAttr, INT *DecodeByte)
{
    INT LineSize = (pFontAttr->iFontWidth + 7) / 8;
    INT CharCode = 0;
    LONG Offset = 0;

    pFontAttr->iRealWidth = pFontAttr->iFontWidth;

    if (pFontAttr->iLocate == BUILD_FONT && pFontAttr->iDecodeType != 0)
    {
        BYTE BuildChar[2], BlankSpace[2] = { 0x20, 0x00 };

        if (pFontAttr->iFontType == BF4_FONT_TYPE)
        {
            if (CharCode = GetBuildFontDecode(pTextString, pFontAttr, DecodeByte))
            {
                BuildChar[0] = (CharCode & 0xff);
                BuildChar[1] = (CharCode >> 8) & 0xff;
                Offset = GetBFontTableDecode(BuildChar, pFontAttr);
            }
            if (Offset == 0)
                Offset = GetBFontTableDecode(BlankSpace, pFontAttr);
        }
    }
    else
    {
        switch (pFontAttr->iFontType)
        {
            case BF1_FONT_TYPE:
            case BF1_FONT_TYPE_V1:
                if (*pTextString >= pFontAttr->iFirstChar && *pTextString <= pFontAttr->iLastChar)
                    CharCode = (*pTextString - pFontAttr->iFirstChar);    
                Offset = pFontAttr->iHeadLen + (CharCode * LineSize * pFontAttr->iRealHeight);                
                *DecodeByte = 1;
                break;
            case BF2_FONT_TYPE:
            case BF1_2_FONT_TYPE_V1:
                return GetBF2Decode(pTextString, pFontAttr, DecodeByte);
            case BF3_FONT_TYPE:
                *DecodeByte = 1;
                return GetBFontTableDecode(pTextString, pFontAttr);
            case BF4_FONT_TYPE:
                *DecodeByte = 2;
                return GetBFontTableDecode(pTextString, pFontAttr);
        }
    }
    return Offset;
}

INT VFontOffset(BYTE *pTextString, _FontAttr* pFontAttr, INT *DecodeByte)
{
    INT CharCode = 0;
    LONG Offset = 0;

    switch (pFontAttr->iFontType)
    {
        case VF1_FONT_TYPE:
            if (*pTextString >= pFontAttr->iFirstChar)
                CharCode = (*pTextString - pFontAttr->iFirstChar);    
            Offset = GetVFontOffset(CharCode, pFontAttr);
            *DecodeByte = 1;
            break;
        case VF2_FONT_TYPE:
            return  GetVF2Decode(pTextString, pFontAttr, DecodeByte);
        case VF3_FONT_TYPE:
            *DecodeByte = 1;
            return GetVFontTableOffset(pTextString, pFontAttr);
        case VF4_FONT_TYPE:
            *DecodeByte = 2;
            return GetVFontTableOffset(pTextString, pFontAttr);
        case EPL_FONT_TYPE:
            *DecodeByte = 1;
            return GetEplFontOffset(pTextString, pFontAttr);
        case THAI_FONT_TYPE:
            *DecodeByte = 1;
            return GetThaiFontOffset(pTextString, pFontAttr);
    }

    return Offset;
}

INT VFontOffsetV1(BYTE *pTextString ,_FontAttr* pFontAttr, INT *DecodeByte)
{
    INT CharCode = 0;
    LONG Offset = 0;

    switch (pFontAttr->iFontType)
    {
        case VF1_FONT_TYPE_V1:
            if     (*pTextString >= pFontAttr->iFirstChar)
                CharCode = (*pTextString - pFontAttr->iFirstChar);
            Offset = GetVFontOffsetV1(CharCode, pFontAttr);
            *DecodeByte = 1;
            break;
        case VF1_2_FONT_TYPE_V1:
            return GetVF2DecodeV1(pTextString, pFontAttr, DecodeByte);
    }

    return Offset;
}

VOID MakeFont(BYTE *pTextString, _FontAttr *pFontAttr, INT Offset)
{
    switch (pFontAttr->iDirection)
    {
        case 0:
            FontRotation(Offset, pFontAttr);
            if (pFontAttr->iRotation == 0 || pFontAttr->iRotation == 180)
            {
                pFontAttr->sCoord.iX += pFontAttr->iRealWidth * pFontAttr->iHoriMulti;
                pFontAttr->sCoord.iX -= pFontAttr->iItalicWidth * pFontAttr->iHoriMulti;
            }
            else
            {
                pFontAttr->sCoord.iX += pFontAttr->iRealHeight * pFontAttr->iVertMulti;
            }
            pFontAttr->sCoord.iX += pFontAttr->iDistance;
            break;
        case 90:
            FontRotation(Offset, pFontAttr);
            if (pFontAttr->iRotation == 0 || pFontAttr->iRotation == 180)
            {
                pFontAttr->sCoord.iY += pFontAttr->iRealHeight * pFontAttr->iVertMulti;
            }
            else
            {
                pFontAttr->sCoord.iY += pFontAttr->iRealWidth * pFontAttr->iHoriMulti;
                pFontAttr->sCoord.iY -= pFontAttr->iItalicWidth * pFontAttr->iHoriMulti;
            }
            pFontAttr->sCoord.iY += pFontAttr->iDistance;
            break;
        case 180:
            if (pFontAttr->iRotation == 0 || pFontAttr->iRotation == 180)
            {
                pFontAttr->sCoord.iX -= pFontAttr->iRealWidth * pFontAttr->iHoriMulti;
                pFontAttr->sCoord.iX += pFontAttr->iItalicWidth * pFontAttr->iHoriMulti;
            }
            else
            {
                pFontAttr->sCoord.iX -= pFontAttr->iRealHeight * pFontAttr->iVertMulti;
            }
            FontRotation(Offset, pFontAttr);
            pFontAttr->sCoord.iX -= pFontAttr->iDistance;
            break;
        case 270:
            if (pFontAttr->iRotation == 0 || pFontAttr->iRotation == 180)
            {
                pFontAttr->sCoord.iY -= pFontAttr->iRealHeight * pFontAttr->iVertMulti;
            }
            else
            {
                pFontAttr->sCoord.iY -= pFontAttr->iRealWidth * pFontAttr->iHoriMulti;
                pFontAttr->sCoord.iY += pFontAttr->iItalicWidth * pFontAttr->iHoriMulti;
            }
            FontRotation(Offset, pFontAttr);
            pFontAttr->sCoord.iY -= pFontAttr->iDistance;
            break;
    }
}

VOID MakeThaiFont(BYTE *pTextString , _FontAttr* pFontAttr , INT Offset)
{
    INT Point = pFontAttr->sThaiTable.wDrawPoint;
    if (pFontAttr->iDirection == 180 || pFontAttr->iDirection == 270)
        Point -= pFontAttr->iRealWidth;

    switch (pFontAttr->iDirection)
    {
        case 0:
            pFontAttr->sCoord.iX -= Point * pFontAttr->iHoriMulti;
            FontRotation(Offset, pFontAttr);
            pFontAttr->sCoord.iX += Point * pFontAttr->iHoriMulti;
            pFontAttr->sCoord.iX += pFontAttr->sThaiTable.wActualWidth * pFontAttr->iHoriMulti;
            if (pFontAttr->sThaiTable.wActualWidth)
                pFontAttr->sCoord.iX += pFontAttr->iDistance;
            break;
        case 90:
            pFontAttr->sCoord.iY -= Point * pFontAttr->iHoriMulti;
            FontRotation(Offset, pFontAttr);
            pFontAttr->sCoord.iY += Point * pFontAttr->iHoriMulti;
            pFontAttr->sCoord.iY += pFontAttr->sThaiTable.wActualWidth * pFontAttr->iHoriMulti;
            if (pFontAttr->sThaiTable.wActualWidth)
                pFontAttr->sCoord.iY += pFontAttr->iDistance;
            break;
        case 180:
            pFontAttr->sCoord.iX += Point * pFontAttr->iHoriMulti;
            FontRotation(Offset, pFontAttr);
            pFontAttr->sCoord.iX -= Point * pFontAttr->iHoriMulti;
            pFontAttr->sCoord.iX -= pFontAttr->sThaiTable.wActualWidth * pFontAttr->iHoriMulti;
            if (pFontAttr->sThaiTable.wActualWidth)
                pFontAttr->sCoord.iX -= pFontAttr->iDistance;
            break;
        case 270:
            pFontAttr->sCoord.iY += Point * pFontAttr->iHoriMulti;
            FontRotation(Offset, pFontAttr);
            pFontAttr->sCoord.iY -= Point * pFontAttr->iHoriMulti;
            pFontAttr->sCoord.iY -= pFontAttr->sThaiTable.wActualWidth * pFontAttr->iHoriMulti;
            if (pFontAttr->sThaiTable.wActualWidth)
                pFontAttr->sCoord.iY -= pFontAttr->iDistance;
            break;
    }
}

VOID MakeJapanHalfFont(BYTE *pTextString, _FontAttr *pFontAttr, INT Offset)
{
    INT RealWidth;

    switch (pFontAttr->iDirection)
    {
        case 0:
            RealWidth = pFontAttr->iRealWidth;
            pFontAttr->iRealWidth = pFontAttr->iFontWidth;
            FontRotation(Offset, pFontAttr);
            pFontAttr->iRealWidth = RealWidth;
            
            if (pFontAttr->iRotation == 0 || pFontAttr->iRotation == 180)
            {
                pFontAttr->sCoord.iX += pFontAttr->iRealWidth * pFontAttr->iHoriMulti;
                pFontAttr->sCoord.iX -= pFontAttr->iItalicWidth * pFontAttr->iHoriMulti;
            }
            else
            {
                pFontAttr->sCoord.iX += pFontAttr->iRealHeight * pFontAttr->iVertMulti;
            }
            pFontAttr->sCoord.iX += pFontAttr->iDistance;
            break;
        case 90:
            RealWidth = pFontAttr->iRealWidth;
            pFontAttr->iRealWidth = pFontAttr->iFontWidth;
            FontRotation(Offset, pFontAttr);
            pFontAttr->iRealWidth = RealWidth;
            if (pFontAttr->iRotation == 0 || pFontAttr->iRotation == 180)
            {
                pFontAttr->sCoord.iY += pFontAttr->iRealHeight * pFontAttr->iVertMulti;
            }
            else
            {
                pFontAttr->sCoord.iY += pFontAttr->iRealWidth * pFontAttr->iHoriMulti;
                pFontAttr->sCoord.iY -= pFontAttr->iItalicWidth * pFontAttr->iHoriMulti;
            }
            pFontAttr->sCoord.iY += pFontAttr->iDistance;
            break;
        case 180:
            if (pFontAttr->iRotation == 0 || pFontAttr->iRotation == 180)
            {
                pFontAttr->sCoord.iX -= pFontAttr->iRealWidth * pFontAttr->iHoriMulti;
                pFontAttr->sCoord.iX += pFontAttr->iItalicWidth * pFontAttr->iHoriMulti;
            }
            else
            {
                pFontAttr->sCoord.iX -= pFontAttr->iRealHeight * pFontAttr->iVertMulti;
            }
            RealWidth = pFontAttr->iRealWidth;
            pFontAttr->iRealWidth = pFontAttr->iFontWidth;
            FontRotation(Offset, pFontAttr);
            pFontAttr->iRealWidth = RealWidth;
            pFontAttr->sCoord.iX -= pFontAttr->iDistance;
            break;
        case 270:
            if (pFontAttr->iRotation == 0 || pFontAttr->iRotation == 180)
            {
                pFontAttr->sCoord.iY -= pFontAttr->iRealHeight * pFontAttr->iVertMulti;
            }
            else
            {
                pFontAttr->sCoord.iY -= pFontAttr->iRealWidth * pFontAttr->iHoriMulti;
                pFontAttr->sCoord.iY += pFontAttr->iItalicWidth * pFontAttr->iHoriMulti;
            }
            RealWidth = pFontAttr->iRealWidth;
            pFontAttr->iRealWidth = pFontAttr->iFontWidth;
            FontRotation(Offset, pFontAttr);
            pFontAttr->iRealWidth = RealWidth;
            pFontAttr->sCoord.iY -= pFontAttr->iDistance;
            break;
    }
}

INT PreviewFontWidth(BYTE *pTextString, _FontAttr *pFontAttr, INT *ByteLen)
{
    _eBF2FontTypeV1 FontStyle;
    INT Width = 0;

    switch (pFontAttr->iFontType)
    {
        case BF1_FONT_TYPE:
        case BF3_FONT_TYPE:
        case BF1_FONT_TYPE_V1:
            Width = pFontAttr->iRealWidth * pFontAttr->iHoriMulti + pFontAttr->iDistance;
            *ByteLen = 1;
            break;
        case BF2_FONT_TYPE:
        case BF4_FONT_TYPE:
        case BF1_2_FONT_TYPE_V1:
            BFontOffset(pTextString, pFontAttr, ByteLen);
            Width = pFontAttr->iRealWidth * pFontAttr->iHoriMulti + pFontAttr->iDistance;
            break;
        case VF1_FONT_TYPE:
        case VF2_FONT_TYPE:
        case VF3_FONT_TYPE:
        case VF4_FONT_TYPE:
        case EPL_FONT_TYPE:
            VFontOffset(pTextString, pFontAttr, ByteLen);
            Width = pFontAttr->iRealWidth * pFontAttr->iHoriMulti + pFontAttr->iDistance;
            break;
        case THAI_FONT_TYPE:
            VFontOffset(pTextString, pFontAttr, ByteLen);
            Width = pFontAttr->sThaiTable.wActualWidth * pFontAttr->iHoriMulti + pFontAttr->iDistance;
            break;
        case VF1_FONT_TYPE_V1:
        case VF1_2_FONT_TYPE_V1:
            VFontOffsetV1(pTextString, pFontAttr, ByteLen);
            Width = pFontAttr->iRealWidth * pFontAttr->iHoriMulti + pFontAttr->iDistance;
            break;
        case BF2_FONT_TYPE_V1:
            GetBF2DecodeV1(pTextString, pFontAttr, ByteLen, &FontStyle);
            Width = pFontAttr->iRealWidth * pFontAttr->iHoriMulti + pFontAttr->iDistance;
            break;
    }
    return Width;
}

VOID PreviewFont(BYTE *pTextString, _FontAttr *pFontAttr)
{
    INT Orientation;
    INT FontWidth, TotalWidth;
    INT FontHeight, TotalHeight;
    INT DecodeByte;

    Orientation = (pFontAttr->iDirection + pFontAttr->iRotation) % 180;
    FontHeight  = pFontAttr->iRealHeight * pFontAttr->iVertMulti + pFontAttr->iDistance;
    TotalWidth  = 0;
    TotalHeight = 0;

    while (*pTextString)
    {
        FontWidth = PreviewFontWidth(pTextString, pFontAttr, &DecodeByte);
        pTextString += DecodeByte;
        if (Orientation == 0)
        {
            TotalWidth += FontWidth;
            TotalHeight = FontHeight;
        }
        else
        {
            if (TotalWidth < FontWidth)
                TotalWidth = FontWidth;
            TotalHeight += FontHeight;
        }
    }
    if (pFontAttr->eLanguage != LANG_ZPL)
        TotalWidth -= pFontAttr->iDistance;
    TotalHeight -= pFontAttr->iDistance;

    pFontAttr->iTextWidth  = TotalWidth;
    pFontAttr->iTextHeight = TotalHeight;
}

VOID OutFont(BYTE *pTextString, _FontAttr *pFontAttr)
{
    _eBF2FontTypeV1 FontStyle;
    INT Orientation;
    INT Width, Height;
    INT DecodeByte;
    LONG Offset;

    Orientation = (pFontAttr->iDirection + pFontAttr->iRotation) % 180;

    PreviewFont(pTextString, pFontAttr);
    Width  = pFontAttr->iTextWidth;
    Height = pFontAttr->iTextHeight;
    if (pFontAttr->eLanguage == LANG_ZPL)
        Width -= pFontAttr->iDistance;

    if (Orientation == 0 && pFontAttr->iRotation == 90)
        pFontAttr->sCoord.iX -= Height;
    if (Orientation == 0 && pFontAttr->iRotation == 180)
        pFontAttr->sCoord.iY -= Height;
    if (Orientation == 90 && pFontAttr->iRotation == 180)
        pFontAttr->sCoord.iX -= Width;
    if (Orientation == 90 && pFontAttr->iRotation == 270)
        pFontAttr->sCoord.iY -= Width;

    if (pFontAttr->iRotation == 180)
        pFontAttr->sCoord.iX -= pFontAttr->iDistance;
    if (pFontAttr->iRotation == 270)
        pFontAttr->sCoord.iY -= pFontAttr->iDistance;

    switch (pFontAttr->iFontType)
    {
        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:
        {
            while (*pTextString)
            {
                Offset = BFontOffset(pTextString, pFontAttr, &DecodeByte);
                if (Offset != 0 && pFontAttr->iRealWidth != 0)
                    MakeFont(pTextString, pFontAttr, Offset);
                pTextString += DecodeByte;
            }
            break;
        }
        case VF1_FONT_TYPE:
        case VF2_FONT_TYPE:
        case VF3_FONT_TYPE:
        case VF4_FONT_TYPE:
        case EPL_FONT_TYPE:
        {
            while (*pTextString)
            {
                Offset = VFontOffset(pTextString, pFontAttr, &DecodeByte);
                if (Offset != 0 && pFontAttr->iRealWidth != 0)
                    MakeFont(pTextString, pFontAttr, Offset);
                pTextString += DecodeByte;
            }
            break;
        }
        case THAI_FONT_TYPE:
        {
            BYTE abString[1024], *pString;

            ThaiStringRegulator(abString, pTextString);
            pString = abString;
            while (*pString)
            {
                Offset = VFontOffset(pString, pFontAttr, &DecodeByte);
                if (Offset != 0 && pFontAttr->iRealWidth != 0)
                    MakeThaiFont(pString, pFontAttr, Offset);
                pString += DecodeByte;
            }
            break;
        }
        case VF1_FONT_TYPE_V1:
        case VF1_2_FONT_TYPE_V1:
        {
            while (*pTextString)
            {
                Offset = VFontOffsetV1(pTextString, pFontAttr, &DecodeByte);
                if (Offset != 0 && pFontAttr->iRealWidth != 0)
                    MakeFont(pTextString, pFontAttr, Offset);
                pTextString += DecodeByte;
            }
            break;
        }
        case BF2_FONT_TYPE_V1:
        {
            while (*pTextString)
            {
                Offset = GetBF2DecodeV1(pTextString, pFontAttr, &DecodeByte, &FontStyle);
                if (FontStyle == BF2_V1_BIG5_HALF)
                {
                    _FontAttr sBackAtrr;
                    sBackAtrr = *pFontAttr;
                    pFontAttr->lpGetData = pExtFontAttr->lpGetData;
                    pFontAttr->lpSetDataPoint = pExtFontAttr->lpSetDataPoint;
                    if (pFontAttr->iRealWidth != 0)
                        MakeFont(pTextString, pFontAttr, Offset);
                    pFontAttr->lpGetData = sBackAtrr.lpGetData;
                    pFontAttr->lpSetDataPoint = sBackAtrr.lpSetDataPoint;
                }
                else if (FontStyle == BF2_V1_JAPAN_HALF)
                {
                    if (Offset != 0 && pFontAttr->iRealWidth != 0)
                        MakeJapanHalfFont(pTextString, pFontAttr, Offset);
                }
                else 
                {
                    if (Offset != 0 && pFontAttr->iRealWidth != 0)
                        MakeFont(pTextString, pFontAttr, Offset);
                }
                pTextString += DecodeByte;
            }
            break;
        }
    }
}

BMF.h   ///、、、、、、、、、、、、、、、、、、、、、、、、、、、

#ifndef BMF_H

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

#define BMF_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 "XText.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                         *
 *                                                                            *
 ******************************************************************************/

#define DECODE_BIG5                    'T'
#define DECODE_GB                    'G'
#define DECODE_GX                    'X'
#define DECODE_KOREA                'K'
#define DECODE_SJIS                    'J'
#define DECODE_JIS                    'j'

#define DECODE_TSC                    't'
#define DECODE_ELTRON                'e'
#define DECODE_ZEBRA                'z'
#define DECODE_DATAMAX                'd'

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

/* None */

/******************************************************************************
 *                                                                            *
 *    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                    *
 *                                                                            *
 ******************************************************************************/

VOID SetExtFontAttr(_FontAttr *);
VOID PreviewFont(BYTE *, _FontAttr *);
VOID OutFont(BYTE *, _FontAttr *);

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

#endif    

Thai.c   、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

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

#define THAI_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         *
 *                                                                            *
 ******************************************************************************/

/******************************************************************************
 *                                                                            *
 *            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 "thai.h"

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

#define isThaiConsonant(X)        (X>=0xA1 && X<=0xCE && X!=0xC4 && X!=0xC6 ?1:0)
#define isThaiAbove(X)            (X==0xD1 || (X>=0xD4 && X<=0xD7) || (X>=0xE7 && X<=0xEE) ?1:0)
#define isThaiBelow(X)            (X>=0xD8 && X<=0xDA ?1:0)
#define isThaiTone(X)            (X>=0xE8 && X<=0xEC ?1:0)
#define isThaiSpecialVowel(X)    (X==0xD3 ?1:0)
#define isThaiSpecialCons(X)    (X==0xAD || X==0xB0 ?1:0)

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

typedef union
{
    BYTE data;
    struct
    {
#if defined(BIG_ENDIAN)
        BYTE up   :1;    // bit 7
        BYTE down :1;    // bit 6
        BYTE left :1;    // bit 5
        BYTE right:1;    // bit 4
        BYTE      :4;    //
#else
        BYTE      :4;    //
        BYTE right:1;    // bit 4
        BYTE left :1;    // bit 5
        BYTE down :1;    // bit 6
        BYTE up   :1;    // bit 7
#endif
    } above;
    struct
    {
#if defined(BIG_ENDIAN)
        BYTE      :4;    //
        BYTE up   :1;    // bit 3
        BYTE down :1;    // bit 2
        BYTE      :2;    //
#else
        BYTE      :2;    //
        BYTE down :1;    // bit 2
        BYTE up   :1;    // bit 3
        BYTE      :4;    //
#endif
    } below;
}_ThaiStatus;

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

/******************************************************************************
 *                                                                            *
 *    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     *
 *                                                                            *
 ******************************************************************************/

/*-------------------------------------------------------*
 | bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 |
 |-------------------------------------------------------|
 |  up  | down | left | right|  up  | down |  -   |  -   |
 |-------------------------------------------------------|
 |           above           |           below           |
 *-------------------------------------------------------*/
STATIC CONST BYTE ThaiSetTable[224] = 
{
    /*  |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 |  A |  B |  C |  D |  E |  F |   */
    /*2*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*2*/
    /*3*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*3*/
    /*4*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*4*/
    /*5*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*5*/
    /*6*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*6*/
    /*7*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*7*/
    /*8*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*8*/
    /*9*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*9*/
    /*A*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08,/*A*/
    /*B*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,/*B*/
    /*C*/0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*C*/
    /*D*/0xFC,0x4C,0xFC,0xFC,0x4C,0x4C,0x4C,0x4C,0x0C,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,/*D*/
    /*E*/0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0x4C,0x4C,0xFC,/*E*/
    /*F*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0x00,0x00,0x00,0x00,/*F*/
    /*  |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 |  A |  B |  C |  D |  E |  F |   */
};

STATIC CONST BYTE ThaiVowelPage[2][2][32] = 
{
    /*  |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 |  A |  B |  C |  D |  E |  F |   */
    {{        // Tone 右下 , above 右 , below 上
    /*D*/0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,/*D*/
    /*E*/0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0x11,0x12,0x13,0x14,0x15,0xED,0xEE,0xEF,/*E*/
    },{        // Tone 左下 , above 左 , below 下
    /*D*/0xD0,0x02,0xD2,0xD3,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0xDB,0xDC,0xDD,0xDE,0xDF,/*D*/
    /*E*/0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0xEE,0xEF,/*E*/
    }},{{    // Tone 右上
    /*D*/0xD0,0x01,0xD2,0xD3,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xDB,0xDC,0xDD,0xDE,0xDF,/*D*/
    /*E*/0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0x01,0xE8,0xE9,0xEA,0xEB,0xEC,0x01,0x01,0xEF,/*E*/
    },{        // Tone 左上
    /*D*/0xD0,0x01,0xD2,0xD3,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xDB,0xDC,0xDD,0xDE,0xDF,/*D*/
    /*E*/0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0x01,0x16,0x17,0x18,0x19,0x1A,0x01,0x01,0xEF,/*E*/
    }}
    /*  |  0 |  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 |  A |  B |  C |  D |  E |  F |   */
};

/******************************************************************************
 *                                                                            *
 *    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     *
 *                                                                            *
 ******************************************************************************/

/******************************************************************************
 *
 * Function:
 *        ThaiStringRegulator
 *
 * Description: 
 *        
 *
 * Input:
 *      None
 *
 * Output:
 *      None.
 *
 ******************************************************************************/
VOID ThaiStringRegulator(BYTE *pTarget, BYTE *pSource)
{
    _ThaiStatus sThaiSt;

    sThaiSt.data = 0x00;

    while (*pSource)
    {
        if (*pSource < 0x20)
        {
        }
        else if (isThaiSpecialVowel(*pSource))
        {
            if ( sThaiSt.above.down == 1 )
            {
                *pTarget++ = 0x01;
            }
            else
            {
                *pTarget++ = ThaiVowelPage[0][sThaiSt.above.right][0xED-0xD0];
                *pTarget++ = 0xD2;
            }
            sThaiSt.data = 0xFC;
        }
        else if (isThaiTone(*pSource) && isThaiSpecialVowel(*(pSource+1)))
        {
            if ( sThaiSt.above.up == 1 )
            {
                *pTarget++ = 0x01;
            }
            else if ( sThaiSt.above.down == 1 )
            {
                *pTarget++ = ThaiVowelPage[1][sThaiSt.above.right][(*pSource)-0xD0];
                *pTarget++ = 0x01;
            }
            else
            {
                *pTarget++ = ThaiVowelPage[0][sThaiSt.above.right][0xED-0xD0];
                *pTarget++ = ThaiVowelPage[1][sThaiSt.above.right][(*pSource)-0xD0];
                *pTarget++ = 0xD2;
            }
            sThaiSt.data = 0xFC;
            
            pSource += 1;
        }
        else if (isThaiAbove(*pSource))
        {
            if ( sThaiSt.above.up == 1 || ( !isThaiTone(*pSource) && sThaiSt.below.down ) )
            {
                *pTarget++ = 0x01;
            }
            else
            {
                *pTarget++ = ThaiVowelPage[sThaiSt.above.down][sThaiSt.above.right][(*pSource)-0xD0];
                sThaiSt.data |= ThaiSetTable[(*pSource)-0x20];
            }
        }
        else if (isThaiBelow(*pSource))
        {
            *pTarget++ = ThaiVowelPage[sThaiSt.below.down][sThaiSt.below.up][(*pSource)-0xD0];
            sThaiSt.data |= ThaiSetTable[(*pSource)-0x20];
        }
        else if (isThaiSpecialCons(*pSource) && isThaiBelow(*(pSource+1)))
        {
            if ( *pSource == 0xAD ) *pTarget++ = 0x1B;
            if ( *pSource == 0xB0 ) *pTarget++ = 0x1C;

            sThaiSt.data = ThaiSetTable[(*pSource)-0x20];
        }
        else
        {
            *pTarget++ = *pSource;
            sThaiSt.data = ThaiSetTable[(*pSource)-0x20];
        }

        if ( *(pTarget-1) == 0x01 )
            sThaiSt.data = 0xFC;

        pSource += 1;
    }
    *pTarget = 0;
}

Thai.h   、、、、、、、、、、、、、、、、、、、、、、、、、、

#ifndef THAI_H

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

#define THAI_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         *
 *                                                                            *
 ******************************************************************************/


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

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

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

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

/******************************************************************************
 *                                                                            *
 *    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     *
 *                                                                            *
 ******************************************************************************/

#ifdef THAI_C
#define EXTERN 
#else
#define EXTERN extern
#endif

/******************************************************************************
 *                                                                            *
 *       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        *
 *                                                                            *
 ******************************************************************************/

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

VOID ThaiStringRegulator(BYTE *, BYTE *);

#undef EXTERN

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

#endif

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值