/*---------------------------------------------------------------------------------------------- A convenient way to initialize a graphite renderer when we don't have an IVwGraphics around. When one is readily available, just call InitRenderer directly. ----------------------------------------------------------------------------------------------*/ void GrUtil::InitGraphiteRenderer(IRenderEngine * preneng, const OLECHAR * pszFace, bool fBold, bool fItalic, BSTR bstrFontVar, int nTrace) { LgCharRenderProps chrp; wcscpy_s(chrp.szFaceName, pszFace); chrp.ttvBold = fBold ? kttvForceOn : kttvOff; chrp.ttvItalic = fItalic ? kttvForceOn : kttvOff; chrp.dympHeight = 12000; // arbitrary to make it something reasonable (12 points) IVwGraphicsWin32Ptr qvg; qvg.CreateInstance(CLSID_VwGraphicsWin32); HDC hdc = ::CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); try { qvg->Initialize(hdc); // puts the DC in the right state qvg->SetupGraphics(&chrp); CheckHr(preneng->InitRenderer(qvg, bstrFontVar)); // Set the trace options (e.g. logging). ComSmartPtr<ITraceControl> qtreng; CheckHr(preneng->QueryInterface(IID_ITraceControl, (void**)&qtreng)); CheckHr(qtreng->SetTracing(nTrace)); } catch (...) { } qvg.Clear(); ::DeleteDC(hdc); }
/*---------------------------------------------------------------------------------------------- See if there are Graphite tables in the font, or failing that, an indication of the Graphite font in the registry. ----------------------------------------------------------------------------------------------*/ bool GrUtil::FontHasGraphiteTables(const OLECHAR * pszFace, bool fBold, bool fItalic) { bool fGraphite = false; LgCharRenderProps chrp; wcscpy_s(chrp.szFaceName, pszFace); chrp.ttvBold = fBold ? kttvForceOn : kttvOff; chrp.ttvItalic = fItalic ? kttvForceOn : kttvOff; chrp.dympHeight = 12000; // arbitrary to make it something reasonable (12 points) IVwGraphicsWin32Ptr qvg; qvg.CreateInstance(CLSID_VwGraphicsWin32); HDC hdc = ::CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); try { qvg->Initialize(hdc); // puts the DC in the right state qvg->SetupGraphics(&chrp); //FwGrGraphics gg(qvg.Ptr()); //fGraphite = GrUtil::FontHasGraphiteTables(&gg); fGraphite = GrUtil::FontHasGraphiteTables(qvg); } catch (...) { } qvg.Clear(); ::DeleteDC(hdc); return fGraphite; }