Example #1
0
        private static TextPaint InnerBuildPaint(FontWeight fontWeight, FontStyle fontStyle, FontFamily fontFamily, double fontSize, double characterSpacing, Windows.UI.Color foreground, BaseLineAlignment baselineAlignment, UnderlineStyle underlineStyle)
        {
            var paint = new TextPaint(PaintFlags.AntiAlias);

            var paintSpecs = BuildPaintValueSpecs(fontSize, characterSpacing);

            paint.Density       = paintSpecs.density;
            paint.TextSize      = paintSpecs.textSize;
            paint.UnderlineText = underlineStyle == UnderlineStyle.Single;

            if (baselineAlignment == BaseLineAlignment.Superscript)
            {
                paint.BaselineShift += (int)(paint.Ascent() / 2);
            }

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                paint.LetterSpacing = paintSpecs.letterSpacing;
            }
            else
            {
                LogCharacterSpacingNotSupported();
            }

            var typefaceStyle = TypefaceStyleHelper.GetTypefaceStyle(fontStyle, fontWeight);
            var typeface      = FontHelper.FontFamilyToTypeFace(fontFamily, fontWeight, typefaceStyle);

            paint.SetTypeface(typeface);
            paint.Color = foreground;

            return(paint);
        }
Example #2
0
        partial void UpdateFontPartial()
        {
            if (Parent != null && _textBoxView != null)
            {
                var style    = GetTypefaceStyle(FontStyle, FontWeight);
                var typeface = FontHelper.FontFamilyToTypeFace(FontFamily, FontWeight);

                _textBoxView.SetTypeface(typeface, style);
                _textBoxView.SetTextSize(ComplexUnitType.Px, (float)Math.Round(ViewHelper.LogicalToPhysicalFontPixels((float)FontSize)));
            }
        }
Example #3
0
        partial void UpdateFontPartial(object sender)
        {
            var textBox = sender as TextBox;

            if (textBox != null && textBox.Parent != null && _textBoxView != null)
            {
                var style    = GetTypefaceStyle(textBox.FontStyle, textBox.FontWeight);
                var typeface = FontHelper.FontFamilyToTypeFace(textBox.FontFamily, textBox.FontWeight);

                _textBoxView.SetTypeface(typeface, style);
                _textBoxView.SetTextSize(ComplexUnitType.Px, (float)Math.Round(ViewHelper.LogicalToPhysicalFontPixels((float)textBox.FontSize)));
            }
        }