I am creating an app that will convert input files to rtf. I am trying to figure out how to define a font table in such a way that if a font is NOT selected by the user of my app the RTF document will open in whatever application's default font. In other words, if a font is not defined, and the RTF is opened in Word (for example) the document will appear in whatever Word's default "normal" font is. In my case, my default Normal font in Word is Calibri. However, no matter what I do to try NOT to set a font in the RTF document, it opens with Times New Roman font.
Does anyone have any idea how to code RTF so that it defers to the app that opens the RTF file to set the default font?
Thanks (I don't know where else to go for an answer).
RTF output help
Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 8474
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: RTF output help
I just did a quick test, and it seems that LC's RTF output will include font assignment for each effective font of text runs and the field itself.
However, in a quick test I found that I could delete the font assignments in the beginning of the RTF file, and when opening in a word processor it uses the app's default font.
In my example file, the first lines of the RTF is:
Given a font name of "dejavu serif", removing that gives us:
With that, the style run "f0" no longer has a font specifier, so runs using that style make no font assignment.
So if you know your font names you should be able to replace those with empty in the opening style def portion of the file to remove them.
However, in a quick test I found that I could delete the font assignments in the beginning of the RTF file, and when opening in a word processor it uses the app's default font.
In my example file, the first lines of the RTF is:
Code: Select all
{\rtf1\ansi {\fonttbl{\f0\fnil \fcharset0 dejavu serif;}}
Code: Select all
{\rtf1\ansi {\fonttbl{\f0\fnil \fcharset0;}}
So if you know your font names you should be able to replace those with empty in the opening style def portion of the file to remove them.
Richard Gaskin
LiveCode Community Liaison
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode Community Liaison
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn