设置RTF文档的字体样式 [英] Setting font style for RTF document

查看:1020
本文介绍了设置RTF文档的字体样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为这个文档设置文本字体样式时遇到了麻烦。我想要所有的测试是新的罗马大小10倍。我生成一个字体表,其中保存类型,它是我的文档的唯一类型。我希望所有的文本是新的罗马时代,但每当生成文档说,由于某种原因,它的损坏,但如果我没有设置字体样式文档出现在信使文本为默认,并没有损坏。 >

  {\fonttbl {\f1 \froman\fprq0\fcharset0 Times New Roman;} 
\par
Hi<#name#>
\par\par

欢迎来到纽约\par\par

\b新的iPad应用程序可用\ b0 \par
这些都是您在住宿期间所做的令人兴奋的事情。 \par \par
}


解决方案

你在上面的例子中缺少了很多格式。例如,从写字板或其他应用程序中保存一个非常简单的RTF文件(Word会输入太多的元数据),并查看所有缺少的内容。首先,这是最新的RTF规范,1.9.1 。第二,任何RTF文档必须 \rtf *开头, N * 其中 N 是RTF版本(当前为1)。在你的例子中你错过了这个。这是为什么它说文件损坏的原因之一。



第三,你在字体表中定义了一些东西,然后不使用定义, F1 这是RTF的老规范,1.6,但看看如何定义字体表。



还有很多其他的东西,但我认为你使用RTF就像你使用HTML或标签的东西。我会阅读规范,看看RTF是如何工作的。这是一个非常小的RTF文件:

  {\rtf1\ansi\ansicpg1252\uc1\htmautsp\ deff2 
{\fonttbl {\f0\fcharset0 Times New Roman;} {\f2\fcharset0 Tahoma;}}
{\colortbl\red0\green0\blue0; \red255\green255\blue255;}
\loch\hich\dbch\pard\plain\ltrpar\itap0 {\lang1033\fs16\f2\cf0 \\ \\ cf0 \ql
{\f2 {\ltrch这是对RTF的测试。} \ li0 \ri0\sa0\sb0\fi0\ql\par}}}


Having trouble setting text font style as Times New Roman for this document. I want all the test to be times new roman size 10. I generated a font table that holds the type and its the only type of my document. I want all the text to be times new roman but whenever the doc is generated it says its corrupted for some reason but if I don't set the font style the doc comes out in courier text as default and its not corrupted.

{\fonttbl{\f1\froman\fprq0\fcharset0 Times New Roman;}
\par
Hi <#name#>
\par\par

Welcome to New York \par\par

\b New iPad\'ae App Is Available \b0 \par 
These are all the exciting things you cna do during your stay. \par \par
}

解决方案

You're missing a lot of formatting in your example up there. For example, save a very simple RTF file from Wordpad or another application (Word puts in too much metadata) and see everything that you're missing.

First, Here is the most recent RTF Spec, 1.9.1. This will help you work through anything RTF related.

Second, any RTF document must start with \rtf*N* where N is the RTF Version (currently 1). You're missing this in your example. This is among one of the many reason why it is saying the file is corrupted.

Third, you define something in the font table and then don't use the definition, f1. This is an old spec for RTF, 1.6, but look at how the font table is defined.

There are many other things, but I think that you're using RTF like you would use HTML or something with tags. I would readup on the specification to see how RTF works. Here is a very small RTF document:

    {\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2
{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset0 Tahoma;}}
{\colortbl\red0\green0\blue0;\red255\green255\blue255;}
\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs16\f2\cf0 \cf0\ql
{\f2 {\ltrch This is a test of RTF.}\li0\ri0\sa0\sb0\fi0\ql\par}}}

这篇关于设置RTF文档的字体样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆