1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "config.h" 6#include "core/css/LocalFontFaceSource.h" 7 8#include "platform/fonts/FontCache.h" 9#include "platform/fonts/FontDescription.h" 10#include "platform/fonts/SimpleFontData.h" 11#include "public/platform/Platform.h" 12 13namespace blink { 14 15bool LocalFontFaceSource::isLocalFontAvailable(const FontDescription& fontDescription) 16{ 17 return FontCache::fontCache()->isPlatformFontAvailable(fontDescription, m_fontName); 18} 19 20PassRefPtr<SimpleFontData> LocalFontFaceSource::createFontData(const FontDescription& fontDescription) 21{ 22 // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter. 23 RefPtr<SimpleFontData> fontData = FontCache::fontCache()->getFontData(fontDescription, m_fontName, true); 24 m_histograms.record(fontData); 25 return fontData.release(); 26} 27 28void LocalFontFaceSource::LocalFontHistograms::record(bool loadSuccess) 29{ 30 if (m_reported) 31 return; 32 m_reported = true; 33 blink::Platform::current()->histogramEnumeration("WebFont.LocalFontUsed", loadSuccess ? 1 : 0, 2); 34} 35 36} // namespace blink 37