本文整理汇总了C++中CPDF_Font::GetBaseFont方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Font::GetBaseFont方法的具体用法?C++ CPDF_Font::GetBaseFont怎么用?C++ CPDF_Font::GetBaseFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Font
的用法示例。
在下文中一共展示了CPDF_Font::GetBaseFont方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetStandardFont
CPDF_Font* CPDF_DocPageData::GetStandardFont(FX_BSTR fontName, CPDF_FontEncoding* pEncoding)
{
if (fontName.IsEmpty()) {
return NULL;
}
FX_POSITION pos = m_FontMap.GetStartPosition();
while (pos) {
CPDF_Dictionary* fontDict;
CPDF_CountedObject<CPDF_Font*>* fontData;
m_FontMap.GetNextAssoc(pos, fontDict, fontData);
CPDF_Font* pFont = fontData->m_Obj;
if (!pFont) {
continue;
}
if (pFont->GetBaseFont() != fontName) {
continue;
}
if (pFont->IsEmbedded()) {
continue;
}
if (pFont->GetFontType() != PDFFONT_TYPE1) {
continue;
}
if (pFont->GetFontDict()->KeyExist(FX_BSTRC("Widths"))) {
continue;
}
CPDF_Type1Font* pT1Font = pFont->GetType1Font();
if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding)) {
continue;
}
fontData->m_nCount ++;
return pFont;
}
CPDF_Dictionary* pDict = FX_NEW CPDF_Dictionary;
pDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Font"));
pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Type1"));
pDict->SetAtName(FX_BSTRC("BaseFont"), fontName);
if (pEncoding) {
pDict->SetAt(FX_BSTRC("Encoding"), pEncoding->Realize());
}
m_pPDFDoc->AddIndirectObject(pDict);
CPDF_CountedObject<CPDF_Font*>* fontData = FX_NEW CPDF_CountedObject<CPDF_Font*>;
if (!fontData) {
return NULL;
}
CPDF_Font* pFont = CPDF_Font::CreateFontF(m_pPDFDoc, pDict);
if (!pFont) {
delete fontData;
return NULL;
}
fontData->m_nCount = 2;
fontData->m_Obj = pFont;
m_FontMap.SetAt(pDict, fontData);
return pFont;
}
示例2: GetInterFormFont
CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString csFontName, CFX_ByteString& csNameTag)
{
if (pFormDict == NULL || csFontName.IsEmpty()) {
return NULL;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
if (pDR == NULL) {
return NULL;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
if (pFonts == NULL) {
return NULL;
}
FX_POSITION pos = pFonts->GetStartPos();
while (pos) {
CPDF_Object* pObj = NULL;
CFX_ByteString csKey;
pObj = pFonts->GetNextElement(pos, csKey);
if (pObj == NULL) {
continue;
}
CPDF_Object* pDirect = pObj->GetDirect();
if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) {
continue;
}
CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
if (pElement->GetString("Type") != "Font") {
continue;
}
CPDF_Font* pFind = pDocument->LoadFont(pElement);
if (pFind == NULL) {
continue;
}
CFX_ByteString csBaseFont;
csBaseFont = pFind->GetBaseFont();
csBaseFont.Remove(' ');
if (csBaseFont == csFontName) {
csNameTag = csKey;
return pFind;
}
}
return NULL;
}
示例3: GetStandardFont
CPDF_Font* CPDF_DocPageData::GetStandardFont(const CFX_ByteStringC& fontName,
CPDF_FontEncoding* pEncoding) {
if (fontName.IsEmpty())
return nullptr;
for (auto& it : m_FontMap) {
CPDF_CountedFont* fontData = it.second;
CPDF_Font* pFont = fontData->get();
if (!pFont)
continue;
if (pFont->GetBaseFont() != fontName)
continue;
if (pFont->IsEmbedded())
continue;
if (!pFont->IsType1Font())
continue;
if (pFont->GetFontDict()->KeyExist("Widths"))
continue;
CPDF_Type1Font* pT1Font = pFont->AsType1Font();
if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding))
continue;
return fontData->AddRef();
}
CPDF_Dictionary* pDict = new CPDF_Dictionary;
pDict->SetAtName("Type", "Font");
pDict->SetAtName("Subtype", "Type1");
pDict->SetAtName("BaseFont", fontName);
if (pEncoding) {
pDict->SetAt("Encoding", pEncoding->Realize());
}
m_pPDFDoc->AddIndirectObject(pDict);
CPDF_Font* pFont = CPDF_Font::CreateFontF(m_pPDFDoc, pDict);
if (!pFont) {
return nullptr;
}
CPDF_CountedFont* fontData = new CPDF_CountedFont(pFont);
m_FontMap[pDict] = fontData;
return fontData->AddRef();
}
示例4: GetInterFormFont
CPDF_Font* GetInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
CFX_ByteString csFontName,
CFX_ByteString& csNameTag) {
if (!pFormDict || csFontName.IsEmpty()) {
return NULL;
}
CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
if (!pDR) {
return NULL;
}
CPDF_Dictionary* pFonts = pDR->GetDict("Font");
if (!pFonts) {
return NULL;
}
for (const auto& it : *pFonts) {
const CFX_ByteString& csKey = it.first;
CPDF_Object* pObj = it.second;
if (!pObj) {
continue;
}
CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
if (!pElement)
continue;
if (pElement->GetString("Type") != "Font")
continue;
CPDF_Font* pFind = pDocument->LoadFont(pElement);
if (!pFind)
continue;
CFX_ByteString csBaseFont;
csBaseFont = pFind->GetBaseFont();
csBaseFont.Remove(' ');
if (csBaseFont == csFontName) {
csNameTag = csKey;
return pFind;
}
}
return NULL;
}