Preply — Study more efficiently by working with a personal tutor. Get 50% off.Affiliate

Wikipedia

Rich Text Format

The Rich Text Format (often abbreviated RTF) is a legacy proprietary document file format with published specification developed by Microsoft Corporation from 1987 until 2008 for cross-platform document interchange with Microsoft products. Prior to 2008, Microsoft published updated specifications for RTF with major revisions of Microsoft Word and Office versions. It is the default format of WordPad and TextEdit but both of those allow saving to ODF since 2009. Full office suites never used it as a default. Since Windows 11 removed WordPad in an update, it is no longer able to open them without additional software. Most word processors are able to read and write some versions of RTF. There are several different revisions of RTF specification; portability of files will depend on what version of RTF is being used. RTF should not be confused with enriched text or its predecessor Rich Text, or with IBM's RFT-DCA (Revisable Format Text-Document Content Architecture), as these are different specifications. RTF is not a markup language. It is not considered human-readable and was never meant to be edited in a text editor. Most RTF files only contain plain text in ASCII encoding because non-ASCII letters are represented by escape sequences and binary data is encoded in Base16. The specification mentions \binN to insert binary data directly but except for possibly some historical exceptions all implementations write binary data in Base16 and the \binN embedding feature has mainly been abused by malicious software. In the context of RTF binary data refers to images, fonts and OLE objects.

History Richard Brodie, Charles Simonyi, and David Luebbert, members of the Microsoft Word development team, developed the original RTF in the middle to late 1980s. The first RTF reader and writer shipped in 1987 as part of Microsoft Word 3.0 for Macintosh, which implemented the RTF version 1.0 specification. All subsequent releases of Microsoft Word for Macintosh, as well as all Windows versions, can read and write in RTF format. Microsoft maintains RTF. The final version was 1.9.1 in 2008, which implemented features of Office 2007. Microsoft has discontinued enhancements to the RTF specification, so features new to Word 2010 or a later version will not save properly to RTF. Microsoft anticipates no further updates to RTF, but has stated willingness to consider editorial and other non-substantive modifications of the RTF Specification during an associated ISO/IEC 29500 balloting period. RTF files were used to produce Windows Help files, though these have since been superseded by Microsoft Compiled HTML Help files. From the beginning, RTF has supported Microsoft OLE embedded objects and Macintosh Edition Manager subscriber objects.

Code syntax RTF is programmed using groups, a backslash, a control word and a delimiter. Groups are contained within curly braces ({}) and indicate which attributes should be applied to certain text. The backslash (\) introduces a control word, which is a specifically programmed command for RTF. Control words can have certain states in which they are active. These states are represented by numbers. For example,

\b0 indicates that the Bold text is off \b1 indicates that the Bold text is on \i0 indicates that the Italic text is off \i1 indicates that the Italic text is on \ul0 indicates that the Underline text is off \ul1 indicates that the Underline text is on \sub0 indicates that the Subscript text is off \sub1 indicates that the Subscript text is on \superscript0 indicates that the Superscript text is off \superscript1 indicates that the Superscript text is on A delimiter is one of three things:

A space A digit or hyphen (e.g. -23, 23, 275) A character other than a digit or letter (e.g. \, /, }) As an example, the following RTF code

would be rendered as follows:

This is some bold text.

Character encoding Escape sequences are used to encode code units outside the 7-bit ASCII range. The two character escapes are code page escapes and, starting with RTF 1.5, Unicode escapes. In a code page escape, two hexadecimal digits following a backslash and typewriter apostrophe denote a character taken from a Windows code page. For example, if the code page is set to Windows-1256, the sequence \'c8 will encode the Arabic letter bāʼ ب. It is also possible to specify a "Character Set" in the preamble of the RTF document and associate it to a header. For example, the preamble has the text \f3\fnil\fcharset128, then, in the body of the document, the text \f3\'bd\'f0 will represent the code point 0xbd 0xf0 from the Character Set 128 (which corresponds to the Shift-JIS code page), which encodes "金".

For a Unicode escape, the control word \u is used, followed by a 16-bit signed integer which corresponds to the Unicode UTF-16 code unit number. For the benefit of programs without Unicode support, this must be followed by the nearest representation of this character in the specified code page. For example, \u1576? would give the Arabic letter bāʼ ب, but indicates that older programs which do not support Unicode should render it as a question mark instead. The control word \uc0 can be used to indicate that subsequent Unicode escape sequences within the current group do not specify the substitution character. Until RTF specification version 1.5 release in 1997, RTF only handled 7-bit characters directly and 8-bit characters encoded as hexadecimal (using \'xx). Since RTF 1.5, however, RTF control words generally accept signed 16-bit numbers as arguments. Unicode values greater than 32767 must be expressed as negative numbers. If a Unicode character is outside BMP, it is encoded with a surrogate pair. Support for Unicode was made due to text handling changes in Microsoft Word – Microsoft Word 97 is a partially Unicode-enabled application and it handles text using the 16-bit Unicode character encoding scheme. Microsoft Word 2000 and later versions are Unicode-enabled applications that handle text using the 16-bit Unicode character encoding scheme. Text written using only ASCII characters (especially English) can be deciphered in a plain text editor.

Features Most word processors support RTF format importing or exporting some version of RTF but don't fully support it. Unknown RTF control words are typically ignored. This means that not only the appearance but also annotations, footnotes, and tables or metadata such as author or title can silently disappear without a trace. There are several consciously designed or accidentally born RTF dialects. Font and margin defaults, style presets and other functions vary according to program defaults. There may also be incompatibilities between different RTF versions, e.g. between RTF 1.0 1987 and later specifications, or between RTF 1.0–1.4 and RTF 1.5+ in use of Unicode characters. And though RTF supports metadata like title and author, not all implementations support this.

Objects Microsoft Object Linking and Embedding (OLE) objects and Macintosh Edition Manager subscriber objects allow embedding of other files inside the RTF, such as tables or charts from spreadsheet application. However, since these objects are not widely supported in programs for viewing or editing RTF files, they also limit RTF's interoperability. If software that understands a particular OLE object is not available, the object is displayed using a picture of the object which is embedded along with it.

Pictures RTF supports inclusion of JPEG, PNG, Enhanced Metafile (EMF), Windows Metafile (WMF), Apple PICT, Windows device-dependent bitmap, Windows device-independent bitmap and OS/2 Metafile picture types. Not all of these picture types are supported in all RTF readers. Some RTF writers like Microsoft Word include the same picture in two different picture types in one RTF file: one supported picture type to display, and one uncompressed WMF copy of the original picture for compatibility with old versions of Word and Wordpad which increases the file size.

Fonts RTF supports embedding of fonts used in the document, but this feature is not widely supported in software implementations. RTF also supports generic font family names used for font substitution: roman (serif), Swiss (sans-serif), modern (monospace), script, decorative and technical. This feature is not widely supported either.

Annotations Since RTF 1.0, the RTF specification has supported document annotations/comments. The RTF 1.7 specification defined some new features for annotations, including the date stamp (there was previously only "time stamp") and parents of annotations. When a RTF document with annotations is opened in an application that does not support RTF annotations, the annotations are not shown. Similarly, when a document with annotations is saved as RTF in an application that does not support RTF annotations, the annotations are not preserved in the RTF file. Some implementations, like Abiword (since version 2.8) and IBM Lotus Symphony (up to version 1.3), may hide annotations by default or require some user action to display them. The RTF specification also supports footnotes, which are widely supported in RTF implementations (e.g. in OpenOffice.org, Abiword, KWord, Ted, but not in Wordpad). Endnotes are implemented as a variation on footnotes, so applications that support footnotes but not endnotes will render an endnote as a footnote.

Drawing objects The RTF 1.2 specification defined use of drawing objects, known as shapes, such as rectangles, ellipses, lines, arrows and polygons. The RTF 1.5 specification introduced many new control words for drawing objects.

Known vulnerabilities While RTF does not come with its own macro language and despite old claims RTF is safe from viruses, RTF is vulnerable to a wide range of attacks. For example template injection attacks using the native template *\template control word or OLE exploits which make it vulnerable to many Microsoft Office exploits if available. Some OLE functionality is available without MS Office too. Microsoft Word will also open other formats renamed to a filename with a .rtf extension and run any contained macros as usual. While WordPad never supported these advanced features, it no longer ships with Windows 11 and old versions of WordPad have been vulnerable to remote code execution exploits when opening RTF files patched in 2017. There are also more recent vulnerabilities. One exploit attacking a vulnerability was patched in Microsoft Word in April 2015. Since 2014 there have been malware RTF files embedding OpenXML exploits.

Implementations

Each RTF implementation usually implements only some versions or subsets of the RTF specification. Many of the available RTF converters cannot understand all new features in the latest RTF specifications. The WordPad editor in Microsoft Windows creates RTF files by default. It once defaulted to the Microsoft Word 6.0 file format, but write support for Word documents (.doc) was dropped in a security update. Read support was also dropped in Windows 7. WordPad does not support some RTF features, such as headers and footers. However, WordPad can read and save many RTF features that it cannot create, including tables, strikeout, superscript, subscript, "extra" colors, text background colors, numbered lists, right or left indent, quasi-hypertext and URL linking, and various line spacings. RTF is also the storage format for "rich text controls" in MS Windows APIs. The default text editor for macOS, TextEdit, can also view, edit and save RTF files as well as RTFD files, and uses the format as its default. As of July 2009, TextEdit has limited ability to edit RTF document margins. Much older Mac word processing application programs such as MacWrite and WriteNow had the same RTF abilities as TextEdit has. The following free and open-source word processors attempt to work with Microsoft's RTF file format, see the criticism paragraph below. AbiWord, Apache OpenOffice, Bean, Calligra, Collabora Online and LibreOffice. Microsoft Outlook and Microsoft Exchange Server support RTF in emails but today Microsoft recommends using HTML instead. Scrivener uses individual RTF files for all the text files that make up a given "project". SIL International's freeware application for developing and publishing dictionaries uses RTF as its most common form of document output. RTF files produced by Toolbox are designed to be used in Microsoft Word, but can also be used by other RTF-aware word processors. RTF is supported by many e-readers.

Libraries and converters Pandoc is a free and open-source document converter that can read a variety of file formats and convert it into a large number of output formats. Pandoc supports both reading from and writing to RTF. It can be used, for example, to convert from Markdown to RTF, or from RTF to HTML. GNU UnRTF is an open-source program to convert RTF into HTML, LaTeX, troff macros and other formats. pyth is a Python library to create and convert documents in RTF, XHTML and PDF format. rtf.js is a JavaScript based library to render RTF documents in HTML. The macOS command line tool textutil can convert files between rtf, rtfd, text, doc, docx, wordml, odt and webarchive formats. The editor Ted can also convert RTF files to HTML and PS format. The open-source script rtf2xml can partially convert RTF to XML.

Criticism The Rich Text Format was the standard file format for text-based documents in applications developed for Microsoft Windows. Microsoft did not initially make the RTF specification publicly available, making it difficult for competitors to develop document conversion features in their applications. Because Microsoft's developers had access to the specification, Microsoft's applications had better compatibility with the format. Also, each time Microsoft changed the RTF specification, Microsoft's own applications had a lead in time-to-market, because competitors had to redevelop their applications after studying the newer version of the format. Novell alleged that Microsoft's practices were anticompetitive in its 2004 antitrust complaint against Microsoft.

Limitations Unicode encoding through \uN is only supported since Vista. In prior versions of Windows for many languages text processors will show only question marks when opening newer documents because the entire text only has ? as fallback character with no sensible fallback representation. Older code pages are explicitly allowed to be mapped wrong by the specification Everything except Word only implements a fraction of RTF. The proclaimed goal of interoperability was not achieved at all. Other formats like OpenDocument offer much better interoperability today. Embedded images (or other binary data) are at least twice the file size of the original file due to being encoded in Base16 and even larger if an extra WMF fallback image is created. Every non-ASCII letter in RTF uses multiple times as many bytes as in UTF-8 Unlike other document formats, RTF is not compressed

See also Rich Text Format Directory (.rtfd file type) Enriched text format Document file format Revisable-Form Text (RFT), part of IBM's Document Content Architecture (DCA) TNEF, Transport Neutral Encapsulation Format, the Microsoft Outlook default message format

References

External links RTF 1.9.1 specification Archived 2019-07-08 at the Wayback Machine, March 2008, from Microsoft RTF 1.9.1 specification, March 2008, via earlier download from Microsoft and Internet Archive RTF 1.8 specification, April 2004, from ysagnier.free.fr RTF 1.6 specification, May 1999, from Microsoft RTF 1.5 specification, April 1997, from biblioscape.com RTF 1.0, 1.2, 1.3, 1.5 and 1.7 specifications Archived 2005-10-27 at the Wayback Machine, from the RTF Tools open-source project RTF 1.0 specification, June 1992, from the latex2rtf open-source project RTF Pocket Guide, book homepage RTF Character Set to Code Page, last edited June 2017

Tags

  • Computer file formats
  • Office document file formats
  • Technical communication
  • Text file formats