/// <summary> /// Measure of the text /// </summary> private SizeF GetTypoMeasure(string text) { ITypographer avtp = TypographerBroker.Instance; avtp.Text = text; avtp.FontSize = Font.Size; avtp.FontName = Font.Name; return(avtp.Measure()); }
/// <summary> /// Measure of the char /// </summary> private SizeF GetTypoMeasure() { ITypographer avtp = TypographerBroker.Instance; avtp.Text = Character.ToString(); avtp.FontSize = Font.Size; avtp.FontName = Font.Name; avtp.FontStyle = Font.Style; return(avtp.Measure()); }
/// <summary> /// Image of the text /// </summary> private IImageAdapter GetTypoResult() { ITypographer avtp = TypographerBroker.Instance; avtp.Text = Character.ToString(); avtp.FontSize = Font.Size; avtp.FontName = Font.Name; avtp.FontStyle = Font.Style; avtp.TextRenderingHint = TextRenderingHint; avtp.BackgroundColor = BackgroundColor; avtp.ForegroundColor = ForegroundColor; return(avtp.Render()); }
} // block instantiation #endregion Constructors #region Methods #region Private Methods #endregion Private Methods #region Public Methods /// <summary> /// Reflection based loader for custom typographers supplied by the end user /// </summary> public static void LoadTypographer(string assemblyToLoad, string type) { Assembly asm = Assembly.Load(assemblyToLoad); Type tpgr = asm.GetType(type); if (tpgr == null) { throw new ApplicationException("Specified type '" + type + "' not found in assembly '" + assemblyToLoad + "'"); } ITypographer ltypo = (ITypographer)tpgr.InvokeMember("Instance", BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty, null, null, null); if (ltypo == null) { throw new ApplicationException("Unable to create the specified typographer ('" + type + "." + assemblyToLoad + "')"); } _typograph = ltypo; }
/// <summary> /// Image of the text /// </summary> private IImageAdapter GetTypoResult() { int maxX = 0; int maxY = 0; ITypographer avtp = TypographerBroker.Instance; foreach (GlyphChar glyphChar in Glyphs) { int x = (int)(glyphChar.ComputedLayout.SizeF.Width + glyphChar.ComputedLayout.PositionF.X + .5); int y = (int)(glyphChar.ComputedLayout.SizeF.Height + glyphChar.ComputedLayout.PositionF.Y + .5); if (x > maxX) { maxX = x; } if (y > maxY) { maxY = y; } } IImageAdapter retVal = new ImageAdapter(maxX, maxY, BackgroundColor); // IImageAdapter imageChar = null; // for (int t = 0; t < _text.Count; t++) foreach (GlyphChar glyphChar in Glyphs) { // HACK : Call Render Char one more time but ignore Background color avtp.Text = glyphChar.Character.ToString(); avtp.FontSize = Font.Size; avtp.FontName = Font.Name; avtp.BackgroundColor = BackgroundColor; avtp.ForegroundColor = ForegroundColor; avtp.TextRenderingHint = TextRenderingHint; glyphChar.GeneratedImage = avtp.Render(); Point offset = glyphChar.ComputedLayout.Position; System.Drawing.Size size = new System.Drawing.Size(glyphChar.GeneratedImage.Width, glyphChar.GeneratedImage.Height); retVal = ImageUtility.CopyImageAdapter(retVal, glyphChar.GeneratedImage, offset, size, true); } return(retVal); }