src/textord/colpartitiongrid.cpp
static bool TestCompatibleCandidates(const ColPartition &part, bool debug,
                                     ColPartition_CLIST *candidates) {
  ColPartition_C_IT it(candidates);
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    ColPartition *candidate = it.data();
    if (!candidate->OKDiacriticMerge(part, false)) {
      ColPartition_C_IT it2(it);
      for (it2.mark_cycle_pt(); !it2.cycled_list(); it2.forward()) {
        ColPartition *candidate2 = it2.data();
        if (candidate2 != candidate &&
            !OKMergeCandidate(candidate, candidate2, false)) {
          if (debug) {
            tprintf("NC overlap failed:Candidate:");
            candidate2->bounding_box().print();
            tprintf("fails to be a good merge with:");
            candidate->bounding_box().print();
          }
          return false;
        }
      }
    }
  }
  return true;
}
// Helper function to test that each partition in candidates is either a
// good diacritic merge with part or an OK merge candidate with all others
// in the candidates list.
// ASCII Art Scenario:
// We sometimes get text such as "join-this" where the - is actually a long
// dash culled from a standard set of extra characters that don't match the
// font of the text. This makes its strokewidth not match and forms a broken
// set of 3 partitions for "join", "-" and "this" and the dash may slightly
// overlap BOTH words.
// -------  -------
// |     ====     |
// -------  -------
// The standard merge rule: "you can merge 2 partitions as long as there is
// no increase in overlap elsewhere" fails miserably here. Merge any pair
// of partitions and the combined box overlaps more with the third than
// before. To allow the merge, we need to consider whether it is safe to
// merge everything, without merging separate text lines. For that we need
// everything to be an OKMergeCandidate (which is supposed to prevent
// separate text lines merging), but this is hard for diacritics to satisfy,
// so an alternative to being OKMergeCandidate with everything is to be an
// OKDiacriticMerge with part as the base character.
Helper function to test that each partition in candidates is either a
good diacritic merge with part or an OK merge candidate with all others
in the candidates list.
ASCII Art Scenario:
We sometimes get text such as "join-this" where the - is actually a long
dash culled from a standard set of extra characters that don't match the
font of the text.



The standard merge rule: "you can merge 2 partitions as long as there is
no increase in overlap elsewhere" fails miserably here. Merge any pair
of partitions and the combined box overlaps more with the third than
before. To allow the merge, we need to consider whether it is safe to
merge everything, without merging separate text lines. For that we need
everything to be an OKMergeCandidate (which is supposed to prevent
separate text lines merging), but this is hard for diacritics to satisfy,
so an alternative to being OKMergeCandidate with everything is to be an
OKDiacriticMerge with part as the base character.
Helper function to test that each partition in candidates is either a good diacritic merge with part or an OK merge candidate with all others in the candidates list . ASCII Art Scenario : We sometimes get text such as " join - this " where the - is actually a long dash culled from a standard set of extra characters that don ' t match the font of the text . The standard merge rule : " you can merge 2 partitions as long as there is no increase in overlap elsewhere " fails miserably here . Merge any pair of partitions and the combined box overlaps more with the third than before . To allow the merge we need to consider whether it is safe to merge everything without merging separate text lines . For that we need everything to be an OKMergeCandidate ( which is supposed to prevent separate text lines merging ) but this is hard for diacritics to satisfy so an alternative to being OKMergeCandidate with everything is to be an OKDiacriticMerge with part as the base character .
static bool TestCompatibleCandidates(const ColPartition &part, bool debug,
                                     ColPartition_CLIST *candidates) {
  ColPartition_C_IT it(candidates);
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    ColPartition *candidate = it.data();
    if (!candidate->OKDiacriticMerge(part, false)) {
      ColPartition_C_IT it2(it);
      for (it2.mark_cycle_pt(); !it2.cycled_list(); it2.forward()) {
        ColPartition *candidate2 = it2.data();
        if (candidate2 != candidate &&
            !OKMergeCandidate(candidate, candidate2, false)) {
          if (debug) {
            tprintf("NC overlap failed:Candidate:");
            candidate2->bounding_box().print();
            tprintf("fails to be a good merge with:");
            candidate->bounding_box().print();
          }
          return false;
        }
      }
    }
  }
  return true;
}
static bool TestCompatibleCandidates ( const ColPartition & part , bool debug , ColPartition_CLIST * candidates ) { ColPartition_C_IT it ( candidates ) ; for ( it . mark_cycle_pt ( ) ; ! it . cycled_list ( ) ; it . forward ( ) ) { ColPartition * candidate = it . data ( ) ; if ( ! candidate -> OKDiacriticMerge ( part , false ) ) { ColPartition_C_IT it2 ( it ) ; for ( it2 . mark_cycle_pt ( ) ; ! it2 . cycled_list ( ) ; it2 . forward ( ) ) { ColPartition * candidate2 = it2 . data ( ) ; if ( candidate2 != candidate && ! OKMergeCandidate ( candidate , candidate2 , false ) ) { if ( debug ) { tprintf ( " " ) ; candidate2 -> bounding_box ( ) . print ( ) ; tprintf ( " " ) ; candidate -> bounding_box ( ) . print ( ) ; } return false ; } } } } return true ; }
Helper function to test that each partition in candidates is either a
good diacritic merge with part or an OK merge candidate with all others
in the candidates list.
Helper function to test that each partition in candidates is either a good diacritic merge with part or an OK merge candidate with all others in the candidates list .