@@ -274,9 +274,10 @@ Status CollectExclusiveCandidateMerges(
274274 continue ;
275275 }
276276
277- if (context.InertSegments ().contains (*it) && context.glyph_condition_set .GlyphsWithSegment (*it).empty ()) {
278- // this segment is effectively a noop, it interacts with nothing and has no glyphs
279- // so don't consider it for a merge.
277+ if (context.InertSegments ().contains (*it) &&
278+ context.glyph_condition_set .GlyphsWithSegment (*it).empty ()) {
279+ // this segment is effectively a noop, it interacts with nothing and has
280+ // no glyphs so don't consider it for a merge.
280281 continue ;
281282 }
282283
@@ -509,41 +510,50 @@ static StatusOr<std::vector<Segment>> ToSegments(
509510 return segments;
510511}
511512
512- Status ClosureGlyphSegmenter::MoveSegmentsToInitFont (SegmentationContext& context) const {
513+ Status ClosureGlyphSegmenter::MoveSegmentsToInitFont (
514+ SegmentationContext& context) const {
513515 if (!context.GetMergeStrategy ().InitFontMergeThreshold ().has_value ()) {
514- return absl::FailedPreconditionError (" Cannot be called when there is no merge threshold configured." );
516+ return absl::FailedPreconditionError (
517+ " Cannot be called when there is no merge threshold configured." );
515518 }
516519
517520 double threshold = *context.GetMergeStrategy ().InitFontMergeThreshold ();
518521
519- VLOG (0 ) << " Checking if there are any segments which should be moved into the initial font." ;
522+ VLOG (0 ) << " Checking if there are any segments which should be moved into "
523+ " the initial font." ;
520524
521- SubsetDefinition initial_segment = context.SegmentationInfo ().InitFontSegment ();
525+ SubsetDefinition initial_segment =
526+ context.SegmentationInfo ().InitFontSegment ();
522527 bool change_made;
523528 do {
524529 change_made = false ;
525530 SegmentSet segments_to_move;
526- for (const auto & [c, glyphs] : context.glyph_groupings .ConditionsAndGlyphs ()) {
531+ for (const auto & [c, glyphs] :
532+ context.glyph_groupings .ConditionsAndGlyphs ()) {
527533 SegmentSet candidate_segments = c.TriggeringSegments ();
528534 if (!candidate_segments.intersects (context.ActiveSegments ())) {
529- // Only do this check for things involving active segments, this let's us skip
530- // checks for conditions are are extremely unlikely to benefit from merging
531- // into the init font.
535+ // Only do this check for things involving active segments, this let's
536+ // us skip checks for conditions are are extremely unlikely to benefit
537+ // from merging into the init font.
532538 continue ;
533539 }
534540
535- double delta = TRY (CandidateMerge::ComputeCostDelta (context, candidate_segments, std::nullopt , 0 ));
536- if (delta >= threshold * (double ) candidate_segments.size ()) {
541+ double delta = TRY (CandidateMerge::ComputeCostDelta (
542+ context, candidate_segments, std::nullopt , 0 ));
543+ if (delta >= threshold * (double )candidate_segments.size ()) {
537544 // Merging doesn't improve cost, skip.
538545 continue ;
539546 }
540547
541- // TODO(garretrieger): to get a more accurate picture we should consider comparing
548+ // TODO(garretrieger): to get a more accurate picture we should consider
549+ // comparing
542550 // to an updated init subset definition on each iteration.
543551 segments_to_move.union_set (candidate_segments);
544- VLOG (0 ) << " Moving segments " << candidate_segments.ToString () << " into the initial font (cost delta = " << delta << " )" ;
552+ VLOG (0 ) << " Moving segments " << candidate_segments.ToString ()
553+ << " into the initial font (cost delta = " << delta << " )" ;
545554 for (segment_index_t s : segments_to_move) {
546- initial_segment.Union (context.SegmentationInfo ().Segments ()[s].Definition ());
555+ initial_segment.Union (
556+ context.SegmentationInfo ().Segments ()[s].Definition ());
547557 }
548558
549559 TRYV (context.ReassignInitSubset (initial_segment, segments_to_move));
@@ -552,7 +562,8 @@ Status ClosureGlyphSegmenter::MoveSegmentsToInitFont(SegmentationContext& contex
552562 }
553563 } while (change_made);
554564
555- VLOG (0 ) << " Initial font now has " << initial_segment.codepoints .size () << " codepoints." ;
565+ VLOG (0 ) << " Initial font now has " << initial_segment.codepoints .size ()
566+ << " codepoints." ;
556567 return absl::OkStatus ();
557568}
558569
@@ -579,9 +590,11 @@ StatusOr<GlyphSegmentation> ClosureGlyphSegmenter::CodepointToGlyphSegments(
579590 return context.ToGlyphSegmentation ();
580591 }
581592
582- // ### First phase of merging is to check for any patches which should be moved to the initial font
593+ // ### First phase of merging is to check for any patches which should be
594+ // moved to the initial font
583595 // (eg. cases where the probability of a patch is ~1.0).
584- if (context.GetMergeStrategy ().UseCosts () && context.GetMergeStrategy ().InitFontMergeThreshold ().has_value ()) {
596+ if (context.GetMergeStrategy ().UseCosts () &&
597+ context.GetMergeStrategy ().InitFontMergeThreshold ().has_value ()) {
585598 TRYV (MoveSegmentsToInitFont (context));
586599 }
587600
@@ -668,9 +681,10 @@ StatusOr<SegmentationCost> ClosureGlyphSegmenter::TotalCost(
668681 segments.push_back (std::move (s));
669682 }
670683
671- double init_font_size =
672- TRY (CandidateMerge::Woff2SizeOf (original_face, segmentation.InitialFontSegment (), 11 ));
673- double non_ift_font_size = TRY (CandidateMerge::Woff2SizeOf (original_face, non_ift, 11 ));
684+ double init_font_size = TRY (CandidateMerge::Woff2SizeOf (
685+ original_face, segmentation.InitialFontSegment (), 11 ));
686+ double non_ift_font_size =
687+ TRY (CandidateMerge::Woff2SizeOf (original_face, non_ift, 11 ));
674688
675689 // TODO(garretrieger): for the total cost we need to also add in the table
676690 // keyed patch costs
0 commit comments