|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "FontTypeMgr.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
#include "FontLaipu.h"
|
|
|
|
|
#include "FontTrueType.h"
|
|
|
|
|
#include "FontBarcode.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CFontTypeMgr CFontTypeMgr::m_Instance;
|
|
|
|
|
|
|
|
|
|
CFontTypeMgr::CFontTypeMgr(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
CFontTypeMgr::~CFontTypeMgr(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
CFontTypeMgr &CFontTypeMgr::Instance()
|
|
|
|
|
{
|
|
|
|
|
return m_Instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC>
|
|
|
|
|
void CFontTypeMgr::Initialize()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//windows TrueType <20>ֿ<EFBFBD>
|
|
|
|
|
CFontType *p1 = new CFontTrueType;
|
|
|
|
|
p1->Initialize();
|
|
|
|
|
AddFontType(p1);
|
|
|
|
|
//<2F><><EFBFBD>յ<EFBFBD><D5B5>ֿ<EFBFBD>
|
|
|
|
|
CFontType *p2 = new CFontLaipu;
|
|
|
|
|
p2->Initialize();
|
|
|
|
|
AddFontType(p2);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>
|
|
|
|
|
CFontType *p3 = new CFontBarcode;
|
|
|
|
|
p3->Initialize();
|
|
|
|
|
AddFontType(p3);
|
|
|
|
|
|
|
|
|
|
m_CurFontTypeIdx = 0;//<2F><>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
bool CFontTypeMgr::CheckIdx(int idx)
|
|
|
|
|
{
|
|
|
|
|
int size = m_FontTypeVec.size();
|
|
|
|
|
if(idx>=0 && idx<size)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CFontTypeMgr::AddFontType(CFontType *p)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD>浽<EFBFBD><E6B5BD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|
|
|
|
Sptr<CFontType> sPtr(p);
|
|
|
|
|
m_FontTypeVec.push_back(sPtr);
|
|
|
|
|
}
|
|
|
|
|
//<2F>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2>뵽comb
|
|
|
|
|
void CFontTypeMgr::FontTypeNameInsertToComb(CComboBox &Comb)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Comb.ResetContent();
|
|
|
|
|
|
|
|
|
|
vector<Sptr<CFontType>>::iterator iter = m_FontTypeVec.begin();
|
|
|
|
|
vector<Sptr<CFontType>>::iterator iter_end = m_FontTypeVec.end();
|
|
|
|
|
for(int i=0;iter!=iter_end;iter++,i++)
|
|
|
|
|
{
|
|
|
|
|
Comb.InsertString(i,(*iter)->GetFontType());
|
|
|
|
|
}
|
|
|
|
|
Comb.SetCurSel(m_CurFontTypeIdx);
|
|
|
|
|
}
|
|
|
|
|
//ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>CComboBox
|
|
|
|
|
void CFontTypeMgr::UpdateFontNameComb(CComboBox &Comb)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Comb.ResetContent();
|
|
|
|
|
if(CheckIdx(m_CurFontTypeIdx))
|
|
|
|
|
{
|
|
|
|
|
m_FontTypeVec[m_CurFontTypeIdx]->UpdateFontNameComb(Comb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
CString CFontTypeMgr::GetFontPath(CString FontName)
|
|
|
|
|
{
|
|
|
|
|
//<2F>Ȼ<EFBFBD><C8BB><EFBFBD>FONT <20>ļ<EFBFBD><C4BC>е<EFBFBD>Ŀ¼--------------------------------------------------------
|
|
|
|
|
CString sPath;
|
|
|
|
|
GetModuleFileName(NULL,sPath.GetBufferSetLength(1023),1024); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰĿ¼
|
|
|
|
|
sPath.ReleaseBuffer();
|
|
|
|
|
int nPos;
|
|
|
|
|
nPos = sPath.ReverseFind('\\');
|
|
|
|
|
sPath = sPath.Left(nPos);
|
|
|
|
|
sPath = sPath + "\\font\\";
|
|
|
|
|
return sPath+FontName;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>õ<EFBFBD>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CFontTypeMgr::SetCurFontType(int idx)
|
|
|
|
|
{
|
|
|
|
|
m_CurFontTypeIdx = idx;
|
|
|
|
|
}
|
|
|
|
|
void CFontTypeMgr::GetCurFontName(int idx)
|
|
|
|
|
{
|
|
|
|
|
if(CheckIdx(m_CurFontTypeIdx))
|
|
|
|
|
{
|
|
|
|
|
m_FontTypeVec[m_CurFontTypeIdx]->SetCurFontNameIdx(idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
int CFontTypeMgr::GetCurFontTypeIdx()
|
|
|
|
|
{
|
|
|
|
|
if(CheckIdx(m_CurFontTypeIdx))
|
|
|
|
|
return m_FontTypeVec[m_CurFontTypeIdx]->GetCurFontNameIdx();
|
|
|
|
|
else
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
//<2F>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CFontTypeMgr::CreatCharVec(char *pChar,vector<PointType> &m_PonitVec)
|
|
|
|
|
{
|
|
|
|
|
if(CheckIdx(m_CurFontTypeIdx))
|
|
|
|
|
{
|
|
|
|
|
m_FontTypeVec[m_CurFontTypeIdx]->CreatCharVec(pChar,m_PonitVec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CString CFontTypeMgr::GetCurFontTypeName()
|
|
|
|
|
{
|
|
|
|
|
CString str;
|
|
|
|
|
if(CheckIdx(m_CurFontTypeIdx))
|
|
|
|
|
{
|
|
|
|
|
str = m_FontTypeVec[m_CurFontTypeIdx]->GetFontType();
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
CString CFontTypeMgr::GetCurFontName()
|
|
|
|
|
{
|
|
|
|
|
CString str;
|
|
|
|
|
if(CheckIdx(m_CurFontTypeIdx))
|
|
|
|
|
{
|
|
|
|
|
str = m_FontTypeVec[m_CurFontTypeIdx]->GetCurFontName();
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
//ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı䵱ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CFontTypeMgr::SetCurFontByName(CString FontTypeName,CString FontName)
|
|
|
|
|
{
|
|
|
|
|
vector<Sptr<CFontType>>::iterator iter = m_FontTypeVec.begin();
|
|
|
|
|
vector<Sptr<CFontType>>::iterator iter_end = m_FontTypeVec.end();
|
|
|
|
|
for(int i=0;iter!=iter_end;iter++,i++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter)->GetFontType() == FontTypeName)//<2F><><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if((*iter)->SetCurFontByName(FontName))//ͬʱ<CDAC><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
m_CurFontTypeIdx = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|