Using lualatex and fontspec with a special Garamond font.
The font I use has two versions of the apostrophe: a normal high and a low small caps one.
The problem occurs using small caps feature, because by default it loads the low apostrophe with small capitals, that, in some cases, is not correct. It creates some problems when it follows the capital letters of names, e.g. in many Italian surnames.
Here a pic, on the left there are the low apostrophes loaded using smallcaps (1, 3): 1 it's a wrong result but 3 is correct. 2 It's right and 4 is wrong. The problem is more serious when small caps are automatic (e.g. in packages like Biblatex philosophy-verbose, this is my real problem). But also using the solution D'O\textsc{nofrio} - when it is possible - it's not good at all because latex lost the kerning between O and \textsc{n}.
Is there a way for changing the type of apostrophe depending on the previous letter? Or is there any other way to solve the problem?
Thank you in advance