我目前正在编写PDF阅读器,但在显示带有嵌入字体的文本时遇到问题。
我认为Type 1字体的字体文件流中将包含带有信息的后记,该信息如何显示每个字形。
我试图对流进行扁平化编码,但是结果不可读,而且似乎毫无意义。
private static byte[] DecodeFlateDecodeData(byte[] data)
{
MemoryStream outputStream;
using (outputStream = new MemoryStream())
{
using (var compressedDataStream = new MemoryStream(data))
{
// Remove the first two bytes to skip the header (it isn't recognized by the DeflateStream class)
compressedDataStream.ReadByte();
compressedDataStream.ReadByte();
var deflateStream = new DeflateStream(compressedDataStream, CompressionMode.Decompress, true);
var decompressedBuffer = new byte[1024];
int read;
while ((read = deflateStream.Read(decompressedBuffer, 0, decompressedBuffer.Length)) != 0)
{
outputStream.Write(decompressedBuffer, 0, read);
}
outputStream.Flush();
compressedDataStream.Close();
}
return outputStream.ToArray();
}
}
来源:Extract embedded PDF fonts to an external ttf file using some utility or script
我期望这样的事情
%!FontType1-1.0: Symbol 001.003
%%CreationDate: Thu Apr 16 1987
%%VMusage: 27647 34029
% Copyright (c) 1985, 1987 Adobe Systems
% Incorporated. All rights reserved.
11 dict begin
/FontInfo 8 dict dup begin
/version (001.003) readonly def
/FullName (Symbol) readonly def
/FamilyName (Symbol) readonly def
/Weight (Medium) readonly def
/ItalicAngle 0 def
/isFixedPitch false def
/UnderlinePosition -98 def
/UnderlineThickness 54 def
end readonly def
/FontName /Symbol def
.
.
.
cleartomark
如第11页的类型1 reference所示。
还是我从根本上误解了这里的某些内容?
答案 0 :(得分:0)
如果原始文件是Type1C而不是Type1(子类型),则会发生这种情况。