private void RenderHorzTextRun(SvgTextContentElement element, ref Point ctp,
                                       string text, double rotate, WpfTextPlacement placement, bool isWhitespace = false)
        {
            if (_horzRenderer == null)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(text) && !isWhitespace)
            {
                return;
            }

            if (placement != null)
            {
                placement.UpdatePositions(text);
            }

            // Force conversion to path geometry for text with surrogate pair, XmlXamlWriter cannot handle the output
            bool isGeometryMode = _context.TextAsGeometry;

            for (int i = 0; i < text.Length - 1; i++)
            {
                if (char.IsSurrogatePair(text[i], text[i + 1]))
                {
                    _context.TextAsGeometry = true;
                    break;
                }
            }
            _horzRenderer.RenderTextRun(element, ref ctp, text, rotate, placement);

            _context.TextAsGeometry = isGeometryMode;
        }
        private void RenderTextRunV(SvgTextContentElement element, ref Point ctp,
                                    string text, double rotate, WpfTextPlacement placement)
        {
            if (string.IsNullOrWhiteSpace(text) || _vertRenderer == null)
            {
                return;
            }

            if (placement != null)
            {
                placement.UpdatePositions(text);
            }
            _vertRenderer.RenderTextRun(element, ref ctp, text, rotate, placement);
        }
        private void RenderTextRunH(SvgTextContentElement element, ref Point ctp,
                                    string text, double rotate, WpfTextPlacement placement)
        {
            if (String.IsNullOrEmpty(text) || _horzRenderer == null)
            {
                return;
            }

            if (placement != null)
            {
                placement.UpdatePositions(text);
            }
            _horzRenderer.RenderTextRun(element, ref ctp, text, rotate, placement);
        }
        private void RenderSingleLineTextV(SvgTextContentElement element, ref Point ctp,
                                           string text, double rotate, WpfTextPlacement placement)
        {
            if (string.IsNullOrWhiteSpace(text) || _vertRenderer == null)
            {
                return;
            }

            string targetText = text.Trim();

            if (placement != null)
            {
                placement.UpdatePositions(targetText);
            }
            _vertRenderer.RenderSingleLineText(element, ref ctp, targetText, rotate, placement);
        }
Пример #5
0
        private void RenderTextRunH(SvgTextContentElement element, ref Point ctp,
                                    string text, double rotate, WpfTextPlacement placement, bool isWhitespace = false)
        {
            if (_horzRenderer == null)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(text) && !isWhitespace)
            {
                return;
            }

            if (placement != null)
            {
                placement.UpdatePositions(text);
            }
            _horzRenderer.RenderTextRun(element, ref ctp, text, rotate, placement);
        }
        private void RenderVertText(SvgTextContentElement element, ref Point ctp,
                                    string text, double rotate, WpfTextPlacement placement, bool isWhitespace = false)
        {
            if (_vertRenderer == null)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(text) && !isWhitespace)
            {
                return;
            }

            string targetText = text.Trim();

            if (placement != null)
            {
                placement.UpdatePositions(targetText);
            }
            _vertRenderer.RenderText(element, ref ctp, targetText, rotate, placement);
        }