I am currently writing the implemenation for subsetting a OTF CFF font. I have written the code to generate the cmap and everything in the CFF data apart from the encoding array. What is confusing me is why there is a need for an encoding array if the cmap is there. Say I have written "hello world" and I will create a subset for those characters from the font e.g.
h = gid 1
e = gid 2
l = gid 3
o = gid 4
What I have done is create the cmap so that the unicode codes map to those new gid's. Looking at the encoding array though, surely it performs the same task? If I were to have both in my font, would one take precedence? If I leave out the encoding array from the CFF data in my font, will it correctly use the cmap, or use the StandardEncoding instead? If so, why is the cmap a required table if it is not used for anything with CFF extensions.