示例#1
0
/*----------------------------------------------------------------------------------------------
	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);
}
示例#2
0
/*----------------------------------------------------------------------------------------------
	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;
}
示例#3
0
/*----------------------------------------------------------------------------------------------
	Return the size of the text, in points.
----------------------------------------------------------------------------------------------*/
float FwGrTxtSrc::getVerticalOffset(toffset ich)
{
	LgCharRenderProps lgchrp;
	int ichMinBogus, ichLimBogus;
	GrResult res = (GrResult)m_qts->GetCharProps(GrToVwOffset(ich), &lgchrp, &ichMinBogus, &ichLimBogus);

	int dympOffset = lgchrp.dympOffset;

	if(lgchrp.ssv != kssvOff)
	{
		// psuedo device context works since we are getting proportions which are invariant
		HDC hdc = ::CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL);

		IVwGraphicsWin32Ptr qvgW;
		qvgW.CreateInstance(CLSID_VwGraphicsWin32);
		qvgW->Initialize(hdc);

		IVwGraphicsPtr qvg;
		CheckHr(qvgW->QueryInterface(IID_IVwGraphics, (void **) &qvg));
		CheckHr(qvg->SetupGraphics(&lgchrp));

		if (lgchrp.ssv == kssvSuper)
		{
			int dSuperscriptYOffsetNumerator;
			int dSuperscriptYOffsetDenominator;
			CheckHr(qvg->GetSuperscriptYOffsetRatio(&dSuperscriptYOffsetNumerator, &dSuperscriptYOffsetDenominator));
			dympOffset += gr::GrEngine::GrIntMulDiv(lgchrp.dympHeight, dSuperscriptYOffsetNumerator, dSuperscriptYOffsetDenominator);
		}
		else if (lgchrp.ssv == kssvSub)
		{
			int dSubscriptYOffsetNumerator;
			int dSubscriptYOffsetDenominator;
			CheckHr(qvg->GetSubscriptYOffsetRatio(&dSubscriptYOffsetNumerator, &dSubscriptYOffsetDenominator));
			dympOffset -= gr::GrEngine::GrIntMulDiv(lgchrp.dympHeight, dSubscriptYOffsetNumerator, dSubscriptYOffsetDenominator);
		}
		qvgW.Clear();
		qvg.Clear();
		::DeleteDC(hdc);
	}

	return (float)(dympOffset / 1000);
}