Esempio n. 1
0
 // Actually produce the layout data.
 // The algorithm is basically ripped from CSS Flexbox.
 //
 // 1. Add up all the space each word takes
 // 2. Subtract that from the line width (w)
 // 3. Save that as the free space (fs)
 // 4. Add up each gap's priority value (Σpri)
 // 5. Assign each gap a final priority (fp) of ((priMax - pri) / Σpri)
 // 6. That space has (fp*fs) pixels.
 public static ImmutableArray <Offset> Layout(
     ISectionable src,
     ImmutableArray <Offset> text,
     int w,
     IFontLibrary fonts,
     float scale           = 1.0f,
     int lineSpacing       = 0,
     int wordSpacing       = 0,
     FontClass?fclass      = default,
     LayoutOptions options = LayoutOptions.Default
     )
 {
     var lw = new WorkQueue <(
                                 List <Offset> wds,
                                 List <int> gaps,
                                 int lnrem,
                                 int sptot,
                                 int maxPri,
                                 int tPri,
                                 int lnh
                                 )>(postcreate: i => i with
     {
         wds  = new List <Offset>(),
         gaps = new List <int>()
     });
Esempio n. 2
0
 public static ImmutableArray <Offset> Layout(
     ISectionable text,
     int w,
     IFontLibrary fonts,
     float scale           = 1.0f,
     int lineSpacing       = 0,
     int wordSpacing       = 0,
     int runeSpacing       = 0,
     FontClass?fclass      = default,
     LayoutOptions options = LayoutOptions.Default
     ) => Layout(
     text,
     Split(text, fonts, scale, wordSpacing, runeSpacing, fclass, options),
     w,
     fonts,
     scale,
     lineSpacing, wordSpacing,
     fclass,
     options
     );