当前位置: 首页>>代码示例>>C#>>正文


C# StyleInfo.GetFontFamily方法代码示例

本文整理汇总了C#中fyiReporting.RDL.StyleInfo.GetFontFamily方法的典型用法代码示例。如果您正苦于以下问题:C# StyleInfo.GetFontFamily方法的具体用法?C# StyleInfo.GetFontFamily怎么用?C# StyleInfo.GetFontFamily使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fyiReporting.RDL.StyleInfo的用法示例。


在下文中一共展示了StyleInfo.GetFontFamily方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MeasureString

        private SizeF MeasureString(string s, StyleInfo si, Graphics g, out float descent)
        {
            Font drawFont=null;
            StringFormat drawFormat=null;
            SizeF ms = SizeF.Empty;
            descent = 0;
            if (s == null || s.Length == 0)
                return ms;
            try
            {
                // STYLE
                System.Drawing.FontStyle fs = 0;
                if (si.FontStyle == FontStyleEnum.Italic)
                    fs |= System.Drawing.FontStyle.Italic;

                // WEIGHT
                switch (si.FontWeight)
                {
                    case FontWeightEnum.Bold:
                    case FontWeightEnum.Bolder:
                    case FontWeightEnum.W500:
                    case FontWeightEnum.W600:
                    case FontWeightEnum.W700:
                    case FontWeightEnum.W800:
                    case FontWeightEnum.W900:
                        fs |= System.Drawing.FontStyle.Bold;
                        break;
                    default:
                        break;
                }
                try
                {
                    FontFamily ff = si.GetFontFamily();
                    drawFont = new Font(ff, si.FontSize, fs);
                    // following algorithm comes from the C# Font Metrics documentation
                    float descentPixel = si.FontSize * ff.GetCellDescent(fs) / ff.GetEmHeight(fs);
                    descent = RSize.PointsFromPixels(g, descentPixel);
                }
                catch
                {
                    drawFont = new Font("Arial", si.FontSize, fs);	// usually because font not found
                    descent = 0;
                }
                drawFormat = new StringFormat();
                drawFormat.Alignment = StringAlignment.Near;

                CharacterRange[] cr = {new CharacterRange(0, s.Length)};
                drawFormat.SetMeasurableCharacterRanges(cr);
                Region[] rs = new Region[1];
                rs = g.MeasureCharacterRanges(s, drawFont, new RectangleF(0,0,float.MaxValue,float.MaxValue),
                    drawFormat);
                RectangleF mr = rs[0].GetBounds(g);

                ms.Height = RSize.PointsFromPixels(g, mr.Height);	// convert to points from pixels
                ms.Width = RSize.PointsFromPixels(g, mr.Width);		// convert to points from pixels
                return ms;
            }
            finally
            {
                if (drawFont != null)
                    drawFont.Dispose();
                if (drawFormat != null)
                    drawFont.Dispose();
            }
        }
开发者ID:huasonli,项目名称:My-FyiReporting,代码行数:65,代码来源:PageTextHtml.cs


注:本文中的fyiReporting.RDL.StyleInfo.GetFontFamily方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。