Example #1
0
        public static void Main(string[] args)
        {
            FontCollection fonts     = new FontCollection();
            FontFamily     font      = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\SixLaborsSampleAB.ttf");
            FontFamily     fontWoff  = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\SixLaborsSampleAB.woff");
            FontFamily     font2     = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\OpenSans-Regular.ttf");
            FontFamily     carter    = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\Carter_One\CarterOne.ttf");
            FontFamily     Wendy_One = fonts.Install(@"..\..\tests\SixLabors.Fonts.Tests\Fonts\Wendy_One\WendyOne-Regular.ttf");

            RenderText(font, "abc", 72);
            RenderText(font, "ABd", 72);
            RenderText(fontWoff, "abe", 72);
            RenderText(fontWoff, "ABf", 72);
            RenderText(font2, "ov", 72);
            RenderText(font2, "a\ta", 72);
            RenderText(font2, "aa\ta", 72);
            RenderText(font2, "aaa\ta", 72);
            RenderText(font2, "aaaa\ta", 72);
            RenderText(font2, "aaaaa\ta", 72);
            RenderText(font2, "aaaaaa\ta", 72);
            RenderText(font2, "Hello\nWorld", 72);
            RenderText(carter, "Hello\0World", 72);
            RenderText(Wendy_One, "Hello\0World", 72);

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\t\t\tx");

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 0
            }, "Zero\tTab");

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 0
            }, "Zero\tTab");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "One\tTab");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 6
            }, "\tTab Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Tab Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Words Then Tab\t");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "                 Spaces Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Words Then Spaces                 ");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs");

            RenderText(new Font(SystemFonts.Find("Arial"), 20f, FontStyle.Regular), "á é í ó ú ç ã õ", 200, 50);
            RenderText(new Font(SystemFonts.Find("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50);

            RenderText(new RendererOptions(SystemFonts.CreateFont("consolas", 72))
            {
                TabWidth = 4
            }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx");

            BoundingBoxes.Generate("a b c y q G H T", SystemFonts.CreateFont("arial", 40f));

            TextAlignment.Generate(SystemFonts.CreateFont("arial", 50f));
            TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f));

            StringBuilder sb = new StringBuilder();

            for (char c = 'a'; c <= 'z'; c++)
            {
                sb.Append(c);
            }
            for (char c = 'A'; c <= 'Z'; c++)
            {
                sb.Append(c);
            }
            for (char c = '0'; c <= '9'; c++)
            {
                sb.Append(c);
            }
            string text = sb.ToString();

            foreach (FontFamily f in fonts.Families)
            {
                RenderText(f, text, 72);
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            var        fonts       = new FontCollection();
            var        woffFonts   = new FontCollection();
            FontFamily font        = fonts.Add(@"Fonts\SixLaborsSampleAB.ttf");
            FontFamily fontWoff    = woffFonts.Add(@"Fonts\SixLaborsSampleAB.woff");
            FontFamily fontWoff2   = woffFonts.Add(@"Fonts\OpenSans-Regular.woff2");
            FontFamily carter      = fonts.Add(@"Fonts\CarterOne.ttf");
            FontFamily wendyOne    = fonts.Add(@"Fonts\WendyOne-Regular.ttf");
            FontFamily whitneyBook = fonts.Add(@"Fonts\whitney-book.ttf");
            FontFamily colorEmoji  = fonts.Add(@"Fonts\Twemoji Mozilla.ttf");
            FontFamily font2       = fonts.Add(@"Fonts\OpenSans-Regular.ttf");
            FontFamily sunflower   = fonts.Add(@"Fonts\Sunflower-Medium.ttf");

#if OS_WINDOWS
            FontFamily emojiFont  = SystemFonts.Get("Segoe UI Emoji");
            FontFamily uiFont     = SystemFonts.Get("Segoe UI");
            FontFamily arabicFont = SystemFonts.Get("Dubai");

            FontFamily tahoma = SystemFonts.Get("Tahoma");
            RenderText(font2, "\uFB01", pointSize: 11.25F);
            RenderText(fontWoff2, "\uFB01", pointSize: 11.25F);
            RenderText(tahoma, "p", pointSize: 11.25F);
            RenderText(tahoma, "Lorem ipsum dolor sit amet", pointSize: 11.25F);
            return;

            RenderText(uiFont, "Soft\u00ADHyphen", pointSize: 72);
            FontFamily bugzilla = fonts.Add(@"Fonts\me_quran_volt_newmet.ttf");

            RenderText(uiFont, "Soft\u00ADHyphen", pointSize: 72);
            RenderText(bugzilla, "بِسْمِ ٱللَّهِ ٱلرَّحْمَٟنِ ٱلرَّحِيمِ", pointSize: 72);

            RenderText(uiFont, "first\n\n\n\nl", pointSize: 20, fallbackFonts: new[] { font2 });

            RenderText(uiFont, "first\n\n\n\nlast", pointSize: 20, fallbackFonts: new[] { font2 });
            RenderText(uiFont, "Testing", pointSize: 20);
            RenderText(emojiFont, "👩🏽‍🚒a", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(arabicFont, "English اَلْعَرَبِيَّةُ English", pointSize: 20);
            RenderText(arabicFont, "English English", pointSize: 20);
            RenderText(arabicFont, "اَلْعَرَبِيَّةُ اَلْعَرَبِيَّةُ", pointSize: 20);
            RenderText(arabicFont, "اَلْعَرَبِيَّةُ", pointSize: 20);
            RenderText(arabicFont, "SS ص", pointSize: 20);
            RenderText(arabicFont, "S ص", pointSize: 20);
            RenderText(arabicFont, "English اَلْعَرَبِيَّةُ", pointSize: 20);

            RenderTextProcessorWithAlignment(emojiFont, "😀A😀", pointSize: 20, fallbackFonts: new[] { colorEmoji });
            RenderTextProcessorWithAlignment(uiFont, "this\nis\na\ntest", pointSize: 20, fallbackFonts: new[] { font2 });
            RenderTextProcessorWithAlignment(uiFont, "first\n\n\n\nlast", pointSize: 20, fallbackFonts: new[] { font2 });

            RenderText(emojiFont, "😀", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(font2, string.Empty, pointSize: 72, fallbackFonts: new[] { emojiFont });
            RenderText(font2, "😀 Hello World! 😀", pointSize: 72, fallbackFonts: new[] { emojiFont });
#endif

            // fallback font tests
            RenderTextProcessor(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 });

            RenderText(colorEmoji, "😀", pointSize: 72, fallbackFonts: new[] { font2 });

            //// general
            RenderText(font, "abc", 72);
            RenderText(font, "ABd", 72);
            RenderText(fontWoff, "abe", 72);
            RenderText(fontWoff, "ABf", 72);
            RenderText(fontWoff2, "woff2", 72);
            RenderText(font2, "ov", 72);
            RenderText(font2, "a\ta", 72);
            RenderText(font2, "aa\ta", 72);
            RenderText(font2, "aaa\ta", 72);
            RenderText(font2, "aaaa\ta", 72);
            RenderText(font2, "aaaaa\ta", 72);
            RenderText(font2, "aaaaaa\ta", 72);
            RenderText(font2, "Hello\nWorld", 72);
            RenderText(carter, "Hello\0World", 72);
            RenderText(wendyOne, "Hello\0World", 72);
            RenderText(whitneyBook, "Hello\0World", 72);
            RenderText(sunflower, "í", 30);

            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\tx");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\tx");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\t\tx");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\t\t\tx");

            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 0
            }, "Zero\tTab");

            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 0
            }, "Zero\tTab");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "One\tTab");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 6
            }, "\tTab Then Words");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Tab Then Words");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Words Then Tab\t");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "                 Spaces Then Words");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Words Then Spaces                 ");
            RenderText(new TextOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs");

#if OS_WINDOWS
            RenderText(new Font(SystemFonts.Get("Arial"), 20f, FontStyle.Regular), "á é í ó ú ç ã õ", 200, 50);
            RenderText(new Font(SystemFonts.Get("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50);
            RenderText(new TextOptions(SystemFonts.CreateFont("consolas", 72))
            {
                TabWidth = 4
            }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx");
            BoundingBoxes.Generate("a b c y q G H T", SystemFonts.CreateFont("arial", 40f));
            TextAlignmentSample.Generate(SystemFonts.CreateFont("arial", 50f));
            TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f));

            FontFamily simsum = SystemFonts.Get("SimSun");
            RenderText(simsum, "这是一段长度超出设定的换行宽度的文本,但是没有在设定的宽度处换行。这段文本用于演示问题。希望可以修复。如果有需要可以联系我。", 16);

            FontFamily jhengHei = SystemFonts.Get("Microsoft JhengHei");
            RenderText(jhengHei, " ,;:!¥()?{}-=+\|~!@#%&", 16);

            FontFamily arial = SystemFonts.Get("Arial");
            RenderText(arial, "ìíîï", 72);
#endif
            var sb = new StringBuilder();
            for (char c = 'a'; c <= 'z'; c++)
            {
                sb.Append(c);
            }

            for (char c = 'A'; c <= 'Z'; c++)
            {
                sb.Append(c);
            }

            for (char c = '0'; c <= '9'; c++)
            {
                sb.Append(c);
            }

            string text = sb.ToString();

            foreach (FontFamily f in fonts.Families)
            {
                RenderText(f, text, 72);
            }
        }
Example #3
0
        public static void Main(string[] args)
        {
            var        fonts      = new FontCollection();
            FontFamily font       = fonts.Install(@"Fonts\SixLaborsSampleAB.ttf");
            FontFamily fontWoff   = fonts.Install(@"Fonts\SixLaborsSampleAB.woff");
            FontFamily carter     = fonts.Install(@"Fonts\CarterOne.ttf");
            FontFamily wendy_One  = fonts.Install(@"Fonts\WendyOne-Regular.ttf");
            FontFamily colorEmoji = fonts.Install(@"Fonts\Twemoji Mozilla.ttf");
            FontFamily font2      = fonts.Install(@"Fonts\OpenSans-Regular.ttf");
            FontFamily emojiFont  = SystemFonts.Find("Segoe UI Emoji");
            FontFamily uiFont     = SystemFonts.Find("Segoe UI");

            RenderTextProcessorWithAlignment(emojiFont, "😀A😀", pointSize: 20, fallbackFonts: new[] { colorEmoji });
            RenderTextProcessorWithAlignment(uiFont, "this\nis\na\ntest", pointSize: 20, fallbackFonts: new[] { font2 });
            RenderTextProcessorWithAlignment(uiFont, "first\n\n\n\nlast", pointSize: 20, fallbackFonts: new[] { font2 });

            // fallback font tests
            RenderTextProcessor(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(colorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 });

            RenderText(colorEmoji, "😀", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(emojiFont, "😀", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(font2, string.Empty, pointSize: 72, fallbackFonts: new[] { emojiFont });
            RenderText(font2, "😀 Hello World! 😀", pointSize: 72, fallbackFonts: new[] { emojiFont });

            //// general
            RenderText(font, "abc", 72);
            RenderText(font, "ABd", 72);
            RenderText(fontWoff, "abe", 72);
            RenderText(fontWoff, "ABf", 72);
            RenderText(font2, "ov", 72);
            RenderText(font2, "a\ta", 72);
            RenderText(font2, "aa\ta", 72);
            RenderText(font2, "aaa\ta", 72);
            RenderText(font2, "aaaa\ta", 72);
            RenderText(font2, "aaaaa\ta", 72);
            RenderText(font2, "aaaaaa\ta", 72);
            RenderText(font2, "Hello\nWorld", 72);
            RenderText(carter, "Hello\0World", 72);
            RenderText(wendy_One, "Hello\0World", 72);

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\t\t\tx");

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 0
            }, "Zero\tTab");

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 0
            }, "Zero\tTab");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "One\tTab");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 6
            }, "\tTab Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Tab Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Words Then Tab\t");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "                 Spaces Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Words Then Spaces                 ");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs");

            RenderText(new Font(SystemFonts.Find("Arial"), 20f, FontStyle.Regular), "á é í ó ú ç ã õ", 200, 50);
            RenderText(new Font(SystemFonts.Find("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50);

            RenderText(new RendererOptions(SystemFonts.CreateFont("consolas", 72))
            {
                TabWidth = 4
            }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx");

            BoundingBoxes.Generate("a b c y q G H T", SystemFonts.CreateFont("arial", 40f));

            TextAlignment.Generate(SystemFonts.CreateFont("arial", 50f));
            TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f));

            var sb = new StringBuilder();

            for (char c = 'a'; c <= 'z'; c++)
            {
                sb.Append(c);
            }

            for (char c = 'A'; c <= 'Z'; c++)
            {
                sb.Append(c);
            }

            for (char c = '0'; c <= '9'; c++)
            {
                sb.Append(c);
            }

            string text = sb.ToString();

            foreach (FontFamily f in fonts.Families)
            {
                RenderText(f, text, 72);
            }

            FontFamily simsum = SystemFonts.Find("SimSun");

            RenderText(simsum, "这是一段长度超出设定的�行宽度的文本,但是没有在设定的宽度处�行。这段文本用于演示问题。希望�以修�。如果有需��以�系我。", 16);

            FontFamily arial = SystemFonts.Find("Arial");

            RenderText(arial, "ìíîï", 72);
        }
Example #4
0
        public static void Main(string[] args)
        {
            var        fonts      = new FontCollection();
            FontFamily font       = fonts.Install(@"Fonts\SixLaborsSampleAB.ttf");
            FontFamily fontWoff   = fonts.Install(@"Fonts\SixLaborsSampleAB.woff");
            FontFamily carter     = fonts.Install(@"Fonts\CarterOne.ttf");
            FontFamily Wendy_One  = fonts.Install(@"Fonts\WendyOne-Regular.ttf");
            FontFamily ColorEmoji = fonts.Install(@"Fonts\Twemoji Mozilla.ttf");
            FontFamily font2      = fonts.Install(@"Fonts\OpenSans-Regular.ttf");
            var        emojiFont  = SystemFonts.Find("Segoe UI Emoji");

            // fallback font tests
            RenderTextProcessor(ColorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(ColorEmoji, "a😀d", pointSize: 72, fallbackFonts: new[] { font2 });

            RenderText(ColorEmoji, "😀", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(emojiFont, "😀", pointSize: 72, fallbackFonts: new[] { font2 });
            RenderText(font2, "", pointSize: 72, fallbackFonts: new[] { emojiFont });
            RenderText(font2, "😀 Hello World! 😀", pointSize: 72, fallbackFonts: new[] { emojiFont });

            //// general

            RenderText(font, "abc", 72);
            RenderText(font, "ABd", 72);
            RenderText(fontWoff, "abe", 72);
            RenderText(fontWoff, "ABf", 72);
            RenderText(font2, "ov", 72);
            RenderText(font2, "a\ta", 72);
            RenderText(font2, "aa\ta", 72);
            RenderText(font2, "aaa\ta", 72);
            RenderText(font2, "aaaa\ta", 72);
            RenderText(font2, "aaaaa\ta", 72);
            RenderText(font2, "aaaaaa\ta", 72);
            RenderText(font2, "Hello\nWorld", 72);
            RenderText(carter, "Hello\0World", 72);
            RenderText(Wendy_One, "Hello\0World", 72);

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\t\tx");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 4
            }, "\t\t\t\t\tx");

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 0
            }, "Zero\tTab");

            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 0
            }, "Zero\tTab");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "One\tTab");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 6
            }, "\tTab Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Tab Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Words Then Tab\t");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "                 Spaces Then Words");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "Words Then Spaces                 ");
            RenderText(new RendererOptions(new Font(font2, 72))
            {
                TabWidth = 1
            }, "\naaaabbbbccccddddeeee\n\t\t\t3 tabs\n\t\t\t\t\t5 tabs");

            RenderText(new Font(SystemFonts.Find("Arial"), 20f, FontStyle.Regular), "á é í ó ú ç ã õ", 200, 50);
            RenderText(new Font(SystemFonts.Find("Arial"), 10f, FontStyle.Regular), "PGEP0JK867", 200, 50);

            RenderText(new RendererOptions(SystemFonts.CreateFont("consolas", 72))
            {
                TabWidth = 4
            }, "xxxxxxxxxxxxxxxx\n\txxxx\txxxx\n\t\txxxxxxxx\n\t\t\txxxx");

            BoundingBoxes.Generate("a b c y q G H T", SystemFonts.CreateFont("arial", 40f));

            TextAlignment.Generate(SystemFonts.CreateFont("arial", 50f));
            TextAlignmentWrapped.Generate(SystemFonts.CreateFont("arial", 50f));

            var sb = new StringBuilder();

            for (char c = 'a'; c <= 'z'; c++)
            {
                sb.Append(c);
            }
            for (char c = 'A'; c <= 'Z'; c++)
            {
                sb.Append(c);
            }
            for (char c = '0'; c <= '9'; c++)
            {
                sb.Append(c);
            }
            string text = sb.ToString();

            foreach (FontFamily f in fonts.Families)
            {
                RenderText(f, text, 72);
            }
        }