"Persian and Urdu write [g] using a kaf character with a line above U+06AF, while Pashto uses kaf with a ring U+06AB. It really should be that simple."
I seem to remember, that Persian used kaf with three dots above (like your Moroccan example) at least in the 19th century. No idea when they switched to the double-lined version. (and I can well imagine how the three dots would have merged to a line, thought this might as well not be the origin of that character). Szabolcs