1180{
1181 const Run* lastRun =
nullptr;
1182 auto startBox = boxes.size();
1184 [textRange0, rectHeightStyle, rectWidthStyle, &boxes, &lastRun, startBox, this]
1188 [
run, runOffsetInLine, textRange0, rectHeightStyle, rectWidthStyle, &boxes, &lastRun, startBox,
this]
1189 (
TextRange textRange,
const TextStyle& style,
const TextLine::ClipContext& lineContext) {
1190
1191 auto intersect = textRange * textRange0;
1193 return true;
1194 }
1195
1197
1198
1199 auto context = this->measureTextInsideOneRun(
1200 intersect,
run, runOffsetInLine, 0,
true, TextAdjustment::GraphemeGluster);
1202 clip.
offset(lineContext.fTextShift - context.fTextShift, 0);
1203
1204 switch (rectHeightStyle) {
1206
1207
1210 break;
1216 clip.fTop += verticalShift;
1217 }
1218 break;
1219 }
1226 clip.fTop += verticalShift / 2.0;
1227 }
1229 clip.fBottom -= verticalShift / 2.0;
1230 }
1231 break;
1232 }
1239 clip.fBottom -= verticalShift;
1240 }
1241 break;
1242 }
1244 const auto& strutStyle = paragraphStyle.getStrutStyle();
1245 if (strutStyle.getStrutEnabled()
1246 && strutStyle.getFontSize() > 0) {
1249 clip.fTop = top + strutMetrics.ascent();
1250 clip.fBottom = top + strutMetrics.descent();
1251 }
1252 }
1253 break;
1255 if (
run->fHeightMultiplier <= 0) {
1256 break;
1257 }
1259 clip.fTop = effectiveBaseline +
run->ascent();
1260 clip.fBottom = effectiveBaseline +
run->descent();
1261 }
1262 break;
1263 default:
1265 break;
1266 }
1267
1268
1269
1273 this->trimmedText().end >
intersect.start)
1274 {
1277
1279 {
1280
1281 trailingSpaces =
clip;
1282 if(
run->leftToRight()) {
1285 } else {
1286 trailingSpaces.
fRight = 0;
1288 }
1290 !
run->leftToRight())
1291 {
1292
1293 trailingSpaces =
clip;
1295 trailingSpaces.
fRight = 0;
1299 {
1300
1301 trailingSpaces =
clip;
1305 }
1306 }
1307
1309 if (trailingSpaces.
width() > 0) {
1311 }
1312
1313
1315 bool mergedBoxes = false;
1316 if (!boxes.empty() &&
1317 lastRun != nullptr &&
1318 context.run->leftToRight() == lastRun->leftToRight() &&
1319 lastRun->placeholderStyle() == nullptr &&
1320 context.run->placeholderStyle() == nullptr &&
1322 context.run->heightMultiplier()) &&
1323 lastRun->font() == context.run->font())
1324 {
1325 auto& lastBox = boxes.back();
1330 {
1331 lastBox.rect.fLeft =
std::min(lastBox.rect.fLeft,
clip.fLeft);
1332 lastBox.rect.fRight =
std::max(lastBox.rect.fRight,
clip.fRight);
1333 mergedBoxes = true;
1334 }
1335 }
1336 lastRun = context.run;
1337 return mergedBoxes;
1338 };
1339
1341 boxes.emplace_back(
clip, context.run->getTextDirection());
1342 }
1344 boxes.emplace_back(trailingSpaces, paragraphStyle.getTextDirection());
1345 }
1346
1348
1349 auto lineStart = this->
offset().
fX;
1351 auto left = boxes[startBox];
1352 auto right = boxes.back();
1354 left.rect.fRight =
left.rect.fLeft;
1355 left.rect.fLeft = 0;
1356 boxes.insert(boxes.begin() + startBox + 1, left);
1357 }
1359 right.rect.fRight >= lineEnd &&
1363 boxes.emplace_back(right);
1364 }
1365 }
1366
1367 return true;
1368 });
1369 return true;
1370 });
1372 for (auto& r : boxes) {
1373 r.rect.fLeft = littleRound(r.rect.fLeft);
1374 r.rect.fRight = littleRound(r.rect.fRight);
1375 r.rect.fTop = littleRound(r.rect.fTop);
1376 r.rect.fBottom = littleRound(r.rect.fBottom);
1377 }
1378 }
1379}
static bool intersect(const SkPoint &p0, const SkPoint &n0, const SkPoint &p1, const SkPoint &n1, SkScalar *t)
static void merge(const uint8_t *SK_RESTRICT row, int rowN, const SkAlpha *SK_RESTRICT srcAA, const int16_t *SK_RESTRICT srcRuns, SkAlpha *SK_RESTRICT dstAA, int16_t *SK_RESTRICT dstRuns, int width)
SkScalar rawAscent() const
InternalLineMetrics strutMetrics() const
SkScalar widthWithTrailingSpaces()
TextRange textWithNewlines() const
TextRange trimmedText() const
SkScalar baseline() const
static float min(float r, float g, float b)
static bool nearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
static bool nearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
@ kIncludeLineSpacingBottom
@ kIncludeLineSpacingMiddle
static constexpr SkRect MakeEmpty()
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
void offset(float dx, float dy)
constexpr float width() const