static void doDrawTextAtPoint(GraphicsContext& context, const String& text, const IntPoint& point, const Font& font, const Color& color, int underlinedIndex) { TextRun run(text.characters(), text.length()); context.setFillColor(color); if (isOneLeftToRightRun(run)) font.drawText(&context, run, point); else { context.setFont(font); context.drawBidiText(run, point); } if (underlinedIndex >= 0) { ASSERT(underlinedIndex < static_cast<int>(text.length())); int beforeWidth; if (underlinedIndex > 0) { TextRun beforeRun(text.characters(), underlinedIndex); beforeWidth = font.width(beforeRun); } else beforeWidth = 0; TextRun underlinedRun(text.characters() + underlinedIndex, 1); int underlinedWidth = font.width(underlinedRun); IntPoint underlinePoint(point); underlinePoint.move(beforeWidth, 1); context.setStrokeColor(color); context.drawLineForText(underlinePoint, underlinedWidth, false); } }
static void doDrawTextAtPoint(GraphicsContext& context, const String& text, const IntPoint& point, const Font& font, const Color& color, int underlinedIndex) { FontCachePurgePreventer fontCachePurgePreventer; TextRun run(text); context.setFillColor(color, ColorSpaceDeviceRGB); if (isOneLeftToRightRun(run)) font.drawText(&context, run, point); else context.drawBidiText(font, run, point); if (underlinedIndex >= 0) { ASSERT_WITH_SECURITY_IMPLICATION(underlinedIndex < static_cast<int>(text.length())); int beforeWidth; if (underlinedIndex > 0) { TextRun beforeRun(StringView(text).substring(0, underlinedIndex)); beforeWidth = font.width(beforeRun); } else beforeWidth = 0; TextRun underlinedRun(StringView(text).substring(underlinedIndex, 1)); int underlinedWidth = font.width(underlinedRun); IntPoint underlinePoint(point); underlinePoint.move(beforeWidth, 1); context.setStrokeColor(color, ColorSpaceDeviceRGB); context.drawLineForText(underlinePoint, underlinedWidth, false); } }