void AddRemoveFonts(TCHAR *location, BOOL add)
{
	int counter = 0;
	TCHAR fontpath[MAX_PATH];
	TCHAR findpath[MAX_PATH];

	WIN32_FIND_DATA fd;

	_stprintf(findpath, _T("%s\\*.ttf"), location);

	HANDLE hFind = FindFirstFile(findpath, &fd);

	if(hFind != INVALID_HANDLE_VALUE) {
		_stprintf(fontpath, _T("%s\\%s"), location, fd.cFileName);
		if (add) {
			counter += AddFontResource(fontpath);
		} else {
			counter += RemoveFontResource(fontpath);
		}

		while(FindNextFile(hFind, &fd)) {
			_stprintf(fontpath, _T("%s\\%s"), location, fd.cFileName);
			if (add) {
				counter += AddFontResource(fontpath);
			} else {
				counter += RemoveFontResource(fontpath);
			}
		}
	}
	FindClose(hFind);

	if (counter > 0) {
		SendMessage(HWND_BROADCAST, WM_FONTCHANGE, NULL, NULL);
	}
}
示例#2
0
void Prefs::open() {

    char *p=getenv( "blitzpath" );
    if( !p ) {
        AfxMessageBox( "blitzpath environment variable not found!",MB_TOPMOST|MB_SETFOREGROUND|MB_ICONINFORMATION );
        ExitProcess(0);
    }

    homeDir=p;

    AddFontResource( (homeDir+"/cfg/blitz.fon").c_str() );

    setDefault();

    bool prg_windowed;

    ifstream in( (homeDir+"/cfg/blitzide.prefs").c_str() );
    if( !in.good() ) return;

    while( !in.eof() ) {
        string t;
        in>>t;
        if( !t.size() ) continue;
        while( in.peek()=='\t' ) in.ignore();
        if( t=="prg_debug" ) in>>prg_debug;
        else if( t=="prg_lastbuild" ) getline( in,prg_lastbuild );
        else if( t=="prg_windowed" ) in>>prg_windowed;
        else if( t=="win_maximized" ) in>>win_maximized;
示例#3
0
void cMainGame::Setup()
{
	//폰트 생성
	D3DXFONT_DESC fd;
	ZeroMemory(&fd,sizeof(D3DXFONT_DESC));
	fd.Height			= 45;
	fd.Width			= 28;
	fd.Weight			= FW_MEDIUM;
	fd.Italic			= false;
	fd.CharSet			= DEFAULT_CHARSET;
	fd.OutputPrecision  = OUT_DEFAULT_PRECIS;
	fd.PitchAndFamily   = FF_DONTCARE;
	//strcpy_s(fd.FaceName, "궁서체");	//글꼴 스타일
	AddFontResource("umberto.ttf");
	strcpy(fd.FaceName, "umberto");

	D3DXCreateFontIndirect(g_pD3DDevice, &fd, &m_pFont);

	m_pCamera = new cCamera;
	m_pCamera->Setup(NULL);

	m_pGrid = new cGrid;
	m_pGrid->Setup(15, 1.0f);
	LPDIRECT3DTEXTURE9	pTexture = NULL;
	D3DXCreateTextureFromFile(g_pD3DDevice, "Batman.png", &pTexture);

	cBody* pBody = new cBody;
	pBody->Setup();
	pBody->SetTexture(pTexture);
	m_pRoot = pBody;

	cHead* pHead = new cHead;
	pHead->Setup();
	pHead->SetTexture(pTexture);
	m_pRoot->AddChild(pHead);

	cLeftArm* pLeftArm = new cLeftArm;
	pLeftArm->Setup();
	pLeftArm->SetTexture(pTexture);
	m_pRoot->AddChild(pLeftArm);

	cRightArm* pRightArm = new cRightArm;
	pRightArm->Setup();
	pRightArm->SetTexture(pTexture);
	m_pRoot->AddChild(pRightArm);

	cLeftLeg* pLeftLeg = new cLeftLeg;
	pLeftLeg->Setup();
	pLeftLeg->SetTexture(pTexture);
	m_pRoot->AddChild(pLeftLeg);

	cRightLeg* pRightLeg = new cRightLeg;
	pRightLeg->Setup();
	pRightLeg->SetTexture(pTexture);
	m_pRoot->AddChild(pRightLeg);

	SAFE_RELEASE(pTexture);

	SetLight();
}
示例#4
0
VOID GlobalInit()
{
	AddFontResource(_T("res/font/fantiquefour.ttf"));
	QueryPerformanceFrequency(&global.clockFrequency);

	GameFolderInit();
	MCIOffsetInit();
	if (global.songs.empty())
	{
		global.status = global.GS_NOSONG;
		return;
	}
	AudioInit();

	Gdiplus::GdiplusStartupInput gdiplusStartupInput;
	Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);

	global.status = global.GS_WELCOME;
	global.heroWidth = 38;
	global.heroHeight = 45;
	settings.foggyMode = FALSE;
	settings.hideJudgeLine = FALSE;
	settings.showAccuracyIndicator = FALSE;
	settings.randomMode = FALSE;
	settings.universalOffset = 0;
}
示例#5
0
void cMainGame::Setup()
{
// 	cObjLoader l;
// 	m_pGroupHead = l.Load("./obj/Map.obj");

		 
	cAseLoader loader;
	m_pRoot = loader.Load("woman/woman_01_all.ASE");

	//폰트 생성
	D3DXFONT_DESC fd;
	ZeroMemory(&fd,sizeof(D3DXFONT_DESC));
	fd.Height			= 45;
	fd.Width			= 28;
	fd.Weight			= FW_MEDIUM;
	fd.Italic			= false;
	fd.CharSet			= DEFAULT_CHARSET;
	fd.OutputPrecision  = OUT_DEFAULT_PRECIS;
	fd.PitchAndFamily   = FF_DONTCARE;
	//strcpy_s(fd.FaceName, "궁서체");	//글꼴 스타일
	AddFontResource("umberto.ttf");
	strcpy(fd.FaceName, "umberto");

	D3DXCreateFontIndirect(g_pD3DDevice, &fd, &m_pFont);

	m_pCamera = new cCamera;
	m_pCamera->Setup(NULL);

	m_pGrid = new cGrid;
	m_pGrid->Setup(15, 1.0f);
	
	SetLight();
}
示例#6
0
VoidFont CFontMgr::LoadFontFromFile( const char *szFile, const char *szFacename, unsigned int iSize, bool bBold, bool bItalic, bool bAntialiased )
{
	if (!AddFontResource(szFile))
	{
		Error("Unable to load font %s", szFile);
		return 0;
	}
	fontreslist.AddToHead( string(szFile) );

	int id = fontsnum;
	fontsnum++;

	D3DX10CreateFont( gEngine.GetD3D()->GetDevice(),// D3DDevice
		iSize, 0,							// Width, Height
		(bBold)?(FW_BOLD):(FW_LIGHT),		// Weight
		0,									// MipLevels
		bItalic,							// Italic
		DEFAULT_CHARSET,					// Charset
		OUT_DEFAULT_PRECIS,					// Precision
		(bAntialiased)?(CLEARTYPE_NATURAL_QUALITY):(NONANTIALIASED_QUALITY),	// Quality
		DEFAULT_PITCH || FF_DONTCARE,		// Pitch
		TEXT(szFacename),					// Facename
		&fonts[id]							// Pointer to LPD3DXFONT
	);
	return id;
}
示例#7
0
int main(int argc, char **argv) {
	if (argc>1) {
		AddFontResource(argv[1]);
		SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
		return 0;
	}
	return 1;
}
示例#8
0
void cMainGame::Setup()
{
	m_pSkinnedMesh = new cSkinnedMesh;
	m_pSkinnedMesh->Setup("Zealot", "zealot.X");

	m_pFrustum = new cFrustum;
	m_pFrustum->Setup();

	// 디버깅용 바운딩 스피어 생성.
	D3DXCreateSphere(g_pD3DDevice, 1.f, 100, 100, &m_pSphere, NULL);
	
	for (int i = 0; i < 1000; ++i)
	{
		float x = rand() % 4000 / 100.0f - 20;
		float y = rand() % 4000 / 100.0f - 20;
		float z = rand() % 4000 / 100.0f - 20;
		m_vecSpherePosition.push_back(D3DXVECTOR3(x, y, z));
	}

// 	cAseLoader loader;
// 	m_pRoot = loader.Load("woman/woman_01_all.ASE");

	ZeroMemory(&m_stWhiteMtl, sizeof(D3DMATERIAL9));
	m_stWhiteMtl.Ambient = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	m_stWhiteMtl.Diffuse = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	m_stWhiteMtl.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);

	ZeroMemory(&m_stRedMtl, sizeof(D3DMATERIAL9));
	m_stRedMtl.Ambient = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f);
	m_stRedMtl.Diffuse = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f);
	m_stRedMtl.Specular = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f);


	//폰트 생성
	D3DXFONT_DESC fd;
	ZeroMemory(&fd,sizeof(D3DXFONT_DESC));
	fd.Height			= 45;
	fd.Width			= 28;
	fd.Weight			= FW_MEDIUM;
	fd.Italic			= false;
	fd.CharSet			= DEFAULT_CHARSET;
	fd.OutputPrecision  = OUT_DEFAULT_PRECIS;
	fd.PitchAndFamily   = FF_DONTCARE;
	//strcpy_s(fd.FaceName, "궁서체");	//글꼴 스타일
	AddFontResource("umberto.ttf");
	strcpy(fd.FaceName, "umberto");

	D3DXCreateFontIndirect(g_pD3DDevice, &fd, &m_pFont);

	m_pCamera = new cCamera;
	m_pCamera->Setup(NULL);

	m_pGrid = new cGrid;
	m_pGrid->Setup(15, 1.0f);
	
	SetLight();
}
示例#9
0
bool C4VectorFont::Init(C4Group &hGrp, const char *szFilename, C4Config &rCfg)
	{
	// name by file
	Name.Copy(GetFilenameOnly(szFilename));
#if defined(_WIN32) && !defined(HAVE_FREETYPE)
	// check whether group is directory or packed
	if (!hGrp.IsPacked())
		{
		// it's open: use the file directly
		SCopy(hGrp.GetFullName().getData(), FileName, _MAX_PATH);
		AppendBackslash(FileName);
		SAppend(szFilename, FileName);
		if (!FileExists(FileName)) { *FileName=0; return false; }
		fIsTempFile = false;
		}
	else
		{
		// it's packed: extract to temp path
		SCopy(rCfg.AtTempPath(szFilename), FileName, _MAX_PATH);
		// make sure the filename is not in use, in case multiple instances of the engine are run
		if (FileExists(FileName))
			{
			RemoveExtension(FileName);
			StdStrBuf sNewFilename;
			for (int i=0; i<1000; ++i)
				{
				sNewFilename.Format("%s%x", FileName, (int)rand());
				if (*GetExtension(szFilename))
					{
					sNewFilename.AppendChar('.');
					sNewFilename.Append(GetExtension(szFilename));
					}
				if (!FileExists(sNewFilename.getData())) break;
				}
			SCopy(sNewFilename.getData(), FileName, _MAX_PATH);
			}
		if (!hGrp.ExtractEntry(szFilename, FileName)) { *FileName=0; return false; }
		fIsTempFile = true;
		}
	// add the font resource
	//if (!AddFontResourceEx(FileName, FR_PRIVATE, NULL)) requires win2k
	if (!AddFontResource(FileName))
		{
		if (fIsTempFile) EraseFile(FileName);
		*FileName='\0';
		return false;
		}
#else
	if (!hGrp.LoadEntry(szFilename, Data)) return false;
#endif
	// success
	return true;
	}
示例#10
0
文件: boe.main.cpp 项目: Ircher/CBoE
void loadFonts()
{
    AddFontResource("maidword.ttf"); // add font to the system font table
    font = CreateFont(12,0,0,0,0, 0,0,0, 0,0, 0,0,0,"MS Sans Serif");
    small_bold_font = CreateFont(12,0,0,0,700, 0,0,0, 0,0, 0,0,0,"MS Sans Serif");
    italic_font = CreateFont(12,0,0,0,700, 1,0,0, 0,0, 0,0,0,"MS Sans Serif");
    underline_font = CreateFont(12,0,0,0,0, 0,1,0, 0,0,	0,0,0,"MS Sans Serif");
    bold_font = CreateFont(14,0,0,0,700, 0,0,0, 0,0, 0,0,0,"MS Sans Serif");
    tiny_font = font;
    fantasy_font = CreateFont(22,0,0,0,0, 0,0,0, 0,0, 0,0,0,"MaidenWord");
    if (fantasy_font == NULL)
    {
        fantasy_font = CreateFont(22,0,0,0,0, 0,0,0, 0,0, 0,0,0,"MS Sans Serif");
    }
}
示例#11
0
void StartmenuInit()
{
	GamefilesInit();
	AddFontResource(FONTNAME TEXT(".ttf"));
	hMenuFont = CreateFont(FONTSIZE_ITEM, 0, 0, 0, 0, FALSE, FALSE, FALSE,
		ANSI_CHARSET, 0, 0, 0, FIXED_PITCH, FONTNAME);
	hMenuSelectedFont = CreateFont(FONTSIZE_ITEM, 0, 0, 0, 0, FALSE, TRUE, FALSE,
		ANSI_CHARSET, 0, 0, 0, FIXED_PITCH, FONTNAME);
	hTitleFont = CreateFont(FONTSIZE_TITLE, 0, 0, 0, 0, FALSE, FALSE, FALSE,
		ANSI_CHARSET, 0, 0, 0, FIXED_PITCH, FONTNAME);
	hDescriptionFont = CreateFont(FONTSIZE_DESCRIPITION, 0, 0, 0, 0, FALSE, FALSE, FALSE,
		ANSI_CHARSET, 0, 0, 0, FIXED_PITCH, FONTNAME_SANS);
	hCopyrightFont = CreateFont(FONTSIZE_COPYRIGHT, 0, 0, 0, 0, FALSE, FALSE, FALSE,
		ANSI_CHARSET, 0, 0, 0, FIXED_PITCH, FONTNAME_SANS);
	DrawerAdd(StartmenuDrawer, 0, 0);
}
示例#12
0
MyFont::MyFont(IDirect3DDevice9 *d, std::string t)
{
	Device = d;
	text = t;
	AddFontResource("font.ttf");
	
	HRESULT hr = D3DXCreateFont(
		Device, 24, 0, FW_NORMAL, 0, FALSE, 
		ANSI_CHARSET, OUT_DEFAULT_PRECIS, 
		DEFAULT_QUALITY, DEFAULT_PITCH, "CloneWars", &font);

	if (FAILED(hr))
	{
		font->Release();
		font = 0;
	}
}
示例#13
0
BOOL CVCheckerApp::InitInstance()
{

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));

	//AfxSetResourceHandle(g_hMod);
	g_hResDll = LoadLibrary(_T("VCheckerResZhCn.dll"));		
	if (g_hResDll == NULL)
	{
		AfxMessageBox(_T("加载资源库文件失败!"));
	}

	CVCheckerClsGlobal clsGlobal;
	if (NULL != AddFontResource(clsGlobal.fGetAppPath() + _T("\\font\\ARLRDBD.TTF")))		// AddFontResource(CUSTOM_FONT))
	{
		::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
	}

	CVCheckerDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: 在此处放置处理何时用“确定”来关闭
		//  对话框的代码
	}

	if(RemoveFontResource(clsGlobal.fGetAppPath() + _T("\\font\\ARLRDBD.ttf")))
	{
		::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
	}

	FreeLibrary(g_hResDll);

	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	//  而不是启动应用程序的消息泵。
	return FALSE;
}
示例#14
0
void manager::init() const
{
#ifdef CAIRO_HAS_FT_FONT
	if (!FcConfigAppFontAddDir(FcConfigGetCurrent(),
		reinterpret_cast<const FcChar8 *>((game_config::path + "/fonts").c_str())))
	{
		ERR_FT << "Could not load the true type fonts\n";
		throw error();
	}
#endif

#if CAIRO_HAS_WIN32_FONT
	foreach(const std::string& path, get_binary_paths("fonts")) {
		std::vector<std::string> files;
		get_files_in_dir(path, &files, NULL, ENTIRE_FILE_PATH);
		foreach(const std::string& file, files)
			if(file.substr(file.length() - 4) == ".ttf" || file.substr(file.length() - 4) == ".ttc")
				AddFontResource(file.c_str());
	}
#endif
}
示例#15
0
void PinFont::Register()
	{

	HDC hdcScreen = GetDC(NULL);

	LOGFONT lf;

	lf.lfCharSet = DEFAULT_CHARSET;
	lstrcpy(lf.lfFaceName, "");
	lf.lfPitchAndFamily = 0;

	EnumFontFamiliesEx(hdcScreen, &lf, (FONTENUMPROC)EnumFontFamExProc, (size_t)this, 0);

	ReleaseDC(NULL, hdcScreen);

	char szPath[MAX_PATH];

	GetModuleFileName(NULL, szPath, MAX_PATH);

	char *szEnd = szPath + lstrlen(szPath);

	while (szEnd > szPath)
		{
		if (*szEnd == '\\')
			{
			break;
			}
		szEnd--;
		}

	*(szEnd+1) = '\0'; // Get rid of exe name

	lstrcat(szPath, "VPTemp.ttf");

	strcpy_s(m_szTempFile, sizeof(m_szTempFile), szPath);

	WriteToFile(m_szTempFile);

	/*const int fonts =*/ AddFontResource(m_szTempFile);
	}
示例#16
0
//////////////////////////////////////////////////////////////////////////////
//INITIALIZATION
//////////////////////////////////////////////////////////////////////////////
bool Prog_Init()
{
   AddFontResource(FONTNAME);
   
   hfntNew = CreateFont(-40,0,0,0,0,0,0,0,0,0,0,0,0,"cour");
   hpenNew = CreatePen(PS_SOLID,0,RGB(255,255,255));
   
   
   //add the font to the DC
   {
      ManageDC aDC(hWndMain);
      
      // retrieve it to save time..
      HDC hdc = aDC.borrowedDC();
      
      // put new font into DC, save off old..
      hfntOld = (HFONT) SelectObject(hdc,hfntNew);
      hpenOld = (HPEN) SelectObject(hdc,hpenNew);
      
      SetBkMode(hdc,TRANSPARENT);
      SetTextColor(hdc,RGB(255,255,255)); // white for now
      ShowProgInfo(  hdc,
                     WINDOWTITLE,
                     windowHorizontalSize,
                     windowVerticalSize);
   }

   //rectangle into which we will place the desired client RECT
   RECT rc;
   SetRect(&rc,0,0,windowHorizontalSize,windowVerticalSize);

   //get the window rect based on our style and extended style
   AdjustWindowRectEx(&rc,WS_BORDER | WS_SYSMENU | WS_CAPTION | WS_VISIBLE,FALSE,0);

   //use movewindow to resize the window
   MoveWindow(hWndMain,0,0,rc.right-rc.left,rc.bottom-rc.top,TRUE);
   
   return(true);//return success
}
    bool setFont(const char * pFontName = nullptr, int nSize = 0)
    {
        bool bRet = false;
        do 
        {
            std::string fontName = pFontName;
            std::string fontPath;
            HFONT       hDefFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            LOGFONTA    tNewFont = {0};
            LOGFONTA    tOldFont = {0};
            GetObjectA(hDefFont, sizeof(tNewFont), &tNewFont);
            if (fontName.c_str())
            {    
                // create font from ttf file
                int nFindttf = fontName.find(".ttf");
                int nFindTTF = fontName.find(".TTF");
                if (nFindttf >= 0 || nFindTTF >= 0)
                {
                    fontPath = FileUtils::getInstance()->fullPathForFilename(fontName.c_str());
                    int nFindPos = fontName.rfind("/");
                    fontName = &fontName[nFindPos+1];
                    nFindPos = fontName.rfind(".");
                    fontName = fontName.substr(0,nFindPos);                
                }
                else
                {
                    auto nFindPos = fontName.rfind("/");
                    if (nFindPos != fontName.npos)
                    {
                        if (fontName.length() == nFindPos + 1)
                        {
                            fontName = "";
                        } 
                        else
                        {
                            fontName = &fontName[nFindPos+1];
                        }
                    }
                }
                tNewFont.lfCharSet = DEFAULT_CHARSET;
                strcpy_s(tNewFont.lfFaceName, LF_FACESIZE, fontName.c_str());
            }
            if (nSize)
            {
                tNewFont.lfHeight = -nSize;
            }
            GetObjectA(_font,  sizeof(tOldFont), &tOldFont);

            if (tOldFont.lfHeight == tNewFont.lfHeight
                && 0 == strcmp(tOldFont.lfFaceName, tNewFont.lfFaceName))
            {
                // already has the font 
                bRet = true;
                break;
            }

            // delete old font
            removeCustomFont();

            if (fontPath.size() > 0)
            {
                _curFontPath = fontPath;
                wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath);
                if (pwszBuffer)
                {
                    if(AddFontResource(pwszBuffer))
                    {
                        SendMessage( _wnd, WM_FONTCHANGE, 0, 0);
                    }						
                    delete [] pwszBuffer;
                    pwszBuffer = nullptr;
                }
            }

            _font = nullptr;

            // disable Cleartype
            tNewFont.lfQuality = ANTIALIASED_QUALITY;

            // create new font
            _font = CreateFontIndirectA(&tNewFont);
            if (! _font)
            {
                // create failed, use default font
                _font = hDefFont;
                break;
            }

            bRet = true;
        } while (0);
        return bRet;
    }
示例#18
0
gxFont *gxGraphics::loadFont( const string &f,int height,int flags ){

	int bold=flags & gxFont::FONT_BOLD ? FW_BOLD : FW_REGULAR;
	int italic=flags & gxFont::FONT_ITALIC ? 1 : 0;
	int underline=flags & gxFont::FONT_UNDERLINE ? 1 : 0;
	int strikeout=0;

	string t;
	int n=f.find('.');
	if( n!=string::npos ){
		t=fullfilename(f);
		if( !font_res.count(t) && AddFontResource( t.c_str() ) ) font_res.insert( t );
		t=filenamefile( f.substr(0,n) );
	}else{
		t=f;
	}

	//save and turn off font smoothing....
	BOOL smoothing=FALSE;
	SystemParametersInfo( SPI_GETFONTSMOOTHING,0,&smoothing,0 );
	SystemParametersInfo( SPI_SETFONTSMOOTHING,FALSE,0,0 );

	HFONT hfont=CreateFont( 
		height,0,0,0,
		bold,italic,underline,strikeout,
		ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE,t.c_str() );

	if( !hfont ){
		//restore font smoothing
		SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 );
		return 0;
	}

	HDC hdc=CreateCompatibleDC( 0 );
	HFONT pfont=(HFONT)SelectObject( hdc,hfont );

	TEXTMETRIC tm={0};
	if( !GetTextMetrics( hdc,&tm ) ){
		SelectObject( hdc,pfont );
		DeleteDC( hdc );
		DeleteObject( hfont );
		SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 );
		return 0;
	}
	height=tm.tmHeight;

	int first=tm.tmFirstChar,last=tm.tmLastChar;
	int sz=last-first+1;
	int *offs=d_new int[sz];
	int *widths=d_new int[sz];
	int *as=d_new int[sz];

	//calc size of canvas to hold font.
	int x=0,y=0,max_x=0;
	for( int k=0;k<sz;++k ){

		char t=k+first;

		SIZE sz;
		GetTextExtentPoint32( hdc,&t,1,&sz );
		int w=sz.cx;

		as[k]=0;

		ABC abc;
		if( GetCharABCWidths( hdc,t,t,&abc ) ){
			if( abc.abcA<0 ){
				as[k]=ceil(-abc.abcA);
				w+=as[k];
			}
			if( abc.abcC<0 ) w+=ceil(-abc.abcC);
		}

		if( x && x+w>getWidth() ){ x=0;y+=height; }
		offs[k]=(x<<16)|y;
		widths[k]=w;
		x+=w;if( x>max_x ) max_x=x;
	}
	SelectObject( hdc,pfont );
	DeleteDC( hdc );

	int cw=max_x,ch=y+height;

	if( gxCanvas *c=createCanvas( cw,ch,0 ) ){
		ddSurf *surf=c->getSurface();

		HDC surf_hdc;
		if( surf->GetDC( &surf_hdc )>=0 ){
			HFONT pfont=(HFONT)SelectObject( surf_hdc,hfont );

			SetBkColor( surf_hdc,0x000000 );
			SetTextColor( surf_hdc,0xffffff );

			for( int k=0;k<sz;++k ){
				int x=(offs[k]>>16)&0xffff,y=offs[k]&0xffff;
				char t=k+first;
				RECT rect={x,y,x+widths[k],y+height};
				ExtTextOut( surf_hdc,x+as[k],y,ETO_CLIPPED,&rect,&t,1,0 );
			}

			SelectObject( surf_hdc,pfont );
			surf->ReleaseDC( surf_hdc );
			DeleteObject( hfont );
			delete[] as;

			c->backup();
			gxFont *font=d_new gxFont( this,c,tm.tmMaxCharWidth,height,first,last+1,tm.tmDefaultChar,offs,widths );
			font_set.insert( font );

			//restore font smoothing
			SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 );
			return font;
		}else{
示例#19
0
    bool setFont(const char * pFontName = NULL, int nSize = 0)
    {
        bool bRet = false;
        do 
        {
			std::string fontName = pFontName;
			std::string fontPath;
            HFONT       hDefFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            LOGFONTA    tNewFont = {0};
            LOGFONTA    tOldFont = {0};
            GetObjectA(hDefFont, sizeof(tNewFont), &tNewFont);
            if (fontName.c_str())
            {	
				// create font from ttf file
				int nFindttf = fontName.find(".ttf");
				int nFindTTF = fontName.find(".TTF");
				if (nFindttf >= 0 || nFindTTF >= 0)
				{
					fontPath = CCFileUtils::fullPathFromRelativePath(fontName.c_str());
					int nFindPos = fontName.rfind("/");
					fontName = &fontName[nFindPos+1];
					nFindPos = fontName.rfind(".");
					fontName = fontName.substr(0,nFindPos);				
				}
				tNewFont.lfCharSet = DEFAULT_CHARSET;
                strcpy_s(tNewFont.lfFaceName, LF_FACESIZE, fontName.c_str());
            }
            if (nSize)
            {
                tNewFont.lfHeight = -nSize;
            }
            GetObjectA(m_hFont,  sizeof(tOldFont), &tOldFont);

            if (tOldFont.lfHeight == tNewFont.lfHeight
                && ! strcpy(tOldFont.lfFaceName, tNewFont.lfFaceName))
            {
                // already has the font 
                bRet = true;
                break;
            }

            // delete old font
            if (m_hFont != hDefFont)
            {
                DeleteObject(m_hFont);
				// release old font register
				if (m_curFontPath.size() > 0)
				{
					wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath);
					if (pwszBuffer)
					{
						if(RemoveFontResource(pwszBuffer))
						{
							SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
						}						
						delete [] pwszBuffer;
						pwszBuffer = NULL;
					}
				}
				fontPath.size()>0?(m_curFontPath = fontPath):(m_curFontPath.clear());
				// register temp font
				if (m_curFontPath.size() > 0)
				{
					wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath);
					if (pwszBuffer)
					{
						if(AddFontResource(pwszBuffer))
						{
							SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0);
						}						
						delete [] pwszBuffer;
						pwszBuffer = NULL;
					}
				}
            }
            m_hFont = NULL;

            // disable Cleartype
            tNewFont.lfQuality = ANTIALIASED_QUALITY;

            // create new font
            m_hFont = CreateFontIndirectA(&tNewFont);
            if (! m_hFont)
            {
                // create failed, use default font
                m_hFont = hDefFont;
                break;
            }
            
            bRet = true;
        } while (0);
        return bRet;
    }
示例#20
0
文件: main.cpp 项目: minoki/wxmaxima
bool MyApp::OnInit()
{
  m_frame = NULL;
//  atexit(Cleanup_Static);
  int lang = wxLANGUAGE_UNKNOWN;
  
  bool batchmode = false;

  wxCmdLineParser cmdLineParser(argc, argv);

  static const wxCmdLineEntryDesc cmdLineDesc[] =
    {
      { wxCMD_LINE_SWITCH, "v", "version", "Output the version info" },
      /* Usually wxCMD_LINE_OPTION_HELP is used with the following option, but that displays a message
       * using a own window and we want the message on the command line. If a user enters a command
       * line option, he expects probably a answer just on the command line... */
      { wxCMD_LINE_SWITCH, "h", "help", "show this help message", wxCMD_LINE_VAL_NONE},
      { wxCMD_LINE_OPTION, "o", "open", "open a file" },
      { wxCMD_LINE_SWITCH, "b", "batch","run the file and exit afterwards. Halts on questions and stops on errors." },
#if defined __WXMSW__
      { wxCMD_LINE_OPTION, "f", "ini", "open an input file" },
#endif
      { wxCMD_LINE_PARAM, NULL, NULL, "input file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
      { wxCMD_LINE_NONE }
    };

  cmdLineParser.SetDesc(cmdLineDesc);
  cmdLineParser.Parse();
  wxString ini, file;
#if defined __WXMSW__
  if (cmdLineParser.Found(wxT("f"),&ini))
    wxConfig::Set(new wxFileConfig(ini));
  else
    wxConfig::Set(new wxConfig(wxT("wxMaxima")));
#else
  wxConfig::Set(new wxConfig(wxT("wxMaxima")));
#endif

  wxImage::AddHandler(new wxPNGHandler);
  wxImage::AddHandler(new wxXPMHandler);
  wxImage::AddHandler(new wxJPEGHandler);

  wxFileSystem::AddHandler(new wxZipFSHandler);

  Dirstructure dirstructure;


  wxConfigBase *config = wxConfig::Get();
  config->Read(wxT("language"), &lang);
  if (lang == wxLANGUAGE_UNKNOWN)
    lang = wxLocale::GetSystemLanguage();
  
  {
    wxLogNull disableErrors;
    m_locale.Init(lang);
  }

#if defined (__WXMSW__)
  wxSetEnv(wxT("LANG"), m_locale.GetName());
  if (!wxGetEnv(wxT("BUILD_DIR"), NULL))
    wxSetWorkingDirectory(wxPathOnly(wxString(argv[0])));
  /* Add private jsMath fonts, if they exist */ 
  if (wxFileExists("fonts/jsMath-cmex10.ttf")) AddFontResource(wxT("fonts/jsMath-cmex10.ttf"));
  if (wxFileExists("fonts/jsMath-cmsy10.ttf")) AddFontResource(wxT("fonts/jsMath-cmsy10.ttf"));
  if (wxFileExists("fonts/jsMath-cmr10.ttf"))  AddFontResource(wxT("fonts/jsMath-cmr10.ttf"));
  if (wxFileExists("fonts/jsMath-cmmi10.ttf")) AddFontResource(wxT("fonts/jsMath-cmmi10.ttf"));
  if (wxFileExists("fonts/jsMath-cmti10.ttf")) AddFontResource(wxT("fonts/jsMath-cmti10.ttf"));
#endif
  
  m_locale.AddCatalogLookupPathPrefix(dirstructure.LocaleDir());
  
  m_locale.AddCatalog(wxT("wxMaxima"));
  m_locale.AddCatalog(wxT("wxMaxima-wxstd"));

#if defined __WXMAC__
  wxString path;
  wxGetEnv(wxT("PATH"), &path);
  wxSetEnv(wxT("PATH"), path << wxT(":/usr/local/bin"));
#endif


#if defined (__WXMAC__)
  wxApp::SetExitOnFrameDelete(false);
  wxMenuBar *menuBar = new wxMenuBar;
  wxMenu *fileMenu = new wxMenu;
  fileMenu->Append(wxMaxima::mac_newId, _("&New\tCtrl-N"));
  fileMenu->Append(wxMaxima::mac_openId, _("&Open\tCtrl-O"));
  menuBar->Append(fileMenu, _("File"));
  wxMenuBar::MacSetCommonMenuBar(menuBar);

  Connect(wxMaxima::mac_newId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu));
  Connect(wxMaxima::mac_openId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu));
  Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu));
#endif

  if (cmdLineParser.Found(wxT("v")))
    {
      std::cout<<"wxMaxima ";
      std::cout << VERSION;
      std::cout<<"\n";
      wxExit();
    }
  if (cmdLineParser.Found(wxT("h")))
    {
      std::cout<<"A feature-rich graphical user interface for the computer algebra system maxima\n";
      std::cout<<cmdLineParser.GetUsageString();
      wxExit();
    }

  if (cmdLineParser.Found(wxT("b")))
  {
    batchmode = true;
  }

  if (cmdLineParser.Found(wxT("o"), &file))
    {
      wxFileName FileName=file;
      FileName.MakeAbsolute();
      wxString CanonicalFilename=FileName.GetFullPath();
      NewWindow(wxString(CanonicalFilename),batchmode);
      return true;
    }
  else
    {
      if (cmdLineParser.GetParamCount()>0)
	{
	  wxFileName FileName=cmdLineParser.GetParam();
	  FileName.MakeAbsolute();
          
	  wxString CanonicalFilename=FileName.GetFullPath();
	  NewWindow(CanonicalFilename,batchmode);
	}
      else
	NewWindow();
    }
  return true;
}
示例#21
0
int Main( int argc, char argv[MAXARG][MAXARGLEN] )
{
    int   k;
    int   n;
    char* p;
    int   status;
    char* argp[MAXARG+1];
    char  buffer[8192];
    char  rootdir[MAX_PATH];
    char  our_cmd[MAX_PATH];
    char  console[MAX_PATH];
    char  unix_rootdir[MAX_PATH];




    // Get the Staden Package directory
    if( !::GetModuleFileName(0,rootdir,MAX_PATH) )
    {
        ::MessageBox(0,"Unable to get Staden Package directory!", "SPRUN.EXE Message", MB_OK );
        return -3;
    }
    _strlwr( rootdir );
    p = strstr( rootdir, "\\sprun.exe" );
   *p = 0;



   // Create a copy of root directory in unix format
   strcpy( unix_rootdir, rootdir );
   p = unix_rootdir;
   while( *p )
   {
      if( *p == '\\' )
        *p = '/';
      p++;
   }



#ifdef RUNTIME_FONT_INSTALL
    /* Install the pregap font if it isn't already installed */
    if( IsFontInstalled("Pregap") == false )
    {
        //MessageBox(0,"Installing pregap.ttf","Debug",MB_OK);
        strcpy( buffer, rootdir );
        strcat( buffer, "\\windows-bin\\pregap.ttf" );
        ::GetShortPathName( buffer, buffer, MAX_PATH );
        _strlwr( buffer );
        if( !AddFontResource(buffer) )
            ::MessageBox(0,"Warning: Failed to install font pregap.ttf.","SPRUN.EXE Message", MB_OK );
        else
            ::SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0 );
    }
#endif



    // Add Staden Package environment variables to current environment
    sprintf( buffer, "TK_LIBRARY=%s/lib/tk", unix_rootdir );
    _putenv( buffer );
    sprintf( buffer, "TCL_LIBRARY=%s/lib/tcl", unix_rootdir );
    _putenv( buffer );
    sprintf( buffer, "STADLIB=%s/lib", unix_rootdir );
    _putenv( buffer );
    sprintf( buffer, "STADTABL=%s/tables", unix_rootdir );
    _putenv( buffer );
    sprintf( buffer, "STADENROOT=%s", unix_rootdir );
    _putenv( buffer );
    _putenv( "MACHINE=windows" );



    // Prepend our paths to PATH environment variable. Normally this is done
    // automatically by the App Path registry entry for sprun.exe, however if
    // we want to run more a remote copy of gap4 then the App Path will be
    // invalid, so we need to do it here again just to be sure we pick up the
    // appropriate dlls.
    sprintf( buffer, "PATH=%s\\windows-bin;%s\\lib\\windows-binaries;", rootdir, rootdir );
    p = getenv( "PATH" );
    assert(p);
    strcat( buffer, p );
    _putenv( buffer );
    


    // Set default command to be winstash, don't use quotes otherwise execve
    // won't work properly, but quotes are required in argp[0]!
    strcpy( our_cmd, rootdir );
    strcat( our_cmd, "\\windows-bin\\wish.exe" );



	// Get command console
    p = getenv( "COMSPEC" );
    if(!p)
    {
        // Assume windows NT
        ::GetWindowsDirectory( console, MAX_PATH );
        strcat( console, "\\system32\\cmd.exe" );
    }
    else
    {
        // Console is specified by environment
        strcpy( console, p );
    }
    


    // Construct suitable argp array for execve
    k = 1;
    n = 1;
    while( n<argc )
    {
        // -c option runs the console with the staden environment intact
        // on windows NT platforms only. Command.com on win9x is crippled
        // in that it ignores the environment given to execve()
        if( (argv[n][0]=='-') && (argv[n][1]=='c') && !argv[n][2] )
            strcpy( our_cmd, console );
        else
        {
            argp[n] = &argv[n][0];
            k++;
        }
        n++;
    }
    argp[k] = 0;
    assert(k<(MAXARG+1));



    // Assemble argv[0], we must put quotes around this
    strcpy( buffer, "\"" );
    strcat( buffer, our_cmd );
    strcat( buffer, "\"" );
    argp[0] = buffer;



    // Execute the program
    status = _execve( our_cmd, argp, _environ );
    if( status == -1 )
    {
        sprintf( buffer, "Sorry: Unable to execute %s - (%d).", our_cmd, errno );
        ::MessageBox(0,buffer,"SPRUN.EXE Message", MB_OK );
    }
    return 0;
}
示例#22
0
void cMainGame::Setup()
{
//  	cObjLoader l;
//  	m_pGroupHead = l.Load("./obj/Map.obj");
// 
// 	m_pMesh = l.LoadMesh("./obj/Map.obj", m_vecMtlTex);

	
	//D3DXCreateBox(g_pD3DDevice, 2, 2, 2, &m_pSphere, NULL);
	D3DXCreateTeapot(g_pD3DDevice, &m_pTeapot, NULL);

	// 주전자의 바운딩 정보 획득
	ST_PN_VERTEX* pV = NULL;
	m_pTeapot->LockVertexBuffer(0, (LPVOID*)&pV);
	D3DXComputeBoundingSphere(&pV[0].p,
		m_pTeapot->GetNumVertices(),
		sizeof(ST_PN_VERTEX),
		&m_vTeapotPos,
		&m_fTeapotRadius);
	m_pTeapot->UnlockVertexBuffer();

	// 디버깅용 바운딩 스피어 생성.
	D3DXCreateSphere(g_pD3DDevice, m_fTeapotRadius, 10, 10, &m_pSphere, NULL);
	
// 	cAseLoader loader;
// 	m_pRoot = loader.Load("woman/woman_01_all.ASE");

	ZeroMemory(&m_stWhiteMtl, sizeof(D3DMATERIAL9));
	m_stWhiteMtl.Ambient = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	m_stWhiteMtl.Diffuse = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	m_stWhiteMtl.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);

	ZeroMemory(&m_stRedMtl, sizeof(D3DMATERIAL9));
	m_stRedMtl.Ambient = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f);
	m_stRedMtl.Diffuse = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f);
	m_stRedMtl.Specular = D3DXCOLOR(0.8f, 0.0f, 0.0f, 1.0f);


	//폰트 생성
	D3DXFONT_DESC fd;
	ZeroMemory(&fd,sizeof(D3DXFONT_DESC));
	fd.Height			= 45;
	fd.Width			= 28;
	fd.Weight			= FW_MEDIUM;
	fd.Italic			= false;
	fd.CharSet			= DEFAULT_CHARSET;
	fd.OutputPrecision  = OUT_DEFAULT_PRECIS;
	fd.PitchAndFamily   = FF_DONTCARE;
	//strcpy_s(fd.FaceName, "궁서체");	//글꼴 스타일
	AddFontResource("umberto.ttf");
	strcpy(fd.FaceName, "umberto");

	D3DXCreateFontIndirect(g_pD3DDevice, &fd, &m_pFont);

	m_pCamera = new cCamera;
	m_pCamera->Setup(NULL);

	m_pGrid = new cGrid;
	m_pGrid->Setup(15, 1.0f);
	
	SetLight();
}
RRESULT OnCreate(void *pParam)
{
	/*
	//	Walk through in debug to trace all routes
	*/
	g_App.PreCheckArguments();

	sprintf( cstrReleaseDate, "Version : %s", ZGetSVNRevision().c_str()); //Possibly
	cclog(cstrReleaseDate); cclog("\n");

	g_DInput.Create(g_hWnd, FALSE, FALSE);
	g_pInput = new ZInput(&g_DInput);
	RSetGammaRamp(Z_VIDEO_GAMMA_VALUE);
	RSetRenderFlags(RRENDER_CLEAR_BACKBUFFER);

	ZGetInitialLoading()->Initialize(  1, 0, 0, RGetScreenWidth(), RGetScreenHeight(), 0, 0, 1024, 768 );

	cclog("InitialLoading success.\n");

	struct _finddata_t c_file;
	intptr_t hFile;
	char szFileName[256];
	#define FONT_DIR	"Font/"
	#define FONT_EXT	"ttf"
	if( (hFile = _findfirst(FONT_DIR"*."FONT_EXT, &c_file )) != -1L ){
		do{
			strcpy(szFileName, FONT_DIR);
			strcat(szFileName, c_file.name);
			AddFontResource(szFileName);
		}while( _findnext( hFile, &c_file ) == 0 );
		_findclose(hFile);
	}

	g_pDefFont = new CCFontR2;

	if( !g_pDefFont->Create("Default", Z_LOCALE_DEFAULT_FONT, DEFAULT_FONT_HEIGHT, 1.0f) )	{
		cclog("Fail to Create default font : CCFontR2 / main.cpp.. onCreate\n" );
		g_pDefFont->Destroy();
		SAFE_DELETE( g_pDefFont );
		g_pDefFont	= NULL;
	}
	g_pDC = new CCDrawContextR2(RGetDevice());

	if( ZGetInitialLoading()->IsUseEnable() )
	{
		ZGetInitialLoading()->AddBitmap( 0, "Interface/Default/LOADING/loading_adult.jpg" );
		ZGetInitialLoading()->AddBitmapBar( "Interface/Default/LOADING/loading.bmp" );
		ZGetInitialLoading()->SetText( g_pDefFont, 5, 5, cstrReleaseDate );
		ZGetInitialLoading()->AddBitmapGrade( "Interface/Default/LOADING/loading_grade_fifteen.jpg" );
		ZGetInitialLoading()->SetPercentage( 0.0f );
		ZGetInitialLoading()->Draw( MODE_FADEIN, 0 , true );
	}


	g_Core.Initialize(800, 600, g_pDC, g_pDefFont);
	Core::GetInstance()->SetHWND(RealSpace2::g_hWnd);

	cclog("interface Initialize success\n");

	ZLoadingProgress appLoading("application");
	if(!g_App.OnCreate(&appLoading))
	{
		ZGetInitialLoading()->Release();
		return R_ERROR_LOADING;
	}

	ZGetSoundEngine()->SetEffectVolume(Z_AUDIO_EFFECT_VOLUME);
	ZGetSoundEngine()->SetMusicVolume(Z_AUDIO_BGM_VOLUME);
	ZGetSoundEngine()->SetEffectMute(Z_AUDIO_EFFECT_MUTE);
	ZGetSoundEngine()->SetMusicMute(Z_AUDIO_BGM_MUTE);

	g_Core.SetWorkspaceSize(g_ModeParams.nWidth, g_ModeParams.nHeight);
	g_Core.GetMainFrame()->SetSize(g_ModeParams.nWidth, g_ModeParams.nHeight);
	ZGetOptionInterface()->Resize(g_ModeParams.nWidth, g_ModeParams.nHeight);

	// Default Key
	for(int i=0; i<ZACTION_COUNT; i++){
		ZACTIONKEYDESCRIPTION& keyDesc = ZGetConfiguration()->GetKeyboard()->ActionKeys[i];
		g_pInput->RegisterActionKey(i, keyDesc.nVirtualKey);
		if(keyDesc.nVirtualKeyAlt!=-1)
			g_pInput->RegisterActionKey(i, keyDesc.nVirtualKeyAlt);
	}

	g_App.SetInitialState();

//	ParseParameter(g_szCmdLine);

//	ZGetFlashBangEffect()->SetDrawCopyScreen(true);

	static const char *szDone = "Done.";
	ZGetInitialLoading()->SetLoadingStr(szDone);
	if( ZGetInitialLoading()->IsUseEnable() )
	{
#ifndef _FASTDEBUG
		ZGetInitialLoading()->SetPercentage( 100.f );
		ZGetInitialLoading()->Draw( MODE_FADEOUT, 0 ,true  );
#endif
		ZGetInitialLoading()->Release();
	}

	cclog("main : OnCreate() done\n");

	SetFocus(g_hWnd);

	return R_OK;
}
bool CGumpEditorDoc::Init()
{
	if (m_bInitUOData) return true;

	UnInit();

	//fix Mulpath if wrong
	if (nConfig::mulpath.size ())
    {
		char last_char = nConfig::mulpath[nConfig::mulpath.length () - 1];
		if ((last_char != '/') && (last_char != '\\'))
		  nConfig::mulpath +="/";
	}

	std::string mulpath = nConfig::mulpath;
	std::string gumpartfile = mulpath + "gumpart.mul";
	std::string gumpidxfile = mulpath + "gumpidx.mul";
	std::string huesfile = mulpath + "hues.mul";
//flo:
	pVerdataLoader = NULL;

	m_pGumpLoader = new cGumpLoader;
	if (!m_pGumpLoader->load(gumpartfile, gumpidxfile))
	{
		MessageBox(NULL, (gumpartfile + " or\n" + gumpidxfile).c_str(), "Can't Open File", MB_OK|MB_ICONERROR);
		delete m_pGumpLoader;
		m_pGumpLoader = NULL;
		return false;
	}

//flo: New
	std::string filename=mulpath + "verdata.mul";
	std::ifstream verdata; 
	verdata.open(filename.c_str (),  std::ios::in | std::ios::binary);
    if (verdata)
    {
        verdata.close();
		pVerdataLoader = new cVerdataLoader (mulpath + "verdata.mul");
    }
//--------
	m_pHueLoader = new cHueLoader;
	if (!m_pHueLoader->load(huesfile))
	{
		MessageBox(NULL, huesfile.c_str(), "Can't Open File", MB_OK|MB_ICONERROR);
		delete m_pHueLoader;
		m_pHueLoader = NULL;
		return false;
	}


	LOGFONT lf;
	memset(&lf,0,sizeof(lf));

	sMyFont font;

	for (std::vector<nConfig::font_info>::iterator iter = nConfig::fonts.begin(); iter != nConfig::fonts.end(); iter++)
	{	
		if (!AddFontResource(iter->file.c_str())) continue;
	
		strcpy(lf.lfFaceName, iter->name.c_str());
		lf.lfHeight = iter->size;
		//lf.lfWeight = FW_BOLD;
		//lf.lfCharSet = ANSI_CHARSET;
		//lf.lfOutPrecision  = OUT_TT_ONLY_PRECIS;

		CFont* pFont = new CFont;
		//if (!pFont->CreateFontIndirect(&lf)) {
		if (!pFont->CreatePointFont(lf.lfHeight*8, lf.lfFaceName)) {
			delete pFont;
			RemoveFontResource(iter->file.c_str());
			continue;
		}

		font.file = iter->file;
		font.font = pFont;
		font.color = GetHueColor(iter->hue, iter->id);

		m_fonts.insert(std::make_pair(iter->id, font));
	}

	m_bInitUOData = true;

	g_pGumpEditorDoc = this;

	return true;
}
示例#25
0
文件: uilib.c 项目: martinpiper/VICE
char *uilib_select_file_autostart(const char *title,
                                   unsigned int filterlist, unsigned int type,
                                   int style, int *autostart,
                                   char *resource_readonly)
{
    char *name = NULL;
    char *initialdir = NULL;
    char *initialfile = NULL;
//    char *filter = NULL;
//    unsigned int filterindex;
//    OPENFILENAME ofn;
//    int result;
    char *ret = NULL;

    if (styles[style].initialdir_resource != NULL)
        resources_get_value(styles[style].initialdir_resource,
            (void *)&initialdir);

    initialfile = ui_file_selector_initialfile[style];
    if (styles[style].file_resource != NULL)
        resources_get_value(styles[style].file_resource,
            (void *)&initialfile);

#if 0
    if (fontfile == NULL) {
        fontfile = util_concat(archdep_boot_path(), 
                               "\\fonts\\cbm-directory-charset.fon", NULL);
        font_loaded = 0;
        EnumFontFamilies(GetDC(NULL), "cbm-directory-charset/ck!",
            (FONTENUMPROC)EnumFontProc, (LPARAM)&font_loaded);
        if (font_loaded == 0) {
            font_loaded = AddFontResource(fontfile);
        }
    }

    filter = set_filter(filterlist, &filterindex);

    memset(&ofn, 0, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = hwnd;
    ofn.hInstance = winmain_instance;
    ofn.lpstrFilter = filter;
    ofn.lpstrCustomFilter = NULL;
    ofn.nMaxCustFilter = 0;
    ofn.nFilterIndex = filterindex;
    ofn.lpstrFile = st_name;
    ofn.nMaxFile = sizeof(st_name);
    ofn.lpstrFileTitle = NULL;
    ofn.nMaxFileTitle = 0;
    ofn.lpstrInitialDir = initialdir;
    ofn.lpstrTitle = title;
    ofn.Flags = OFN_EXPLORER | OFN_HIDEREADONLY | OFN_NOTESTFILECREATE
                | OFN_SHAREAWARE | OFN_ENABLESIZING;
    if (styles[style].TemplateID != 0) {
        ofn.Flags |= OFN_ENABLEHOOK | OFN_ENABLETEMPLATE;
        ofn.lpfnHook = styles[style].hook_proc;
        ofn.lpTemplateName = MAKEINTRESOURCE(styles[style].TemplateID);
    } else {
        ofn.lpfnHook = NULL;
        ofn.lpTemplateName = NULL;
    }
    if (type == UILIB_SELECTOR_TYPE_FILE_LOAD)
        ofn.Flags |= OFN_FILEMUSTEXIST;

    ofn.nFileOffset = 0;
    ofn.nFileExtension = 0;
    ofn.lpstrDefExt = NULL;

    read_content_func = styles[style].content_read_function;
    autostart_result = autostart;
    res_readonly = resource_readonly;
    vsync_suspend_speed_eval();

    if (type == UILIB_SELECTOR_TYPE_FILE_SAVE)
        result = GetSaveFileName(&ofn);
    else
        result = GetOpenFileName(&ofn);

    update_filter_history(ofn.nFilterIndex);
#endif

    name = ui_filereq(title, styles[style].TemplateID, initialdir, initialfile, styles[style].content_read_function, autostart, resource_readonly);

    if (name != NULL) {
        char newdir[1024], *ptr = PathPart(name);
        memcpy(newdir, name, (int)(ptr - name));
        newdir[(int)(ptr - name)] = '\0';

        if (ui_file_selector_initialfile[style] != NULL)
            lib_free(ui_file_selector_initialfile[style]);
        if (styles[style].file_resource != NULL)
            resources_set_value(styles[style].file_resource, FilePart(name));
        ui_file_selector_initialfile[style] = lib_stralloc(FilePart(name));

        resources_set_value(styles[style].initialdir_resource, newdir);
        ret = lib_stralloc(name);
    }

//    lib_free(filter);

    return ret;
}
示例#26
0
	FontManager::FontManager()
	{
		int nFontsLoaded = AddFontResource("Resources\\Fonts\\Sony_Sketch_EF.ttf");
	}
示例#27
0
//--------------------------------------------------------------------------------------
DWORD WINAPI FuzzIterationThread(LPVOID lpParam)
{
    MSG Msg;

    // load fuzzed font
    if (AddFontResource(m_TmpFontPath) == 0)
    {
        DbgMsg(__FILE__, __LINE__, "AddFontResource() fails\n");
        return -1;
    }

#ifdef USE_BOADCAST_MESSAGES

    SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);

#endif

    int x = (GetSystemMetrics(SM_CXSCREEN) - WND_W) / 2;
    int y = (GetSystemMetrics(SM_CYSCREEN) - WND_H) / 2;

    // create new empty window
    m_hWnd = CreateWindowEx(
        WS_EX_CLIENTEDGE,
        _T(WND_CLASS), _T(WND_TITLE), 
        WS_OVERLAPPEDWINDOW,
        x, y, WND_W, WND_H, 
        NULL, NULL, 
        m_hInstance, 
        NULL
    );
    if (m_hWnd)
    {
        ShowWindow(m_hWnd, SW_SHOWNORMAL);
        UpdateWindow(m_hWnd);

        SendMessage(m_hWnd, WM_COMMAND, ID_CLOSE, 0);

        // Main message loop
        while (GetMessage(&Msg, NULL, 0, 0))
        {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
        }
    }
    else
    {
        DbgMsg(__FILE__, __LINE__, "CreateWindow() ERROR %d\n", GetLastError());
    }    

    // unload fuzzed font
    if (!RemoveFontResource(m_TmpFontPath))
    {
        DbgMsg(__FILE__, __LINE__, "RemoveFontResource() fails\n");
    }

#ifdef USE_BOADCAST_MESSAGES

    SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);

#endif

    return 0;
}
示例#28
0
文件: ft_tt.c 项目: Gaikokujin/WinNT4
BOOL bTestLoadFOT (
    HDC     hdc
    )
{
    HFONT   hfont;
    HFONT   hfontOriginal;
    LOGFONT lfnt;
    TEXTMETRIC  tm;

// Clear the screen to black.

    BitBlt(hdc, 0, 0, CX, CY, (HDC) 0, 0, 0, 0);

    DbgPrint("ft!bTestLoadFOT(): check gcTrueTypeFonts\n");
    DbgBreakPoint();

// Add a TrueType .FOT font file.

    if ( !AddFontResource("lcallig.fot") )
    {
        DbgPrint("ft!bTestLoadFOT(): failed to load .FOT file\n");
        return FALSE;
    }
    GdiFlush();
    DbgPrint("ft!bTestLoadFOT(): check gcTrueTypeFonts (it should be 1 bigger)\n");
    DbgBreakPoint();

// Get a font.

    memset(&lfnt, 0, sizeof(lfnt));
    lstrcpy(lfnt.lfFaceName, "Lucida Calligraphy");
    lfnt.lfHeight = -14;
    lfnt.lfWeight = 400;

    if ((hfont = CreateFontIndirect(&lfnt)) == NULL)
    {
        DbgPrint("ft!bTestLoadFOT(): Logical font creation failed.\n");
        return FALSE;
    }

    hfontOriginal = SelectObject(hdc, hfont);

// Get metrics.

    if ( GetTextMetrics(hdc, &tm) )
        vPrintTM(hdc, &tm);
    else
        DbgPrint("ft!bTestLoadFOT(): GetTextMetrics call failed\n");

// Restore the font.

    SelectObject(hdc, hfontOriginal);
    DeleteObject(hfont);

// Remove the TrueType .FOT font file.

    if ( !RemoveFontResource("lcallig.fot") )
    {
        DbgPrint("ft!bTestLoadFOT(): error removing .FOT file\n");
        return FALSE;
    }
    GdiFlush();
    DbgPrint("ft!bTestLoadFOT(): check gcTrueTypeFonts (it should be 1 smaller)\n");
    DbgBreakPoint();

    return TRUE;
}
示例#29
0
static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
{
    if(!fnt->data.isEmpty()) {
#ifndef Q_OS_WINCE
        PtrAddFontMemResourceEx ptrAddFontMemResourceEx = (PtrAddFontMemResourceEx)QSystemLibrary::resolve(QLatin1String("gdi32"),
                                                                                                     "AddFontMemResourceEx");
        if (!ptrAddFontMemResourceEx)
            return;
#endif
        getFamiliesAndSignatures(fnt->data, fnt);
        if (fnt->families.isEmpty())
            return;

#ifdef Q_OS_WINCE
        HANDLE handle = 0;

        {
#ifdef QT_NO_TEMPORARYFILE
           wchar_t lpBuffer[MAX_PATH];
           GetTempPath(MAX_PATH, lpBuffer);
           QString s = QString::fromWCharArray(lpBuffer);
           QFile tempfile(s + QLatin1String("/font") + QString::number(GetTickCount()) + QLatin1String(".ttf"));
           if (!tempfile.open(QIODevice::ReadWrite))
#else
            QTemporaryFile tempfile(QLatin1String("XXXXXXXX.ttf"));
            if (!tempfile.open())
#endif // QT_NO_TEMPORARYFILE
                return;
            if (tempfile.write(fnt->data) == -1)
                return;

#ifndef QT_NO_TEMPORARYFILE
            tempfile.setAutoRemove(false);
#endif
            fnt->fileName = QFileInfo(tempfile.fileName()).absoluteFilePath();
        }

        if (AddFontResource((LPCWSTR)fnt->fileName.utf16()) == 0) {
            QFile(fnt->fileName).remove();
            return;
        }
#else
        DWORD dummy = 0;
        HANDLE handle = ptrAddFontMemResourceEx((void *)fnt->data.constData(), fnt->data.size(), 0,
                                                &dummy);
        if (handle == 0)
            return;
#endif // Q_OS_WINCE

        fnt->handle = handle;
        fnt->data = QByteArray();
        fnt->memoryFont = true;
    } else {
        QFile f(fnt->fileName);
        if (!f.open(QIODevice::ReadOnly))
            return;
        QByteArray data = f.readAll();
        f.close();
        getFamiliesAndSignatures(data, fnt);

#ifdef Q_OS_WINCE
        QFileInfo fileinfo(fnt->fileName);
        fnt->fileName = fileinfo.absoluteFilePath();
        if (AddFontResource((LPCWSTR)fnt->fileName.utf16()) == 0)
            return;
#else
        PtrAddFontResourceExW ptrAddFontResourceExW = (PtrAddFontResourceExW)QSystemLibrary::resolve(QLatin1String("gdi32"),
                                                                                               "AddFontResourceExW");
        if (!ptrAddFontResourceExW
            || ptrAddFontResourceExW((wchar_t*)fnt->fileName.utf16(), FR_PRIVATE, 0) == 0)
            return;
#endif // Q_OS_WINCE

        fnt->memoryFont = false;
    }
}
示例#30
0
void TEMPLATE_CONTROL_API LoadFontFromFile( LPCSTR lpFilePath )
{
	int nRet = AddFontResource(lpFilePath);
	if (0 == nRet) return;
	::SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
}