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


C# Font.GetCalculatedBaseFont方法代码示例

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


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

示例1: ApplyForText

        public void ApplyForText(PdfContentByte cb, IDictionary<String, String> css, Chunk chunk)
        {
            SetStrokeAndFillColor(cb, css);
            SetStrokeAndFill(cb, css);

            try
            {
                Font font = new Font(Font.FontFamily.COURIER, 6, Font.NORMAL, BaseColor.BLACK);

                Font font2 = chunk.Font;

                BaseFont bf2 = font2.BaseFont;
                //BaseFont bf = ;

                if (bf2 == null)
                {
                    cb.SetFontAndSize(font.GetCalculatedBaseFont(false), font2.Size);
                }
                else
                {
                    cb.SetFontAndSize(bf2, font2.Size);
                }
            } catch { }

        }
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: AddFont

 /**
 * Adds a <CODE>Font</CODE> to be searched for valid characters.
 * @param font the <CODE>Font</CODE>
 */    
 public void AddFont(Font font) {
     if (font.BaseFont != null) {
         fonts.Add(font);
         return;
     }
     BaseFont bf = font.GetCalculatedBaseFont(true);
     Font f2 = new Font(bf, font.Size, font.CalculatedStyle, font.Color);
     fonts.Add(f2);
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:13,代码来源:FontSelector.cs

示例3: Write

 // ===========================================================================
 public void Write(Stream stream)
 {
     string RESOURCE = Utility.ResourcePosters;
     // step 1
     using (Document document = new Document())
     {
         // step 2
         PdfWriter writer = PdfWriter.GetInstance(document, stream);
         // step 3
         document.Open();
         // step 4
         Chunk c;
         String foobar = "Foobar Film Festival";
         // Measuring a String in Helvetica
         Font helvetica = new Font(Font.FontFamily.HELVETICA, 12);
         BaseFont bf_helv = helvetica.GetCalculatedBaseFont(false);
         float width_helv = bf_helv.GetWidthPoint(foobar, 12);
         c = new Chunk(foobar + ": " + width_helv, helvetica);
         document.Add(new Paragraph(c));
         document.Add(new Paragraph(string.Format(
           "Chunk width: {0}", c.GetWidthPoint()
         )));
         // Measuring a String in Times
         BaseFont bf_times = BaseFont.CreateFont(
           "c:/windows/fonts/times.ttf",
           BaseFont.WINANSI, BaseFont.EMBEDDED
         );
         Font times = new Font(bf_times, 12);
         float width_times = bf_times.GetWidthPoint(foobar, 12);
         c = new Chunk(foobar + ": " + width_times, times);
         document.Add(new Paragraph(c));
         document.Add(new Paragraph(String.Format(
           "Chunk width: {0}", c.GetWidthPoint()
         )));
         document.Add(Chunk.NEWLINE);
         // Ascent and descent of the String
         document.Add(new Paragraph(
           "Ascent Helvetica: " + bf_helv.GetAscentPoint(foobar, 12)
         ));
         document.Add(new Paragraph(
           "Ascent Times: " + bf_times.GetAscentPoint(foobar, 12)
         ));
         document.Add(new Paragraph(
           "Descent Helvetica: " + bf_helv.GetDescentPoint(foobar, 12)
         ));
         document.Add(new Paragraph(
           "Descent Times: " + bf_times.GetDescentPoint(foobar, 12)
         ));
         document.Add(Chunk.NEWLINE);
         // Kerned text
         width_helv = bf_helv.GetWidthPointKerned(foobar, 12);
         c = new Chunk(foobar + ": " + width_helv, helvetica);
         document.Add(new Paragraph(c));
         // Drawing lines to see where the text is added
         PdfContentByte canvas = writer.DirectContent;
         canvas.SaveState();
         canvas.SetLineWidth(0.05f);
         canvas.MoveTo(400, 806);
         canvas.LineTo(400, 626);
         canvas.MoveTo(508.7f, 806);
         canvas.LineTo(508.7f, 626);
         canvas.MoveTo(280, 788);
         canvas.LineTo(520, 788);
         canvas.MoveTo(280, 752);
         canvas.LineTo(520, 752);
         canvas.MoveTo(280, 716);
         canvas.LineTo(520, 716);
         canvas.MoveTo(280, 680);
         canvas.LineTo(520, 680);
         canvas.MoveTo(280, 644);
         canvas.LineTo(520, 644);
         canvas.Stroke();
         canvas.RestoreState();
         // Adding text with PdfContentByte.ShowTextAligned()
         canvas.BeginText();
         canvas.SetFontAndSize(bf_helv, 12);
         canvas.ShowTextAligned(Element.ALIGN_LEFT, foobar, 400, 788, 0);
         canvas.ShowTextAligned(Element.ALIGN_RIGHT, foobar, 400, 752, 0);
         canvas.ShowTextAligned(Element.ALIGN_CENTER, foobar, 400, 716, 0);
         canvas.ShowTextAligned(Element.ALIGN_CENTER, foobar, 400, 680, 30);
         canvas.ShowTextAlignedKerned(Element.ALIGN_LEFT, foobar, 400, 644, 0);
         canvas.EndText();
         // More lines to see where the text is added
         canvas.SaveState();
         canvas.SetLineWidth(0.05f);
         canvas.MoveTo(200, 590);
         canvas.LineTo(200, 410);
         canvas.MoveTo(400, 590);
         canvas.LineTo(400, 410);
         canvas.MoveTo(80, 572);
         canvas.LineTo(520, 572);
         canvas.MoveTo(80, 536);
         canvas.LineTo(520, 536);
         canvas.MoveTo(80, 500);
         canvas.LineTo(520, 500);
         canvas.MoveTo(80, 464);
         canvas.LineTo(520, 464);
         canvas.MoveTo(80, 428);
         canvas.LineTo(520, 428);
//.........这里部分代码省略.........
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:101,代码来源:FoobarFilmFestival.cs


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