| 507 | } |
| 508 | |
| 509 | Data Device::getTextureDataForText(std::string_view text, |
| 510 | const FontDefinition& textDefinition, |
| 511 | TextAlign align, |
| 512 | int& width, |
| 513 | int& height, |
| 514 | bool& hasPremultipliedAlpha) |
| 515 | { |
| 516 | Data ret; |
| 517 | do |
| 518 | { |
| 519 | auto& textRenderer = sharedTextRenderer(); |
| 520 | |
| 521 | if (!textRenderer.setFont(textDefinition)) |
| 522 | { |
| 523 | AXLOGW("Can't found font({}), use system default", textDefinition._fontName); |
| 524 | } |
| 525 | |
| 526 | // draw text |
| 527 | // does changing to SIZE here affects the font size by rounding from float? |
| 528 | SIZE size = {(LONG)textDefinition._dimensions.width, (LONG)textDefinition._dimensions.height}; |
| 529 | AX_BREAK_IF(!textRenderer.drawText(text, size, align, textDefinition)); |
| 530 | |
| 531 | int dataLen = size.cx * size.cy * 4; |
| 532 | unsigned char* dataBuf = (unsigned char*)malloc(sizeof(unsigned char) * dataLen); |
| 533 | AX_BREAK_IF(!dataBuf); |
| 534 | |
| 535 | width = static_cast<int>(size.cx); |
| 536 | height = static_cast<int>(size.cy); |
| 537 | |
| 538 | const int bpp = 32; |
| 539 | size_t rowPitch = (width * bpp + 7) / 8; |
| 540 | textRenderer.copyPixels(dataBuf, dataLen, rowPitch); |
| 541 | |
| 542 | ret.fastSet(dataBuf, dataLen); |
| 543 | hasPremultipliedAlpha = false; |
| 544 | } while (0); |
| 545 | |
| 546 | return ret; |
| 547 | } |
| 548 | |
| 549 | void Device::setKeepScreenOn(bool /*value*/) {} |
| 550 |
nothing calls this directly
no test coverage detected