General TRichView support forum. Please post your questions here
w2m
Posts: 114 Joined: Thu Sep 29, 2005 2:43 am
Contact:
Post
by w2m » Sat May 04, 2013 7:55 pm
I try to set the initial font for load pascal (*.pas} file as text but after loading font is not correct. How to load .pas file with 'Courier New' Font size = 10?
Code: Select all
// set the initial font
iFontInfo := TFontInfo.Create(nil);
try
iFontInfo.FontName := 'Courier New';
iFontInfo.Size := 10;
iStyleNo := RichViewEdit.Style.TextStyles.FindSuchStyleEX(0, iFontInfo,
RVAllFontInfoProperties);
if iStyleNo < 0 then
begin
RichViewEdit.Style.TextStyles.Add;
iStyleNo := RichViewEdit.Style.TextStyles.Count - 1;
RichViewEdit.Style.TextStyles[iStyleNo].Assign(iFontInfo);
RichViewEdit.Style.TextStyles[iStyleNo].Standard := False;
end;
finally
iFontInfo.Free;
end;
w2m
Posts: 114 Joined: Thu Sep 29, 2005 2:43 am
Contact:
Post
by w2m » Sat May 04, 2013 8:03 pm
This should have been posted in the private forum because am a registered user. I do not know why it appeared here instead?
Sergey Tkachenko
Site Admin
Posts: 17564 Joined: Sat Aug 27, 2005 10:28 am
Contact:
Post
by Sergey Tkachenko » Sun May 05, 2013 7:58 am
This code must work, if you pass iStyleNo variable as StyleNo parameter to RichViewEdit.LoadText.
This is a shorter code producing the same result (requires TRichView 14.x):
Code: Select all
// set the initial font
iFontInfo := TFontInfo.Create(nil);
try
iFontInfo.FontName := 'Courier New';
iFontInfo.Size := 10;
iStyleNo := RichViewEdit.Style.FindTextStyle(iFontInfo);
finally
iFontInfo.Free;
end;
PS: I can move this topic to the private section, but it does not contain anything specific to the newest full version, so it may be discussed here.