procedure TForm1.TheMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var Fsub,tmp:TFont;
procedure PintaFormula(const str:string; Fnormal, Fsubindice:TFont; C:Tcanvas);
var Xpixel, i:Integer;
begin
Xpixel := 10;
for i:=1 to Length(str) do
begin
if str[i] in ['0'..'9'] then
begin
C.Font.Assign(Fsubindice); C.TextOut(Xpixel,30,str[i]); end
else
begin
C.Font.Assign(Fnormal); C.TextOut(Xpixel,20,str[i]); end;
Xpixel := Xpixel + C.TextWidth(str[i]); end;
end;
begin
Fsub := TFont.Create; tmp := TFont.Create; tmp.Assign(PaintBox1.Canvas.Font);
PaintBox1.Font.Size:= 12;
Fsub.Assign(PaintBox1.Font);
Fsub.Size:= Fsub.Size -2;
PintaFormula('K2SO4',tmp,Fsub,PaintBox1.Canvas);
tmp.Free; Fsub.Free;
end;