Either I'm missing something or Kerning doesn't appear to work properly with character range queries. It mostly seems to return undefined, even for a character range of a single character.
It's potentially important to check if kerning has been manually altered to be able to take steps to preserve that kerning during a scripted edit. autoKernType seems to work as expected, only returning undefined on mixed autoKernTypes in a single text layer, it's just kerning that does. Makes it impossible to query in any useful way.
1. Create a comp, a text layer with some text, set to Metrics. Run attached kerntest script and you get:
autoKern all = Metrics first char = Metrics
kerning all = undefined first char = undefined
Kerning should be returning 0 in both cases (the scripting docs say so too)
2. Use Character panel to set Kerning to 0. Run script:
autoKern all = None first char = None
kerning all = undefined first char = undefined
Kerning should be returning 0 in both cases.
3. Click between two later characters on the text layer and set Kerning pulldown to 100. Run script:
autoKern all = None first char = None
kerning all = 100 first char = undefined
Again seems wrong. Why is full char range returning 100?
All should be returning undefined, and first char should return 0.
Only that later char will return the kerning value you just set.
4. Set text back to Metrics, click between two later characters and set Kerning to 100. Run script:
autoKern all = Metrics first char = Metrics
kerning all = undefined first char = undefined
Kerning should be returning same as in Step 3. All is undefined, first is 0, only the later char returns its altered value.