int FontPlatformData::emSizeInFontUnits() const
{
    if (m_emSizeInFontUnits)
        return m_emSizeInFontUnits;

    SkAdvancedTypefaceMetrics* metrics = m_typeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
    m_emSizeInFontUnits = metrics->fEmSize;
    metrics->unref();
    return m_emSizeInFontUnits;
}
示例#2
0
int FontPlatformData::emSizeInFontUnits() const
{
    if (mEmSizeInFontUnits)
        return mEmSizeInFontUnits;

    SkAdvancedTypefaceMetrics* metrics = 0;
    if (mTypeface)
        metrics = mTypeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
    if (metrics) {
        mEmSizeInFontUnits = metrics->fEmSize;
        metrics->unref();
    } else
        mEmSizeInFontUnits = 1000;  // default value copied from Skia.
    return mEmSizeInFontUnits;
}
int FontPlatformData::emSizeInFontUnits() const
{
    if (m_emSizeInFontUnits)
        return m_emSizeInFontUnits;

    // FIXME: Switch to the SkTypeface::GetUnitsPerEm API once this becomes available.
    // https://bugs.webkit.org/show_bug.cgi?id=75961
#if OS(ANDROID)
    // Android doesn't currently support Skia's getAdvancedTypefaceMetrics(),
    // but it has access to another method to replace this functionality.
    m_emSizeInFontUnits = SkFontHost::GetUnitsPerEm(m_typeface->uniqueID());
#else
    SkAdvancedTypefaceMetrics* metrics = m_typeface->getAdvancedTypefaceMetrics(SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo);
    m_emSizeInFontUnits = metrics->fEmSize;
    metrics->unref();
#endif
    return m_emSizeInFontUnits;
}