@@ -14,6 +14,7 @@ static class Program
1414 {
1515 static void Main ( string [ ] args )
1616 {
17+
1718 System . IO . Directory . CreateDirectory ( "output" ) ;
1819
1920 using Image img = new Image < Rgba32 > ( 1500 , 500 ) ;
@@ -24,19 +25,20 @@ static void Main(string[] args)
2425 // Add more complex paths and shapes here.
2526 IPath path = pathBuilder . Build ( ) ;
2627
27- // For production application we would recommend you create a FontCollection
28- // singleton and manually install the ttf fonts yourself as using SystemFonts
29- // can be expensive and you risk font existing or not existing on a deployment
30- // by deployment basis.
31- Font font = SystemFonts . CreateFont ( "Segoe UI" , 39 , FontStyle . Regular ) ;
32- const string text = "Hello World Hello World Hello World Hello World Hello World" ;
28+ var fonts = new FontCollection ( ) ;
29+ var mainFont = fonts . Add ( "Roboto-Regular.ttf" ) ;
30+ var emojiiFont = fonts . Add ( "Twemoji Mozilla.ttf" ) ;
31+
32+ const string text = "Hello World 🎉🎉 Hello World Hello World Hello World Hello World" ;
3333
3434 // Draw the text along the path wrapping at the end of the line
35- TextOptions textOptions = new ( font )
35+ RichTextOptions textOptions = new ( mainFont . CreateFont ( 39 , FontStyle . Regular ) )
3636 {
3737 WrappingLength = path . ComputeLength ( ) ,
3838 VerticalAlignment = VerticalAlignment . Bottom ,
3939 HorizontalAlignment = HorizontalAlignment . Left ,
40+ FallbackFontFamilies = [ emojiiFont ] ,
41+ Path = path
4042 } ;
4143
4244 // Let's generate the text as a set of vectors drawn along the path
@@ -45,7 +47,7 @@ static void Main(string[] args)
4547 img . Mutate ( ctx => ctx
4648 . Fill ( Color . White ) // white background image
4749 . Draw ( Color . Gray , 3 , path ) // draw the path so we can see what the text is supposed to be following
48- . Fill ( Color . Black , glyphs ) ) ;
50+ . DrawText ( textOptions , text , new SolidBrush ( Color . Gray ) ) ) ;
4951
5052 img . Save ( "output/wordart.png" ) ;
5153 }
0 commit comments