本文整理汇总了C++中primaryFont函数的典型用法代码示例。如果您正苦于以下问题:C++ primaryFont函数的具体用法?C++ primaryFont怎么用?C++ primaryFont使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了primaryFont函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: primaryFont
QFont Font::font() const
{
QFont f = primaryFont()->getQtFont();
if (m_letterSpacing != 0)
f.setLetterSpacing(QFont::AbsoluteSpacing, m_letterSpacing);
if (m_wordSpacing != 0)
f.setWordSpacing(m_wordSpacing);
return f;
}
示例2: 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);
}
示例3: ENABLE
float Font::floatWidth(const TextRun& run) const
{
#if ENABLE(SVG_FONTS)
if (primaryFont()->isSVGFont())
return floatWidthUsingSVGFont(run);
#endif
if (canUseGlyphCache(run))
return floatWidthForSimpleText(run, 0);
return floatWidthForComplexText(run);
}
示例4: primaryFont
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*) const
{
SkPaint paint;
primaryFont()->platformData().setupPaint(&paint);
//printf("--------- complext measure %d chars\n", run.to() - run.from());
SkScalar width = paint.measureText(run.characters(), run.length() << 1);
return SkScalarToFloat(width);
}
示例5: primaryFont
QFont Font::font() const
{
QFont f = primaryFont()->getQtFont();
f.setWeight(toQFontWeight(weight()));
f.setItalic(italic());
if (m_letterSpacing != 0)
f.setLetterSpacing(QFont::AbsoluteSpacing, m_letterSpacing);
if (m_wordSpacing != 0)
f.setWordSpacing(m_wordSpacing);
return f;
}
示例6: svgFont
SVGFontElement* Font::svgFont() const
{
if (!isSVGFont())
return 0;
SVGFontElement* fontElement = 0;
SVGFontFaceElement* fontFaceElement = 0;
if (svgFontAndFontFaceElementForFontData(primaryFont(), fontFaceElement, fontElement))
return fontElement;
return 0;
}
示例7: primaryFont
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow*) const
{
if (run.length() == 0)
return run.padding();
const FontPlatformData& fontPlatformData = primaryFont()->platformData();
const float scaleFactor = fontPlatformData.scaleFactor();
Olympia::Platform::Text::Font* font = fontPlatformData.font();
Olympia::Platform::Text::DrawParam drawParam;
String sanitized = setupTextDrawing(this, run, &drawParam);
// WebKit calls us with plain spaces almost half of the time.
// Exit early with a cached value to avoid lots of calls into Text API.
if (sanitized.length() == 1 && sanitized[0] == ' ')
return primaryFont()->spaceWidth();
#if PLATFORM(EGL) // FIXME: remove after Text API fixes shared context handling
if (eglGetCurrentContext() == EGL_NO_CONTEXT)
EGLDisplayOpenVG::current()->sharedPlatformSurface()->makeCurrent();
#endif
Olympia::Platform::Text::TextMetrics metrics;
FontPlatformData::engine()->drawText(0 /* no drawing, only measuring */,
*font, sanitized.characters(), sanitized.length(), 0 /*x*/, 0 /*y*/,
0 /* no wrap */, &drawParam, &metrics);
if (fallbackFonts && primaryFont()->lineSpacing() < metrics.m_ascent + metrics.m_descent) {
FontPlatformData tallerFontPlatformData = fontPlatformData;
tallerFontPlatformData.setLineSpacingOverride(metrics.m_ascent, metrics.m_descent);
// HACK: We can't generate a cached SimpleFontData from outside of FontCache,
// so instead we abuse FontCache::getFontDataForCharacters() to do that.
// Safe to use this way because we also pass 0 as string length,
// which avoids clashes with possible regular calls of that method.
fallbackFonts->add(fontCache()->getFontDataForCharacters(*this,
reinterpret_cast<const UChar*>(&tallerFontPlatformData), 0));
}
return metrics.m_linearAdvance * scaleFactor;
}
示例8: primaryFont
void FontFallbackList::determinePitch(const Font* font) const
{
const FontData* fontData = primaryFont(font);
if (!fontData->isSegmented())
m_pitch = static_cast<const SimpleFontData*>(fontData)->pitch();
else {
const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
unsigned numRanges = segmentedFontData->numRanges();
if (numRanges == 1)
m_pitch = segmentedFontData->rangeAt(0).fontData()->pitch();
else
m_pitch = VariablePitch;
}
}
示例9: primaryFont
FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
{
void* font = 0;
const UChar* str = 0;
const SimpleFontData* sfont = 0;
int i, len;
float x0,x1,x2;
float scale = 0;
UChar c = 0;
len = run.length();
if (!len) return FloatRect();
if (from>=len || to>len) return FloatRect();
if (from>=to) return FloatRect();
if (from<0) from = 0;
if (to>len) to = len;
str = run.characters();
sfont = primaryFont();
if (!sfont) return FloatRect();
font = sfont->platformData().Font();
if (!font) return FloatRect();
scale = sfont->platformData().scale();
x0=x1=x2=0;
for (i=0; i<from; i++) {
c = fixedChar(str[i]);
if (!c) continue;
x0 += ((float)wkcFontGetCharWidthPeer(font, c) * scale);
}
for (i=from; i<to; i++) {
c = fixedChar(str[i]);
if (!c) continue;
x1 += ((float)wkcFontGetCharWidthPeer(font, c) * scale);
}
for (i=to; i<len; i++) {
c = fixedChar(str[i]);
if (!c) continue;
x2 += ((float)wkcFontGetCharWidthPeer(font, c) * scale);
}
if (run.rtl()) {
return FloatRect(point.x() + x2, point.y(), x1, h);
} else {
return FloatRect(point.x() + x0, point.y(), x1, h);
}
}
示例10: state
void Font::drawComplexText(GraphicsContext* graphicsContext,
const TextRunPaintInfo& runInfo,
const FloatPoint& point) const
{
UniscribeHelperTextRun state(runInfo.run, *this);
SkColor color = graphicsContext->effectiveFillColor();
unsigned char alpha = SkColorGetA(color);
// Skip 100% transparent text; no need to draw anything.
if (!alpha && graphicsContext->strokeStyle() == NoStroke)
return;
HDC hdc = 0;
// Uniscribe counts the coordinates from the upper left, while WebKit uses
// the baseline, so we have to subtract off the ascent.
state.draw(graphicsContext, primaryFont()->platformData(), hdc, lroundf(point.x()), lroundf(point.y() - fontMetrics().ascent()), runInfo.bounds, runInfo.from, runInfo.to);
}
示例11: ENABLE
float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
#if ENABLE(SVG_FONTS)
if (primaryFont()->isSVGFont())
return floatWidthUsingSVGFont(run);
#endif
CodePath codePathToUse = codePath(run);
if (codePathToUse != Complex) {
// If the complex text implementation cannot return fallback fonts, avoid
// returning them for simple text as well.
static bool returnFallbackFonts = canReturnFallbackFontsForComplexText();
return floatWidthForSimpleText(run, 0, returnFallbackFonts ? fallbackFonts : 0, codePathToUse == SimpleWithGlyphOverflow || (glyphOverflow && glyphOverflow->computeBounds) ? glyphOverflow : 0);
}
return floatWidthForComplexText(run, fallbackFonts, glyphOverflow);
}
示例12: UNUSED_PARAM
float Font::width(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
{
#if !ENABLE(SVG_FONTS)
UNUSED_PARAM(extraCharsAvailable);
#else
if (primaryFont()->isSVGFont())
return floatWidthUsingSVGFont(run, extraCharsAvailable, charsConsumed, glyphName);
#endif
charsConsumed = run.length();
glyphName = "";
if (codePath(run) != Complex)
return floatWidthForSimpleText(run, 0);
return floatWidthForComplexText(run);
}
示例13: drawComplexText
void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
FloatPoint const& point, int, int) const
{
SkCanvas* canvas = gc->platformContext()->mCanvas;
SkPaint paint;
if (!setupForText(&paint, gc, primaryFont())) {
return;
}
// go to chars, instead of glyphs, which was set by setupForText()
paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
canvas->drawText(run.characters(), run.length() << 1,
SkFloatToScalar(point.x()), SkFloatToScalar(point.y()),
paint);
}
示例14: primaryFont
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*) const
{
#if 0
SkPaint paint;
primaryFont()->platformData().setupPaint(&paint);
//printf("--------- complext measure %d chars\n", run.to() - run.from());
SkScalar width = paint.measureText(run.characters(), run.length() << 1);
return SkScalarToFloat(width);
#else
WidthIterator it(this, run);
it.advance(run.length());
return SkScalarToFloat(it.m_runWidthSoFar);
#endif
}
示例15: floatWidthForSimpleText
float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
if (!primaryFont()->platformData().size())
return 0;
if (!run.length())
return 0;
String sanitized = Font::normalizeSpaces(run.characters(), run.length());
QString string = fromRawDataWithoutRef(sanitized);
int w = QFontMetrics(font()).width(string, -1, Qt::TextBypassShaping);
// WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does)
if (treatAsSpace(run[0]))
w -= m_wordSpacing;
return w + run.expansion();
}