本文整理汇总了C++中GlyphPage::fontDataForCharacter方法的典型用法代码示例。如果您正苦于以下问题:C++ GlyphPage::fontDataForCharacter方法的具体用法?C++ GlyphPage::fontDataForCharacter怎么用?C++ GlyphPage::fontDataForCharacter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlyphPage
的用法示例。
在下文中一共展示了GlyphPage::fontDataForCharacter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: primaryFontHasGlyphForCharacter
bool Font::primaryFontHasGlyphForCharacter(UChar32 character) const
{
unsigned pageNumber = (character / GlyphPage::size);
GlyphPageTreeNode* node = GlyphPageTreeNode::getRootChild(primaryFont(), pageNumber);
GlyphPage* page = node->page();
return page && page->fontDataForCharacter(character);
}
示例2: make_pair
//.........这里部分代码省略.........
while (true) {
page = node->page();
if (page) {
GlyphData data = page->glyphDataForCharacter(c);
if (data.fontData) {
// The variantFontData function should not normally return 0.
// But if it does, we will just render the capital letter big.
RefPtr<SimpleFontData> variantFontData = data.fontData->variantFontData(description, variant);
if (!variantFontData)
return std::make_pair(data, page);
GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber);
GlyphPage* variantPage = variantNode->page();
if (variantPage) {
GlyphData data = variantPage->glyphDataForCharacter(c);
if (data.fontData)
return std::make_pair(data, variantPage);
}
// Do not attempt system fallback off the variantFontData. This is the very unlikely case that
// a font has the lowercase character but the small caps font does not have its uppercase version.
return std::make_pair(variantFontData->missingGlyphData(), page);
}
if (node->isSystemFallback())
break;
}
node = node->getChild(realizeFontDataAt(description, node->level()), pageNumber);
if (pageNumber)
m_pages.set(pageNumber, node);
else
m_pageZero = node;
}
}
ASSERT(page);
ASSERT(node->isSystemFallback());
// System fallback is character-dependent. When we get here, we
// know that the character in question isn't in the system fallback
// font's glyph page. Try to lazily create it here.
UChar codeUnits[2];
int codeUnitsLength;
if (c <= 0xFFFF) {
codeUnits[0] = Font::normalizeSpaces(c);
codeUnitsLength = 1;
} else {
codeUnits[0] = U16_LEAD(c);
codeUnits[1] = U16_TRAIL(c);
codeUnitsLength = 2;
}
const SimpleFontData* originalFontData = primaryFontData(description)->fontDataForCharacter(c);
RefPtr<SimpleFontData> characterFontData = fontCache().systemFallbackForCharacters(description, originalFontData, m_isForPlatformFont, codeUnits, codeUnitsLength);
if (characterFontData) {
if (characterFontData->platformData().orientation() == Vertical && !characterFontData->hasVerticalGlyphs() && Font::isCJKIdeographOrSymbol(c))
variant = BrokenIdeographVariant;
if (variant != NormalVariant)
characterFontData = characterFontData->variantFontData(description, variant);
}
if (characterFontData) {
// Got the fallback glyph and font.
GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData.get(), pageNumber)->page();
GlyphData data = fallbackPage && fallbackPage->fontDataForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData();
// Cache it so we don't have to do system fallback again next time.
if (variant == NormalVariant) {
#if OS(WINCE)
// missingGlyphData returns a null character, which is not suitable for GDI to display.
// Also, sometimes we cannot map a font for the character on WINCE, but GDI can still
// display the character, probably because the font package is not installed correctly.
// So we just always set the glyph to be same as the character, and let GDI solve it.
page->setGlyphDataForCharacter(c, c, characterFontData.get());
characterFontData->setMaxGlyphPageTreeLevel(std::max(characterFontData->maxGlyphPageTreeLevel(), node->level()));
return std::make_pair(page->glyphDataForCharacter(c), page);
#else
page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
if (!Font::isCJKIdeographOrSymbol(c) && data.fontData->platformData().orientation() != Horizontal && !data.fontData->isTextOrientationFallback())
return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data, fallbackPage, pageNumber);
#endif
}
return std::make_pair(data, page);
}
// Even system fallback can fail; use the missing glyph in that case.
// FIXME: It would be nicer to use the missing glyph from the last resort font instead.
GlyphData data = primarySimpleFontData(description)->missingGlyphData();
if (variant == NormalVariant) {
#if OS(WINCE)
// See comment about WINCE GDI handling near setGlyphDataForCharacter above.
page->setGlyphDataForCharacter(c, c, data.fontData);
data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
return std::make_pair(page->glyphDataForCharacter(c), page);
#else
page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
#endif
}
return std::make_pair(data, page);
}
示例3: make_pair
//.........这里部分代码省略.........
} else {
return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, m_fontDescription.nonCJKGlyphOrientation(), data, page, pageNumber);
}
return make_pair(data, page);
}
if (node->isSystemFallback())
break;
}
// Proceed with the fallback list.
node = node->getChild(fontDataAt(node->level()), pageNumber);
if (pageNumber)
m_fontFallbackList->m_pages.set(pageNumber, node);
else
m_fontFallbackList->m_pageZero = node;
}
}
if (variant != NormalVariant) {
while (true) {
page = node->page();
if (page) {
GlyphData data = page->glyphDataForCharacter(c);
if (data.fontData) {
// The variantFontData function should not normally return 0.
// But if it does, we will just render the capital letter big.
RefPtr<SimpleFontData> variantFontData = data.fontData->variantFontData(m_fontDescription, variant);
if (!variantFontData)
return make_pair(data, page);
GlyphPageTreeNode* variantNode = GlyphPageTreeNode::getRootChild(variantFontData.get(), pageNumber);
GlyphPage* variantPage = variantNode->page();
if (variantPage) {
GlyphData data = variantPage->glyphDataForCharacter(c);
if (data.fontData)
return make_pair(data, variantPage);
}
// Do not attempt system fallback off the variantFontData. This is the very unlikely case that
// a font has the lowercase character but the small caps font does not have its uppercase version.
return make_pair(variantFontData->missingGlyphData(), page);
}
if (node->isSystemFallback())
break;
}
// Proceed with the fallback list.
node = node->getChild(fontDataAt(node->level()), pageNumber);
if (pageNumber)
m_fontFallbackList->m_pages.set(pageNumber, node);
else
m_fontFallbackList->m_pageZero = node;
}
}
ASSERT(page);
ASSERT(node->isSystemFallback());
// System fallback is character-dependent. When we get here, we
// know that the character in question isn't in the system fallback
// font's glyph page. Try to lazily create it here.
// FIXME: Unclear if this should normalizeSpaces above 0xFFFF.
// Doing so changes fast/text/international/plane2-diffs.html
UChar32 characterToRender = c;
if (characterToRender <= 0xFFFF)
characterToRender = Character::normalizeSpaces(characterToRender);
const SimpleFontData* fontDataToSubstitute = fontDataAt(0)->fontDataForCharacter(characterToRender);
RefPtr<SimpleFontData> characterFontData = FontCache::fontCache()->platformFallbackForCharacter(m_fontDescription, characterToRender, fontDataToSubstitute);
if (characterFontData) {
if (characterFontData->platformData().orientation() == Vertical && !characterFontData->hasVerticalGlyphs() && Character::isCJKIdeographOrSymbol(c))
variant = BrokenIdeographVariant;
if (variant != NormalVariant)
characterFontData = characterFontData->variantFontData(m_fontDescription, variant);
}
if (characterFontData) {
// Got the fallback glyph and font.
GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData.get(), pageNumber)->page();
GlyphData data = fallbackPage && fallbackPage->fontDataForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData();
// Cache it so we don't have to do system fallback again next time.
if (variant == NormalVariant) {
page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
data.fontData->setMaxGlyphPageTreeLevel(max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
if (!Character::isCJKIdeographOrSymbol(c) && data.fontData->platformData().orientation() != Horizontal && !data.fontData->isTextOrientationFallback())
return glyphDataAndPageForNonCJKCharacterWithGlyphOrientation(c, m_fontDescription.nonCJKGlyphOrientation(), data, fallbackPage, pageNumber);
}
return make_pair(data, page);
}
// Even system fallback can fail; use the missing glyph in that case.
// FIXME: It would be nicer to use the missing glyph from the last resort font instead.
GlyphData data = primaryFont()->missingGlyphData();
if (variant == NormalVariant) {
page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
data.fontData->setMaxGlyphPageTreeLevel(max(data.fontData->maxGlyphPageTreeLevel(), node->level()));
}
return make_pair(data, page);
}
示例4: glyphDataForCharacter
//.........这里部分代码省略.........
}
// Proceed with the fallback list.
node = node->getChild(fontDataAt(node->level()), pageNumber);
if (pageNumber)
m_fontList->m_pages.set(pageNumber, node);
else
m_fontList->m_pageZero = node;
}
} else {
while (true) {
page = node->page();
if (page) {
GlyphData data = page->glyphDataForCharacter(c);
if (data.fontData) {
// The smallCapsFontData function should not normally return 0.
// But if it does, we will just render the capital letter big.
const SimpleFontData* smallCapsFontData = data.fontData->smallCapsFontData(m_fontDescription);
if (!smallCapsFontData)
return data;
GlyphPageTreeNode* smallCapsNode = GlyphPageTreeNode::getRootChild(smallCapsFontData, pageNumber);
const GlyphPage* smallCapsPage = smallCapsNode->page();
if (smallCapsPage) {
GlyphData data = smallCapsPage->glyphDataForCharacter(c);
if (data.fontData)
return data;
}
// Do not attempt system fallback off the smallCapsFontData. This is the very unlikely case that
// a font has the lowercase character but the small caps font does not have its uppercase version.
return smallCapsFontData->missingGlyphData();
}
if (node->isSystemFallback())
break;
}
// Proceed with the fallback list.
node = node->getChild(fontDataAt(node->level()), pageNumber);
if (pageNumber)
m_fontList->m_pages.set(pageNumber, node);
else
m_fontList->m_pageZero = node;
}
}
ASSERT(page);
ASSERT(node->isSystemFallback());
// System fallback is character-dependent. When we get here, we
// know that the character in question isn't in the system fallback
// font's glyph page. Try to lazily create it here.
UChar codeUnits[2];
int codeUnitsLength;
if (c <= 0xFFFF) {
codeUnits[0] = Font::normalizeSpaces(c);
codeUnitsLength = 1;
} else {
codeUnits[0] = U16_LEAD(c);
codeUnits[1] = U16_TRAIL(c);
codeUnitsLength = 2;
}
const SimpleFontData* characterFontData = fontCache()->getFontDataForCharacters(*this, codeUnits, codeUnitsLength);
if (useSmallCapsFont && characterFontData)
characterFontData = characterFontData->smallCapsFontData(m_fontDescription);
if (characterFontData) {
// Got the fallback glyph and font.
GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData, pageNumber)->page();
GlyphData data = fallbackPage && fallbackPage->fontDataForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData();
// Cache it so we don't have to do system fallback again next time.
if (!useSmallCapsFont) {
#if OS(WINCE)
// missingGlyphData returns a null character, which is not suitable for GDI to display.
// Also, sometimes we cannot map a font for the character on WINCE, but GDI can still
// display the character, probably because the font package is not installed correctly.
// So we just always set the glyph to be same as the character, and let GDI solve it.
page->setGlyphDataForCharacter(c, c, characterFontData);
return page->glyphDataForCharacter(c);
#else
page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
#endif
}
return data;
}
// Even system fallback can fail; use the missing glyph in that case.
// FIXME: It would be nicer to use the missing glyph from the last resort font instead.
GlyphData data = primaryFont()->missingGlyphData();
if (!useSmallCapsFont) {
#if OS(WINCE)
// See comment about WINCE GDI handling near setGlyphDataForCharacter above.
page->setGlyphDataForCharacter(c, c, data.fontData);
return page->glyphDataForCharacter(c);
#else
page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
#endif
}
return data;
}