At many places where we are using replaceRegion to copy glyph into MTLTexture we have used literals for index update.
Update them to use loop increment like :
for (int i = 0; i < (w * h); i++) {
imageData[dstIndex++] = 0xFF;
imageData[dstIndex++] = glyph->image[srcIndex++];
imageData[dstIndex++] = glyph->image[srcIndex++];
imageData[dstIndex++] = glyph->image[srcIndex++];
}
Update them to use loop increment like :
for (int i = 0; i < (w * h); i++) {
imageData[dstIndex++] = 0xFF;
imageData[dstIndex++] = glyph->image[srcIndex++];
imageData[dstIndex++] = glyph->image[srcIndex++];
imageData[dstIndex++] = glyph->image[srcIndex++];
}