| 196 | } |
| 197 | |
| 198 | float TextPool::fitScale(const std::string& s, float maxWidth, float scale, float minScale) const |
| 199 | { |
| 200 | const float w = StringUtils::textWidth(s, scale); |
| 201 | if (w <= maxWidth || w <= 0.0f) { |
| 202 | return scale; |
| 203 | } |
| 204 | return std::max(scale * maxWidth / w, minScale); |
| 205 | } |
| 206 | |
| 207 | std::string TextPool::truncate(const std::string& s, float maxWidth, float scale) const |
| 208 | { |