Beispiel #1
0
        public static ImageSource ToImageSource(this IconChar iconChar,
                                                Brush foregroundBrush = null, double size = DefaultSize)
        {
            var typeFace = TypefaceFor(iconChar.ToChar(), out var gt, out var glyphIndex);

            return(typeFace == null ? null : ToImageSource(foregroundBrush, size, gt, glyphIndex));
        }
        public void Be_Creatable(IconChar iconChar)
        {
            var markupExtension = new ToText(iconChar);

            markupExtension.Should().NotBeNull();
            var serviceProvider = Substitute.For <IServiceProvider>();
            var text            = markupExtension.ProvideValue(serviceProvider) as string;

            text.Single().Should().Be(iconChar.ToChar());
        }
Beispiel #3
0
        internal static FontFamily FontFor(IconChar iconChar)
        {
            if (Orphans.Contains(iconChar))
            {
                return(null);
            }
            var typeFace = TypefaceFor(iconChar.ToChar(), out _, out _);

            return(typeFace?.FontFamily);
        }
Beispiel #4
0
        public static ImageSource ToImageSource(this IconChar iconChar,
                                                Brush foregroundBrush = null, double size = DefaultSize)
        {
            if (TypefaceFor(iconChar.ToChar(), out var gt, out var glyphIndex) == null)
            {
                return(null);
            }
            var fontSize = PixelsToPoints(size);
            var width    = gt.AdvanceWidths[glyphIndex];
            var glyphRun = new GlyphRun(gt, 0, false, fontSize,
                                        new[] { glyphIndex }, new Point(0, 0), new[] { width },
                                        null, null, null, null, null, null);
            var glyphRunDrawing = new GlyphRunDrawing(foregroundBrush ?? DefaultBrush, glyphRun);

            return(new DrawingImage(glyphRunDrawing));
        }
Beispiel #5
0
 public static FontFamily FontFor(IconChar iconChar)
 {
     return(TypefaceFor(iconChar.ToChar(), out _, out _)?.FontFamily);
 }