I am developing some code (in Delphi 6) where I draw a widestring on a canvas. This works fine for the drawing itself.
However I would like to enable customer to have variable pitch. I do this currently by calculating a certain spacing and moving this step for each glyph. Works for most, but some scripts have accent marks that suddenly become separated. Illustration below :
The top in illustration is my desired output. The disired is from pasting in MSWord, then adding spaces manually. The bottom in illustration is Word, adding letter spacing to a paragraph style.
Other software has same "simple way" of drawing, I tried InkScape as well.
Question is - can it be done using a Windows API ? Or is it a question of knowing which codepoints represent accent marks, then avoid space after these ? (the list should be this one I guess) The last can of course be done, but is like a little "hack" in my book.
For reference, I use the "DrawTextW" function, similar to example here
My code for output:
for d := 1 to Textlength do
begin
DrawTextW(
bmp.Canvas.Handle,
PWideChar(copy(TextW,d,1)),
1,
tmpArea,
DT_SINGLELINE or DT_NOCLIP);
// widest is width of widest char, for spacing
//
// this is where I could check if next is a nonspacing/combining
// to avoid adding space.
if dtoPitch in Options.Option then
tmpArea.Left := tmpArea.Left + widest;
end;