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

📄 guivarbitmap.c

📁 The combined demo is dedicated for S1C33L05, so DMT33L05 should be used to load and run the demo. F
💻 C
字号:
/* $id: guiVarbitmap.c V1.0 2001/11/5 */
/***************************************************************************
 *    This source code has been made available to you by EPSON on an AS-IS
 *    basis. Anyone receiving this source is licensed under EPSON
 *    copyrights to use it in any way he or she deems fit, including
 *    copying it, modifying it, compiling it, and redistributing it either
 *    with or without modifications.
 *
 *    Any person who transfers this source code or any derivative work
 *    must include the EPSON copyright notice, this paragraph, and the
 *    preceding two paragraphs in the transferred software.
 *
 *    COPYRIGHT   EPSON  CORPORATION 2001
 *    LICENSED MATERIAL  -  PROGRAM PROPERTY OF EPSON
 **************************************************************************/


/***************************************************************************
 * FILE: guiVarbitmap.c
 * MODULE: FONT
 *
 * PURPOSE: The management of Varity Bitmap Font operation set .
 *
 *
 * AUTHOR(S): ZhaoJZ
 * GROUP: GUI Group
 * DATE CREATED: 2001/11/5
 * REFERENCE DOCUMENT ID:
 * MODIFICATIONS:
 *    Date           userName          Description
 *    2001/11/5      ZhaoJZ            Create this file
 **************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sysGUI.h"
//#include "guiTotal.h"
#include "guiFont.h"

#include "guiDevfont.h"
#include "guiVarbitmap.h"
#include "guiCharset.h"
#include "guiFontname.h"

/*************** Variable bitmap font operations *********************************/
T_MODULE T_WORD get_char_width(
				T_GUI_LogFont *logfont,
				T_GUI_DevFont *devfont,
                T_CONST T_UBYTE *mchar,
				T_WORD len
				)
{
    T_FNT_VBFInfo* vbf_info = VARFONT_INFO_P(devfont);

    if(vbf_info->width == NULL)
        return vbf_info->max_width;

    /* get the default width */
    if(*mchar < vbf_info->first_char || *mchar > vbf_info->last_char)
        return vbf_info->width[vbf_info->def_char - vbf_info->first_char];

    return vbf_info->width[*mchar - vbf_info->first_char];
}

T_MODULE T_WORD get_max_width(T_GUI_LogFont *logfont, T_GUI_DevFont *devfont)
{
   return VARFONT_INFO_P(devfont)->max_width;
}

T_MODULE T_WORD get_str_width(
				T_GUI_LogFont *logfont,
				T_GUI_DevFont *devfont,
                T_CONST T_UBYTE *mstr,
				T_WORD n,
				T_WORD cExtra
				)
{
    T_WORD i;
    T_WORD str_width;
    T_FNT_VBFInfo *vbf_info = VARFONT_INFO_P(devfont);

    if(vbf_info->width == NULL)
        return n * (vbf_info->max_width + cExtra);

    str_width = 0;
    for(i = 0; i < n; i++)
	{
        if(mstr[i] < vbf_info->first_char || mstr[i] > vbf_info->last_char)
            str_width += vbf_info->width[vbf_info->def_char - vbf_info->first_char];
        else
            str_width += vbf_info->width[mstr[i] - vbf_info->first_char];
        str_width += cExtra;
    }

    return str_width;
}

T_MODULE T_WORD get_ave_width(T_GUI_LogFont *logfont, T_GUI_DevFont *devfont)
{
    return VARFONT_INFO_P(devfont)->ave_width;
}

T_MODULE T_WORD get_font_height(T_GUI_LogFont *logfont, T_GUI_DevFont *devfont)
{
    return VARFONT_INFO_P(devfont)->height;
}

T_MODULE T_WORD get_font_size(T_GUI_LogFont *logfont, T_GUI_DevFont *devfont, T_WORD expect)
{
    return VARFONT_INFO_P(devfont)->height;
}

/* get the length of the part over the base line of the character */
T_MODULE T_WORD get_font_ascent(T_GUI_LogFont *logfont, T_GUI_DevFont *devfont)
{
    return VARFONT_INFO_P(devfont)->height - VARFONT_INFO_P(devfont)->descent;
}

/* get the length of the part under the base line of the character */
T_MODULE T_WORD get_font_descent(T_GUI_LogFont *logfont, T_GUI_DevFont *devfont)
{
    return VARFONT_INFO_P(devfont)->descent;
}

/* get the bytes occupied by the character */
T_MODULE T_GUI_SIZE char_bitmap_size(
				    T_GUI_LogFont *logfont,
				    T_GUI_DevFont *devfont,
                    T_CONST T_UBYTE *mchar,
				    T_WORD len
				    )
{
    T_WORD width;
    T_FNT_VBFInfo *vbf_info = VARFONT_INFO_P(devfont);

    if(vbf_info->width == NULL)
        width = vbf_info->max_width;
    else if(*mchar < vbf_info->first_char || *mchar > vbf_info->last_char)
        width = vbf_info->width[vbf_info->def_char - vbf_info->first_char];
    else
        width = vbf_info->width[*mchar - vbf_info->first_char];

    return ((width + 7) >> 3) * vbf_info->height;
}

T_MODULE T_GUI_SIZE max_bitmap_size(T_GUI_LogFont *logfont, T_GUI_DevFont *devfont)
{
    return (((size_t)VARFONT_INFO_P(devfont)->max_width + 7) >> 3)
                * VARFONT_INFO_P(devfont)->height;
}

/* get the character's lattice  */
T_MODULE T_CONST T_VOID* get_char_bitmap(
						 T_GUI_LogFont *logfont,
						 T_GUI_DevFont *devfont,
                         T_CONST T_UBYTE *mchar,
						 T_WORD len
						 )
{
    T_WORD offset;
    T_UBYTE eff_char = *mchar;
    T_FNT_VBFInfo* vbf_info = VARFONT_INFO_P(devfont);

    if(*mchar < vbf_info->first_char || *mchar > vbf_info->last_char)
        eff_char = vbf_info->def_char;

    if(vbf_info->offset == NULL)
        offset = (((size_t)vbf_info->max_width + 7) >> 3) * vbf_info->height
                    * (eff_char - vbf_info->first_char);
    else
        offset = vbf_info->offset[eff_char - vbf_info->first_char];

    return vbf_info->bits + offset;
}

/* define the font operations of varity bitmap */
T_MODULE T_GUI_FontOps var_bitmap_font_ops =
{
    get_char_width,
    get_str_width,
    get_ave_width,
    get_max_width,
    get_font_height,
    get_font_size,
    get_font_ascent,
    get_font_descent,
    char_bitmap_size,
    max_bitmap_size,
    get_char_bitmap,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
};

/****************************************************************/
T_EXTERN T_FNT_VBFInfo   vbf_SansSerif11x13;

T_MODULE T_FNT_VBFInfo* incore_vbfonts[] =
{
    &vbf_SansSerif11x13,
};

#define NR_VBFONTS  (sizeof(incore_vbfonts) /sizeof(T_FNT_VBFInfo*))



T_MODULE T_GUI_DevFont *incore_vbf_dev_font;

/* get the charsetops from the font's name */
T_MODULE T_GUI_CharsetOps *vbfGetCharsetOps(T_FNT_VBFInfo* vbfont)
{
    T_WORD count = 0;
    T_CONST T_BYTE* font_name = vbfont->name;

    while(*font_name)
	{
        if(*font_name == '-') 
			count ++;
        if(count == 4) 
			break;

        font_name ++;
    }

    if(*font_name != '-') 
		return NULL;
    font_name ++;

    return fnFNT_GetCharsetOps(font_name);
}

/******************************************************************
 * FUNCTION: fnFNT_InitIncoreVBFonts
 *
 * PURPOSE:
 *    Initialize the various bitmap font
 *
 * PARAMETERS
 *    Input:
 *    Output:
 *    InOut:
 * Return value: T_BOOL --- if initialization is TRUE ,or FALSE
 * Reentrant : No
 *****************************************************************/
T_BOOL  fnFNT_InitIncoreVBFonts(T_VOID)
{
    T_WORD i;

   if((incore_vbf_dev_font = malloc(NR_VBFONTS * sizeof(T_GUI_DevFont))) == NULL)
        return FALSE;

    /* create the devfonts */
    for(i = 0; i < NR_VBFONTS; i++)
	{
        if((incore_vbf_dev_font[i].charset_ops
                = vbfGetCharsetOps(incore_vbfonts[i])) == NULL)
		{
            free(incore_vbf_dev_font);
            return FALSE;
        }

        strncpy(incore_vbf_dev_font[i].name, incore_vbfonts[i]->name, LEN_DEVFONT_NAME);
        incore_vbf_dev_font[i].name [LEN_DEVFONT_NAME] = '\0';
        incore_vbf_dev_font[i].font_ops = &var_bitmap_font_ops;
        incore_vbf_dev_font[i].data = incore_vbfonts[i];
    }

    /* add the devfonts to the list of devfonts */
    for(i = 0; i < NR_VBFONTS; i++)
        AddSBDevFont(incore_vbf_dev_font + i);  /* this font is limited only in the single byte font */

    return TRUE;
}

/******************************************************************
 * FUNCTION: fnFNT_TermIncoreVBFonts
 *
 * PURPOSE:
 *    Terminate the varity  bitmap font
 *
 * PARAMETERS
 *    Input:
 *    Output:
 *    InOut:
 * Return value:
 * Reentrant : No
 *****************************************************************/T_VOID  fnFNT_TermIncoreVBFonts(T_VOID){    free(incore_vbf_dev_font);
    incore_vbf_dev_font = NULL;}

⌨️ 快捷键说明

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