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

📄 fontres.c

📁 windows环境下的一套汉字处理引擎,可以对汉字进行相应的处理
💻 C
字号:
/*************************************************************************
    File:
	FontRes.c
    Module:
	WSENGINE.DLL
    Created By:
	Wang Zhidong
    Date:
	1993.9 - 1995.1
    Functions:
	_InitFontRes
	_ExitFontRes
    Exports:
	WseRemoteFontFaceName
	WseAddFontFaceName
*************************************************************************/
#include <windows.h>
#include <mate.h>
#include "engine.h"

extern HINSTANCE hInst;

NPSTR	pFotReg, pFotBd, pFotBi, pFotI;

char szRegularStyle[]	 = "\0Regular\0\0";
char szItalicStyle[]	 = " Italic\0Italic\0\0";
char szBoldStyle[]	 = " Bold\0Bold\0\0";
char szBoldItalicStyle[] = " Bold Italic\0Bold Italic\0\0";

int AddOneFontFace (NPSTR pFile, LPSTR lpFace, int nCnt)
{
    HFILE   hFile;

    hFile = _lopen (pFile, OF_READWRITE);
    if (hFile == HFILE_ERROR)
	return NULL;

    _llseek (hFile, FOT_FACENAME, 0);
    _lwrite (hFile, lpFace, nCnt);
    _lclose (hFile);

    return AddFontResource (pFile);
}

int WINAPI WseAddFontFaceName (LPSTR lpFace, LPSTR lpTemplate, LPARAM lParam)
{
    NPSTR   pStyle;
    int     nLen, bRet;

#ifdef DEMO
    return NULL;
#endif

#ifdef ATTNCR
    return NULL;
#endif

    nLen = lstrlen (lpFace);

    pStyle = (NPSTR)LocalAlloc (LPTR, 100);

    lstrcpy (lstrcpy (pStyle, lpFace)+nLen+1, lpFace);
    nLen = 2*nLen+1;

    WseRepMovsb (pStyle+nLen, szRegularStyle,	  10);
    bRet  = AddOneFontFace (pFotReg, pStyle, nLen+10);
    WseRepMovsb (pStyle+nLen, szItalicStyle,	  16);
    bRet += AddOneFontFace (pFotI,   pStyle, nLen+16);
    WseRepMovsb (pStyle+nLen, szBoldStyle,	  12);
    bRet += AddOneFontFace (pFotBd,  pStyle, nLen+12);
    WseRepMovsb (pStyle+nLen, szBoldItalicStyle,  26);
    bRet += AddOneFontFace (pFotBi,  pStyle, nLen+26);

    LocalFree ((HANDLE)pStyle);
    return bRet;
}

int RemoveOneFontFace (NPSTR pFile, LPSTR lpFace, int nCnt)
{
    HFILE   hFile;

    hFile = _lopen (pFile, OF_READWRITE);
    if (hFile == HFILE_ERROR)
	return NULL;

    _llseek (hFile, FOT_FACENAME, 0);
    _lwrite (hFile, lpFace, nCnt);
    _lclose (hFile);

    return RemoveFontResource (pFile);
}

int WINAPI WseRemoveFontFaceName (LPSTR lpFace, LPSTR lpTemplate, LPARAM lParam)
{
    NPSTR   pStyle;
    int     nLen, bRet;

#ifdef DEMO
    return NULL;
#endif

#ifdef ATTNCR
    return NULL;
#endif

    nLen = lstrlen (lpFace);

    pStyle = (NPSTR)LocalAlloc (LPTR, 100);

    lstrcpy (lstrcpy (pStyle, lpFace)+nLen+1, lpFace);
    nLen = 2*nLen+1;

    WseRepMovsb (pStyle+nLen, szRegularStyle,	    10);
    bRet  = RemoveOneFontFace (pFotReg,pStyle, nLen+10);
    WseRepMovsb (pStyle+nLen, szItalicStyle,	    16);
    bRet += RemoveOneFontFace (pFotI,  pStyle, nLen+16);
    WseRepMovsb (pStyle+nLen, szBoldStyle,	    12);
    bRet += RemoveOneFontFace (pFotBd, pStyle, nLen+12);
    WseRepMovsb (pStyle+nLen, szBoldItalicStyle,    26);
    bRet += RemoveOneFontFace (pFotBi, pStyle, nLen+26);

    LocalFree ((HANDLE)pStyle);
    return bRet;
}

BOOL GetOneFontResource (UINT idFnt, NPSTR pFile)
{
    HRSRC   hRes;
    HGLOBAL hResMem;
    LPSTR   lpRes;
    HFILE   hFile;

    hRes = FindResource (hInst,
			 MAKEINTRESOURCE(idFnt),
			 MAKEINTRESOURCE(RT_FOT));
    if (!hRes)
	return NULL;

    hResMem = LoadResource (hInst, hRes);
    if (!hResMem)
	return NULL;

    lpRes = (LPSTR)LockResource (hResMem);
    if (!lpRes)
	{
	FreeResource (hResMem);
	return NULL;
	}

    hFile = _lcreat (pFile, 0);
    if (hFile == HFILE_ERROR)
	{
	UnlockResource (hResMem);
	FreeResource (hResMem);
	return FALSE;
	}

    _lwrite (hFile, lpRes, (UINT)GlobalSize (hResMem));
    _lclose (hFile);

    UnlockResource (hResMem);
    FreeResource (hResMem);

    return TRUE;
}

BOOL FAR _InitFontRes ()
{
    int nLen;

    pFotReg = (NPSTR)LocalAlloc (LPTR, 256);
    WseGetModuleFilePath (NULL, pFotReg, 250);
    nLen = lstrlen (pFotReg)+16;
    LocalFree ((HANDLE)pFotReg);

    pFotReg = (NPSTR)LocalAlloc (LPTR, nLen);
    pFotBd  = (NPSTR)LocalAlloc (LPTR, nLen);
    pFotBi  = (NPSTR)LocalAlloc (LPTR, nLen);
    pFotI   = (NPSTR)LocalAlloc (LPTR, nLen);

    WseGetModuleFilePath (NULL, pFotReg, nLen-2);
    lstrcat (lstrcpy (pFotBd, pFotReg), "VFONTBD.FOT");
    lstrcat (lstrcpy (pFotBi, pFotReg), "VFONTBI.FOT");
    lstrcat (lstrcpy (pFotI,  pFotReg), "VFONTI.FOT");
    lstrcat (pFotReg, "VFONTREG.FOT");

    GetOneFontResource (FNT_REG,    pFotReg);
    GetOneFontResource (FNT_BOLD,   pFotBd);
    GetOneFontResource (FNT_ITALIC, pFotI);
    GetOneFontResource (FNT_BI,     pFotBi);
	return TRUE;
}

BOOL FAR _ExitFontRes ()
{
    WseDeleteFile (pFotReg);
    WseDeleteFile (pFotBd);
    WseDeleteFile (pFotBi);
    WseDeleteFile (pFotI);

    LocalFree ((HANDLE)pFotReg);
    LocalFree ((HANDLE)pFotBd);
    LocalFree ((HANDLE)pFotBi);
    LocalFree ((HANDLE)pFotI);
	return TRUE;
}

⌨️ 快捷键说明

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