本文整理汇总了C++中CPDF_Dictionary::SetAtNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Dictionary::SetAtNumber方法的具体用法?C++ CPDF_Dictionary::SetAtNumber怎么用?C++ CPDF_Dictionary::SetAtNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Dictionary
的用法示例。
在下文中一共展示了CPDF_Dictionary::SetAtNumber方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateNewDoc
void CPDF_Document::CreateNewDoc() {
ASSERT(!m_pRootDict && !m_pInfoDict);
m_pRootDict = new CPDF_Dictionary;
m_pRootDict->SetAtName("Type", "Catalog");
int objnum = AddIndirectObject(m_pRootDict);
CPDF_Dictionary* pPages = new CPDF_Dictionary;
pPages->SetAtName("Type", "Pages");
pPages->SetAtNumber("Count", 0);
pPages->SetAt("Kids", new CPDF_Array);
objnum = AddIndirectObject(pPages);
m_pRootDict->SetAtReference("Pages", this, objnum);
m_pInfoDict = new CPDF_Dictionary;
AddIndirectObject(m_pInfoDict);
}
示例2: AddFont
CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert)
{
if (pFont == NULL) {
return NULL;
}
FX_BOOL bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || charset == FXFONT_GB2312_CHARSET ||
charset == FXFONT_HANGEUL_CHARSET || charset == FXFONT_SHIFTJIS_CHARSET;
CFX_ByteString basefont = pFont->GetFamilyName();
basefont.Replace(" ", "");
int flags = 0;
if (pFont->IsBold()) {
flags |= PDFFONT_FORCEBOLD;
}
if (pFont->IsItalic()) {
flags |= PDFFONT_ITALIC;
}
if (pFont->IsFixedWidth()) {
flags |= PDFFONT_FIXEDPITCH;
}
CPDF_Dictionary* pBaseDict = FX_NEW CPDF_Dictionary;
pBaseDict->SetAtName("Type", "Font");
IFX_FontEncoding* pEncoding = FXGE_CreateUnicodeEncoding(pFont);
CPDF_Dictionary* pFontDict = pBaseDict;
if (!bCJK) {
CPDF_Array* pWidths = FX_NEW CPDF_Array;
int charcode;
for (charcode = 32; charcode < 128; charcode ++) {
int glyph_index = pEncoding->GlyphFromCharCode(charcode);
int char_width = pFont->GetGlyphWidth(glyph_index);
pWidths->AddInteger(char_width);
}
if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET ||
charset == FXFONT_SYMBOL_CHARSET) {
if (charset == FXFONT_SYMBOL_CHARSET) {
flags |= PDFFONT_SYMBOLIC;
} else {
flags |= PDFFONT_NONSYMBOLIC;
}
pBaseDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding");
for (charcode = 128; charcode <= 255; charcode ++) {
int glyph_index = pEncoding->GlyphFromCharCode(charcode);
int char_width = pFont->GetGlyphWidth(glyph_index);
pWidths->AddInteger(char_width);
}
} else {
flags |= PDFFONT_NONSYMBOLIC;
int i;
for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes); i ++)
if (g_FX_CharsetUnicodes[i].m_Charset == charset) {
break;
}
if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
CPDF_Dictionary* pEncodingDict = FX_NEW CPDF_Dictionary;
pEncodingDict->SetAtName(FX_BSTRC("BaseEncoding"), "WinAnsiEncoding");
CPDF_Array* pArray = FX_NEW CPDF_Array;
pArray->AddInteger(128);
const FX_WCHAR* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
for (int j = 0; j < 128; j ++) {
CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
if (name.IsEmpty()) {
pArray->AddName(FX_BSTRC(".notdef"));
} else {
pArray->AddName(name);
}
int glyph_index = pEncoding->GlyphFromCharCode(pUnicodes[j]);
int char_width = pFont->GetGlyphWidth(glyph_index);
pWidths->AddInteger(char_width);
}
pEncodingDict->SetAt(FX_BSTRC("Differences"), pArray);
AddIndirectObject(pEncodingDict);
pBaseDict->SetAtReference(FX_BSTRC("Encoding"), this, pEncodingDict);
}
}
if (pFont->IsBold() && pFont->IsItalic()) {
basefont += ",BoldItalic";
} else if (pFont->IsBold()) {
basefont += ",Bold";
} else if (pFont->IsItalic()) {
basefont += ",Italic";
}
pBaseDict->SetAtName("Subtype", "TrueType");
pBaseDict->SetAtName("BaseFont", basefont);
pBaseDict->SetAtNumber("FirstChar", 32);
pBaseDict->SetAtNumber("LastChar", 255);
pBaseDict->SetAt("Widths", pWidths);
} else {
flags |= PDFFONT_NONSYMBOLIC;
pFontDict = FX_NEW CPDF_Dictionary;
CFX_ByteString cmap;
CFX_ByteString ordering;
int supplement;
CPDF_Array* pWidthArray = FX_NEW CPDF_Array;
switch (charset) {
case FXFONT_CHINESEBIG5_CHARSET:
cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
ordering = "CNS1";
supplement = 4;
pWidthArray->AddInteger(1);
_InsertWidthArray1(pFont, pEncoding, 0x20, 0x7e, pWidthArray);
break;
//.........这里部分代码省略.........
示例3: AddMacFont
//.........这里部分代码省略.........
charSets.Add(g_FX_CharsetUnicodes[i].m_Charset);
if (IsHasCharSet(languages, charSets)) {
break;
}
}
if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
CPDF_Dictionary* pEncoding = FX_NEW CPDF_Dictionary;
pEncoding->SetAtName(FX_BSTRC("BaseEncoding"), "WinAnsiEncoding");
CPDF_Array* pArray = FX_NEW CPDF_Array;
pArray->AddInteger(128);
const FX_WCHAR* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
for (int j = 0; j < 128; j ++) {
CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
if (name.IsEmpty()) {
pArray->AddName(FX_BSTRC(".notdef"));
} else {
pArray->AddName(name);
}
}
pEncoding->SetAt(FX_BSTRC("Differences"), pArray);
AddIndirectObject(pEncoding);
pBaseDict->SetAtReference(FX_BSTRC("Encoding"), this, pEncoding);
}
}
if (weight > 0.0 && trait & kCTFontItalicTrait) {
basefont += ",BoldItalic";
} else if (weight > 0.0) {
basefont += ",Bold";
} else if (trait & kCTFontItalicTrait) {
basefont += ",Italic";
}
pBaseDict->SetAtName("Subtype", "TrueType");
pBaseDict->SetAtName("BaseFont", basefont);
pBaseDict->SetAtNumber("FirstChar", 32);
pBaseDict->SetAtNumber("LastChar", 255);
int char_widths[224];
FX_GetCharWidth(font, 32, 255, char_widths);
CPDF_Array* pWidths = FX_NEW CPDF_Array;
for (int i = 0; i < 224; i ++) {
pWidths->AddInteger(char_widths[i]);
}
pBaseDict->SetAt("Widths", pWidths);
} else {
flags |= PDFFONT_NONSYMBOLIC;
CPDF_Array* pArray = NULL;
pFontDict = FX_NEW CPDF_Dictionary;
CFX_ByteString cmap;
CFX_ByteString ordering;
int supplement;
FX_BOOL bFound = FALSE;
CPDF_Array* pWidthArray = FX_NEW CPDF_Array;
charSets.RemoveAll();
charSets.Add(FXFONT_CHINESEBIG5_CHARSET);
if (IsHasCharSet(languages, charSets)) {
cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
ordering = "CNS1";
supplement = 4;
pWidthArray->AddInteger(1);
_InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
bFound = TRUE;
}
charSets.RemoveAll();
charSets.Add(FXFONT_GB2312_CHARSET);
if (!bFound && IsHasCharSet(languages, charSets)) {
cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
ordering = "GB1", supplement = 2;
示例4: AddWindowsFont
CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName)
{
pLogFont->lfHeight = -1000;
pLogFont->lfWidth = 0;
HGDIOBJ hFont = CreateFontIndirectA(pLogFont);
HDC hDC = CreateCompatibleDC(NULL);
hFont = SelectObject(hDC, hFont);
int tm_size = GetOutlineTextMetrics(hDC, 0, NULL);
if (tm_size == 0) {
hFont = SelectObject(hDC, hFont);
DeleteObject(hFont);
DeleteDC(hDC);
return NULL;
}
LPBYTE tm_buf = FX_Alloc(BYTE, tm_size);
OUTLINETEXTMETRIC* ptm = (OUTLINETEXTMETRIC*)tm_buf;
GetOutlineTextMetrics(hDC, tm_size, ptm);
int flags = 0, italicangle, ascend, descend, capheight, bbox[4];
if (pLogFont->lfItalic) {
flags |= PDFFONT_ITALIC;
}
if ((pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH) {
flags |= PDFFONT_FIXEDPITCH;
}
if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN) {
flags |= PDFFONT_SERIF;
}
if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT) {
flags |= PDFFONT_SCRIPT;
}
FX_BOOL bCJK = pLogFont->lfCharSet == CHINESEBIG5_CHARSET || pLogFont->lfCharSet == GB2312_CHARSET ||
pLogFont->lfCharSet == HANGEUL_CHARSET || pLogFont->lfCharSet == SHIFTJIS_CHARSET;
CFX_ByteString basefont;
if (bTranslateName && bCJK) {
basefont = _FPDF_GetPSNameFromTT(hDC);
}
if (basefont.IsEmpty()) {
basefont = pLogFont->lfFaceName;
}
italicangle = ptm->otmItalicAngle / 10;
ascend = ptm->otmrcFontBox.top;
descend = ptm->otmrcFontBox.bottom;
capheight = ptm->otmsCapEmHeight;
bbox[0] = ptm->otmrcFontBox.left;
bbox[1] = ptm->otmrcFontBox.bottom;
bbox[2] = ptm->otmrcFontBox.right;
bbox[3] = ptm->otmrcFontBox.top;
FX_Free(tm_buf);
basefont.Replace(" ", "");
CPDF_Dictionary* pBaseDict = FX_NEW CPDF_Dictionary;
pBaseDict->SetAtName("Type", "Font");
CPDF_Dictionary* pFontDict = pBaseDict;
if (!bCJK) {
if (pLogFont->lfCharSet == ANSI_CHARSET || pLogFont->lfCharSet == DEFAULT_CHARSET ||
pLogFont->lfCharSet == SYMBOL_CHARSET) {
if (pLogFont->lfCharSet == SYMBOL_CHARSET) {
flags |= PDFFONT_SYMBOLIC;
} else {
flags |= PDFFONT_NONSYMBOLIC;
}
pBaseDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding");
} else {
flags |= PDFFONT_NONSYMBOLIC;
int i;
for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes); i ++)
if (g_FX_CharsetUnicodes[i].m_Charset == pLogFont->lfCharSet) {
break;
}
if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
CPDF_Dictionary* pEncoding = FX_NEW CPDF_Dictionary;
pEncoding->SetAtName(FX_BSTRC("BaseEncoding"), "WinAnsiEncoding");
CPDF_Array* pArray = FX_NEW CPDF_Array;
pArray->AddInteger(128);
const FX_WCHAR* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
for (int j = 0; j < 128; j ++) {
CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
if (name.IsEmpty()) {
pArray->AddName(FX_BSTRC(".notdef"));
} else {
pArray->AddName(name);
}
}
pEncoding->SetAt(FX_BSTRC("Differences"), pArray);
AddIndirectObject(pEncoding);
pBaseDict->SetAtReference(FX_BSTRC("Encoding"), this, pEncoding);
}
}
if (pLogFont->lfWeight > FW_MEDIUM && pLogFont->lfItalic) {
basefont += ",BoldItalic";
} else if (pLogFont->lfWeight > FW_MEDIUM) {
basefont += ",Bold";
} else if (pLogFont->lfItalic) {
basefont += ",Italic";
}
pBaseDict->SetAtName("Subtype", "TrueType");
pBaseDict->SetAtName("BaseFont", basefont);
pBaseDict->SetAtNumber("FirstChar", 32);
pBaseDict->SetAtNumber("LastChar", 255);
int char_widths[224];
GetCharWidth(hDC, 32, 255, char_widths);
//.........这里部分代码省略.........