Esempio n. 1
1
 public FontInfo(String Name, double Size, FontFamily Family)
 {
     this.Name = Name;
     this.Size = Size;
     
     this.Family = Family;
     this.Typeface = Family.GetTypefaces().First();
     
 }
Esempio n. 2
0
        public FontFamilyWrapper(FontFamily fontFamily)
        {
            this.fontFamily = fontFamily;

            FamilyNames = fontFamily.FamilyNames.ToArray();
            Typefaces = fontFamily.GetTypefaces().ToArray();
        }
Esempio n. 3
0
        public static string[] Find(int charCode)
        {
            var r = new List<string>();

            GlyphTypeface glyph;

            foreach (string familyName in Fonts)
            {
                var font = new FontFamily(familyName);
                foreach (Typeface tf in font.GetTypefaces())
                {
                    if (tf.TryGetGlyphTypeface(out glyph))
                    {
                        if (glyph.CharacterToGlyphMap.ContainsKey(charCode))
                        {
                            //Debug.Print("Found in {0} font.", familyName);
                            r.Add(familyName);
                            break;
                        }
                    }
                }
            }

            return r.ToArray();
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the FontFamily class from the specified font family name and an optional base uniform resource identifier (URI) value.
        /// Sample: Add(new Uri("pack://application:,,,/"), "./myFonts/#FontFamilyName");)
        /// </summary>
        /// <param name="baseUri">Specifies the base URI that is used to resolve familyName.</param>
        /// <param name="familyName">The family name or names that comprise the new FontFamily. Multiple family names should be separated by commas.</param>
        public void Add(Uri baseUri, string familyName)
        {
            // TODO: What means 'Multiple family names should be separated by commas.'?
            // does not work

            if (String.IsNullOrEmpty(familyName))
            {
                throw new ArgumentNullException("familyName");
            }
            if (familyName.Contains(","))
            {
                throw new NotImplementedException("Only one family name is supported.");
            }

            // family name starts right of '#'
            int idxHash = familyName.IndexOf('#');

            if (idxHash < 0)
            {
                throw new ArgumentException("Family name must contain a '#'. Example './#MyFontFamilyName'", "familyName");
            }

            string key = familyName.Substring(idxHash + 1);

            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentException("familyName has invalid format.");
            }

            if (this.fontFamilies.ContainsKey(key))
            {
                throw new ArgumentException("An entry with the specified family name already exists.");
            }

#if !SILVERLIGHT
            System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily(baseUri, familyName);
#else
            System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily(familyName);
#endif

            // Check whether font data really exists
#if DEBUG && !SILVERLIGHT
            ICollection <Typeface> list = fontFamily.GetTypefaces();
            foreach (Typeface typeFace in list)
            {
                //Debug.WriteLine(String.Format("{0}, {1}, {2}, {3}", typeFace.FaceNames.Values.First(), typeFace.Style, typeFace.Weight, typeFace.Stretch));
                GlyphTypeface glyphTypeface;
                if (!typeFace.TryGetGlyphTypeface(out glyphTypeface))
                {
                    throw new ArgumentException("Font with the specified family name does not exist.");
                }
            }
#endif

            this.fontFamilies.Add(key, fontFamily);
        }
Esempio n. 5
0
        private List <Polygon> RenderString(TextToolOptions options, Vector offset)
        {
            var fontfamily = new FontFamily(options.Font.FontFamily.Name);

            var typeface = FindTypeface(options, fontfamily, EmptySynonymMap) ??
                           FindTypeface(options, fontfamily, SynonymMap) ?? fontfamily.GetTypefaces().First();

            var decorations = new TextDecorationCollection();

            if (options.Font.Strikeout)
            {
                decorations.Add(TextDecorations.Strikethrough);
            }

            if (options.Font.Underline)
            {
                decorations.Add(TextDecorations.Underline);
            }

            const double sizeFactor    = 0.1;
            var          formattedText = new FormattedText(options.Text, CultureInfo.InvariantCulture,
                                                           FlowDirection.LeftToRight, typeface, options.Font.SizeInPoints * sizeFactor, Brushes.Black, 1)
            {
                LineHeight = options.LineHeight * options.Font.SizeInPoints * sizeFactor
            };

            formattedText.SetTextDecorations(decorations);

            var smoothness = options.Smoothness;
            var geom       = formattedText.BuildGeometry(new Point(0, 0));

            List <Polygon> polys;

            try
            {
                (polys, smoothness) = BuildPolygons(geom, offset, smoothness);
            }
            catch (PolygonException)
            {
                var opt = TextToolOptions.Default;
                opt.Text = "Unable to render\nthis font without\ntopology errors.";
                return(RenderString(opt, offset));
            }

            try
            {
                FinalizePolygons(polys);
                return(polys);
            }
            catch (TopologyException)
            {
                var opt = options;
                opt.Smoothness = smoothness;
                return(RenderString(opt, offset));
            }
        }
        /// <summary>
        /// Create a WPF GlyphTypeface and retrieve font data from it.
        /// </summary>
        internal static XFontSource CreateFontSource(string familyName, FontResolvingOptions fontResolvingOptions,
                                                     out WpfFontFamily wpfFontFamily, out WpfTypeface wpfTypeface, out WpfGlyphTypeface wpfGlyphTypeface, string typefaceKey)
        {
            if (string.IsNullOrEmpty(typefaceKey))
            {
                typefaceKey = XGlyphTypeface.ComputeKey(familyName, fontResolvingOptions);
            }
            XFontStyle style = fontResolvingOptions.FontStyle;

#if DEBUG
            if (StringComparer.OrdinalIgnoreCase.Compare(familyName, "Segoe UI Semilight") == 0 &&
                (style & XFontStyle.BoldItalic) == XFontStyle.Italic)
            {
                familyName.GetType();
            }
#endif

            // Use WPF technique to create font data.
            wpfTypeface = XPrivateFontCollection.TryCreateTypeface(familyName, style, out wpfFontFamily);
#if DEBUG__
            if (wpfTypeface != null)
            {
                WpfGlyphTypeface          glyphTypeface;
                ICollection <WpfTypeface> list = wpfFontFamily.GetTypefaces();
                foreach (WpfTypeface tf in list)
                {
                    if (!tf.TryGetGlyphTypeface(out glyphTypeface))
                    {
                        Debug - Break.Break();
                    }
                }

                //if (!WpfTypeface.TryGetGlyphTypeface(out glyphTypeface))
                //    throw new InvalidOperationException(PSSR.CannotGetGlyphTypeface(familyName));
            }
#endif
            if (wpfFontFamily == null)
            {
                wpfFontFamily = new WpfFontFamily(familyName);
            }

            if (wpfTypeface == null)
            {
                wpfTypeface = FontHelper.CreateTypeface(wpfFontFamily, style);
            }

            // Let WPF choose the right glyph typeface.
            if (!wpfTypeface.TryGetGlyphTypeface(out wpfGlyphTypeface))
            {
                throw new InvalidOperationException(PSSR.CannotGetGlyphTypeface(familyName));
            }

            // Get or create the font source and cache it unter the specified typeface key.
            XFontSource fontSource = XFontSource.GetOrCreateFromWpf(typefaceKey, wpfGlyphTypeface);
            return(fontSource);
        }
Esempio n. 7
0
 internal static bool IsSymbolFont(FontFamily fontFamily)
 {
     foreach (Typeface typeface in fontFamily.GetTypefaces()) {
         GlyphTypeface face;
         if (typeface.TryGetGlyphTypeface(out face)) {
             return face.Symbol;
         }
     }
     return false;
 }
Esempio n. 8
0
		static bool IsSymbolFont(FontFamily fontFamily)
		{
			foreach (var tf in fontFamily.GetTypefaces()) {
				GlyphTypeface glyph;
				try {
					if (tf.TryGetGlyphTypeface(out glyph))
						return glyph.Symbol;
				} catch (Exception) {
					return true;
				}
			}
			return false;
		}
Esempio n. 9
0
        private static Typeface FindTypeface(TextToolOptions options, FontFamily fontfamily,
                                             Dictionary <string, string> synonymMap)
        {
            Typeface typeface = null;

            foreach (var familyTypeface in fontfamily.GetTypefaces())
            {
                var faceName = familyTypeface.FaceNames[XmlLanguage.GetLanguage("en-US")];

                var styleName =
                    options.Font.Style.ToString()
                    .Replace(",", "")
                    .Replace("Underline", "")
                    .Replace("Strikeout", "")
                    .Trim();
                var fixedStyleName = familyTypeface.Weight + " " + familyTypeface.Style;

                if (familyTypeface.Style.ToString() == styleName)
                {
                    typeface = familyTypeface;
                    break;
                }

                if (fixedStyleName == options.FontStyleName)
                {
                    typeface = familyTypeface;
                    break;
                }

                if (fixedStyleName == options.FontStyleName.Replace(faceName, "").Trim())
                {
                    typeface = familyTypeface;
                    break;
                }

                if (synonymMap.Any(v => faceName == styleName.Replace(v.Key, v.Value)))
                {
                    typeface = familyTypeface;
                    break;
                }
            }

            return(typeface);
        }
Esempio n. 10
0
		// Checks chars 0x20-0x7E (the only ones used by the hex editor) whether they have the same
		// width and height. There's probably a better way of doing this...
		static bool IsMonospacedFont(FontFamily ff) {
			if (ff.Source.Equals(GLOBAL_MONOSPACE_FONT, StringComparison.OrdinalIgnoreCase))
				return true;

			foreach (var tf in ff.GetTypefaces()) {
				if (tf.Weight != FontWeights.Normal)
					continue;
				if (tf.Style != FontStyles.Normal)
					continue;

				GlyphTypeface gtf;
				if (!tf.TryGetGlyphTypeface(out gtf))
					return false;
				if (gtf.Symbol)
					return false;
				if (!CheckSameSize(gtf))
					return false;

				return true;
			}

			return false;
		}
    /// <summary>
    /// Initializes a new instance of the FontFamily class from the specified font family name and an optional base uniform resource identifier (URI) value.
    /// Sample: Add(new Uri("pack://application:,,,/"), "./myFonts/#FontFamilyName");)
    /// </summary>
    /// <param name="baseUri">Specifies the base URI that is used to resolve familyName.</param>
    /// <param name="familyName">The family name or names that comprise the new FontFamily. Multiple family names should be separated by commas.</param>
    public void Add(Uri baseUri, string familyName)
    {
      // TODO: What means 'Multiple family names should be separated by commas.'?
      // does not work

      if (String.IsNullOrEmpty(familyName))
        throw new ArgumentNullException("familyName");
      if (familyName.Contains(","))
        throw new NotImplementedException("Only one family name is supported.");

      // family name starts right of '#'
      int idxHash = familyName.IndexOf('#');
      if (idxHash < 0)
        throw new ArgumentException("Family name must contain a '#'. Example './#MyFontFamilyName'", "familyName");

      string key = familyName.Substring(idxHash + 1);
      if (String.IsNullOrEmpty(key))
        throw new ArgumentException("familyName has invalid format.");

      if (this.fontFamilies.ContainsKey(key))
        throw new ArgumentException("An entry with the specified family name already exists.");

#if !SILVERLIGHT
      System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily(baseUri, familyName);
#else
      System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily(familyName);
#endif

      // Check whether font data really exists
#if DEBUG && !SILVERLIGHT
      ICollection<Typeface> list = fontFamily.GetTypefaces();
      foreach (Typeface typeFace in list)
      {
        //Debug.WriteLine(String.Format("{0}, {1}, {2}, {3}", typeFace.FaceNames.Values.First(), typeFace.Style, typeFace.Weight, typeFace.Stretch));
        GlyphTypeface glyphTypeface;
        if (!typeFace.TryGetGlyphTypeface(out glyphTypeface))
          throw new ArgumentException("Font with the specified family name does not exist.");
      }
#endif

      this.fontFamilies.Add(key, fontFamily);
    }
Esempio n. 12
0
        private void UpdateNewFont()
        {
            string cr = "";

            foreach (Typeface typeface in TheFontFamily.GetTypefaces())
            {
                // which face are we using ?
                typeface.TryGetGlyphTypeface(out GlyphTypeface glyph);
                if (glyph != null)
                {
                    characterMap = glyph.CharacterToGlyphMap;
                    cr           = glyph.Copyrights.Values.FirstOrDefault();
                }
            }

            MyCharMap = new Dictionary <int, int>();

            GridOChars.Children.Clear();
            GridOChars.RowDefinitions.Clear();
            GridOChars.ColumnDefinitions.Clear();

            //Populate GridoChars
            for (int y = 0; y < 30; y++)
            {
                GridOChars.RowDefinitions.Add(new RowDefinition());
            }
            for (int x = 0; x < 60; x++)
            {
                GridOChars.ColumnDefinitions.Add(new ColumnDefinition());
            }

            // start at space (Char 32 x20)
            int c = 32;

            for (int y = 0; y < 30; y++)
            {
                for (int x = 0; x < 60; x++)
                {
                    bool skipping = true;
                    while (skipping && c < 0xFFFF)
                    {
                        if (characterMap.ContainsKey(c))
                        {
                            skipping = false;
                            var i = new System.Windows.Controls.Image()
                            {
                                Stretch = Stretch.None
                            };
                            i.MouseEnter += UpdateFontView;
                            i.Margin      = new Thickness(0);
                            i.Source      = WriteChar2BM(((char)c).ToString());
                            i.ToolTip     = c;

                            string charname = UnicodeInfo.GetName(c);
                            if (!string.IsNullOrEmpty(charname))
                            {
                                i.Name = charname.Replace(" ", "_").Replace("-", "_").ToLowerInvariant();
                            }

                            GridOChars.Children.Add(i);
                            Grid.SetRow(i, y);
                            Grid.SetColumn(i, x);

                            MyCharMap[c] = x + y * 60;
                        }
                        c++;
                    }
                }
            }

            Label1.Content    = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*0123456789";
            Label1.FontFamily = TheFontFamily;
            Label1.FontSize   = 16;

            Label2.Content    = TheFont.FontFamily.Name; // TheFontFamily.Source;
            Label2.FontFamily = TheFontFamily;
            Label2.FontSize   = 16;

            Label3.Content  = cr;
            Label3.FontSize = 16;

            CodeOutput.Text = RegenerateCode();
        }
Esempio n. 13
0
 private Typeface SelectBestMatchingTypeface(FontFamily family)
 {
     if (Typeface == null)
     {
         ICollection<Typeface> typefaces = family.GetTypefaces();
         return typefaces.Count == 0 ? null : typefaces.First();
     }
     return SelectBestMatchingTypeface(family, Typeface.Style, Typeface.Weight, Typeface.Stretch);
 }
Esempio n. 14
0
 private static Typeface SelectBestMatchingTypeface(FontFamily family, FontStyle style, FontWeight weight, FontStretch stretch)
 {
     ICollection<Typeface> typefaces = family.GetTypefaces();
     if (typefaces.Count == 0)
         return null;
     IEnumerable<Typeface> matchingTypefaces
         = from tf in typefaces
           where tf.Style == style && tf.Weight == weight && tf.Stretch == stretch
           select tf;
     if (matchingTypefaces.Count() == 0)
         matchingTypefaces = from tf in typefaces
                             where tf.Style == style && tf.Weight == weight
                             select tf;
     if (matchingTypefaces.Count() == 0)
         matchingTypefaces = from tf in typefaces
                             where tf.Style == style
                             select tf;
     if (matchingTypefaces.Count() == 0)
         return typefaces.First();
     return matchingTypefaces.First();
 }
Esempio n. 15
0
			bool DetectMonospaced(FontFamily fontFamily)
			{
				var tf = fontFamily.GetTypefaces().FirstOrDefault(t => t.Style == FontStyles.Normal);
				if (tf == null)
					return false;
				// determine if the length of i == m because I see no other way of
				// getting if a font is monospaced or not.
				FormattedText formatted = new FormattedText("i.", CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
				                                            tf, 12f, Brushes.Black);
				FormattedText formatted2 = new FormattedText("mw", CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
				                                             tf, 12f, Brushes.Black);
				return formatted.Width == formatted2.Width;
			}
        /// <summary>
        /// Gets the typefaces available for the selected font. 
        /// </summary>
        /// <remarks>BoldSimulated and ObliqueSimulated font styles are filtered out of this collection. ArcGIS Pro does not render these styles.</remarks>
        private void InitializeTypefaceList()
        {
            FontFamily family = new FontFamily();
            if (SelectedFontFamily != null)
                family = SelectedFontFamily.Font;
            if (family != null)
            {
                ICollection<Typeface> faceCollection = family.GetTypefaces(); //family is a FontFamily object

                List<TypefaceListItem> items = new List<TypefaceListItem>();


                foreach (Typeface face in faceCollection)
                {
                    if ((face.IsBoldSimulated) || (face.IsObliqueSimulated)) 
                        continue;
                    items.Add(new TypefaceListItem(face));
                }

                items.Sort();

                TypeFaceCollection = new Collection<TypefaceListItem>(items);
                SelectedTypeFace = TypeFaceCollection.FirstOrDefault();

            }
        }
Esempio n. 17
0
		/// <summary>
		/// Checks whether <paramref name="ff"/> is a symbol font
		/// </summary>
		/// <param name="ff">Font</param>
		/// <returns></returns>
		public static bool IsSymbol(FontFamily ff) {
			foreach (var tf in ff.GetTypefaces()) {
				GlyphTypeface gtf;
				if (!tf.TryGetGlyphTypeface(out gtf))
					return true;
				if (gtf.Symbol)
					return true;
			}
			return false;
		}
Esempio n. 18
0
        //---------------------------------------------------------------------------------------------
        // lstFamilyName の選択の変更に伴って、lstTypeface を更新する
        private void UpdateTypeFace()
        {
            var list = new List<TextBlock>();
            var family = new FontFamily(txtFamilyName.Text);

            foreach (Typeface face in family.GetTypefaces())
            {
                TextBlock item = new TextBlock();

                // シミュレートするフォントのとき
                if (face.IsObliqueSimulated)
                    item.Text = face.Style.ToString() + " (Simulate)";
                else
                    item.Text = face.Style.ToString();

                item.Tag = face.Style;

                list.Add(item);
            }

            //-------------------------------------------------------
            // 重複する項目を削除する
            for (int i = 0; i < list.Count; ++i)
            {
                TextBlock item = list[i] as TextBlock;
                string s = item.Text as string;

                for (int j = i + 1; j < list.Count; ++j)
                {
                    TextBlock item1 = list[j] as TextBlock;
                    string s1 = item1.Text as string;

                    if (s == s1)
                    {
                        list.RemoveAt(j);
                    }
                }
            }

            lstTypeface.ItemsSource = list;

            //-------------------------------------------------------
            if (lstTypeface.Items.Count > 0)
            {
                lstTypeface.SelectedIndex = 0;
                txtTypeface.Text = ((TextBlock)lstTypeface.SelectedItem).Text;
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Create a WPF GlyphTypeface and retrieve font data from it.
        /// </summary>
        internal static XFontSource CreateFontSource(string familyName, FontResolvingOptions fontResolvingOptions,
            out WpfFontFamily wpfFontFamily, out WpfTypeface wpfTypeface, out WpfGlyphTypeface wpfGlyphTypeface, string typefaceKey)
        {
            if (string.IsNullOrEmpty(typefaceKey))
                typefaceKey = XGlyphTypeface.ComputeKey(familyName, fontResolvingOptions);
            XFontStyle style = fontResolvingOptions.FontStyle;

#if DEBUG
            if (StringComparer.OrdinalIgnoreCase.Compare(familyName, "Segoe UI Semilight") == 0
                && (style & XFontStyle.BoldItalic) == XFontStyle.Italic)
                familyName.GetType();
#endif

            // Use WPF technique to create font data.
            wpfTypeface = XPrivateFontCollection.TryCreateTypeface(familyName, style, out wpfFontFamily);
#if DEBUG__
            if (wpfTypeface != null)
            {
                WpfGlyphTypeface glyphTypeface;
                ICollection<WpfTypeface> list = wpfFontFamily.GetTypefaces();
                foreach (WpfTypeface tf in list)
                {
                    if (!tf.TryGetGlyphTypeface(out glyphTypeface))
                        Debug-Break.Break();
                }

                //if (!WpfTypeface.TryGetGlyphTypeface(out glyphTypeface))
                //    throw new InvalidOperationException(PSSR.CannotGetGlyphTypeface(familyName));
            }
#endif
            if (wpfFontFamily == null)
                wpfFontFamily = new WpfFontFamily(familyName);

            if (wpfTypeface == null)
                wpfTypeface = FontHelper.CreateTypeface(wpfFontFamily, style);

            // Let WPF choose the right glyph typeface.
            if (!wpfTypeface.TryGetGlyphTypeface(out wpfGlyphTypeface))
                throw new InvalidOperationException(PSSR.CannotGetGlyphTypeface(familyName));

            // Get or create the font source and cache it unter the specified typeface key.
            XFontSource fontSource = XFontSource.GetOrCreateFromWpf(typefaceKey, wpfGlyphTypeface);
            return fontSource;
        }
Esempio n. 20
0
        public IPdfReportData CreatePdfReport()
        {
            var fontFamilyName = "Wingdings";
            var fontProvider = new GenericFontProvider(
                                System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\WINGDING.TTF"),
                                System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\verdana.ttf"))
                                {
                                    Size = 17,
                                    Color = new BaseColor(System.Drawing.Color.DarkRed.ToArgb())
                                };

            return new PdfReport().DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.LeftToRight);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A4);
                doc.DocumentMetadata(new DocumentMetadata { Author = "Vahid", Application = "PdfRpt", Keywords = "Test", Subject = "Test Rpt", Title = "Test" });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression = true,
                    EnableFullCompression = true
                });
            })
            .DefaultFonts(fonts =>
            {
                fonts.Path(System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\arial.ttf"),
                                  System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\verdana.ttf"));
                fonts.Size(9);
                fonts.Color(System.Drawing.Color.Black);
            })
            .PagesFooter(footer =>
            {
                footer.DefaultFooter(DateTime.Now.ToString("MM/dd/yyyy"));
            })
            .PagesHeader(header =>
            {
                header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                header.DefaultHeader(defaultHeader =>
                {
                    defaultHeader.RunDirection(PdfRunDirection.LeftToRight);
                    defaultHeader.Message("Characters Map");
                });
            })
            .MainTableTemplate(template =>
            {
                template.BasicTemplate(BasicTemplate.SilverTemplate);
            })
            .MainTablePreferences(table =>
            {
                table.ColumnsWidthsType(TableColumnWidthType.Relative);
                table.MainTableType(TableType.HorizontalStackPanel);
                table.HorizontalStackPanelPreferences(columnsPerRow: 10);
            })
            .MainTableDataSource(dataSource =>
            {
                // FontFamily is defined in System.Windows.Media of PresentationCore.dll assembly.
                var fontFamily = new FontFamily(fontFamilyName);

                var listOfRows = new List<CharacterInfo>();
                GlyphTypeface glyph = null;
                foreach (var typeface in fontFamily.GetTypefaces())
                {
                    if (typeface.TryGetGlyphTypeface(out glyph) && (glyph != null))
                        break;
                }

                if (glyph == null)
                    throw new InvalidOperationException("Couldn't find a GlyphTypeface.");

                foreach (var item in glyph.CharacterToGlyphMap)
                {
                    var index = item.Key;
                    listOfRows.Add(new CharacterInfo
                    {
                        Character = Convert.ToChar(index),
                        CharacterCode = string.Format("0x{0:X}", index)
                    });
                }

                dataSource.StronglyTypedList(listOfRows);
            })
            .MainTableColumns(columns =>
            {
                columns.AddColumn(column =>
                {
                    column.PropertyName("rowNo");
                    column.IsRowNumber(true);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(0);
                    column.Width(1);
                    column.HeaderCell("#");
                });

                columns.AddColumn(column =>
                {
                    column.PropertyName<CharacterInfo>(x => x.Character);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(1);
                    column.Width(1);
                    column.HeaderCell(fontFamilyName + " Characters", mergeHeaderCell: true);
                    column.ColumnItemsTemplate(itemsTemplate =>
                        {
                            itemsTemplate.CustomTemplate(new CellTemplate(fontProvider));
                        });
                });
            })
            .MainTableEvents(events =>
            {
                events.DataSourceIsEmpty(message: "There is no data available to display.");
            })
            .Generate(data => data.AsPdfFile(string.Format("{0}\\Pdf\\CharacterMapSample-{1}.pdf", AppPath.ApplicationPath, Guid.NewGuid().ToString("N"))));
        }
Esempio n. 21
0
 private void AddFont(ICollection<FontFamily> fontCollection, FontFamily fontFamily)
 {
     bool flag = false;
     try
     {
         foreach (Typeface typeface in (IEnumerable<Typeface>)fontFamily.GetTypefaces())
         {
             GlyphTypeface glyphTypeface;
             if (typeface.TryGetGlyphTypeface(out glyphTypeface) && glyphTypeface.Symbol)
                 flag = true;
         }
     }
     catch
     {
         flag = true;
     }
     if (flag)
         return;
     this.fontFamilies.Add(fontFamily);
 }