| 47 | } |
| 48 | |
| 49 | void PiuViewDrawString(PiuView* self, xsSlot* string, xsIntegerValue offset, xsIntegerValue length, PiuFont* font, PiuCoordinate x, PiuCoordinate y, PiuDimension width, PiuDimension stringWidth) |
| 50 | { |
| 51 | if ((*self)->color.a == 0) return; |
| 52 | xsMachine* the = (*self)->the; |
| 53 | xsStringValue text = PiuToString(string); |
| 54 | GContext *ctx = (*self)->ctx; |
| 55 | if ((*font)->gfont) { |
| 56 | char tmp[100]; |
| 57 | text += offset; |
| 58 | if ((-1 != length) && text[length]) { |
| 59 | if (length >= (xsIntegerValue)sizeof(tmp)) |
| 60 | length = sizeof(tmp) - 1; |
| 61 | c_memmove(tmp, text, length); |
| 62 | tmp[length] = 0; |
| 63 | text = tmp; |
| 64 | } |
| 65 | |
| 66 | GRect box = GRect( |
| 67 | x, |
| 68 | y - fonts_get_font_cap_offset((*font)->gfont) + 1, // +1 for leading applied by modFindPebbleFont |
| 69 | stringWidth ? stringWidth : 10000, |
| 70 | 127); |
| 71 | |
| 72 | GColor saveColor = ctx->draw_state.text_color; |
| 73 | ctx->draw_state.text_color.argb = (*self)->color.argb; |
| 74 | graphics_draw_text(ctx, text, (*font)->gfont, box, GTextOverflowModeTrailingEllipsis, GTextAlignmentLeft, C_NULL); |
| 75 | ctx->draw_state.text_color = saveColor; |
| 76 | } |
| 77 | else { |
| 78 | static const char ellipsisUTF8[4] = {0xE2, 0x80, 0xA6, 0}; // 0x2026 |
| 79 | static const char *ellipsisFallback = "..."; |
| 80 | const char *ellipsis; |
| 81 | PocoDimension ellipsisWidth; |
| 82 | xsIntegerValue character = 0; |
| 83 | CFEGlyph glyph; |
| 84 | PiuCoordinate advance; |
| 85 | |
| 86 | CFESetFontData(gCFE, (*font)->buffer, (*font)->bufferSize); |
| 87 | CFESetFontSize(gCFE, (*font)->size); |
| 88 | |
| 89 | if (width) { |
| 90 | glyph = CFEGetGlyphFromUnicode(gCFE, 0x2026, 0); |
| 91 | if (glyph) { |
| 92 | ellipsisWidth = glyph->advance; |
| 93 | ellipsis = (char *)ellipsisUTF8; |
| 94 | } |
| 95 | else { |
| 96 | glyph = CFEGetGlyphFromUnicode(gCFE, '.', 0); |
| 97 | if (glyph) { |
| 98 | ellipsisWidth = 3 * glyph->advance; |
| 99 | ellipsis = ellipsisFallback; |
| 100 | } |
| 101 | else |
| 102 | ellipsisWidth = 0; |
| 103 | } |
| 104 | } |
| 105 | else { |
| 106 | ellipsis = NULL; |
nothing calls this directly
no test coverage detected