void UIPainter::draw(const TextRenderer& text, bool forceCopy) { if (clip) { auto targetClip = clip.get() - text.getPosition(); if (text.getClip()) { targetClip = text.getClip().get().intersection(targetClip); } auto onScreen = Rect4f(Vector2f(), text.getExtents()).intersection(targetClip); if (onScreen.getWidth() > 0.1f && onScreen.getHeight() > 0.1f) { painter.addCopy(text.clone().setClip(clip.get() - text.getPosition()), mask, layer, getCurrentPriority()); } } else { if (forceCopy) { painter.addCopy(text, mask, layer, getCurrentPriority()); } else { painter.add(text, mask, layer, getCurrentPriority()); } } }