@@ -3,7 +3,7 @@ import { getClosestPropertyValue, maxLinesProperty, textOverflowProperty } from
3
3
import { ShadowCSSValues } from '../styling/css-shadow' ;
4
4
5
5
// Requires
6
- import { Font , isFontWeightBold } from '../styling/font' ;
6
+ import { Font } from '../styling/font' ;
7
7
import { backgroundColorProperty } from '../styling/style-properties' ;
8
8
import { TextBaseCommon , formattedTextProperty , textAlignmentProperty , textDecorationProperty , textProperty , textTransformProperty , textShadowProperty , textStrokeProperty , letterSpacingProperty , whiteSpaceProperty , lineHeightProperty , resetSymbol } from './text-base-common' ;
9
9
import { Color } from '../../color' ;
@@ -593,33 +593,17 @@ function createSpannableStringBuilder(formattedString: FormattedString, defaultF
593
593
594
594
function setSpanModifiers ( ssb : android . text . SpannableStringBuilder , span : Span , start : number , end : number , defaultFontSize : number ) : void {
595
595
const spanStyle = span . style ;
596
- const bold = isFontWeightBold ( spanStyle . fontWeight ) ;
597
- const italic = spanStyle . fontStyle === 'italic' ;
598
596
const align = spanStyle . verticalAlignment ;
599
597
600
- // We set font style using StyleSpan in case the font doesn't support font styles
601
- if ( bold && italic ) {
602
- ssb . setSpan ( new android . text . style . StyleSpan ( android . graphics . Typeface . BOLD_ITALIC ) , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
603
- } else if ( bold ) {
604
- ssb . setSpan ( new android . text . style . StyleSpan ( android . graphics . Typeface . BOLD ) , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
605
- } else if ( italic ) {
606
- ssb . setSpan ( new android . text . style . StyleSpan ( android . graphics . Typeface . ITALIC ) , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
607
- }
608
-
609
- const fontFamily = span . fontFamily ;
610
- if ( fontFamily ) {
611
- const font = new Font ( fontFamily , 0 , spanStyle . fontStyle , spanStyle . fontWeight , spanStyle . fontScaleInternal , spanStyle . fontVariationSettings ) ;
612
- const typeface = font . getAndroidTypeface ( ) || android . graphics . Typeface . create ( fontFamily , 0 ) ;
613
- const typefaceSpan : android . text . style . TypefaceSpan = new org . nativescript . widgets . CustomTypefaceSpan ( fontFamily , typeface ) ;
614
- ssb . setSpan ( typefaceSpan , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
615
- }
598
+ const font = new Font ( spanStyle . fontFamily , spanStyle . fontSize , spanStyle . fontStyle , spanStyle . fontWeight , spanStyle . fontScaleInternal , spanStyle . fontVariationSettings ) ;
599
+ const typefaceSpan = new org . nativescript . widgets . CustomTypefaceSpan ( font . getAndroidTypeface ( ) ) ;
600
+ ssb . setSpan ( typefaceSpan , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
616
601
617
- const realFontSize = span . fontSize ;
618
- if ( realFontSize ) {
619
- ssb . setSpan ( new android . text . style . AbsoluteSizeSpan ( realFontSize * layout . getDisplayDensity ( ) ) , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
602
+ if ( spanStyle . fontSize ) {
603
+ ssb . setSpan ( new android . text . style . AbsoluteSizeSpan ( layout . toDevicePixels ( spanStyle . fontSize ) ) , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
620
604
}
621
605
622
- const color = span . color ;
606
+ const color = spanStyle . color ;
623
607
if ( color ) {
624
608
ssb . setSpan ( new android . text . style . ForegroundColorSpan ( color . android ) , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
625
609
}
@@ -646,7 +630,7 @@ function setSpanModifiers(ssb: android.text.SpannableStringBuilder, span: Span,
646
630
647
631
if ( align ) {
648
632
initializeBaselineAdjustedSpan ( ) ;
649
- ssb . setSpan ( new BaselineAdjustedSpan ( defaultFontSize * layout . getDisplayDensity ( ) , align ) , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
633
+ ssb . setSpan ( new BaselineAdjustedSpan ( layout . toDevicePixels ( defaultFontSize ) , align ) , start , end , android . text . Spanned . SPAN_EXCLUSIVE_EXCLUSIVE ) ;
650
634
}
651
635
652
636
const tappable = span . tappable ;
0 commit comments