#include "components/services/font/public/cpp/font_service_thread.h"
#include <utility>
#include "base/files/file.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/thread_pool.h"
#include "base/timer/elapsed_timer.h"
#include "components/services/font/public/cpp/mapped_font_file.h"
#include "pdf/buildflags.h"
namespace font_service {
namespace internal {
FontServiceThread::FontServiceThread()
: … { … }
FontServiceThread::~FontServiceThread() { … }
void FontServiceThread::Init(
mojo::PendingRemote<mojom::FontService> pending_font_service) { … }
bool FontServiceThread::MatchFamilyName(
const char family_name[],
SkFontStyle requested_style,
SkFontConfigInterface::FontIdentity* out_font_identity,
SkString* out_family_name,
SkFontStyle* out_style) { … }
bool FontServiceThread::FallbackFontForCharacter(
uint32_t character,
std::string locale,
font_service::mojom::FontIdentityPtr* out_font_identity,
std::string* out_family_name,
bool* out_is_bold,
bool* out_is_italic) { … }
bool FontServiceThread::FontRenderStyleForStrike(
std::string family,
uint32_t size,
bool is_italic,
bool is_bold,
float device_scale_factor,
font_service::mojom::FontRenderStylePtr* out_font_render_style) { … }
bool FontServiceThread::MatchFontByPostscriptNameOrFullFontName(
std::string postscript_name_or_full_font_name,
mojom::FontIdentityPtr* out_identity) { … }
#if BUILDFLAG(ENABLE_PDF)
void FontServiceThread::MatchFontWithFallback(
std::string family,
bool is_bold,
bool is_italic,
uint32_t charset,
uint32_t fallback_family_type,
base::File* out_font_file_handle) { … }
#endif
scoped_refptr<MappedFontFile> FontServiceThread::OpenStream(
const SkFontConfigInterface::FontIdentity& identity) { … }
void FontServiceThread::MatchFamilyNameImpl(
base::WaitableEvent* done_event,
const char family_name[],
SkFontStyle requested_style,
bool* out_valid,
SkFontConfigInterface::FontIdentity* out_font_identity,
SkString* out_family_name,
SkFontStyle* out_style) { … }
void FontServiceThread::OnMatchFamilyNameComplete(
base::WaitableEvent* done_event,
bool* out_valid,
SkFontConfigInterface::FontIdentity* out_font_identity,
SkString* out_family_name,
SkFontStyle* out_style,
mojom::FontIdentityPtr font_identity,
const std::string& family_name,
mojom::TypefaceStylePtr style) { … }
void FontServiceThread::OpenStreamImpl(base::WaitableEvent* done_event,
base::File* output_file,
const uint32_t id_number) { … }
void FontServiceThread::OnOpenStreamComplete(base::WaitableEvent* done_event,
base::File* output_file,
base::File file) { … }
void FontServiceThread::FallbackFontForCharacterImpl(
base::WaitableEvent* done_event,
uint32_t character,
std::string locale,
bool* out_valid,
font_service::mojom::FontIdentityPtr* out_font_identity,
std::string* out_family_name,
bool* out_is_bold,
bool* out_is_italic) { … }
void FontServiceThread::OnFallbackFontForCharacterComplete(
base::WaitableEvent* done_event,
bool* out_valid,
font_service::mojom::FontIdentityPtr* out_font_identity,
std::string* out_family_name,
bool* out_is_bold,
bool* out_is_italic,
mojom::FontIdentityPtr font_identity,
const std::string& family_name,
bool is_bold,
bool is_italic) { … }
void FontServiceThread::FontRenderStyleForStrikeImpl(
base::WaitableEvent* done_event,
std::string family,
uint32_t size,
bool is_italic,
bool is_bold,
float device_scale_factor,
bool* out_valid,
mojom::FontRenderStylePtr* out_font_render_style) { … }
void FontServiceThread::OnFontRenderStyleForStrikeComplete(
base::WaitableEvent* done_event,
bool* out_valid,
mojom::FontRenderStylePtr* out_font_render_style,
mojom::FontRenderStylePtr font_render_style) { … }
void FontServiceThread::MatchFontByPostscriptNameOrFullFontNameImpl(
base::WaitableEvent* done_event,
bool* out_valid,
std::string postscript_name_or_full_font_name,
mojom::FontIdentityPtr* out_font_identity) { … }
void FontServiceThread::OnMatchFontByPostscriptNameOrFullFontNameComplete(
base::WaitableEvent* done_event,
bool* out_valid,
mojom::FontIdentityPtr* out_font_identity,
mojom::FontIdentityPtr font_identity) { … }
#if BUILDFLAG(ENABLE_PDF)
void FontServiceThread::MatchFontWithFallbackImpl(
base::WaitableEvent* done_event,
std::string family,
bool is_bold,
bool is_italic,
uint32_t charset,
uint32_t fallback_family_type,
base::File* out_font_file_handle) { … }
void FontServiceThread::OnMatchFontWithFallbackComplete(
base::WaitableEvent* done_event,
base::File* out_font_file_handle,
base::File file) { … }
#endif
void FontServiceThread::OnFontServiceDisconnected() { … }
void FontServiceThread::InitImpl(
mojo::PendingRemote<mojom::FontService> pending_font_service) { … }
}
}