Solved

Default font settings RTF control

  • 16 October 2019
  • 2 replies
  • 112 views

To set a default font for the RTF control, are options available similar to those for HTML controls?

Edit: the options given for fields with an HTML control were:

  • [dbo].[sanitize_html] (function is available in the SF database only)
  • replace () in default or trigger logic (cumbersome in the case of RTF)

Crystal Reports is fed various RTF fields and curruntly for each line of text, four lines of hardcoded RTF formatting are applied in the SF.

The code that fills those RTF fields in the application is revised so that more of it is applicable for a shared set of fields.

I hope to get rid of all the RTF formatting in control procedures, as all text is formatted to a single font anyway. It just happens not to be Times New Roman, which is what the RTF control applies by default.

 

How to change the default font of RTF controls in the 2019.1 suite?

 

icon

Best answer by Erik Brink 25 October 2019, 17:13

View original

2 replies

In case someone stumbles upon this thread while trying to solve the same problem, we discussed a number of options:

  • leave RTF as-is;
  • create an additional plain text column for each RTF column, and migrate on a case-by-case basis (on inserts, only use plain text; on edits provide RTF as read only and plain text on a best effort basis, as a starting point for the user to copy/paste or correct by hand;
  • change the RTF columns to plain texst and strip all RTF control codes from the RTF them.

We went with the last option. It turned out to be quite a hassle, and near impossible to cleanly strip all RTF control codes.

The solution takes a list of control codes and a bit of logic to iterate through those codes. We defined a table which holds all control codes from the RTF specifications, additional codes and hacks, and an iteration number.

The logic builds replace statements based on the provided table, column and those codes.

The current version of the logic results in a mostly cleaned up plain text field. There are some stray numbers and characters.

The solution is intended for a single conversion; it is a brute force replacement of > 1000 iterations per field, as such it does not combine well with update triggers.

Userlevel 5
Badge +5

Hi Boudewijn,

 

I would say, the GUI shows the RTF inside the form based on the configured form editor font. When saving a typed value in the control to the database, no styling is saved except when the user styled a specific part of the text itself. 

This way the RTF text could be styled from the out-side, displaying it in a report for example. So the font you specified for the report itself will be applied to the non formatted text.

I don't think we provide any helpful functions yet to strip formatting from RTF text yet.

Regards,
Erik

Reply