コード例 #1
0
ファイル: FullTextLine.cs プロジェクト: redmcg/wpf
            private TextMetrics GetRunMetrics(FullTextState textState, TextRun textRun, CharacterBufferRange chars)
            {
                if (textRun is TextCharacters)
                {
                    var textChars    = (TextCharacters)textRun;
                    var result       = new TextMetrics();
                    var props        = textChars.Properties;
                    var typeface     = props.Typeface;
                    var ideal_emsize = TextFormatterImp.RealToIdeal(props.FontRenderingEmSize);

                    result._textAscent     = (int)Math.Round(typeface.Baseline(ideal_emsize, Constants.DefaultIdealToReal, props.PixelsPerDip, _textFormattingMode));
                    result._textHeight     = (int)Math.Round(typeface.LineSpacing(ideal_emsize, Constants.DefaultIdealToReal, props.PixelsPerDip, _textFormattingMode));
                    result._height         = result._textHeight;
                    result._baselineOffset = result._textAscent;

                    // width calculation
                    var formatted = GetFormattedTextSymbols(textChars, chars, 0);                     // isSideways
                    result._textWidth = formatted.UnscaledWidth;

                    return(result);
                }
                else if (textRun is TextHidden)
                {
                    var result = new TextMetrics();
                    // Default should be empty
                    return(result);
                }
                else
                {
                    throw new NotImplementedException(String.Format("Managed.TextFormatting.FullTextLine.GetRunMetrics for {0}", textRun.GetType().FullName));
                }
            }
コード例 #2
0
ファイル: FullTextState.cs プロジェクト: redmcg/wpf
 /// <summary>
 /// Get distance from the start of main text to the end of marker
 /// </summary>
 /// <remarks>
 /// Positive distance is filtered out. Marker overlapping the main text is not supported.
 /// </remarks>
 internal int GetMainTextToMarkerIdealDistance()
 {
     if (_markerStore != null)
     {
         return(Math.Min(0, TextFormatterImp.RealToIdeal(_markerStore.Pap.TextMarkerProperties.Offset) - _store.Settings.TextIndent));
     }
     return(0);
 }
コード例 #3
0
        /// <summary>
        /// Constructing paragraph properties
        /// </summary>
        /// <param name="formatter">Text formatter</param>
        /// <param name="paragraphProperties">paragraph properties</param>
        /// <param name="optimalBreak">produce optimal break</param>
        internal ParaProp(
            TextFormatterImp formatter,
            TextParagraphProperties paragraphProperties,
            bool optimalBreak
            )
        {
            _paragraphProperties = paragraphProperties;

            _emSize          = TextFormatterImp.RealToIdeal(paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize);
            _indent          = TextFormatterImp.RealToIdeal(paragraphProperties.Indent);
            _paragraphIndent = TextFormatterImp.RealToIdeal(paragraphProperties.ParagraphIndent);
            _height          = TextFormatterImp.RealToIdeal(paragraphProperties.LineHeight);

            if (_paragraphProperties.FlowDirection == FlowDirection.RightToLeft)
            {
                _statusFlags |= StatusFlags.Rtl;
            }

            if (optimalBreak)
            {
                _statusFlags |= StatusFlags.OptimalBreak;
            }
        }