Page 1 of 1

Change Font FACE In Table Cell

Posted: Mon Feb 07, 2011 7:05 pm
by DickBryant
This relates to the Change Font In Table Cell question - which had a relatively easy solution.

Now I would like to add the option to change the text in each table cell to the same BASE (typeface and any font effects - e.g. Arial, bold) but retain the rest of the 'font effects' relating to each text item in the cell. So if the item in the cell was Times New Roman, Underlined, red and 20 point, the resulting item would be Arial,bold,underlined,red and 20 point.

This would seem to require the creation of new styles as we step through the items. This was my approach to the previous question, but seemed to have problems whenever there was a mix of Unicode and non-unicode fonts and styles.

I know how to step through each item and check its style and how to check the base style. What I don't know is what steps to do to the item I'm processing so that for ARBITRARY styles and text I can achieve the desired result.

Dick

Posted: Mon Feb 07, 2011 7:07 pm
by Sergey Tkachenko
Do you use RichViewActions?

Posted: Mon Feb 07, 2011 7:13 pm
by DickBryant
Yes - for many operations.

Posted: Mon Feb 07, 2011 7:39 pm
by Sergey Tkachenko
You can use TrvActionFontEx.

This code applies 'Arial', bold to the selection:

Code: Select all

rvActionFontEx1.UserInterface := False;
rvActionFontEx1.Font.Name := 'Arial';
rvActionFontEx1.Font.Style := [fsBold];
rvActionFontEx1.ValidProperties := [rvfimFontName, rvfimBold];
rvActionFontEx1.ExecuteTarget(RichViewEdit1);
rvActionFontEx1.UserInterface := True;

Posted: Mon Feb 07, 2011 9:45 pm
by DickBryant
Perfect! Just the functionality I was looking for!

Thanks Very Much :-)

Posted: Mon Feb 07, 2011 11:02 pm
by DickBryant
Just a question to make sure I'm not doing something wrong. When I do the conversion on my test file to force its current 26 text styles to be one of three styles by using

FMain.RichViewEdit1.ApplyTextStyle([0,1 or 2]) on the selected columns the result seems fine and the number of styles after doing DeleteUnusedStyles does equal 3 - but the size of the file grows from 929,481 to 1,762,260.

Is this to be expected? I had rather thought the file size would decrease slightly because of the reduction in different text styles.

Posted: Tue Feb 08, 2011 7:21 am
by Sergey Tkachenko
File size may be increased if text is converted from ANSI to Unicode.
If this is not the case, please send me a file sample (before applying) by email.

Posted: Tue Feb 08, 2011 2:33 pm
by DickBryant
Will send a 'before and after' set of two files via e-mail. Probably you're right about ANSI to Unicode being the cause of the growth, since the styles that 'remain' after the conversion are Unicode styles.