Skip to main content
Olivier Beltrami
Legend
December 30, 2025
Answered

Loosening the criteria for AttributeBossList::IntersectionContainsDifferences()

  • December 30, 2025
  • 1 reply
  • 153 views

Hi,

In my code, I use AttributeBossList::IntersectionContainsDifferences() to locate runs of text of a particular set of attributes. But this function sometimes "fails" when looking for specific font sizes, such as 14.2pt or 18.53pt, for example. I am assuming that, internally, it is looking for an exact match in fixed units, and the conversion used by the SDK seems to differ ever so slightly, depending if one's UI is in points or millimeters, for example.

Short of re-writing my own version of AttributeBossList::IntersectionContainsDifferences(), to be able to handle borderline cases, does anyone have any suggestion as to how to loosen the matching criteria used by the SDK ?

Or should I use AttributeBossList::ConvertAttributeList() on both sets of attributes, and then do the comparison myself ?

Any suggestions would be greatly appreciated.

Very best regards,

Olivier

Correct answer Eugene Tyson

You could try something like the below, we've seen it before where InDesign shows a value but internally the size is a few more decimals. 

constexpr PMReal kEpsilon = 0.01; // ~1/100 pt is visually identical

PMReal sizeA = Utils<ITextAttrUtils>()->GetFontSize(attrListA);
PMReal sizeB = Utils<ITextAttrUtils>()->GetFontSize(attrListB);

if (Abs(sizeA - sizeB) <= kEpsilon)
{
    // Treat as equal
}

 

1 reply

Eugene TysonCommunity ExpertCorrect answer
Community Expert
January 1, 2026

You could try something like the below, we've seen it before where InDesign shows a value but internally the size is a few more decimals. 

constexpr PMReal kEpsilon = 0.01; // ~1/100 pt is visually identical

PMReal sizeA = Utils<ITextAttrUtils>()->GetFontSize(attrListA);
PMReal sizeB = Utils<ITextAttrUtils>()->GetFontSize(attrListB);

if (Abs(sizeA - sizeB) <= kEpsilon)
{
    // Treat as equal
}

 

Olivier Beltrami
Legend
January 6, 2026

@Eugene Tyson Thnak you very much !