The most common application of your question is birthday cakes upon which "happy birthday" wishes are written with icing. We will therefore use a cake as an example to illustrate the basic rules:

"Erasing" is one of the 39 Acts of Work which are prohibited on Shabbat. The act of erasing includes any form of obliterating or defacing letters.

This leads to your question regarding foods which have edible lettering on them:

One may not break apart or cut a cake if in the process letters which are upon it will be broken.1 However, one can remove the letters intact with some of the icing or cake beneath it, even one letter at a time,2 or cut the cake between the letters. This can be done even if the letters are attached to each other; they can be removed individually, or one may cut in between them, provided that the shape of each letter remains complete.

The letters themselves may be eaten whole, though they will obviously be obliterated when eaten.

Best wishes,

Rabbi Baruch S. Davidson