drawText method

  1. @override
void drawText(
  1. PdfTextRun run
)

Implementation

@override
void drawText(PdfTextRun run) {
  final glyphs = run.glyphs;
  if (!_slugEnabled ||
      run.invisible ||
      !stripsActive ||
      delegateText ||
      glyphs == null ||
      !run.fill ||
      run.strokeColor != null ||
      run.gradient != null) {
    super.drawText(run);
    return;
  }

  // Finish strips that precede this run, then commit the complete run as one
  // Slug batch immediately. Immediate commit is deliberately conservative
  // while the worker-plan and glyph-layer paths are integrated: it preserves
  // painter order without changing StripBinningDevice's flush ordinals.
  flushPending();
  final plan = _plan;
  if (plan != null) {
    final ordinal = flushPointCount - 1;
    if (_planSlugNext < plan.slugBatches.length &&
        plan.slugBatches[_planSlugNext].flushOrdinal == ordinal) {
      _addSlugBatch(plan.slugBatches[_planSlugNext++]);
      return;
    }
    if (_planSlugFallbackNext >= plan.slugFallbackOrdinals.length ||
        plan.slugFallbackOrdinals[_planSlugFallbackNext] != ordinal) {
      // Slug-eligible run with no outline quads: successful no-op, not a
      // fallback. This distinction is explicit in the worker plan so the
      // UI never has to inspect outlines to recover routing.
      return;
    }
    _planSlugFallbackNext++;
    // The worker applied the same eligibility checks and routed this run
    // into strips. With binning disabled, super only advances routing; its
    // planned strip batch is consumed at the next flush point.
    _slugFallbackOutlineRuns++;
    totalSlugFallbackOutlineRuns++;
    super.drawText(run);
    return;
  }
  if (!_addSlugRun(glyphs, run, stripArgbColor(run.color, 1))) {
    _slugFallbackOutlineRuns++;
    totalSlugFallbackOutlineRuns++;
    super.drawText(run);
    return;
  }
  _flushSlug(flushPointCount - 1);
}