PDA

View Full Version : Problem in appending text in multiple fonts


Unregistered
November 1, 2002, 07:11:16
hello!!

I am using Delphi 5 and the textcontrol in the designing of an editor. I am reading the font information along with the words and am then trying to write these words along with their font to the textcontrol(Appending the words to the existing content in the textcontrol) .I want the textcontrol to retain the font information too. But this is not happening. I am attaching a sample of this code below please let me know how this problem can be solved.

The sample of the code :

**********
wrd:='';
pos:='';
newtext:='';
counter:=0;
richedit1.formatselection:=true;
setlength(data,length(richedit1.text));
data:=richedit1.text;
for i:=1 to length(data)do
begin
richedit1.selstart:=i;
richedit1.sellength:=1;
richedit1.seltext;
k:=ord(data);
ch:=data[i];
ReversedISCIIstring:='';
if ( k > 32) then
begin
wrd:=wrd + data[i];
if (k>128)then
fontis:= 'GurmukhiLys 020'
else
fontis:= 'Arial';
end
else
begin
counter := counter + 1;
wrd:=wrd + data[i];
pos:= ISCIItoGur(wrd);
pos1:=convert_tippi_bindi(pos);
newword[counter].ntext:= pos1;
newword[counter].nfont:=fontis;
wrd:='';
fontwrd:='';
end;
end;
richedit1.text:='';
startposition:=0;
for j := 1 to counter do
begin
richedit1.formatselection:=true;
wordis:= newword[j].ntext;
richedit1.text:= richedit1.text + newword[j].ntext;
richedit1.selstart:=startposition;
richedit1.sellength:= length(wordis)-1;
richedit1.seltext;
richedit1.fontname:= newword[j].nfont;
startposition:= startposition + length(wordis);

end;
showmessage(richedit1.text);


**********

In this sample the textcontrol is named Richedit1 and the word and its font information is getting stored in an array of records(newword).

Thanks ,
Ramneet.


[I]This message was originally posted by Ramneet Mavi in the old TX Text Control Support Forum.