コード例 #1
0
void VProcess::_ReadProductName( VString& outName) const
{
#if VERSIONWIN
#ifndef XTOOLBOX_AS_STANDALONE
	DWORD size = ::GetFileVersionInfoSizeW( GetExecutableFilePath().GetPath().GetCPointer(), NULL);
	void *buffer = malloc( size);
	if ( (buffer != NULL) && GetFileVersionInfoW( GetExecutableFilePath().GetPath().GetCPointer(), NULL, size, buffer))
	{
		void *valueAdress;
		UINT valueSize;
		if (::VerQueryValueW( buffer, L"\\StringFileInfo\\040904B0\\ProductName", &valueAdress, &valueSize))
		{
			outName.FromBlock( valueAdress, (valueSize - 1) * sizeof( UniChar), VTC_UTF_16);
		}
	}
	if (buffer != NULL)
		free( buffer);
#endif
#elif VERSIONMAC
	CFStringRef cfProductName = (CFStringRef) CFBundleGetValueForInfoDictionaryKey( CFBundleGetMainBundle(), kCFBundleNameKey);
	if (cfProductName != NULL)
		outName.MAC_FromCFString( cfProductName);

#elif VERSION_LINUX
    outName="Wakanda Server";	//Postponed Linux Implementation
#endif
}
コード例 #2
0
void VProcess::_ReadProductVersion( VString& outVersion) const
{
#if VERSIONWIN
#ifndef XTOOLBOX_AS_STANDALONE
	DWORD size = ::GetFileVersionInfoSizeW( GetExecutableFilePath().GetPath().GetCPointer(), NULL);
	void *buffer = malloc( size);
	if ( (buffer != NULL) && GetFileVersionInfoW( GetExecutableFilePath().GetPath().GetCPointer(), NULL, size, buffer))
	{
		void *valueAdress;
		UINT valueSize;
		if (::VerQueryValueW( buffer, L"\\StringFileInfo\\040904B0\\ProductVersion", &valueAdress, &valueSize))
		{
			outVersion.FromBlock( valueAdress, (valueSize - 1) * sizeof( UniChar), VTC_UTF_16);
		}
	}
	if (buffer != NULL)
		free( buffer);
#endif
#elif VERSIONMAC
	// The constant for the "short version" property does not exist.
	CFStringRef cfProductVersion = (CFStringRef) CFBundleGetValueForInfoDictionaryKey( CFBundleGetMainBundle(), CFSTR ( "CFBundleShortVersionString" ) /*kCFBundleVersionKey*/);
	if (cfProductVersion != NULL)
	{
		outVersion.MAC_FromCFString( cfProductVersion);
	}

#elif VERSION_LINUX
    //jmo - We get the Linux product version with SetProductVersion() on VRIAServerApplication init
#endif
}
コード例 #3
0
VFilePath VProcess::GetExecutableFilePath() const
{
	VFilePath filePath;

#if VERSIONMAC

	CFURLRef exeURL = ::CFBundleCopyExecutableURL( ::CFBundleGetMainBundle());
	
	if (testAssert( exeURL != NULL ))
	{
		CFStringRef cfPath = ::CFURLCopyFileSystemPath( exeURL, kCFURLHFSPathStyle);
		if (testAssert( cfPath != NULL ))
		{
			VString thepath;
			thepath.MAC_FromCFString( cfPath);
			thepath.Compose();
			filePath.FromFullPath( thepath, FPS_SYSTEM);
			::CFRelease( cfPath);
		}
		
		::CFRelease(exeURL );
	}

#elif VERSIONWIN

	// Get a path to the exe.
	UniChar path[4096];
	DWORD pathLength=0;

	path[sizeof(path)/sizeof(UniChar)-2]=0;
	pathLength = ::GetModuleFileNameW(NULL, path, sizeof(path));
	
	if (testAssert(pathLength != 0 && !path[sizeof(path)/sizeof(UniChar)-2]))
	{
		VString thepath( path);
		filePath.FromFullPath( thepath, FPS_SYSTEM);
	}

#elif VERSION_LINUX

	PathBuffer path;

	VError verr=path.InitWithExe();
	xbox_assert(verr==VE_OK);

	path.ToPath(&filePath);
	xbox_assert(verr==VE_OK);
		
#endif
	
	return filePath;
}
コード例 #4
0
bool XMacSystem::SearchExecutablePath( const VString& inExecutableName, VFilePath& outPath)
{
	// first lookup in environment variables
	bool found = XBSDSystem::SearchExecutablePath( inExecutableName, outPath);
	
	// then ask launch services
	if (!found)
	{
		VString name( inExecutableName);
		
		if (!name.EndsWith( CVSTR( ".app")))
			name += CVSTR( ".app");
		
		CFURLRef cfAppUrl = NULL;
		CFStringRef cfName = name.MAC_RetainCFStringCopy();
		OSStatus status = LSFindApplicationForInfo( kLSUnknownCreator, NULL /* inBundleID */, cfName, NULL /* outFSRef */, &cfAppUrl);
		if (cfName != NULL)
			CFRelease( cfName);
			
		if (status == noErr)
		{
			if (testAssert( cfAppUrl != NULL))
			{
				CFStringRef cfPosixPath = ::CFURLCopyFileSystemPath( cfAppUrl, kCFURLPOSIXPathStyle);
				if (testAssert( cfPosixPath != NULL))
				{
					VString posixPath;
					posixPath.MAC_FromCFString( cfPosixPath);
					
					posixPath.Compose();
					
					// add an ending / because it's a bundle folder
					posixPath += "/";
					outPath.FromFullPath( posixPath, FPS_POSIX);
					
					found = true;
					::CFRelease( cfPosixPath);
				}
			}
		}

		if (cfAppUrl != NULL)
			CFRelease( cfAppUrl);
	}
	
	return found;
}
コード例 #5
0
void XMacFontMgr::GetStdFont( StdFont inFont, VString& outName, VFontFace& outFace, GReal& outSize)
{
	// on risque de perdre des infos, il faudrait retourner une VFont
	
	CTFontUIFontType fontType = StdFontToThemeFontID( inFont);
	CTFontRef fontRef = ::CTFontCreateUIFontForLanguage( fontType, 0 /*size*/, NULL /*language*/ );

	if (testAssert( fontRef != NULL))
	{
		outSize = ::CTFontGetSize( fontRef);

		CFStringRef cfName = ::CTFontCopyFamilyName( fontRef);
		if (cfName != NULL)
		{
			outName.MAC_FromCFString( cfName);
			::CFRelease( cfName);
		}
		else
		{
			outName.Clear();
		}
		
		CTFontSymbolicTraits traits = ::CTFontGetSymbolicTraits( fontRef);
		outFace = 0;
		
		if (traits & kCTFontItalicTrait)
			outFace |= KFS_ITALIC;
		
		if (traits & kCTFontBoldTrait)
			outFace |= KFS_BOLD;
		
		if (traits & kCTFontExpandedTrait)
			outFace |= KFS_EXTENDED;
		
		if (traits & kCTFontCondensedTrait)
			outFace |= KFS_CONDENSED;

		CFRelease( fontRef); 
	}
	else
	{
		outName.Clear();
		outSize = 0;
		outFace = 0;
	}
}
コード例 #6
0
void XMacFontMgr::BuildFontList()
{
	fFontFamilies.SetCount(0);
	//fFontNames.SetCount(0);
	fFontNames.clear();
	/*
	FMFontFamilyIterator	iterator;
	OSErr	error = ::FMCreateFontFamilyIterator(NULL, NULL, kFMDefaultOptions, &iterator);
	if (error == noErr)
	{
		FMFontFamily	family;
		
		assert(sizeof(FMFontFamily) == sizeof(sWORD));
		while (::FMGetNextFontFamily(&iterator, &family) == noErr)
		{
			Str255 spFontName;
			if (testAssert(::FMGetFontFamilyName(family, spFontName) == noErr))
			{
				VStr255	name;
				CFStringRef cfname;
				ATSFontFamilyRef ffref = ::ATSFontFamilyFindFromQuickDrawName(spFontName);
				::ATSFontFamilyGetName(ffref, kATSOptionFlagsDefault, &cfname);
				//name.MAC_FromMacPString(spFontName);
				name.MAC_FromCFString(cfname);
				if(name[0] != '.' && name[0] != '%')
				{	
					fFontNames.AppendString(name);
					fFontFamilies.AppendWord((sWORD) family);
				}
				//CFRelease(cfname);
			}
		}
		
		::FMDisposeFontFamilyIterator(&iterator);
	}*/
	
	CTFontCollectionRef FontCollection = ::CTFontCollectionCreateFromAvailableFonts(0);//kCTFontCollectionRemoveDuplicatesOption
	if(FontCollection)
    {
		CFArrayRef fonts = CTFontCollectionCreateMatchingFontDescriptors(FontCollection);
		if(fonts)
		{
			const int numFonts = CFArrayGetCount(fonts);
			for(int i = 0; i < numFonts; ++i) 
			{
				VString	vname;
				CTFontDescriptorRef vfont = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fonts, i);
				CFStringRef family_name = (CFStringRef)CTFontDescriptorCopyAttribute(vfont, kCTFontFamilyNameAttribute);
				if(family_name!=NULL)
				{
					vname.MAC_FromCFString(family_name);
				
					if( std::find(fFontNames.begin(), fFontNames.end(), vname) == fFontNames.end())
						fFontNames.push_back(vname);
				}
				//CFRelease(family_name);
			}
		}
	}	
	
	//fFontNames.SynchronizedSort(false, &fFontFamilies);
	//fFontNames.Sort(0, fFontNames.GetCount()-1);
	std::sort(fFontNames.begin(),fFontNames.end());
}
コード例 #7
0
ファイル: VFont.cpp プロジェクト: sanyaade-iot/core-XToolbox
/** return true if font with the specified font family name, style and size exists on the current system */
bool VFont::FontExists(const VString& inFontFamilyName, const VFontFace& inFace, GReal inSize, const GReal inDPI, const VGraphicContext *inGC)
{
#if VERSIONWIN
	bool exists = false;
	//JQ 21/06/2010: fixed and optimized FontExists (was not coherent with font creation)
	VFont *font = RetainFont( inFontFamilyName, inFace, inSize, inDPI, true);
	if (font)
	{
		if (!font->IsTrueTypeFont())
		{
			//not TrueType fonts are drawed with GDI
			//so return true if a valid HFONT is set

			HFONT hFont = font->GetFontRef();
			exists = hFont != NULL;
			font->Release();
			return exists;
		}
#if ENABLE_D2D
		if (inGC && inGC->IsD2DImpl())
		{
			//if DWrite font family name is not equal to inFontFamilyName
			//DWrite has returned a compatible font 
			//so return true only if DWrite font family name matches inFontFamilyName

			VTaskLock lock(&VWinD2DGraphicContext::GetMutexDWriteFactory());
			exists = false;
			if (font->GetImpl().GetDWriteTextFormat() != NULL)
			{
				UINT32 nameLength = font->GetImpl().GetDWriteTextFormat()->GetFontFamilyNameLength();
				if (nameLength+1 <= 80)
				{
					WCHAR familyName[80];
					HRESULT hr = font->GetImpl().GetDWriteTextFormat()->GetFontFamilyName( familyName, nameLength+1);
					exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
				}
				else
				{
					WCHAR *familyName = new WCHAR[nameLength+1];
					font->GetImpl().GetDWriteTextFormat()->GetFontFamilyName( familyName, nameLength+1);
					exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
					delete [] familyName;
				}
			}
			font->Release();
			return exists;
		}
#endif
		//if gdiplus font family name is not equal to inFontFamilyName
		//gdiplus has returned a compatible font 
		//so return true only if gdiplus font family name matches inFontFamilyName
		Gdiplus::FontFamily *family = new Gdiplus::FontFamily();
		Gdiplus::Status status = font->GetImpl().GetGDIPlusFont()->GetFamily(family);
		WCHAR familyName[LF_FACESIZE];
		family->GetFamilyName( familyName);
		exists = wcscmp( inFontFamilyName.GetCPointer(), familyName) == 0;
		delete family;

		font->Release();
	}
	return exists;
#else
	bool exists = false;
	VFont *font = RetainFont( inFontFamilyName, inFace, inSize, inDPI, true);
	if (font)
	{
		//ensure returned font has the requested family name (here we check only the family name but not the full name)
		//otherwise it is a font substitute
		CTFontRef ctfont = font->GetFontRef();
		CFStringRef name = CTFontCopyFamilyName(ctfont);
		VString xname;
		xname.MAC_FromCFString( name);
		CFRelease(name);
		VString inname( inFontFamilyName);
		inname.Truncate( xname.GetLength());
		return inname.EqualToString( xname);
	}
	return exists;
#endif
}