Exemplo n.º 1
0
        private double                      _baseGuidelineY;            // the Y guideline of the text line.

        /// <summary>
        /// Construct drawing state for full text
        /// </summary>
        internal DrawingState(
            DrawingContext                  drawingContext,
            Point                           lineOrigin,
            MatrixTransform                 antiInversion,
            TextMetrics.FullTextLine        currentLine
            )
        {
            _drawingContext = drawingContext;
            _antiInversion = antiInversion;
            _currentLine = currentLine;            

            if (antiInversion == null)
            {
                _lineOrigin = lineOrigin;
            }
            else
            {
                _vectorToLineOrigin = lineOrigin;
            }

            if (_drawingContext != null)
            {
                // LineServices draws GlyphRun and TextDecorations in multiple 
                // callbacks and GlyphRuns may have different baselines. Pushing guideline
                // for each DrawGlyphRun are too costly. We optimize for the common case where
                // GlyphRuns and TextDecorations in the TextLine share the same baseline. 
                _baseGuidelineY = lineOrigin.Y + currentLine.Baseline;

                _drawingContext.PushGuidelineY1(_baseGuidelineY);
            }
        }
Exemplo n.º 2
0
 private FullTextLine(TextFormattingMode textFormattingMode, bool justify)
 {
     _textFormattingMode = textFormattingMode;
     if (justify)
     {
         _statusFlags |= StatusFlags.IsJustified;
     }
     _metrics = new TextMetrics();
     _ploline = new SecurityCriticalDataForSet<IntPtr>(IntPtr.Zero);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Empty private constructor
 /// </summary>
 private FullTextBreakpoint()
 {
     _metrics = new TextMetrics();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Empty private constructor
 /// </summary>
 private FullTextBreakpoint()
 {
     _metrics = new TextMetrics();
 }
Exemplo n.º 5
0
        /// <summary> 
        /// Create a rectangle of the two specified UV coordinates 
        /// </summary>
        /// <param name="origin">line drawing origin</param> 
        /// <param name="topLeft">logical top-left point</param>
        /// <param name="bottomRight">logical bottom-right point</param>
        /// <param name="line">container line</param>
        internal static Rect RectUV( 
            Point           origin,
            LSPOINT         topLeft, 
            LSPOINT         bottomRight, 
            TextMetrics.FullTextLine    line
            ) 
        {
            int dx = topLeft.x - bottomRight.x;
            if(dx == 1 || dx == -1)
            { 
                // in certain situation LS can be off by 1
                bottomRight.x = topLeft.x; 
            } 

            Rect rect = new Rect( 
                new Point(line.Formatter.IdealToReal(topLeft.x), line.Formatter.IdealToReal(topLeft.y)),
                new Point(line.Formatter.IdealToReal(bottomRight.x), line.Formatter.IdealToReal(bottomRight.y))
                );
 
            if(DoubleUtil.AreClose(rect.TopLeft.X, rect.BottomRight.X))
            { 
                rect.Width = 0; 
            }
 
            if(DoubleUtil.AreClose(rect.TopLeft.Y, rect.BottomRight.Y))
            {
                rect.Height = 0;
            } 

            return rect; 
        } 
Exemplo n.º 6
0
        /// <summary>
        /// Map a UV ideal coordinate to an XY ideal coordinate 
        /// </summary>
        /// <param name="origin">line drawing origin</param>
        /// <param name="vectorToOrigin">vector to line origin UV</param>
        /// <param name="u">ideal distance in text flow direction</param> 
        /// <param name="v">ideal distance in paragraph flow direction</param>
        /// <param name="line">container line</param> 
        /// <param name="nominalX">ideal X origin</param> 
        /// <param name="nominalY">ideal Y origin</param>
        internal static void UVToNominalXY( 
            Point origin,
            Point vectorToOrigin,
            int u,
            int v, 
            TextMetrics.FullTextLine line,
            out int nominalX, 
            out int nominalY 
            )
        { 
            origin.Y += vectorToOrigin.Y;

            if (line.RightToLeft)
            { 
                nominalX = line.ParagraphWidth - u + TextFormatterImp.RealToIdeal(-vectorToOrigin.X + origin.X);
            } 
            else 
            {
                nominalX = u + TextFormatterImp.RealToIdeal(vectorToOrigin.X + origin.X); 
            }

            nominalY = v + TextFormatterImp.RealToIdeal(origin.Y);
        } 
Exemplo n.º 7
0
        /// <summary> 
        /// Map a UV ideal coordinate to an XY real coordinate
        /// </summary> 
        /// <param name="origin">line drawing origin</param> 
        /// <param name="vectorToOrigin">vector to line origin UV</param>
        /// <param name="u">ideal distance in text flow direction</param> 
        /// <param name="v">ideal distance in paragraph flow direction</param>
        /// <param name="line">container line</param>
        internal static Point UVToXY(
            Point           origin, 
            Point           vectorToOrigin,
            int             u, 
            int             v, 
            TextMetrics.FullTextLine    line
            ) 
        {
            Point xy;
            origin.Y += vectorToOrigin.Y;
 
            if (line.RightToLeft)
            { 
                xy = new Point(line.Formatter.IdealToReal(line.ParagraphWidth - u) - vectorToOrigin.X + origin.X, line.Formatter.IdealToReal(v) + origin.Y); 
            }
            else 
            {
                xy = new Point(line.Formatter.IdealToReal(u) + vectorToOrigin.X + origin.X, line.Formatter.IdealToReal(v) + origin.Y);
            }
 
            return xy;
        }