/// <summary>
        /// Создать карту.
        /// </summary>
        /// <param name="program">Программа.</param>
        /// <param name="width">Ширина.</param>
        /// <param name="fontSize">Размер шрифта.</param>
        /// <param name="maxLines">Максимальное число линий.</param>
        /// <returns>Карта.</returns>
        public ITextRender2MeasureMap CreateMap(ITextRender2RenderProgram program, double width, double fontSize, int? maxLines)
        {
            if (program == null) throw new ArgumentNullException(nameof(program));
            var interProgram = CreateIntermediateProgram(program).ToArray();
            var allText = interProgram.Aggregate(new StringBuilder(), (sb, s) => sb.Append(s.RenderString)).ToString();
            using (var tf = new CanvasTextFormat())
            {
                tf.FontFamily = "Segoe UI";
                tf.FontSize = (float)fontSize;
                tf.WordWrapping = CanvasWordWrapping.Wrap;
                tf.Direction = CanvasTextDirection.LeftToRightThenTopToBottom;
                tf.Options = CanvasDrawTextOptions.Default;

                var screen = DisplayInformation.GetForCurrentView();
                using (var ds = new CanvasRenderTarget(CanvasDevice.GetSharedDevice(), (float) width, 10f, screen.LogicalDpi))
                {
                    using (var tl = new CanvasTextLayout(ds, allText, tf, (float)width, 10f))
                    {
                        var helperArgs = interProgram.OfType<MappingHelperArg>().ToList();
                        mappingHelper.ApplyAttributes(tl, helperArgs, fontSize);
                        var map = AnalyzeMap(tl, allText).ToArray();
                        var result = new MeasureMap(map, width, maxLines, StrikethrougKoef);
                        return result;
                    }
                }
            }
        }
 private ITextRender2MeasureMap DoMeasure(double width, ITextRender2RenderProgram program)
 {
     var mapper = new Direct2DTextRender2MeasureMapper();
     return mapper.CreateMap(program, width, ControlCallback.PostFontSize, MaxLines > 0 ? (int?)MaxLines : null);
 }
 private IEnumerable<IntermediateElement> CreateIntermediateProgram(ITextRender2RenderProgram program)
 {
     var idx = 0;
     foreach (var p in program.GetCommands())
     {
         if (p.Content.Id == CommonTextRenderContent.LineBreak)
         {
             yield return new IntermediateElement() {RenderString = "\n", Command = p, Index = idx};
             idx++;
         }
         if (p.Content.Id == CommonTextRenderContent.Text)
         {
             var t = p.Content as ITextRenderTextContent;
             var s = t?.Text ?? "";
             if (s.Length > 0)
             {
                 yield return new IntermediateElement() { RenderString = t?.Text ?? "", Command = p, Index = idx };
                 idx += s.Length;
             }
         }
     }
 }