blank.rtf - empty -so I could see the "plain" header line
{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\froman Times New Roman;}}{\colortbl\red0\green0\blue0;}\deflang1033\pard\plain\f2\fs20 \par }
plaintext.rtf - too see how having any text was handled
{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\froman Times New Roman;}}{\colortbl\red0\green0\blue0;}\deflang1033\pard\plain\f2\fs20 this is plain text
\par }
difffont.rtf - different font, same size, same text
{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\froman Times New Roman;}{\f3\fswiss\fprq2 Arial;}}{\colortbl\red0\green0\blue0;}\deflang1033\pard\plain\f3\fs20 plain text different font\plain\f2\fs20
\par }
diffsize.rtf - text set to 18 point in the default font
{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\froman Times New Roman;}}{\colortbl\red0\green0\blue0;}\deflang1033\pard\plain\f2\fs36 plain text different font\plain\f2\fs20
\par }
diffcolor.rtf - etc. my favourite of course - blue.
{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\froman Times New Roman;}}{\colortbl\red0\green0\blue0;\red0\green0\blue255;}\deflang1033\pard\plain\f2\fs20\cf1 plain text different font\plain\f2\fs20
\par }
Looking at the resultant codes you see how the RTF stream is formatted. It comprises a:
- INITIAL HEADER (\rtf1\.....)
- FONTTABLE (\f0\fswiss...)
- COLORTABLE (\colortbl)
- MISCELLANEOUS
- DEFAULT FORMAT (\pard....)
- BODY OF THE FILE.
As a result of that I rewrote this code:
WriteToBuffer(''''{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS
SansSerif;}{\f1\froman\fcharset2 Symbol;}{\f2\fmodern Courier New;}}'''' #13 #10);
WriteToBuffer(''''{\colortbl\red0\green0\blue0;}'''' #13 #10);
WriteToBuffer(''''\deflang1033\pard\plain\f2\fs20 '''');
to become:
WriteToBuffer(''''{\rtf1\ansi\deff0\deftab720'''');
WriteFontTable;
WriteColorTable;
WriteToBuffer(''''\deflang1033\pard\plain\f0\fs20 '''');
The procedures Write[Font,Color]Table basically creates a table of fonts/colors we can reference later on. Each Font and Color type is stored by index in a TList internally. It acts as a lookup tables - by matching the Font name or Color value we can find the [num] to code into the RTF stream at the required moment:
\f[num] = the index of which Font you want to use, as pre-set in the "on the fly" font table
\fs[num] = point size - (for example 20 = 10point)
\cf[num] = the index of which Color to use, as preset in "on the fly" color table
\cb[num] = which background color to use - (ignored in RichEdit version 2.0)
PROBLEM#2 Crashes in long comments or text (existing problem)
There is a bug in ScanForRtf. Can you see it?
begin
FStrBuffSize:= FStrBuffSize 1024;
ReAllocMem(FStrBuff, FStrBuffSize);
FStrBuffEnd:= FStrBuff 1023;
end; { AllocStrBuff }
procedure TPasConversion.ScanForRtf;
var
i: Integer;
begin
RunStr:= FStrBuff;
FStrBuffEnd:= FStrBuff 1023;
for i:=1 to TokenLen do
begin
Case TokenStr[i] of
''''\'''', ''''{'''', ''''}'''':
begin
RunStr^:= ''''\'''';
inc(RunStr);
end
end;
if RunStr >= FStrBuffEnd then AllocStrBuff;
文章整理:西部数码--专业提供域名注册、虚拟主机服务
RunStr^:= TokenStr[i];
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
网站运营
建站经验
策划盈利
搜索优化
网站推广
免费资源
网站联盟
联盟新闻
联盟介绍
联盟点评
网赚技巧
行业资讯
业界动态
搜索引擎
网络游戏
门户动态
电子商务
广告传媒
网络编程
Asp.Net编程
Asp编程
Php编程
Xml编程
Access
Mssql
Mysql
其它
服务器技术
Web服务器
Ftp服务器
Mail服务器
Dns服务器
安全防护
软件技巧
其它软件
Word
Excel
Powerpoint
Ghost
Vista
QQ空间
QQ
FlashGet
迅雷
Internet Explorer
网页制作
FrontPages
Dreamweaver
Javascript
css
photoshop
fireworks
Flash
程序设计
Java技术
C/C++
VB
delphi
网络知识
网络协议
网络安全
网络管理
组网方案
Cisco技术
操作系统
Win2000
WinXP
Win2003
Mac OS
Linux
FreeBSD




