本文整理汇总了C++中CPDF_Font类的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Font类的具体用法?C++ CPDF_Font怎么用?C++ CPDF_Font使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPDF_Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalcCharPos
void CPDF_TextObject::CalcCharPos(FX_FLOAT* pPosArray) const
{
CPDF_Font* pFont = m_TextState.GetFont();
FX_BOOL bVertWriting = FALSE;
CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
if (pCIDFont) {
bVertWriting = pCIDFont->IsVertWriting();
}
FX_FLOAT fontsize = m_TextState.GetFontSize();
for (int i = 0, index = 0; i < m_nChars; ++i) {
FX_DWORD charcode = m_nChars == 1 ?
(FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
if (charcode == (FX_DWORD) - 1) {
continue;
}
pPosArray[index++] = i ? m_pCharPos[i - 1] : 0;
FX_FLOAT charwidth;
if (bVertWriting) {
FX_WORD CID = pCIDFont->CIDFromCharCode(charcode);
charwidth = pCIDFont->GetVertWidth(CID) * fontsize / 1000;
} else {
charwidth = pFont->GetCharWidthF(charcode) * fontsize / 1000;
}
pPosArray[index] = pPosArray[index - 1] + charwidth;
index++;
}
}
示例2: ISLATINWORD
int Document::CountWords(CPDF_TextObject* pTextObj)
{
if (!pTextObj) return 0;
int nWords = 0;
CPDF_Font* pFont = pTextObj->GetFont();
if (!pFont) return 0;
FX_BOOL bIsLatin = FALSE;
for (int i=0, sz=pTextObj->CountChars(); i<sz; i++)
{
FX_DWORD charcode = -1;
FX_FLOAT kerning;
pTextObj->GetCharInfo(i, charcode, kerning);
CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
FX_WORD unicode = 0;
if (swUnicode.GetLength() > 0)
unicode = swUnicode[0];
if (ISLATINWORD(unicode) && bIsLatin)
continue;
bIsLatin = ISLATINWORD(unicode);
if (unicode != 0x20)
nWords++;
}
return nWords;
}
示例3: GetItemInfo
void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const
{
pInfo->m_CharCode =
m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[index];
pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0;
pInfo->m_OriginY = 0;
if (pInfo->m_CharCode == -1) {
return;
}
CPDF_Font* pFont = m_TextState.GetFont();
if (pFont->GetFontType() != PDFFONT_CIDFONT) {
return;
}
if (!((CPDF_CIDFont*)pFont)->IsVertWriting()) {
return;
}
FX_WORD CID = ((CPDF_CIDFont*)pFont)->CIDFromCharCode(pInfo->m_CharCode);
pInfo->m_OriginY = pInfo->m_OriginX;
pInfo->m_OriginX = 0;
short vx, vy;
((CPDF_CIDFont*)pFont)->GetVertOrigin(CID, vx, vy);
FX_FLOAT fontsize = m_TextState.GetFontSize();
pInfo->m_OriginX -= fontsize * vx / 1000;
pInfo->m_OriginY -= fontsize * vy / 1000;
}
示例4: GetCharWidth
FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const {
FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000;
CPDF_Font* pFont = m_TextState.GetFont();
FX_BOOL bVertWriting = FALSE;
CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
if (pCIDFont) {
bVertWriting = pCIDFont->IsVertWriting();
}
if (!bVertWriting)
return pFont->GetCharWidthF(charcode, 0) * fontsize;
FX_WORD CID = pCIDFont->CIDFromCharCode(charcode);
return pCIDFont->GetVertWidth(CID) * fontsize;
}
示例5: ToDictionary
CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name));
if (!pFontDict) {
m_bResourceMissing = TRUE;
return CPDF_Font::GetStockFont(m_pDocument, "Helvetica");
}
CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict);
if (pFont && pFont->GetType3Font()) {
pFont->GetType3Font()->SetPageResources(m_pResources);
pFont->GetType3Font()->CheckType3FontMetrics();
}
return pFont;
}
示例6: GetNativeInterFormFont
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
CFX_ByteString& csNameTag) {
csNameTag.clear();
uint8_t charSet = CPDF_InterForm::GetNativeCharSet();
CPDF_Font* pFont = GetDefaultInterFormFont(pFormDict, pDocument);
if (pFont) {
CFX_SubstFont* pSubst = pFont->GetSubstFont();
if (pSubst && pSubst->m_Charset == (int)charSet) {
FindInterFormFont(pFormDict, pFont, csNameTag);
return pFont;
}
}
return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag);
}
示例7: GetNativeInterFormFont
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString& csNameTag)
{
csNameTag = "";
FX_BYTE charSet = CPDF_InterForm::GetNativeCharSet();
CFX_SubstFont* pSubst;
CPDF_Font* pFont = GetDefaultInterFormFont(pFormDict, pDocument);
if (pFont != NULL) {
pSubst = (CFX_SubstFont*)pFont->GetSubstFont();
if (pSubst != NULL && pSubst->m_Charset == (int)charSet) {
FindInterFormFont(pFormDict, pFont, csNameTag);
return pFont;
}
}
return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag);
}
示例8: GetSpaceCharWidth
FX_FLOAT CPDF_TextObject::GetSpaceCharWidth() const {
CPDF_Font* pFont = m_TextState.GetFont();
FX_DWORD charCode = m_TextState.GetFont()->CharCodeFromUnicode(32);
if (charCode != (FX_DWORD)-1) {
return GetCharWidth(charCode);
}
FX_FLOAT fontSize = m_TextState.GetFontSize() / 4000.0f;
FX_BOOL bVertWriting = FALSE;
CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
if (pCIDFont) {
bVertWriting = pCIDFont->IsVertWriting();
}
FX_RECT fontRect;
pFont->GetFontBBox(fontRect);
fontSize *=
bVertWriting ? (FX_FLOAT)fontRect.Height() : (FX_FLOAT)fontRect.Width();
return fontSize;
}
示例9: GetCharRect
void CPDF_TextObject::GetCharRect(int index, CFX_FloatRect& rect) const
{
CPDF_Font* pFont = m_TextState.GetFont();
FX_BOOL bVertWriting = FALSE;
CPDF_CIDFont* pCIDFont = pFont->GetCIDFont();
if (pCIDFont) {
bVertWriting = pCIDFont->IsVertWriting();
}
FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000;
int count = 0;
for (int i = 0; i < m_nChars; ++i) {
FX_DWORD charcode = m_nChars == 1 ?
(FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
if (charcode == (FX_DWORD) - 1) {
continue;
}
if (count != index) {
++count;
continue;
}
FX_FLOAT curpos = i > 0 ? m_pCharPos[i - 1] : 0;
FX_RECT char_rect;
pFont->GetCharBBox(charcode, char_rect, 0);
if (!bVertWriting) {
rect.left = curpos + char_rect.left * fontsize;
rect.right = curpos + char_rect.right * fontsize;
rect.top = char_rect.top * fontsize;
rect.bottom = char_rect.bottom * fontsize;
} else {
FX_WORD CID = pCIDFont->CIDFromCharCode(charcode);
short vx, vy;
pCIDFont->GetVertOrigin(CID, vx, vy);
char_rect.left -= vx;
char_rect.right -= vx;
char_rect.top -= vy;
char_rect.bottom -= vy;
rect.left = char_rect.left * fontsize;
rect.right = char_rect.right * fontsize;
rect.top = curpos + char_rect.top * fontsize;
rect.bottom = curpos + char_rect.bottom * fontsize;
}
return;
}
}
示例10: GetDocument
CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict,
CFX_ByteString& sFontAlias,
int32_t nCharset) {
if (!pResDict)
return NULL;
CPDF_Document* pDocument = GetDocument();
ASSERT(pDocument != NULL);
CPDF_Dictionary* pFonts = pResDict->GetDict("Font");
if (pFonts == NULL)
return NULL;
CPDF_Font* pFind = 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* pFont = pDocument->LoadFont(pElement);
if (pFont == NULL)
continue;
const CFX_SubstFont* pSubst = pFont->GetSubstFont();
if (pSubst == NULL)
continue;
if (pSubst->m_Charset == nCharset) {
sFontAlias = csKey;
pFind = pFont;
}
}
return pFind;
}
示例11: AddNativeInterFormFont
void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc,
const CPDF_Dictionary* pResDict,
CPDF_Font*& pSysFont,
CFX_ByteString& sSysFontAlias) {
if (!pDoc || !pResDict)
return;
CFX_ByteString sFontAlias;
CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictBy("AcroForm");
CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias);
if (!pPDFFont)
return;
if (CPDF_Dictionary* pFontList = pResDict->GetDictBy("Font")) {
if (!pFontList->KeyExist(sSysFontAlias))
pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->GetFontDict());
}
pSysFont = pPDFFont;
}
示例12: 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;
}
示例13: FX_Free
void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
FX_FLOAT* pKerning,
int nsegs)
{
if (m_nChars > 1 && m_pCharCodes) {
FX_Free(m_pCharCodes);
m_pCharCodes = nullptr;
}
if (m_pCharPos) {
FX_Free(m_pCharPos);
m_pCharPos = nullptr;
}
CPDF_Font* pFont = m_TextState.GetFont();
m_nChars = 0;
for (int i = 0; i < nsegs; ++i) {
m_nChars += pFont->CountChar(pStrs[i], pStrs[i].GetLength());
}
m_nChars += nsegs - 1;
if (m_nChars > 1) {
m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
int index = 0;
for (int i = 0; i < nsegs; ++i) {
const FX_CHAR* segment = pStrs[i];
int offset = 0, len = pStrs[i].GetLength();
while (offset < len) {
m_pCharCodes[index++] =
pFont->GetNextChar(segment, len, offset);
}
if (i != nsegs - 1) {
m_pCharPos[index - 1] = pKerning[i];
m_pCharCodes[index++] = (FX_DWORD) - 1;
}
}
} else {
int offset = 0;
m_pCharCodes =
(FX_DWORD*)(uintptr_t)pFont->GetNextChar(pStrs[0],
pStrs[0].GetLength(),
offset);
}
}
示例14: GetNativeInterFormFont
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
uint8_t charSet,
CFX_ByteString& csNameTag) {
if (!pFormDict) {
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_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont();
if (!pSubst) {
continue;
}
if (pSubst->m_Charset == (int)charSet) {
csNameTag = csKey;
return pFind;
}
}
return NULL;
}
示例15: 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;
}