public void TestGetAdjustedTsString() { ITsStrBldr strBldr = TsStrBldrClass.Create(); ITsStrBldr strBldrExpected = TsStrBldrClass.Create(); ITsPropsBldr propsBldr = TsPropsBldrClass.Create(); propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "StyleA"); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_hvoGermanWs); strBldr.ReplaceRgch(0, 0, "Hello People", 12, propsBldr.GetTextProps()); strBldrExpected.ReplaceRgch(0, 0, "Hello People", 12, propsBldr.GetTextProps()); propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "StyleA"); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_hvoEnglishWs); strBldr.ReplaceRgch(0, 0, "Hello numero dos", 16, propsBldr.GetTextProps()); var propsBldrExpected = propsBldr; propsBldrExpected.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 20500); strBldrExpected.ReplaceRgch(0, 0, "Hello numero dos", 16, propsBldrExpected.GetTextProps()); propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "StyleB"); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_hvoGermanWs); strBldr.ReplaceRgch(0, 0, "3 Hello", 7, propsBldr.GetTextProps()); propsBldrExpected = propsBldr; propsBldrExpected.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, ExpectedFontHeightForArial); strBldrExpected.ReplaceRgch(0, 0, "3 Hello", 7, propsBldrExpected.GetTextProps()); propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "StyleB"); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_hvoEnglishWs); strBldr.ReplaceRgch(0, 0, "This is 4", 9, propsBldr.GetTextProps()); strBldrExpected.ReplaceRgch(0, 0, "This is 4", 9, propsBldr.GetTextProps()); var tss = FontHeightAdjuster.GetAdjustedTsString(strBldr.GetString(), 23000, m_stylesheet, m_wsManager); var propsWithWiggleRoom = new Dictionary <int, int>(); if (GetUbuntuVersion() == 14) { propsWithWiggleRoom[(int)FwTextPropType.ktptFontSize] = 1000; // millipoints. for some reason, the result is sometimes a point smaller on Trusty } AssertEx.AreTsStringsEqual(strBldrExpected.GetString(), tss, propsWithWiggleRoom); }
public void TestGetAdjustedTsString() { ITsStrBldr strBldr = TsStrBldrClass.Create(); ITsStrBldr strBldrExpected = TsStrBldrClass.Create(); ITsPropsBldr propsBldr = TsPropsBldrClass.Create(); ITsPropsBldr propsBldrExpected; propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "StyleA"); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_hvoGermanWs); strBldr.ReplaceRgch(0, 0, "Hello People", 12, propsBldr.GetTextProps()); strBldrExpected.ReplaceRgch(0, 0, "Hello People", 12, propsBldr.GetTextProps()); propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "StyleA"); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_hvoEnglishWs); strBldr.ReplaceRgch(0, 0, "Hello numero dos", 16, propsBldr.GetTextProps()); propsBldrExpected = propsBldr; propsBldrExpected.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 20500); strBldrExpected.ReplaceRgch(0, 0, "Hello numero dos", 16, propsBldrExpected.GetTextProps()); propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "StyleB"); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_hvoGermanWs); strBldr.ReplaceRgch(0, 0, "3 Hello", 7, propsBldr.GetTextProps()); propsBldrExpected = propsBldr; propsBldrExpected.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, GetExpectedFontHeightForArial()); strBldrExpected.ReplaceRgch(0, 0, "3 Hello", 7, propsBldrExpected.GetTextProps()); propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "StyleB"); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_hvoEnglishWs); strBldr.ReplaceRgch(0, 0, "This is 4", 9, propsBldr.GetTextProps()); strBldrExpected.ReplaceRgch(0, 0, "This is 4", 9, propsBldr.GetTextProps()); ITsString tss = FontHeightAdjuster.GetAdjustedTsString(strBldr.GetString(), 23000, m_stylesheet, m_wsManager); AssertEx.AreTsStringsEqual(strBldrExpected.GetString(), tss); }