Esempio n. 1
0
            public LineHeightSpan(TextPaint?paint, double lineHeight)
            {
                _lineHeight = lineHeight;
                var fm = paint?.GetFontMetricsInt();

                _ascent  = fm?.Ascent ?? 1;
                _descent = fm?.Descent ?? 1;
            }
Esempio n. 2
0
            private float GetSpacingAdd(TextPaint paint)
            {
                if (_lineHeight == 0f)
                {
                    return(0f);
                }

                // Use integer font metrics to match StaticLayout's usage and avoid pixel rounding errors
                var fmi            = paint.GetFontMetricsInt();
                var baseLineHeight = fmi.Descent - fmi.Ascent;

                float spacingOffset = _lineHeight - baseLineHeight;

                if (_lineStackingStrategy == LineStackingStrategy.MaxHeight)
                {
                    //If LineStackingStrategy is MaxHeight, don't apply negative spacing
                    spacingOffset = Math.Max(0f, spacingOffset);
                }

                return(spacingOffset);
            }