private void EnsureTypographyList(TypographyHandler typographyHandler)
        {
            if (!needRefreshTypographyList)
            {
                return;
            }

            textLayout.DrawToTextRenderer(typographyHandler, 0, 0);

            TypographyOptions = typographyHandler.TypographyOptions;

            TypographyFeatureInfo previousOption = CurrentTypographyOption;

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("TypographyOptions"));
            }

            if (TypographyOptions.Contains(previousOption))
            {
                CurrentTypographyOption = previousOption;
            }
            else
            {
                CurrentTypographyOption = new TypographyFeatureInfo(CanvasTypographyFeatureName.None);
            }

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("CurrentTypographyOption"));
            }

            needRefreshTypographyList = false;
        }
        private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            EnsureResources(sender, sender.Size);

            currentDrawingSession = args.DrawingSession;

            bool needsTypographyHandler         = needRefreshTypographyList || HighlightTypographyAffectedGlyphs;
            TypographyHandler typographyHandler = needsTypographyHandler ? new TypographyHandler(testString) : null;

            EnsureTypographyList(typographyHandler);

            EnsureTypography();

            args.DrawingSession.DrawTextLayout(textLayout, 0, 0, Colors.LightBlue);

            if (HighlightTypographyAffectedGlyphs && CurrentTypographyOption.Name != CanvasTypographyFeatureName.None)
            {
                typographyHandler.CurrentMode        = TypographyHandler.Mode.Highlight;
                typographyHandler.FeatureToHighlight = CurrentTypographyOption.Name;
                textLayout.DrawToTextRenderer(typographyHandler, 0, 0);
            }
        }
        private void EnsureTypographyList(TypographyHandler typographyHandler)
        {
            if (!needRefreshTypographyList)
                return;

            textLayout.DrawToTextRenderer(typographyHandler, 0, 0);

            TypographyOptions = typographyHandler.TypographyOptions;

            TypographyFeatureInfo previousOption = CurrentTypographyOption;

            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("TypographyOptions"));

            if (TypographyOptions.Contains(previousOption))
                CurrentTypographyOption = previousOption;
            else
                CurrentTypographyOption = new TypographyFeatureInfo(CanvasTypographyFeatureName.None);

            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("CurrentTypographyOption"));

            needRefreshTypographyList = false;
        }