summaryrefslogtreecommitdiff
path: root/FontInfo.h
diff options
context:
space:
mode:
Diffstat (limited to 'FontInfo.h')
-rw-r--r--FontInfo.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/FontInfo.h b/FontInfo.h
new file mode 100644
index 0000000..7385c33
--- /dev/null
+++ b/FontInfo.h
@@ -0,0 +1,111 @@
+// FontInfo.h : Declaration of the CFontInfo
+
+#ifndef __FONTINFO_H_
+#define __FONTINFO_H_
+
+#include "resource.h" // main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CFontInfo
+class ATL_NO_VTABLE CFontInfo :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public CComCoClass<CFontInfo, &CLSID_FontInfo>,
+ public ISupportErrorInfo,
+ public IDispatchImpl<ITrueTypeFontInfo, &IID_ITrueTypeFontInfo, &LIBID_TtfInfoLib>
+{
+public:
+ CFontInfo()
+ {
+ OSVERSIONINFO info = {0};
+ info.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
+ GetVersionEx( &info );
+
+ if ( VER_PLATFORM_WIN32_NT == info.dwPlatformId )
+ m_strFontsKey = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
+ else
+ m_strFontsKey = _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Fonts");
+
+ Initialize();
+ }
+
+DECLARE_REGISTRY_RESOURCEID(IDR_FONTINFO)
+
+BEGIN_COM_MAP(CFontInfo)
+ COM_INTERFACE_ENTRY(ITrueTypeFontInfo)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(ISupportErrorInfo)
+END_COM_MAP()
+
+// Attributes
+protected:
+ _bstr_t m_bstrFileName;
+ _bstr_t m_bstrCopyright;
+ _bstr_t m_bstrFamily;
+ _bstr_t m_bstrID;
+ _bstr_t m_bstrName;
+ _bstr_t m_bstrPostscriptName;
+ _bstr_t m_bstrSubfamily;
+ _bstr_t m_bstrTrademark;
+ _bstr_t m_bstrVersion;
+ static LPCTSTR m_strFontsKey;
+
+// Inline helpers
+public:
+ inline void Initialize();
+ inline _bstr_t GetRegistryFontName() const;
+ inline static LONG OpenFontsKey( CRegKey& reg, REGSAM samDesired = KEY_ALL_ACCESS );
+
+
+// ISupportsErrorInfo
+public:
+ STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
+
+// ITrueTypeFontInfo
+public:
+ STDMETHOD(Uninstall)(/*[in, optional]*/ VARIANT_BOOL bPermanent);
+ STDMETHOD(Install)(/*[in, optional]*/ VARIANT_BOOL bPermanent);
+ STDMETHOD(GetFontsDirectory)(/*[out, retval]*/ BSTR* pVal);
+ STDMETHOD(get_RegisteredFileName)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_Version)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_Trademark)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_Subfamily)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_PostscriptName)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_ID)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_Family)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_Copyright)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(get_FileName)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(put_FileName)(/*[in]*/ BSTR newVal);
+ STDMETHOD(get__FileName)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(put__FileName)(/*[in]*/ BSTR newVal);
+};
+
+///////////////////////////////////////////////////////////////////////////////////
+// Inline Helpers
+///////////////////////////////////////////////////////////////////////////////////
+
+inline void CFontInfo::Initialize()
+{
+ m_bstrFileName = "";
+ m_bstrCopyright = "";
+ m_bstrFamily = "";
+ m_bstrID = "";
+ m_bstrName = "";
+ m_bstrPostscriptName = "";
+ m_bstrSubfamily = "";
+ m_bstrTrademark = "";
+ m_bstrVersion = "";
+}
+
+inline _bstr_t CFontInfo::GetRegistryFontName() const
+{
+ return m_bstrName + _T(" (TrueType)");
+}
+
+inline LONG CFontInfo::OpenFontsKey( CRegKey& reg, REGSAM samDesired /* = KEY_ALL_ACCESS */ )
+{
+ return reg.Open( HKEY_LOCAL_MACHINE, m_strFontsKey, samDesired );
+}
+
+
+#endif //__FONTINFO_H_