| | 531 | |
| | 532 | IntSize shadowSize; |
| | 533 | int shadowBlur; |
| | 534 | Color shadowColor; |
| | 535 | graphicsContext->getShadow(shadowSize, shadowBlur, shadowColor); |
| | 536 | |
| | 537 | bool hasSimpleShadow = graphicsContext->textDrawingMode() == cTextFill && shadowColor.isValid() && !shadowBlur && !shadowSize.isEmpty(); |
| | 538 | if (hasSimpleShadow) { |
| | 539 | // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing. |
| | 540 | graphicsContext->clearShadow(); |
| | 541 | Color fillColor = graphicsContext->fillColor(); |
| | 542 | Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255); |
| | 543 | graphicsContext->setFillColor(shadowFillColor); |
| | 544 | CGContextTranslateCTM(context, shadowSize.width(), shadowSize.height()); |
| | 545 | status = ATSUDrawText(params.m_layout, from, drawPortionLength, 0, 0); |
| | 546 | if (status == noErr && params.m_hasSyntheticBold) { |
| | 547 | // Force relayout for the bold pass |
| | 548 | ATSUClearLayoutCache(params.m_layout, 0); |
| | 549 | params.m_syntheticBoldPass = true; |
| | 550 | status = ATSUDrawText(params.m_layout, from, drawPortionLength, 0, 0); |
| | 551 | // Force relayout for the next pass |
| | 552 | ATSUClearLayoutCache(params.m_layout, 0); |
| | 553 | params.m_syntheticBoldPass = false; |
| | 554 | } |
| | 555 | CGContextTranslateCTM(context, -shadowSize.width(), -shadowSize.height()); |
| | 556 | graphicsContext->setFillColor(fillColor); |
| | 557 | } |
| | 558 | |
| 647 | | |
| | 677 | |
| | 678 | IntSize shadowSize; |
| | 679 | int shadowBlur; |
| | 680 | Color shadowColor; |
| | 681 | context->getShadow(shadowSize, shadowBlur, shadowColor); |
| | 682 | |
| | 683 | bool hasSimpleShadow = context->textDrawingMode() == cTextFill && shadowColor.isValid() && !shadowBlur && !shadowSize.isEmpty(); |
| | 684 | if (hasSimpleShadow) { |
| | 685 | // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing. |
| | 686 | context->clearShadow(); |
| | 687 | Color fillColor = context->fillColor(); |
| | 688 | Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255); |
| | 689 | context->setFillColor(shadowFillColor); |
| | 690 | CGContextSetTextPosition(cgContext, point.x() + shadowSize.width(), point.y() + shadowSize.height()); |
| | 691 | CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs); |
| | 692 | if (font->m_syntheticBoldOffset) { |
| | 693 | CGContextSetTextPosition(cgContext, point.x() + shadowSize.width() + font->m_syntheticBoldOffset, point.y() + shadowSize.height()); |
| | 694 | CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs); |
| | 695 | } |
| | 696 | context->setFillColor(fillColor); |
| | 697 | } |
| | 698 | |