Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The values you are getting are the semantical codes for the rich text format. The code for an entire Java based rtf parser would be to long to post here, but for reference there is a <a href="http://docs.oracle.com/javase/6/docs/api/javax/swing/text/rtf/RTFEditorKit.html" rel="nofollow">RTFEditorKit</a>0 in Swing and the <a href="http://tika.apache.org/1.4/api/" rel="nofollow">Tika</a> project at Apache has a RTFParser.</p> <p>RTF uses Control Words - they have opening and closing tags similar to other markup languages like: </p> <p><strong>EXAMPLE:</strong> \someAsciiTag1 ... \someAsciiTag1</p> <p>In the case of your question:</p> <p>Font style is right there in the font table or <strong>\fnttbl</strong> group - groups are encapsulated by braces{}. </p> <p>Font styles are ordered on an index like structure with <strong>\f*<em>index</em>*</strong> as the control code.</p> <p>Next code is <strong>\f*<em>font-family</em>*</strong> and so on. </p> <p>While global font styles are set at the top of the file in the \fnttbl certain style modifications can be made in the plain text section like html for instance: <strong>\fs20</strong> means font-size = 20 of whatever units are inherited further up the structure like css. </p> <p>While I could post Java code here to show you how to access a particular tag, <em>and will if you just need to access a few global elements</em>, but I don't know the scope of your whole project, if it is your goal to get ALL the style from your text I would really, very strongly encourage you to use one of the parsers available above as RTF is a very complex format.</p> <p>In case you doubt me on this here is a link to the Microsoft spec it's about 270 pages, the lightest weight implementation that I know of that is pretty close to spec complete is over 9000 lines of code, which is why you probably don't want to do it yourself.</p> <p><a href="http://www.microsoft.com/en-us/download/details.aspx?id=10725" rel="nofollow">http://www.microsoft.com/en-us/download/details.aspx?id=10725</a></p> <p><strong>EDIT:</strong></p> <p>I realized i didn't fully answer your second question in the previous answer</p> <p><strong>\b or \b1 = bold(true or 1)</strong> AND <strong>\b0 = bold(false or 0)</strong></p> <p><strong>\i or \i1 = italic(true or 1)</strong> AND <strong>\i0 = italic(false or 0)</strong></p> <p>FYI however, these are not the only ways to set style, rtf allows other less common programatic ways of setting these values. Also there are differences between ascii and unicode rtf codes, so once again use a parser.</p> <p>I have none the less included the font tag structure so if you want global info you can get it.</p> <pre><code>&lt;fonttbl&gt; '{' \fonttbl (&lt;fontinfo&gt; | ('{' &lt;fontinfo&gt; '}'))+ '}' &lt;fontinfo&gt; &lt;themefont&gt;? \fN &lt;fontfamily&gt; \fcharsetN? \fprq? &lt;panose&gt;? &lt;nontaggedname&gt;? &lt;fontemb&gt;? \cpgN? &lt;fontname&gt; &lt;fontaltname&gt;? ';' &lt;themefont&gt; \flomajor | \fhimajor | \fdbmajor | \fbimajor | \flominor | \fhiminor | \fdbminor | \fbiminor &lt;fontfamily&gt; \fnil | \froman | \fswiss | \fmodern | \fscript | \fdecor | \ftech | \fbidi &lt;panose&gt; '{\*' \panose &lt;data&gt; '}' &lt;nontaggedname&gt; '{\*' \fname #PCDATA ';}' &lt;fontname&gt; #PCDATA &lt;fontaltname&gt; '{\*' \falt #PCDATA '}' &lt;fontemb&gt; '{\*' \fontemb &lt;fonttype&gt; &lt;fontfname&gt;? &lt;data&gt;? '}' &lt;fonttype&gt; \ftnil | \fttruetype &lt;fontfname&gt; '{\*' \fontfile \cpgN? #PCDATA '}' </code></pre> <p>That is a list of font data tags and the general structure of the font data in line. Hope that helps. </p> <p><strong>EDIT: Follow Up</strong></p> <p>Well from look of it you have a nice chunk of Mac rtfd (the extra tags) </p> <blockquote> <p>cocoartf1038\cocoasubrtf360 - tells you it's mac encoded</p> </blockquote> <p>The first part gives the encoding The second gives two main font styles Verdana at f0, and Tahoma at f1 the third line tells you it's white rgb(255,255,255) and all. the fourth and fifth define tabs and pagination. the sixth (non-blank) say f0\i\fs34 = Verdana, Italic, size 34 \cf0 is black foreground color the seventh is Tahoma italic, bold is around module, while world is underlined and so on then repeats.</p> <p>There is a Java based rtf parser that recently added support for some of the mac custom tags you can find it <a href="https://github.com/tmyroadctfig/com.etranslate.tm.processing.rtf" rel="nofollow">on GitHub here</a> it should be fairly simple to wire-up the modules and parse any files you may need.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload