1 Star 7 Fork 2

Walkline/FontMaker Client

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Charset.cpp 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
#include "StdAfx.h"
#include "Charset.h"
#include <iostream>
CCharset::CCharset(void)
{
m_pTable = NULL;
m_nCount = 0;
}
CCharset::~CCharset(void) {}
BOOL CCharset::LoadFromFile(LPCTSTR pFileName)
{
CFile cf;
ULONG len;
if (!cf.Open(pFileName,CFile::modeRead|CFile::shareDenyNone)) {return FALSE;}
len = (ULONG)cf.GetLength();
m_pTable = (WCHAR*)malloc(len+2);
if(m_pTable==NULL) {
cf.Close();
return FALSE;
}
ZeroMemory(m_pTable,len+2);
if(cf.Read(m_pTable,len)!=len) {
cf.Close();
free(m_pTable);
m_pTable = NULL;
return FALSE;
}
cf.Close();
m_nCount = len/2;
return TRUE;
}
BOOL CCharset::CreateFromResource(LPCTSTR pString, DWORD dwSize)
{
ULONG len = dwSize;
m_pTable = (WCHAR*) malloc(len + 2);
if (!m_pTable) {return false;}
ZeroMemory(m_pTable, len + 2);
m_pTable = _wcsdup(pString);
m_nCount = len / 2;
return false;
}
BOOL CCharset::Create(LPCTSTR pString)
{
m_nCount = (UINT)wcslen(pString);
m_pTable = _wcsdup(pString);
return FALSE;
}
void CCharset::Delete()
{
free(m_pTable);
m_pTable = NULL;
m_nCount = 0;
}
WCHAR CCharset::GetChar(UINT index)
{
if(m_pTable == NULL) {return L'?';}
if(index < m_nCount) {return *(m_pTable+index);}
return L'?';
}
UINT CCharset::GetCharCount() {return m_nCount;}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/walkline/fontmaker-client.git
git@gitee.com:walkline/fontmaker-client.git
walkline
fontmaker-client
FontMaker Client
master

搜索帮助