IReadOnlyList <DevOption> Inflate()
        {
            var v = Options.Variant;
            var c = Character;

            bool hasSymbol = FontFinder.IsSegoeMDL2(v) && Enum.IsDefined(typeof(Symbol), (int)c.UnicodeIndex);
            var  hex       = c.UnicodeIndex.ToString("x4").ToUpper();

            string pathIconData = GetOutlineGeometry(c, Options);

            var ops = new List <DevOption>()
            {
                new ("TxtXamlCode/Header", c.UnicodeIndex > 0xFFFF ? $"\\U{c.UnicodeIndex:x8}".ToUpper() : $"\\u{hex}"),
                new ("TxtFontIcon/Header", $"new FontIcon {{ FontFamily = new Windows.UI.Xaml.Media.FontFamily(\"{v?.XamlFontSource}\") , Glyph = \"\\u{hex}\" }};"),
            };

            if (!string.IsNullOrWhiteSpace(pathIconData))
            {
                ops.Add(new DevOption("TxtPathIcon/Text", $"new PathIcon {{ Data = (Windows.UI.Xaml.Media.Geometry)Windows.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(Windows.UI.Xaml.Media.Geometry), \"{pathIconData}\"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }};",
                                      supportsTypography: true));
            }

            if (hasSymbol)
            {
                ops.Add(new DevOption("TxtSymbolIcon/Header", $"new SymbolIcon {{ Symbol = Symbol.{(Symbol)c.UnicodeIndex} }};"));
            }

            return(ops);
        }
        IReadOnlyList <DevOption> Inflate()
        {
            var v = Options.Variant;
            var c = Character;

            bool   hasSymbol    = FontFinder.IsSegoeMDL2(v) && Enum.IsDefined(typeof(Symbol), (int)c.UnicodeIndex);
            string hex          = c.UnicodeIndex.ToString("x4").ToUpper();
            string pathIconData = GetOutlineGeometry(c, Options);
            string fontIcon     = $"auto f = ref new FontIcon();\n" +
                                  $"f->FontFamily = ref new Media::FontFamily(L\"{v?.XamlFontSource}\");\n" +
                                  $"f->Glyph = L\"\\u{hex}\";";

            var ops = new List <DevOption>()
            {
                new ("TxtXamlCode/Header", c.UnicodeIndex > 0xFFFF ? $"\\U{c.UnicodeIndex:x8}".ToUpper() : $"\\u{hex}"),
                new ("TxtFontIcon/Header", fontIcon, true),
            };

            if (!string.IsNullOrWhiteSpace(pathIconData))
            {
                var data = $"auto p = ref new PathIcon();\n" +
                           "p->VerticalAlignment = Windows::UI::Xaml::VerticalAlignment::Center;\n" +
                           "p->HorizontalAlignment = Windows::UI::Xaml::HorizontalAlignment::Center;\n" +
                           $"p->Data = (Geometry^)Markup::XamlBindingHelper::ConvertValue(Geometry::typeid, L\"{pathIconData}\");";

                ops.Add(new DevOption("TxtPathIcon/Text", data, true, true));
            }

            if (hasSymbol)
            {
                ops.Add(new DevOption("TxtSymbolIcon/Header", $"ref new SymbolIcon(Symbol::{(Symbol)c.UnicodeIndex});"));
            }

            return(ops);
        }
Exemplo n.º 3
0
        IReadOnlyList <DevOption> Inflate()
        {
            var v = Options.Variant;
            var c = Character;

            bool hasSymbol = FontFinder.IsSegoeMDL2(v) && Enum.IsDefined(typeof(Symbol), (int)c.UnicodeIndex);
            var  hex       = c.UnicodeIndex.ToString("x4").ToUpper();

            string pathIconData = GetOutlineGeometry(c, Options);

            var ops = new List <DevOption>()
            {
                new ("TxtXamlCode/Header", $"&#x{hex};"),
                new ("TxtFontIcon/Header", $@"<FontIcon FontFamily=""{GetFontSource(v?.XamlFontSource)}"" Glyph=""&#x{hex};"" />", supportsTypography : true),
            };

            if (!string.IsNullOrWhiteSpace(pathIconData))
            {
                ops.Add(new DevOption("TxtPathIcon/Text", $"<PathIcon Data=\"{pathIconData}\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\" />", supportsTypography: true));
            }

            if (hasSymbol)
            {
                ops.Add(new DevOption("TxtSymbolIcon/Header", $@"<SymbolIcon Symbol=""{(Symbol)c.UnicodeIndex}"" />"));
            }

            return(ops);
        }
        public static (string Hex, string FontIcon, string Path, string Symbol) GetDevValues(
            Character c, FontVariant v, CanvasTextLayoutAnalysis a, CanvasTypography t, bool isXaml)
        {
            if (v == FontFinder.DefaultFont.DefaultVariant)
            {
                return(string.Empty, string.Empty, string.Empty, string.Empty);
            }

            NativeInterop interop = Utils.GetInterop();

            string h, f, p, s = null;
            bool   hasSymbol = FontFinder.IsSegoeMDL2(v) && Enum.IsDefined(typeof(Symbol), (int)c.UnicodeIndex);

            // Add back in future build
            //string pathData;
            //using (var geom = ExportManager.CreateGeometry(ResourceHelper.AppSettings.GridSize, v, c, a, t))
            //{
            //    pathData = interop.GetPathData(geom).Path;
            //}

            // Creating geometry is expensive. It may be worth delaying this.
            string pathIconData = null;

            if (v != null)
            {
                using var geom = ExportManager.CreateGeometry(20, v, c, a, t);
                pathIconData   = interop.GetPathData(geom).Path;
            }

            var hex = c.UnicodeIndex.ToString("x4").ToUpper();

            if (isXaml)
            {
                h = $"&#x{hex};";
                f = $@"<FontIcon FontFamily=""{v?.XamlFontSource}"" Glyph=""&#x{hex};"" />";
                p = $"<PathIcon Data=\"{pathIconData}\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\" />";

                if (hasSymbol)
                {
                    s = $@"<SymbolIcon Symbol=""{(Symbol)c.UnicodeIndex}"" />";
                }
            }
            else
            {
                h = c.UnicodeIndex > 0xFFFF ? $"\\U{c.UnicodeIndex:x8}".ToUpper() : $"\\u{hex}";
                f = $"new FontIcon {{ FontFamily = new Windows.UI.Xaml.Media.FontFamily(\"{v?.XamlFontSource}\") , Glyph = \"\\u{hex}\" }};";
                p = $"new PathIcon {{ Data = (Windows.UI.Xaml.Media.Geometry)Windows.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(Geometry), \"{pathIconData}\"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }};";

                if (hasSymbol)
                {
                    s = $"new SymbolIcon {{ Symbol = Symbol.{(Symbol)c.UnicodeIndex} }};";
                }
            }

            return(h, f, p, s);
        }
        IReadOnlyList <DevOption> Inflate()
        {
            var v = Options.Variant;
            var c = Character;

            bool   hasSymbol    = FontFinder.IsSegoeMDL2(v) && Enum.IsDefined(typeof(Symbol), (int)c.UnicodeIndex);
            string hex          = c.UnicodeIndex.ToString("x4").ToUpper();
            string pathIconData = GetOutlineGeometry(c, Options);

            string fontIcon =
                "// Add \"#include <winrt/Windows.UI.Xaml.Media.h>\" to pch.h\n" +
                "auto f = FontIcon();\n" +
                $"f.Glyph(L\"\\u{hex}\");\n" +
                $"f.FontFamily(Media::FontFamily(L\"{v?.XamlFontSource}\"));";

            var ops = new List <DevOption>()
            {
                new ("TxtXamlCode/Header", c.UnicodeIndex > 0xFFFF ? $"\\U{c.UnicodeIndex:x8}".ToUpper() : $"\\u{hex}"),
                new ("TxtFontIcon/Header", fontIcon, true),
            };

            if (!string.IsNullOrWhiteSpace(pathIconData))
            {
                var data =
                    $"// Add \"#include <winrt/Windows.UI.Xaml.Media.h>\" to pch.h\n" +
                    $"auto p = PathIcon();\n" +
                    $"p.VerticalAlignment(VerticalAlignment::Center);\n" +
                    $"p.HorizontalAlignment(HorizontalAlignment::Center);\n" +
                    $"p.Data(Markup::XamlBindingHelper::ConvertValue(winrt::xaml_typename<Geometry>(), box_value(L\"{pathIconData}\")).try_as<Geometry>());";

                ops.Add(new DevOption("TxtPathIcon/Text", data, true, true));
            }

            if (hasSymbol)
            {
                ops.Add(new DevOption("TxtSymbolIcon/Header", $"SymbolIcon(Symbol::{(Symbol)c.UnicodeIndex});"));
            }

            return(ops);
        }