Hi all
I need to read a program in c/c++ in linux which shall read rtf file text and then informs me the information about the fonts properties of the text in rtf file. Can anyone tell me how to do that.. does any library exists for this that I may use.
Also can any one tell me that in linux which library is common or useful to work with fonts

Recommended Answers

All 5 Replies

Well RTF files are just HTML, only different.

That is, a text file which contains the presentation information as well as the content, in an easy (relatively speaking) text file.

Start by putting "rtf file format" in your favourite search engine.

here are a few utilities in bsd ports.
>cat /usr/ports/textproc/rtfreader/pkg-descr
RTF is the Microsoft Richtext Format, a more portable, mostly-ASCII
formatting language that is exported by word processors like MS Word.
These files generally have the extension .rtf, but occassionally have
.doc extensions as well. This parser is from the Microsoft spec,
"ported" to Unix systems.
WWW: http://www.fiction.net/blong/programs/#rtf

>cat /usr/ports/textproc/rtf2html/pkg-descr
A simple rtf2html converter. If no file is specified rtf2html reads from
standard input.
- ehaupt

>cat /usr/ports/textproc/rtfx/pkg-descr
rtfx converts RTF files into a generic XML format. It majors on keeping
meta data like style names, etc... rather than every bit of formatting.
This makes it handy for converting RTF documents into a custom XML
format (using XSL or an additional processing step).
RTF features supported: page breaks, section breaks, style names,
lists (various types), tables, footnotes, info block, bold, italic,
underline, super/sub script, hidden text, strike out, text color, fonts.
Author: Nielsen <nielsen at memberwebs.com>
WWW: http://memberwebs.com/nielsen/software/rtfx/

>cat /usr/ports/textproc/unrtf/pkg-descr
UnRTF is a command-line converter from RTF (Rich Text) to HTML, LaTeX,
PostScript, plain text, and text with VT100 codes. When converting to HTML, it
supports tables, fonts, embedded images, hyperlinks, paragraph alignment, and
more. All other conversions are "alpha" i.e. being newly developed.
WWW: http://www.gnu.org/software/unrtf/unrtf.html

>cat /usr/ports/print/rtf2latex/pkg-descr
rtf2LaTeX is a filter built on Paul DuBois' RTF reader that converts
RTF (Microsoft's Rich Text Format) into LaTeX.
rtf2LaTeX expends a good deal of effort in an attempt to make the resulting
LaTeX maintainable and modifiable.

Ok I understand now about the rich text stuff.
Now one more thing that I am feeling I need to know is about the Font Metrics. In windows we can get Font Metrics information through the device context object and other Win API functions.
But In Linux how can I get Font Metrics. Also the Font Metrics Attributes will be same or different on windows and Linux. I mean character size, spacing, height, width etc of the given font (say any ttf) will be same on both OS or there can be difference.
During searching I have found QFontMetrics class of QT library. I am reading it now but want to know if any body has used it before or may be familiar with this class may tell me if I am reading right class. Also there is a Free Type library .. any one know about this library. I havnt explored it yet but if someone know this library then I ask him to le me know if this is more suitable library to use for Font Metrics on Linux.

Also I need to know that does Linux have its own native API's for this purpose or it depends on these libraries.

Windows was designed as a 'do everything' GUI, so you automatically get things like GetFontMetrics().

X11 is an entirely different beast. I don't know of any standard libraries for stuff you want. If you are willing to use QT then I highly recommend it. It is a powerful system for this kind of stuff. I recommend you to the QT Online Reference Documentation. It is very complete and is chuck-full of examples.

Otherwise you are going to have to go pretty low-level.

Hope this helps.

Ok I understand what you are saying... I will try to focus on QT now and if I have any other ambiguity I ll come back here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.