+ if ( !bestIsSystem && (flags & FALLBACK_NEAREST_LARGER) )
+ {
+ bool iconLarger = (sx >= sizeX) && (sy >= sizeY);
+ int iconDiff = abs(sx - sizeX) + abs(sy - sizeY);
+
+ // Use current icon as candidate for the best icon, if either:
+ // - we have no candidate yet
+ // - we have no candidate larger than desired size and current icon is
+ // - current icon is closer to desired size than candidate
+ if ( !iconBest.IsOk() ||
+ (!bestIsLarger && iconLarger) ||
+ (iconLarger && (iconDiff < bestDiff)) )