Esempio n. 1
0
EStatusCode CFFANSIFontWriter::WriteFont(	FreeTypeFaceWrapper& inFontInfo,
        WrittenFontRepresentation* inFontOccurrence,
        ObjectsContext* inObjectsContext)
{
    const char* postscriptFontName = FT_Get_Postscript_Name(inFontInfo);
    if(!postscriptFontName)
    {
        TRACE_LOG("CFFANSIFontWriter::WriteFont, unexpected failure. no postscript font name for font");
        return PDFHummus::eFailure;
    }
    std::string subsetFontName = inObjectsContext->GenerateSubsetFontPrefix() + scPlus + postscriptFontName;

    const char* fontType = inFontInfo.GetTypeString();

    // reset embedded font object ID (and flag...to whether it was actually embedded or not, which may
    // happen due to font embedding restrictions)
    mEmbeddedFontFileObjectID = 0;

    EStatusCode status;
    if(strcmp(scType1Type,fontType) == 0)
    {
        Type1ToCFFEmbeddedFontWriter embeddedFontWriter;

        status = embeddedFontWriter.WriteEmbeddedFont(inFontInfo,
                 inFontOccurrence->GetGlyphIDsAsOrderedVector(),
                 scType1C,
                 subsetFontName,
                 inObjectsContext,
                 mEmbeddedFontFileObjectID);
    }
    else if(strcmp(scCFF,fontType) == 0)
    {
        CFFEmbeddedFontWriter embeddedFontWriter;

        status = embeddedFontWriter.WriteEmbeddedFont(inFontInfo,
                 inFontOccurrence->GetGlyphIDsAsOrderedVector(),
                 scType1C,
                 subsetFontName,
                 inObjectsContext,
                 mEmbeddedFontFileObjectID);
    }
    else
    {

        TRACE_LOG("CFFANSIFontWriter::WriteFont, Exception, unfamilar font type for embedding representation");
        status = PDFHummus::eFailure;
    }
    if(status != PDFHummus::eSuccess)
        return status;

    ANSIFontWriter fontWriter;

    return fontWriter.WriteFont(inFontInfo,inFontOccurrence,inObjectsContext,this,subsetFontName);
}
EStatusCode TrueTypeANSIFontWriter::WriteFont(	FreeTypeFaceWrapper& inFontInfo,
											WrittenFontRepresentation* inFontOccurrence,
											ObjectsContext* inObjectsContext,
											bool inEmbedFont)
{
	std::string postscriptFontName = inFontInfo.GetPostscriptName();
	if(postscriptFontName.length() == 0)
	{
		TRACE_LOG("TrueTypeANSIFontWriter::WriteFont, unexpected failure. no postscript font name for font");
		return PDFHummus::eFailure;
	}
	std::string fontName;

	// reset embedded font object ID (and flag...to whether it was actually embedded or not, which may 
	// happen due to font embedding restrictions, or due to users choice)
	mEmbeddedFontFileObjectID = 0;

	TrueTypeEmbeddedFontWriter embeddedFontWriter;

	if (inEmbedFont)
	{
		fontName = inObjectsContext->GenerateSubsetFontPrefix() + scPlus + postscriptFontName;
		EStatusCode status = embeddedFontWriter.WriteEmbeddedFont(inFontInfo,
																	inFontOccurrence->GetGlyphIDsAsOrderedVector(),
																	inObjectsContext,
																	mEmbeddedFontFileObjectID);
		if (PDFHummus::eFailure == status)
			return status;
	}
	else
		fontName  = postscriptFontName;

	ANSIFontWriter fontWriter;

	return fontWriter.WriteFont(inFontInfo, inFontOccurrence, inObjectsContext, this, fontName);
}