@@ -105,6 +105,7 @@ public static String getFontWeightSuffix(String fontWeight) {
105
105
return Build .VERSION .SDK_INT >= 16 ? "-light" : "" ;
106
106
case FontWeight .NORMAL :
107
107
case "400" :
108
+ case "" :
108
109
return "" ;
109
110
case FontWeight .MEDIUM :
110
111
case FontWeight .SEMI_BOLD :
@@ -258,8 +259,8 @@ static ArrayList<ArrayList<String>> parseFormattedString(String formattedString)
258
259
259
260
260
261
public static void setSpanModifiers (Context context , String fontFolder , SpannableStringBuilder ssb , ArrayList <String > span , int start , int end ) {
261
- boolean bold = span .get (2 ) == "1" ;
262
- boolean italic = span .get (3 ) == "1" ;
262
+ boolean bold = span .get (2 ). equals ( "bold" ) || span . get ( 2 ). equals ( "700" ) ;
263
+ boolean italic = span .get (3 ). equals ( "1" ) ;
263
264
264
265
if (bold && italic ) {
265
266
ssb .setSpan (new android .text .style .StyleSpan (android .graphics .Typeface .BOLD_ITALIC ), start , end , android .text .Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
@@ -270,8 +271,8 @@ public static void setSpanModifiers(Context context, String fontFolder, Spannabl
270
271
}
271
272
272
273
String fontFamily = span .get (0 );
273
- if (!fontFamily .equals ("undefined " ) ) {
274
- Typeface typeface = createTypeface (context , fontFolder , fontFamily , bold ? "bold" : "normal" ,
274
+ if (!fontFamily .equals ("0 " ) ) {
275
+ Typeface typeface = createTypeface (context , fontFolder , fontFamily , span . get ( 2 ) ,
275
276
bold , italic );
276
277
// const font = new Font(fontFamily, 0, (italic) ? "italic" : "normal", (bold) ? "bold" : "normal");
277
278
// const typeface = font.getAndroidTypeface() || android.graphics.Typeface.create(fontFamily, 0);
@@ -280,30 +281,32 @@ public static void setSpanModifiers(Context context, String fontFolder, Spannabl
280
281
}
281
282
282
283
String fontSize = span .get (1 );
283
- if (!fontSize .equals ("undefined " ) ) {
284
+ if (!fontSize .equals ("-1 " ) ) {
284
285
ssb .setSpan (new AbsoluteSizeSpan (Math .round (Float .parseFloat (fontSize ) * context .getResources ().getDisplayMetrics ().density )), start , end , android .text .Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
285
286
}
286
287
287
288
String color = span .get (5 );
288
- if (!color .equals ("undefined " ) ) {
289
+ if (!color .equals ("-1 " ) ) {
289
290
ssb .setSpan (new ForegroundColorSpan (Integer .parseInt (color )), start , end , android .text .Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
290
291
}
291
292
292
293
293
294
String backgroundColor = span .get (6 );
294
295
295
- if (!backgroundColor .equals ("undefined " ) ) {
296
+ if (!backgroundColor .equals ("-1 " ) ) {
296
297
ssb .setSpan (new BackgroundColorSpan (Integer .parseInt (backgroundColor )), start , end , android .text .Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
297
298
}
298
299
299
300
300
301
String textDecoration = span .get (4 );
301
- if (textDecoration .contains ("underline" )) {
302
- ssb .setSpan (new android .text .style .UnderlineSpan (), start , end , android .text .Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
303
- }
302
+ if (!textDecoration .equals ("0" ) ) {
303
+ if (textDecoration .contains ("underline" )) {
304
+ ssb .setSpan (new android .text .style .UnderlineSpan (), start , end , android .text .Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
305
+ }
304
306
305
- if (textDecoration .contains ("line-through" )) {
306
- ssb .setSpan (new android .text .style .StrikethroughSpan (), start , end , android .text .Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
307
+ if (textDecoration .contains ("line-through" )) {
308
+ ssb .setSpan (new android .text .style .StrikethroughSpan (), start , end , android .text .Spanned .SPAN_EXCLUSIVE_EXCLUSIVE );
309
+ }
307
310
}
308
311
long stopTime = System .nanoTime ();
309
312
// TODO: Implement letterSpacing for Span here.
0 commit comments