public TypographyHandler(string text)
            {
                var textAnalyzer = new CanvasTextAnalyzer(text, CanvasTextDirection.TopToBottomThenLeftToRight);
                analyzedScript = textAnalyzer.AnalyzeScript();

                TypographyOptions = new List<TypographyFeatureInfo>();
                TypographyOptions.Add(new TypographyFeatureInfo(CanvasTypographyFeatureName.None));

                CurrentMode = Mode.BuildTypographyList;
                FeatureToHighlight = CanvasTypographyFeatureName.None;
            }
Esempio n. 2
0
            public TypographyHandler(string text)
            {
                var textAnalyzer = new CanvasTextAnalyzer(text, CanvasTextDirection.TopToBottomThenLeftToRight);

                analyzedScript = textAnalyzer.AnalyzeScript();

                TypographyOptions = new List <TypographyFeatureInfo>();
                TypographyOptions.Add(new TypographyFeatureInfo(CanvasTypographyFeatureName.None));

                CurrentMode        = Mode.BuildTypographyList;
                FeatureToHighlight = CanvasTypographyFeatureName.None;
            }
Esempio n. 3
0
        private void EnsureLayout(CanvasControl sender)
        {
            if (!needsLayout)
            {
                return;
            }

            var geometry = GetLayoutGeometry(sender);

            string text       = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lacinia odio lectus, eget luctus felis tincidunt sit amet. Maecenas vel ex porttitor, ultrices nunc feugiat, porttitor quam. Cras non interdum urna. In sagittis tempor leo quis laoreet. Sed pretium tellus ut commodo viverra. Ut volutpat in risus at aliquam. Sed faucibus vitae dolor ut commodo. Mauris mollis rhoncus libero ut porttitor. Suspendisse at egestas nunc. Proin non neque nibh. Mauris eu ornare arcu. Etiam non sem eleifend, imperdiet erat at, hendrerit ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer porttitor mauris eu pulvinar commodo. Interdum et malesuada fames ac ante ipsum primis in faucibus. Mauris ultricies fermentum sem sed consequat. Vestibulum iaculis dui nulla, nec pharetra dolor gravida in. Pellentesque vel nisi urna. Donec gravida nunc sed pellentesque feugiat. Aliquam iaculis enim non enim ultrices aliquam. In at leo sed lorem interdum bibendum at non enim.";
            var    textFormat = new CanvasTextFormat();

            textFormat.FontFamily = fontPicker.CurrentFontFamily;

            CanvasTextAnalyzer textAnalyzer = new CanvasTextAnalyzer(text, CanvasTextDirection.LeftToRightThenTopToBottom);

            //
            // Figure out what fonts to use.
            //
            var fontResult = textAnalyzer.ChooseFonts(textFormat);

            //
            // Perform a script analysis on the text.
            //
            var scriptAnalysis = textAnalyzer.AnalyzeScript();

            float maxLineSpacing = 0;
            List <FormattingSpan> formattingSpans = EvaluateFormattingSpans(textAnalyzer, fontResult, scriptAnalysis, out maxLineSpacing);

            //
            // Perform line break analysis.
            //
            var breakpoints = textAnalyzer.AnalyzeBreakpoints();

            //
            // Get the rectangles to layout text into.
            //
            layoutRectangles = SplitGeometryIntoRectangles(geometry, maxLineSpacing, sender);

            //
            // Insert glyph runs into the layout boxes.
            //
            glyphRuns = CreateGlyphRuns(layoutRectangles, formattingSpans, breakpoints);

            if (ShouldJustify)
            {
                Justify(textAnalyzer, glyphRuns, layoutRectangles);
            }

            needsLayout = false;
        }