The cmap table in OpenType files translates a character code into a glyph ID.
Could any one help me to understand the C expression:
*(idRangeOffset[i]/2 + (c - startCount[i]) + &idRangeOffset[i])
Here is the Format 4 cmap subtable.
So, in that expression i = segment index and c = character code. idRangeOffset gets the offset of the segment into a glyphIdArray inside the cmap. The value you're actually looking for in this case is glyphIdArray[something]. Since glyphIdArray immediately follows idRangeOffset in the font file, you use idRangeOffset as the base pointer.
To get to the start of the glyphIdArray you need to add the idRangeOffset, but since that value is in bytes and the idRangeOffset table is 16bit, you need to divide by 2 to get the word count. You then get the offset of segment i inside the glyphIdArray.
Your character's offset however inside this segment is at c - startCount[i] so you need to add that as well.
The final expression is a pointer so you need to dereference it to actually get the glyph's index.
This index is then used for the LOCA table.