* Moved enconding files into system/data/PDF Writer directory,
as correctly pointed out by Ingo these are no setting files. * Use find_directory() here and in places marked with TODOs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37772 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f8f48f3d14
commit
6f0d416957
@ -590,7 +590,7 @@ AddDirectoryToHaikuImage home config settings printers "Save as PDF"
|
||||
: home-config-settings-printers-save-as-pdf.rdef ;
|
||||
|
||||
# PDF Writer enconding files
|
||||
CopyDirectoryToHaikuImage common settings
|
||||
CopyDirectoryToHaikuImage system data
|
||||
: [ FDirName $(HAIKU_TOP) src add-ons print drivers pdf encoding ]
|
||||
: "PDF Writer" : -x .svn -x Jamfile ;
|
||||
|
||||
|
@ -35,6 +35,12 @@
|
||||
#include "Report.h"
|
||||
|
||||
|
||||
static const char* kEncodingDirectory = "PDF Writer";
|
||||
static const char* kSettingsDirectory = "PDF Writer";
|
||||
static const char* kBookmarksDirectory = "bookmarks";
|
||||
static const char* kCrossReferencesDirectory = "xrefs";
|
||||
|
||||
|
||||
PDFWriter::PDFWriter()
|
||||
:
|
||||
PrinterDriver(),
|
||||
@ -331,7 +337,7 @@ PDFWriter::InitWriter()
|
||||
if (setCreator && JobFile()->ReadAttr("_spool/MimeType", B_STRING_TYPE, 0,
|
||||
buffer, sizeof(buffer))) {
|
||||
SetAttribute("Creator", buffer);
|
||||
ToPDFUnicode(buffer, s); PDF_set_info(fPdf, "Creator", s.String());
|
||||
ToPDFUnicode(buffer, s); PDF_set_info(fPdf, "Creator", s.String());
|
||||
}
|
||||
|
||||
int32 compression;
|
||||
@ -344,33 +350,12 @@ PDFWriter::InitWriter()
|
||||
PDF_set_parameter(fPdf, "fontwarning", "false");
|
||||
// PDF_set_parameter(fPdf, "native-unicode", "true");
|
||||
|
||||
REPORT(kDebug, 0, "Start of fonts declaration:");
|
||||
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"t1enc0==/boot/common/settings/PDF Writer/t1enc0.enc");
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"t1enc1==/boot/common/settings/PDF Writer/t1enc1.enc");
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"t1enc2==/boot/common/settings/PDF Writer/t1enc2.enc");
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"t1enc3==/boot/common/settings/PDF Writer/t1enc3.enc");
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"t1enc4==/boot/common/settings/PDF Writer/t1enc4.enc");
|
||||
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"ttenc0==/boot/common/settings/PDF Writer/ttenc0.cpg");
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"ttenc1==/boot/common/settings/PDF Writer/ttenc1.cpg");
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"ttenc2==/boot/common/settings/PDF Writer/ttenc2.cpg");
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"ttenc3==/boot/common/settings/PDF Writer/ttenc3.cpg");
|
||||
PDF_set_parameter(fPdf, "Encoding",
|
||||
"ttenc4==/boot/common/settings/PDF Writer/ttenc4.cpg");
|
||||
REPORT(kDebug, 0, "Start of declarations:");
|
||||
|
||||
DeclareEncodingFiles();
|
||||
DeclareFonts();
|
||||
|
||||
REPORT(kDebug, fPage, "End of fonts declaration.");
|
||||
REPORT(kDebug, fPage, "End of declarations.");
|
||||
|
||||
// Links
|
||||
float width;
|
||||
@ -416,6 +401,40 @@ PDFWriter::InitWriter()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PDFWriter::DeclareEncodingFiles()
|
||||
{
|
||||
BPath prefix;
|
||||
if (find_directory(B_SYSTEM_DATA_DIRECTORY, &prefix) != B_OK)
|
||||
return;
|
||||
|
||||
DeclareEncodingFile(&prefix, "t1enc0", "t1enc0.enc");
|
||||
DeclareEncodingFile(&prefix, "t1enc1", "t1enc1.enc");
|
||||
DeclareEncodingFile(&prefix, "t1enc2", "t1enc2.enc");
|
||||
DeclareEncodingFile(&prefix, "t1enc3", "t1enc3.enc");
|
||||
DeclareEncodingFile(&prefix, "t1enc4", "t1enc4.enc");
|
||||
|
||||
DeclareEncodingFile(&prefix, "ttenc0", "ttenc0.cpg");
|
||||
DeclareEncodingFile(&prefix, "ttenc1", "ttenc1.cpg");
|
||||
DeclareEncodingFile(&prefix, "ttenc2", "ttenc2.cpg");
|
||||
DeclareEncodingFile(&prefix, "ttenc3", "ttenc3.cpg");
|
||||
DeclareEncodingFile(&prefix, "ttenc4", "ttenc4.cpg");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PDFWriter::DeclareEncodingFile(BPath* prefix, const char* id, const char* name)
|
||||
{
|
||||
BPath path(*prefix);
|
||||
path.Append(kEncodingDirectory);
|
||||
path.Append(name);
|
||||
|
||||
BString encodingDeclaration;
|
||||
encodingDeclaration << id << "==" << path.Path();
|
||||
PDF_set_parameter(fPdf, "Encoding", encodingDeclaration.String());
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
PDFWriter::DeclareFonts()
|
||||
{
|
||||
@ -448,26 +467,32 @@ PDFWriter::DeclareFonts()
|
||||
bool
|
||||
PDFWriter::LoadBookmarkDefinitions(const char* name)
|
||||
{
|
||||
// TODO: use B_USER_SETTINGS_DIRECTORY instead of hard coded constant
|
||||
BString path("/boot/home/config/settings/PDF Writer/bookmarks/");
|
||||
path.Append(name);
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK)
|
||||
return false;
|
||||
|
||||
return fBookmark->Read(path.String());
|
||||
path.Append(kSettingsDirectory);
|
||||
path.Append(kBookmarksDirectory);
|
||||
|
||||
return fBookmark->Read(path.Path());
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PDFWriter::LoadXRefsDefinitions(const char* name)
|
||||
{
|
||||
// TODO: use B_USER_SETTINGS_DIRECTORY instead of hard coded constant
|
||||
BString path("/boot/home/config/settings/PDF Writer/xrefs/");
|
||||
path.Append(name);
|
||||
BPath path;
|
||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK)
|
||||
return false;
|
||||
|
||||
if (fXRefs->Read(path.String())) {
|
||||
fXRefDests = new XRefDests(fXRefs->Count());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
path.Append(kSettingsDirectory);
|
||||
path.Append(kCrossReferencesDirectory);
|
||||
|
||||
if (!fXRefs->Read(path.Path()))
|
||||
return false;
|
||||
|
||||
fXRefDests = new XRefDests(fXRefs->Count());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,6 +125,9 @@ class PDFWriter : public PrinterDriver, public PictureIterator {
|
||||
void DrawChar(uint16 unicode, const char *utf8, int16 size);
|
||||
void ClipChar(BFont* font, const char* unicode, const char *utf8, int16 size, float width);
|
||||
bool EmbedFont(const char* n);
|
||||
void DeclareEncodingFiles();
|
||||
void DeclareEncodingFile(BPath* path, const char* id,
|
||||
const char* name);
|
||||
status_t DeclareFonts();
|
||||
void RecordFont(const char* family, const char* style, float size);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user