Drop Caps (TRVLabel)
Posted: Wed Mar 15, 2023 7:58 pm
Hi Sergey,
I've been reworking my code for drop caps. I'm using some code from the forum I found some time ago.
I ran into a problem where the drop cap in the rve looks OK, but in the print preview the vertical position is different. I've been using these lines to fix it
For the regular rve, I do this:
But for the print preview I do this:
I don't like using "magic numbers" (in this case plus and minus "4"). I've tried it without that but if I don't set the OuterVSpacing it doesn't position correctly. I've tried various combinations of RemoveInternalLeading and RemoveSpaceBelow and those didn't help.
I'll attach an example rvf file. Put it into the RichViewActionsTest demo and it should look like this:
Then, do a print preview and it looks like this:
I want the drop cap position in the print preview to match the regular rve. My current code is working but I have a feeling there may be a much better way.
Thanks Sergey
Stan
I've been reworking my code for drop caps. I'm using some code from the forum I found some time ago.
Code: Select all
Lii := TRVLabelItemInfo.Create(rv.RVData);
FI := TFontInfo.Create(nil);
try
FI.FontName := rv.Style.TextStyles[0].FontName;
FI.Size := (rv.Style.TextStyles[0].Size * 3);
FI.StyleName := 'InitCap';
FI.Standard := False;
Lii.VAlign := rvvaLeft ;
Lii.TextStyleNo := rv.Style.FindTextStyle(FI);
Lii.Text := rv.GetSelTextW; //Ch;
Lii.OuterVSpacing := -4;
Lii.SetExtraIntProperty( rvepOuterVSpacing , Lii.OuterVSpacing );
rv.InsertItem('', Lii);
For the regular rve, I do this:
Code: Select all
TRVLabelItemInfo(rv.RVData.GetItem(i)).OuterVSpacing := -4;
Code: Select all
TRVLabelItemInfo(rv.RVData.GetItem(i)).OuterVSpacing := 4;
I'll attach an example rvf file. Put it into the RichViewActionsTest demo and it should look like this:
Then, do a print preview and it looks like this:
I want the drop cap position in the print preview to match the regular rve. My current code is working but I have a feeling there may be a much better way.
Thanks Sergey
Stan