当前位置: 首页>>代码示例>>C++>>正文


C++ CPDF_Font::UnicodeFromCharCode方法代码示例

本文整理汇总了C++中CPDF_Font::UnicodeFromCharCode方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Font::UnicodeFromCharCode方法的具体用法?C++ CPDF_Font::UnicodeFromCharCode怎么用?C++ CPDF_Font::UnicodeFromCharCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPDF_Font的用法示例。


在下文中一共展示了CPDF_Font::UnicodeFromCharCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:mcanthony,项目名称:libpdf,代码行数:33,代码来源:Document.cpp

示例2: GetObjWordStr

CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex)
{
	ASSERT(pTextObj != NULL);

	CFX_WideString swRet;

	CPDF_Font* pFont = pTextObj->GetFont();
	if (!pFont) return L"";

	int nWords = 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)
		{
		}
		else
		{
			bIsLatin = ISLATINWORD(unicode);
			if (unicode != 0x20)
				nWords++;
		}

		if (nWords-1 == nWordIndex)
			swRet += unicode;
	}

	return swRet;
}
开发者ID:mcanthony,项目名称:libpdf,代码行数:40,代码来源:Document.cpp

示例3: ProcessObject


//.........这里部分代码省略.........
        }
    }
    m_pLastObj = pObj;
    int nItems = pObj->CountItems();
    FX_FLOAT Ignorekerning = 0;
    for(int i = 1; i < nItems - 1; i += 2) {
        CPDF_TextObjectItem item;
        pObj->GetItemInfo(i, &item);
        if (item.m_CharCode == (FX_DWORD) - 1) {
            if(i == 1) {
                Ignorekerning = item.m_OriginX;
            } else if(Ignorekerning > item.m_OriginX) {
                Ignorekerning = item.m_OriginX;
            }
        } else {
            Ignorekerning = 0;
            break;
        }
    }
    FX_FLOAT spacing = 0;
    for (; item_index < nItems; item_index ++) {
        CPDF_TextObjectItem item;
        pObj->GetItemInfo(item_index, &item);
        if (item.m_CharCode == (FX_DWORD) - 1) {
            CFX_WideString wstr = m_Buffer.GetWideString();
            if (wstr.IsEmpty() || wstr.GetAt(wstr.GetLength() - 1) == L' ') {
                continue;
            }
            FX_FLOAT fontsize_h = pObj->m_TextState.GetFontSizeH();
            spacing = -fontsize_h * (item.m_OriginX - Ignorekerning) / 1000;
            continue;
        }
        FX_FLOAT charSpace = pObj->m_TextState.GetObject()->m_CharSpace;
        if(nItems > 3 && !spacing) {
            charSpace = 0;
        }
        if((spacing || charSpace) && item_index > 0) {
            int last_width = 0;
            FX_FLOAT fontsize_h = pObj->m_TextState.GetFontSizeH();
            FX_DWORD space_charcode = pFont->CharCodeFromUnicode(' ');
            FX_FLOAT threshold = 0;
            if (space_charcode != -1) {
                threshold = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000 ;
            }
            if(threshold > fontsize_h / 3) {
                threshold = 0;
            } else {
                threshold /= 2;
            }
            if (threshold == 0) {
                threshold = fontsize_h;
                int this_width = FXSYS_abs(GetCharWidth(item.m_CharCode, pFont));
                threshold = this_width > last_width ? (FX_FLOAT)this_width : (FX_FLOAT)last_width;
                int nDivide = 6;
                if (threshold < 300) {
                    nDivide = 2;
                } else if (threshold < 500) {
                    nDivide = 4;
                } else if (threshold < 700) {
                    nDivide = 5;
                }
                threshold = threshold / nDivide;
                threshold = fontsize_h * threshold / 1000;
            }
            if(charSpace > 0.001) {
                spacing += matrix.TransformDistance(charSpace);
            } else if(charSpace < -0.001) {
                spacing -= matrix.TransformDistance(FXSYS_fabs(charSpace));
            }
            if (threshold && (spacing && spacing >= threshold) ) {
                m_Buffer.AppendChar(L' ');
                if (m_pObjArray) {
                    m_pObjArray->Add(NULL);
                    m_pObjArray->Add(NULL);
                }
            }
            if (item.m_CharCode == (FX_DWORD) - 1) {
                continue;
            }
            spacing = 0;
        }
        CFX_WideString unicode_str = pFont->UnicodeFromCharCode(item.m_CharCode);
        if (unicode_str.IsEmpty()) {
            m_Buffer.AppendChar((FX_WCHAR)item.m_CharCode);
            if (m_pObjArray) {
                m_pObjArray->Add((void*)pObj);
                m_pObjArray->Add((void*)(FX_INTPTR)item_index);
            }
        } else {
            m_Buffer << unicode_str;
            if (m_pObjArray) {
                for (int i = 0; i < unicode_str.GetLength(); i ++) {
                    m_pObjArray->Add((void*)pObj);
                    m_pObjArray->Add((void*)(FX_INTPTR)item_index);
                }
            }
        }
    }
    return FALSE;
}
开发者ID:151706061,项目名称:PDFium,代码行数:101,代码来源:fpdf_text_search.cpp


注:本文中的CPDF_Font::UnicodeFromCharCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。