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


C++ platformData函数代码示例

本文整理汇总了C++中platformData函数的典型用法代码示例。如果您正苦于以下问题:C++ platformData函数的具体用法?C++ platformData怎么用?C++ platformData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: ASSERT

void Font::platformInit()
{
    if (!m_platformData.size())
        return;

    ASSERT(m_platformData.scaledFont());
    cairo_font_extents_t fontExtents;
    cairo_scaled_font_extents(m_platformData.scaledFont(), &fontExtents);

    float ascent = narrowPrecisionToFloat(fontExtents.ascent);
    float descent = narrowPrecisionToFloat(fontExtents.descent);
    float capHeight = narrowPrecisionToFloat(fontExtents.height);
    float lineGap = narrowPrecisionToFloat(fontExtents.height - fontExtents.ascent - fontExtents.descent);

    {
        CairoFtFaceLocker cairoFtFaceLocker(m_platformData.scaledFont());

        // If the USE_TYPO_METRICS flag is set in the OS/2 table then we use typo metrics instead.
        FT_Face freeTypeFace = cairoFtFaceLocker.ftFace();
        TT_OS2* OS2Table = freeTypeFace ? static_cast<TT_OS2*>(FT_Get_Sfnt_Table(freeTypeFace, ft_sfnt_os2)) : nullptr;
        if (OS2Table) {
            const FT_Short kUseTypoMetricsMask = 1 << 7;
            if (OS2Table->fsSelection & kUseTypoMetricsMask) {
                // FT_Size_Metrics::y_scale is in 16.16 fixed point format.
                // Its (fractional) value is a factor that converts vertical metrics from design units to units of 1/64 pixels.
                double yscale = (freeTypeFace->size->metrics.y_scale / 65536.0) / 64.0;
                ascent = narrowPrecisionToFloat(yscale * OS2Table->sTypoAscender);
                descent = -narrowPrecisionToFloat(yscale * OS2Table->sTypoDescender);
                lineGap = narrowPrecisionToFloat(yscale * OS2Table->sTypoLineGap);
            }
        }
    }

    m_fontMetrics.setAscent(ascent);
    m_fontMetrics.setDescent(descent);
    m_fontMetrics.setCapHeight(capHeight);

#if PLATFORM(EFL)
    m_fontMetrics.setLineSpacing(ascent + descent + lineGap);
#else
    // Match CoreGraphics metrics.
    m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
#endif
    m_fontMetrics.setLineGap(lineGap);

    cairo_text_extents_t textExtents;
    cairo_scaled_font_text_extents(m_platformData.scaledFont(), "x", &textExtents);
    m_fontMetrics.setXHeight(narrowPrecisionToFloat((platformData().orientation() == Horizontal) ? textExtents.height : textExtents.width));

    cairo_scaled_font_text_extents(m_platformData.scaledFont(), " ", &textExtents);
    m_spaceWidth = narrowPrecisionToFloat((platformData().orientation() == Horizontal) ? textExtents.x_advance : -textExtents.y_advance);

    if ((platformData().orientation() == Vertical) && !isTextOrientationFallback()) {
        CairoFtFaceLocker cairoFtFaceLocker(m_platformData.scaledFont());
        FT_Face freeTypeFace = cairoFtFaceLocker.ftFace();
        m_fontMetrics.setUnitsPerEm(freeTypeFace->units_per_EM);
    }

    m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:60,代码来源:SimpleFontDataFreeType.cpp

示例2: adoptCF

CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typesettingFeatures, FontOrientation orientation) const
{
    unsigned key = typesettingFeatures + 1;
    HashMap<unsigned, RetainPtr<CFDictionaryRef>>::AddResult addResult = m_CFStringAttributes.add(key, RetainPtr<CFDictionaryRef>());
    RetainPtr<CFDictionaryRef>& attributesDictionary = addResult.iterator->value;
    if (!addResult.isNewEntry)
        return attributesDictionary.get();

    attributesDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 4, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
    CFMutableDictionaryRef mutableAttributes = (CFMutableDictionaryRef)attributesDictionary.get();

    CFDictionarySetValue(mutableAttributes, kCTFontAttributeName, platformData().ctFont());

    if (!(typesettingFeatures & Kerning)) {
        const float zero = 0;
        static CFNumberRef zeroKerningValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
        CFDictionarySetValue(mutableAttributes, kCTKernAttributeName, zeroKerningValue);
    }

    bool allowLigatures = (orientation == Horizontal && platformData().allowsLigatures()) || (typesettingFeatures & Ligatures);
    if (!allowLigatures) {
        const int zero = 0;
        static CFNumberRef essentialLigaturesValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &zero);
        CFDictionarySetValue(mutableAttributes, kCTLigatureAttributeName, essentialLigaturesValue);
    }

    if (orientation == Vertical)
        CFDictionarySetValue(mutableAttributes, kCTVerticalFormsAttributeName, kCFBooleanTrue);

    return attributesDictionary.get();
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:31,代码来源:SimpleFontDataCoreText.cpp

示例3: TRY_CALL_PTHREADS

js::detail::MutexImpl::~MutexImpl()
{
  if (!platformData_)
    return;

  TRY_CALL_PTHREADS(pthread_mutex_destroy(&platformData()->ptMutex),
                    "js::detail::MutexImpl::~MutexImpl: pthread_mutex_destroy failed");

  js_delete(platformData());
}
开发者ID:bitwiseworks,项目名称:mozilla-os2,代码行数:10,代码来源:MutexImpl.cpp

示例4: platformData

float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
{
    if (!glyph || !platformData().size())
        return 0;

    QVector<quint32> glyphIndexes;
    glyphIndexes.append(glyph);
    QVector<QPointF> advances = platformData().rawFont().advancesForGlyphIndexes(glyphIndexes);
    ASSERT(!advances.isEmpty());
    return advances.at(0).x();
}
开发者ID:dzhshf,项目名称:WebKit,代码行数:11,代码来源:SimpleFontDataQt.cpp

示例5: FontDescription

SimpleFontData* SimpleFontData::scaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
    FontDescription desc = FontDescription(fontDescription);
    desc.setSpecifiedSize(scaleFactor * fontDescription.computedSize());
    FontPlatformData platformData(desc, desc.family().family());
    return new SimpleFontData(platformData, isCustomFont(), false);
}
开发者ID:dslab-epfl,项目名称:warr,代码行数:7,代码来源:SimpleFontDataWx.cpp

示例6: SkDebugf

bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill,
                                   unsigned offset,
                                   unsigned length,
                                   UChar* buffer,
                                   unsigned bufferLength) const {
  if (U16_IS_LEAD(buffer[bufferLength - 1])) {
    SkDebugf("%s last char is high-surrogate", __FUNCTION__);
    return false;
  }

  SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length);

  uint16_t* glyphs = glyphStorage.get();
  SkTypeface* typeface = platformData().typeface();
  typeface->charsToGlyphs(buffer, SkTypeface::kUTF16_Encoding, glyphs, length);

  bool haveGlyphs = false;
  for (unsigned i = 0; i < length; i++) {
    if (glyphs[i]) {
      pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this);
      haveGlyphs = true;
    }
  }

  return haveGlyphs;
}
开发者ID:HansMuller,项目名称:engine,代码行数:26,代码来源:SimpleFontDataSkia.cpp

示例7: platformData

Glyph SimpleFontData::glyphForCharacter(UChar32 codepoint) const {
  uint16_t glyph;
  SkTypeface* typeface = platformData().typeface();
  RELEASE_ASSERT(typeface);
  typeface->charsToGlyphs(&codepoint, SkTypeface::kUTF32_Encoding, &glyph, 1);
  return glyph;
}
开发者ID:mirror,项目名称:chromium,代码行数:7,代码来源:SimpleFontData.cpp

示例8: defined

bool RendererGlLinux::initialize( void *window, RendererRef sharedRenderer )
{
	mContext = reinterpret_cast<GLFWwindow*>( window );

	::glfwMakeContextCurrent( mContext );

#if defined( CINDER_GL_ES )
	gl::Environment::setEs();
#else
	gl::Environment::setCore();
#endif
	gl::env()->initializeFunctionPointers();

	std::shared_ptr<gl::PlatformDataLinux> platformData( new gl::PlatformDataLinux( mContext ) );
	platformData->mDebug = mRenderer->getOptions().getDebug();
	platformData->mDebugLogSeverity = mRenderer->getOptions().getDebugLogSeverity();
	platformData->mDebugBreakSeverity = mRenderer->getOptions().getDebugBreakSeverity();
	platformData->mObjectTracking = mRenderer->getOptions().getObjectTracking();

	mCinderContext = gl::Context::createFromExisting( platformData );
	mCinderContext->makeCurrent();

	::glfwSwapInterval( 1 );

	return true;
}
开发者ID:cinder,项目名称:Cinder,代码行数:26,代码来源:RendererGlLinuxGlfw.cpp

示例9: platformData

float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
{
    Olympia::Platform::Text::Font* font = platformData().font();
    ASSERT(font);

    const Olympia::Platform::Text::Utf16Char characters[] = { glyph };
    Olympia::Platform::Text::TextMetrics metrics;

#if PLATFORM(EGL) // FIXME: remove after Text API fixes shared context handling
    if (eglGetCurrentContext() == EGL_NO_CONTEXT)
        EGLDisplayOpenVG::current()->sharedPlatformSurface()->makeCurrent();
#endif
    FontPlatformData::engine()->drawText(0 /* no drawing, only measuring */,
        *font, characters, 1 /* number of characters */, 0 /*x*/, 0 /*y*/,
        0 /* no wrap */, 0 /* draw params */, &metrics);

    return metrics.m_linearAdvance * platformData().scaleFactor();
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:18,代码来源:SimpleFontDataBlackBerry.cpp

示例10: return

bool
js::Thread::Id::operator==(const Id& aOther) const
{
  const PlatformData& self = *platformData();
  const PlatformData& other = *aOther.platformData();
  return (!self.hasThread && !other.hasThread) ||
         (self.hasThread == other.hasThread &&
          pthread_equal(self.ptThread, other.ptThread));
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:9,代码来源:Thread.cpp

示例11: platformData

String Font::description() const
{
    if (isSVGFont())
        return "[SVG font]";
    if (isCustomFont())
        return "[custom font]";

    return platformData().description();
}
开发者ID:alexgcastro,项目名称:webkit,代码行数:9,代码来源:Font.cpp

示例12: FontDescription

SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
{
    if (!m_smallCapsFontData) {
        FontDescription desc = FontDescription(fontDescription);
        desc.setSpecifiedSize(0.70f * fontDescription.computedSize());
        FontPlatformData platformData(desc, desc.family().family());
        m_smallCapsFontData = new SimpleFontData(platformData);
    }
    return m_smallCapsFontData;
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:10,代码来源:SimpleFontDataPango.cpp

示例13: platformData

const char* SharedBuffer::data() const
{
    if (hasPlatformData())
        return platformData();
    
    if (m_purgeableBuffer)
        return m_purgeableBuffer->data();
    
    return buffer().data();
}
开发者ID:Moondee,项目名称:Artemis,代码行数:10,代码来源:SharedBuffer.cpp

示例14: smallCapsPlatformFont

SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& desc) const
{
    if (m_smallCapsFontData)
        return m_smallCapsFontData;

    FontDescription smallCapsDesc = desc;
    smallCapsDesc.setSmallCaps(true);

    FontPlatformData smallCapsPlatformFont(smallCapsDesc, platformData().fontFamily());
    m_smallCapsFontData = new SimpleFontData(smallCapsPlatformFont);
    return m_smallCapsFontData;
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:12,代码来源:SimpleFontDataBlackBerry.cpp

示例15: ASSERT

void SimpleFontData::platformInit()
{
    if (!m_platformData.m_size)
        return;

    ASSERT(m_platformData.scaledFont());
    cairo_font_extents_t fontExtents;
    cairo_scaled_font_extents(m_platformData.scaledFont(), &fontExtents);

    float ascent = narrowPrecisionToFloat(fontExtents.ascent);
    float descent = narrowPrecisionToFloat(fontExtents.descent);
    float lineGap = narrowPrecisionToFloat(fontExtents.height - fontExtents.ascent - fontExtents.descent);

    m_fontMetrics.setAscent(ascent);
    m_fontMetrics.setDescent(descent);

#if PLATFORM(EFL)
    m_fontMetrics.setLineSpacing(ascent + descent + lineGap);
#else
    // Match CoreGraphics metrics.
    m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
#endif
    m_fontMetrics.setLineGap(lineGap);

    cairo_text_extents_t textExtents;
    cairo_scaled_font_text_extents(m_platformData.scaledFont(), "x", &textExtents);
    m_fontMetrics.setXHeight(narrowPrecisionToFloat((platformData().orientation() == Horizontal) ? textExtents.height : textExtents.width));

    cairo_scaled_font_text_extents(m_platformData.scaledFont(), " ", &textExtents);
    m_spaceWidth = narrowPrecisionToFloat((platformData().orientation() == Horizontal) ? textExtents.x_advance : -textExtents.y_advance);

    if ((platformData().orientation() == Vertical) && !isTextOrientationFallback()) {
        FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont());
        m_fontMetrics.setUnitsPerEm(freeTypeFace->units_per_EM);
        cairo_ft_scaled_font_unlock_face(m_platformData.scaledFont());
    }

    m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
}
开发者ID:Web5design,项目名称:webkit.js,代码行数:39,代码来源:SimpleFontDataFreeType.cpp


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