| 423 | } |
| 424 | |
| 425 | void PiuViewDrawStringAux(PiuView* self, xsSlot* string, xsIntegerValue offset, xsIntegerValue length, PiuFont* font, PocoColor color, uint8_t blend, PiuCoordinate x, PiuCoordinate y, PiuDimension width, PiuDimension stringWidth) |
| 426 | { |
| 427 | xsMachine* the = (*self)->the; |
| 428 | Poco poco = (*self)->poco; |
| 429 | xsStringValue text = PiuToString(string); |
| 430 | xsIntegerValue character = 0; |
| 431 | PiuGlyph glyph; |
| 432 | PiuCoordinate advance; |
| 433 | |
| 434 | #if pebble |
| 435 | if ((*font)->gfont) { |
| 436 | extern GContext *getPocoPebbleGContext(Poco poco); |
| 437 | |
| 438 | char tmp[100]; |
| 439 | GContext *ctx = getPocoPebbleGContext(poco); // might cache this in PiuView |
| 440 | text += offset; |
| 441 | if ((-1 != length) && text[length]) { |
| 442 | if (length >= (xsIntegerValue)sizeof(tmp)) |
| 443 | length = sizeof(tmp) - 1; |
| 444 | c_memmove(tmp, text, length); |
| 445 | tmp[length] = 0; |
| 446 | text = tmp; |
| 447 | } |
| 448 | |
| 449 | GRect box = GRect( |
| 450 | x, |
| 451 | y - fonts_get_font_cap_offset((*font)->gfont) + 1, // +1 for leading applied by modFindPebbleFont |
| 452 | stringWidth ? stringWidth : 10000, |
| 453 | 127); |
| 454 | |
| 455 | GColor saveTextColor = ctx->draw_state.text_color; |
| 456 | ctx->draw_state.text_color.argb = color; |
| 457 | graphics_draw_text(ctx, text, (*font)->gfont, box, |
| 458 | GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, C_NULL); |
| 459 | ctx->draw_state.text_color = saveTextColor; |
| 460 | |
| 461 | return; |
| 462 | } |
| 463 | #endif |
| 464 | |
| 465 | static const char ellipsisUTF8[4] = {0xE2, 0x80, 0xA6, 0}; // 0x2026 |
| 466 | static const char *ellipsisFallback = "..."; |
| 467 | const char *ellipsis = C_NULL; |
| 468 | PocoDimension ellipsisWidth = 0; |
| 469 | if (width) { |
| 470 | PiuGlyph glyph = PiuFontGetGlyph(font, 0x2026, 0); |
| 471 | if (glyph && !glyph->substitute) { |
| 472 | ellipsisWidth = glyph->advance; |
| 473 | ellipsis = (char *)ellipsisUTF8; |
| 474 | } |
| 475 | else { |
| 476 | glyph = PiuFontGetGlyph(font, '.', 0); |
| 477 | if (glyph) { |
| 478 | ellipsisWidth = 3 * glyph->advance; |
| 479 | ellipsis = ellipsisFallback; |
| 480 | } |
| 481 | } |
| 482 | } |
no test coverage detected