(StringBuilder out, Spanned text, int start, int end)
| 374 | } |
| 375 | |
| 376 | private /* static */ void withinParagraph(StringBuilder out, Spanned text, int start, int end) { |
| 377 | int next; |
| 378 | for (int i = start; i < end; i = next) { |
| 379 | next = nextSpanTransition(text, i, end, CharacterStyle.class); |
| 380 | try { |
| 381 | CharacterStyle[] style = getSpans(text, i, next, CharacterStyle.class); |
| 382 | |
| 383 | for (int j = 0; j < style.length; j++) { |
| 384 | if (style[j] instanceof StyleSpan) { |
| 385 | int s = ((StyleSpan) style[j]).getStyle(); |
| 386 | |
| 387 | if ((s & Typeface.BOLD) != 0) { |
| 388 | out.append("<b>"); |
| 389 | } |
| 390 | if ((s & Typeface.ITALIC) != 0) { |
| 391 | out.append("<i>"); |
| 392 | } |
| 393 | } |
| 394 | if (style[j] instanceof TypefaceSpan) { |
| 395 | String s = ((TypefaceSpan) style[j]).getFamily(); |
| 396 | |
| 397 | //if ("monospace".equals(s)) { |
| 398 | // out.append("<tt>"); |
| 399 | //} |
| 400 | |
| 401 | out.append("<span style='font-family:" + s + ";'>"); |
| 402 | } |
| 403 | if (style[j] instanceof SuperscriptSpan) { |
| 404 | out.append("<sup>"); |
| 405 | } |
| 406 | if (style[j] instanceof SubscriptSpan) { |
| 407 | out.append("<sub>"); |
| 408 | } |
| 409 | if (style[j] instanceof UnderlineSpan) { |
| 410 | out.append("<u>"); |
| 411 | } |
| 412 | if (style[j] instanceof StyleHelper.MarkSpan) { |
| 413 | out.append("<mark>"); |
| 414 | } |
| 415 | if (style[j] instanceof StrikethroughSpan) { |
| 416 | out.append("<span style=\"text-decoration:line-through;\">"); |
| 417 | } |
| 418 | if (style[j] instanceof URLSpan) { |
| 419 | out.append("<a href=\""); |
| 420 | out.append(((URLSpan) style[j]).getURL()); |
| 421 | out.append("\">"); |
| 422 | } |
| 423 | if (style[j] instanceof AbsoluteSizeSpan) { |
| 424 | AbsoluteSizeSpan s = ((AbsoluteSizeSpan) style[j]); |
| 425 | float sizeDip = s.getSize(); |
| 426 | if (!s.getDip()) { |
| 427 | //Application application = ActivityThread.currentApplication(); |
| 428 | sizeDip /= context.getResources().getDisplayMetrics().density; |
| 429 | } |
| 430 | |
| 431 | // px in CSS is the equivalance of dip in Android |
| 432 | out.append(String.format("<span style=\"font-size:%.0fpx\";>", sizeDip)); |
| 433 | } |
no test coverage detected