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


C# FontFamily.GetCellDescent方法代码示例

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


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

示例1: RecalcLayout

        public override void RecalcLayout()
        {
            base.RecalcLayout();

            Font font = NumIndicator.AbsFont;
            FontFamily family = new FontFamily(font.Name);

            int descent = family.GetCellDescent(font.Style);
            float descentPixel = font.Size * descent / family.GetEmHeight(font.Style);

            _Descent = (int)(descentPixel / 2) + 1;
        }
开发者ID:,项目名称:,代码行数:12,代码来源:

示例2: ObtainFontMetrics

        void ObtainFontMetrics(Graphics g)
        {
            string infoString = "";  // enough space for one line of output
            int ascent;             // font family ascent in design units
            float ascentPixel;      // ascent converted to pixels
            int descent;            // font family descent in design units
            float descentPixel;     // descent converted to pixels
            int lineSpacing;        // font family line spacing in design units
            float lineSpacingPixel; // line spacing converted to pixels

            FontStyle fontStyle = FontStyle.Regular;
            //fontStyle = FontStyle.Italic | FontStyle.Bold;
            FontFamily fontFamily = new FontFamily("arial");
            //fontFamily = FontFamily.GenericSansSerif;

            Font font = new Font(
                fontFamily,
                16, fontStyle,
                GraphicsUnit.Pixel);
            PointF pointF = new PointF(10, 10);
            SolidBrush solidBrush = new SolidBrush(Color.Black);

            // Display the font size in pixels.
            infoString = "font family : " + font.FontFamily.Name + " " + fontStyle + ".";
            g.DrawString(infoString, font, solidBrush, pointF);

            // Move down one line.
            pointF.Y += font.Height;

            // Display the font size in pixels.
            infoString = "font.Size returns " + font.Size + ".";
            g.DrawString(infoString, font, solidBrush, pointF);

            // Move down one line.
            pointF.Y += font.Height;

            // Display the font family em height in design units.
            infoString = "fontFamily.GetEmHeight() returns " +
                         fontFamily.GetEmHeight(fontStyle) + ".";
            g.DrawString(infoString, font, solidBrush, pointF);

            // Move down two lines.
            pointF.Y += 2 * font.Height;

            // Display the ascent in design units and pixels.
            ascent = fontFamily.GetCellAscent(fontStyle);

            // 14.484375 = 16.0 * 1854 / 2048
            ascentPixel =
                font.Size * ascent / fontFamily.GetEmHeight(fontStyle);
            infoString = "The ascent is " + ascent + " design units, " + ascentPixel +
                         " pixels.";
            g.DrawString(infoString, font, solidBrush, pointF);

            // Move down one line.
            pointF.Y += font.Height;

            // Display the descent in design units and pixels.
            descent = fontFamily.GetCellDescent(fontStyle);

            // 3.390625 = 16.0 * 434 / 2048
            descentPixel =
                font.Size * descent / fontFamily.GetEmHeight(fontStyle);
            infoString = "The descent is " + descent + " design units, " +
                         descentPixel + " pixels.";
            g.DrawString(infoString, font, solidBrush, pointF);

            // Move down one line.
            pointF.Y += font.Height;

            // Display the line spacing in design units and pixels.
            lineSpacing = fontFamily.GetLineSpacing(fontStyle);

            // 18.398438 = 16.0 * 2355 / 2048
            lineSpacingPixel =
                font.Size * lineSpacing / fontFamily.GetEmHeight(fontStyle);
            infoString = "The line spacing is " + lineSpacing + " design units, " +
                         lineSpacingPixel + " pixels.";
            g.DrawString(infoString, font, solidBrush, pointF);

            title = "ObtainFontMetrics";
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:82,代码来源:DrawingView.cs

示例3: GetMetricInfo

        public MetricsInfo GetMetricInfo(int character, GraphicsContext context, DeviceDescription description)
        {
            var svgContext = _mapper.MapGraphicsContextToSvg(new Point(), 0, context);
            var s = new string(new[] { (char)character });
            var family = new FontFamily(svgContext.Font.Family);
            var style = GetStyle(context.FontFace);

            return new MetricsInfo
            {
                Ascent = family.GetCellAscent(style),
                Descent = family.GetCellDescent(style),
                Width = MeasureWidth(s, context, description),
            };
        }
开发者ID:narutoswj,项目名称:rdotnet-onboarding,代码行数:14,代码来源:SvgGraphicsDevice.cs

示例4: uiButtonApply_Click


//.........这里部分代码省略.........
                                myGraphic.RotateTransform(float.Parse(rotate.Value));
                                myGraphic.DrawImageUnscaled(currentCardImage, img.PosX, img.PosY, img.ImgWidth, img.ImgHieght);
                                myGraphic.RotateTransform(-float.Parse(rotate.Value));
                                myGraphic.TranslateTransform(-(float)img.ImgWidth / 2, -(float)img.ImgHieght / 2);
                            }
                            else
                            {
                                myGraphic.DrawImageUnscaled(currentCardImage, img.PosX, img.PosY, img.ImgWidth, img.ImgHieght);
                            }

                            // add image uploaded by user as attachment
                            msg.Attachments.Add(new Attachment(Server.MapPath("~/" + path)));
                            msg.Body += "Image " + (dli.ItemIndex + 1).ToString() + " : <br />";
                            msg.Body += "contrust :  " + contrast.Value + "<br />";
                            msg.Body += "brightness :  " + brightness.Value + " <br />";
                            msg.Body += "rotaion : " + rotate.Value + " <br />";
                            msg.Body += "style : " + style.SelectedValue.Substring(0, style.SelectedValue.IndexOf("=")) + " <br />";

                        }

                    }
                }

                myGraphic.ResetTransform();

                // draw layout
                //myGraphic.DrawImageUnscaled(imgSelectedLayout, 0, 0,imgSelectedLayout.Width, imgSelectedLayout.Height);
                myGraphic.DrawImage(imgSelectedLayout, 0, 0, imgSelectedLayout.Width, imgSelectedLayout.Height);
                myGraphic.Save();

                // draw strings
                myGraphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                msg.Body += "<br /> =========================================================== <br />";
                msg.Body += " ========================= Text Info ================== <br />";

                foreach (DataListItem dli in uiDataListCardText.Items)
                {
                    if (dli.ItemType == ListItemType.Item || dli.ItemType == ListItemType.AlternatingItem)
                    {
                        HiddenField hf = (HiddenField)dli.FindControl("uiHiddenFieldTextID");
                        HiddenField hfc = (HiddenField)dli.FindControl("uiHiddenFieldMyColor");
                        DropDownList ddlfont = (DropDownList)dli.FindControl("uiDropDownListFonts");
                        DropDownList ddlfontsize = (DropDownList)dli.FindControl("uiDropDownListFontSize");
                        CardText text = new CardText();
                        TextBox tb = (TextBox)dli.FindControl("uiTextBoxText");
                        text.LoadByPrimaryKey(Convert.ToInt32(hf.Value));

                        System.Drawing.Color fontcolor = System.Drawing.ColorTranslator.FromHtml(hfc.Value);
                        System.Drawing.Brush fontbrush = new System.Drawing.SolidBrush(fontcolor);

                        FontFamily family = new FontFamily(ddlfont.SelectedItem.Text);
                        float fontsize = (Convert.ToInt32(ddlfontsize.SelectedItem.Text) * family.GetEmHeight(FontStyle.Regular)) / family.GetCellDescent(FontStyle.Regular);

                        myGraphic.DrawString(tb.Text, new Font(ddlfont.SelectedItem.Text, fontsize, FontStyle.Italic), fontbrush, new RectangleF(text.PosX, text.PosY, text.Width, text.Height));

                        msg.Body += text.TextLabel + " : " + tb.Text + "<br />";
                        msg.Body += "font :  " + ddlfont.SelectedItem.Text + "<br />";
                        msg.Body += "font size :  " + ddlfontsize.SelectedItem.Text + " <br />";
                        msg.Body += "color : " + hfc.Value + " <br />";
                    }
                }

                myGraphic.Save();

                string newpath = Guid.NewGuid().ToString();

                // save generated img
                GeneratedImg.Save(Server.MapPath("~/images/UserOrders/" + newpath + "_2.jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg);
                uiImageMain.ImageUrl = "~/images/UserOrders/" + newpath + "_2.jpeg";

                // add final image as attachment
                msg.Attachments.Add(new Attachment(Server.MapPath("~/images/UserOrders/" + newpath + "_2.jpeg")));

                myGraphic.Dispose();

                UserPayement temp = new UserPayement();
                temp.AddNew();
                temp.CardID = CardID;
                temp.CardDesign = "images/UserOrders/" + newpath + "_2.jpeg";
                temp.CardCount = 1;
                try
                {
                    temp.GetColumn("ItemPrice");
                }
                catch (Exception)
                {
                    temp.AddColumn("ItemPrice", Type.GetType("System.Double"));
                }
                temp.SetColumn("ItemPrice", card.PriceNow);
                Session["UserPayment"] = temp;
                uipanelError.Visible = false;

                OrderMail = msg;

            }
            catch (Exception ex)
            {
                uipanelError.Visible = true;
            }
        }
开发者ID:menasbeshay,项目名称:ivalley-svn,代码行数:101,代码来源:customize.aspx.cs

示例5: FontFamily_String

		public void FontFamily_String ()
		{
			HostIgnoreList.CheckTest ("MonoTests.System.Drawing.FontFamilyTest.FontFamily_String");
			FontFamily ff = new FontFamily (name);
			CheckMono (ff);
			FontStyle style = FontStyle.Bold;
			Assert.AreEqual (ff.Name, ff.GetName (0), "GetName");
			Assert.IsTrue ((ff.GetCellAscent (style) > 0), "GetCellAscent");
			Assert.IsTrue ((ff.GetCellDescent (style) > 0), "GetCellDescent");
			Assert.IsTrue ((ff.GetEmHeight (style) > 0), "GetEmHeight");
			Assert.IsTrue ((ff.GetLineSpacing (style) > 0), "GetLineSpacing");
			Assert.IsTrue (ff.IsStyleAvailable (style), "IsStyleAvailable");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:13,代码来源:FontFamilyTest.cs


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