I am looking for an algorithm to wrap text within a non-rectangular shape, preferably based on the Knuth and Plass algorithm. The hardest part of this is that the lines may
Let's say each letter has a specific size(width and height, in this case we probably only care about width because all letters have the same height). Then we need the following:
Now that we have the size of each strip of the image, let's say we have this (i'm using arbitary unit for width):
[_________] [__________] <-- 10 width (5 each)
[__________________] <-- 9 width
[_____________] <-- 7 width
[_______] <-- 5 width
[___] <-- 3 width
[_] <-- 2 width
EDIT: Just realized how ugly the heart is, my bad.
Now we need the size of each word, and insert them sequentially. Each block has x width, and each word object has y width. If y width > x width, we move to the next line and check there
considering we already have widths
while(image.hasNextChunk()){
currentChunk = image.nextChunk();
if(currentWord.width < currentChunk.width) //insert here and then change currentWord to nextWord
...
}
I think this is what you want, but I'm not completely sure. Let me know if this helped! :)