Skip to content

Commit

Permalink
Fix desktop build
Browse files Browse the repository at this point in the history
  • Loading branch information
uazo committed Apr 11, 2024
1 parent 0ac13dd commit b7ca0a9
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions build/patches/Embed-System-Fonts-on-Android.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
chrome/browser/BUILD.gn | 13 +++
.../fonts_pack_component_installer.cc | 97 +++++++++++++++++++
.../fonts_pack_component_installer.h | 60 ++++++++++++
.../browser/component_updater/registration.cc | 5 +
.../browser/component_updater/registration.cc | 7 ++
chrome/renderer/BUILD.gn | 3 +
components/services/font/BUILD.gn | 11 +++
components/services/font/font_service_app.cc | 43 ++++++++
Expand All @@ -21,16 +21,18 @@ License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
.../renderer_host/render_process_host_impl.cc | 12 ++-
content/child/BUILD.gn | 7 ++
content/renderer/BUILD.gn | 4 +
.../renderer/renderer_blink_platform_impl.cc | 48 ++++++++-
.../renderer/renderer_blink_platform_impl.cc | 50 +++++++++-
skia/BUILD.gn | 12 +++
.../fonts/skia/bromite_allowed_fonts.h | 3 +
.../include/ports/SkFontConfigInterface.h | 2 +
.../skia/include/ports/SkFontMgr_android.h | 39 +++++++-
.../skia/src/ports/SkFontConfigInterface.cpp | 4 +
.../ports/SkFontConfigInterface_direct.cpp | 5 +
.../src/ports/SkFontConfigInterface_direct.h | 1 +
.../skia/src/ports/SkFontMgr_android.cpp | 45 ++++++---
.../src/ports/SkFontMgr_android_parser.cpp | 37 +++++--
.../skia/src/ports/SkFontMgr_android_parser.h | 2 +
26 files changed, 497 insertions(+), 27 deletions(-)
28 files changed, 507 insertions(+), 27 deletions(-)
create mode 100644 chrome/browser/component_updater/fonts_pack_component_installer.cc
create mode 100644 chrome/browser/component_updater/fonts_pack_component_installer.h

Expand Down Expand Up @@ -234,7 +236,7 @@ new file mode 100644
diff --git a/chrome/browser/component_updater/registration.cc b/chrome/browser/component_updater/registration.cc
--- a/chrome/browser/component_updater/registration.cc
+++ b/chrome/browser/component_updater/registration.cc
@@ -96,10 +96,15 @@
@@ -96,10 +96,17 @@
#include "ui/aura/env.h"
#endif

Expand All @@ -246,7 +248,9 @@ diff --git a/chrome/browser/component_updater/registration.cc b/chrome/browser/c

void RegisterComponentsForUpdate() {
auto* const cus = g_browser_process->component_updater();
+#if BUILDFLAG(IS_ANDROID)
+ RegisterFontsPackComponent(cus);
+#endif

#if BUILDFLAG(IS_WIN)
RegisterRecoveryImprovedComponent(cus, g_browser_process->local_state());
Expand Down Expand Up @@ -626,10 +630,11 @@ diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer
using blink::Platform;
using blink::WebAudioDevice;
using blink::WebAudioLatencyHint;
@@ -173,6 +190,30 @@ gpu::ContextType ToGpuContextType(blink::Platform::ContextType type) {
@@ -173,6 +190,32 @@ gpu::ContextType ToGpuContextType(blink::Platform::ContextType type) {
return gpu::CONTEXT_TYPE_OPENGLES2;
}

+#if BUILDFLAG(IS_ANDROID)
+void InitializeCustomFonts() {
+ std::string font_config = "cromite_fonts.xml";
+ sk_sp<SkFontConfigInterface> fci(SkFontConfigInterface::RefGlobal());
Expand All @@ -653,11 +658,12 @@ diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer
+ SkFontMgr_New_Android(std::move(custom));
+ skia::OverrideDefaultSkFontMgr(std::move(skia_font_manager));
+}
+#endif
+
} // namespace

//------------------------------------------------------------------------------
@@ -186,18 +227,21 @@ RendererBlinkPlatformImpl::RendererBlinkPlatformImpl(
@@ -186,18 +229,21 @@ RendererBlinkPlatformImpl::RendererBlinkPlatformImpl(
is_locked_to_site_(false),
main_thread_scheduler_(main_thread_scheduler),
next_frame_sink_id_(uint32_t{std::numeric_limits<int32_t>::max()} + 1) {
Expand Down Expand Up @@ -801,6 +807,29 @@ diff --git a/third_party/skia/src/ports/SkFontConfigInterface.cpp b/third_party/
}

void SkFontConfigInterface::SetGlobal(sk_sp<SkFontConfigInterface> fc) {
diff --git a/third_party/skia/src/ports/SkFontConfigInterface_direct.cpp b/third_party/skia/src/ports/SkFontConfigInterface_direct.cpp
--- a/third_party/skia/src/ports/SkFontConfigInterface_direct.cpp
+++ b/third_party/skia/src/ports/SkFontConfigInterface_direct.cpp
@@ -707,3 +707,8 @@ bool SkFontConfigInterfaceDirect::matchFamilyName(const char familyName[],
SkStreamAsset* SkFontConfigInterfaceDirect::openStream(const FontIdentity& identity) {
return SkStream::MakeFromFile(identity.fString.c_str()).release();
}
+
+SkStreamAsset* SkFontConfigInterfaceDirect::openStreamFromName(const char* filename) {
+ SkASSERT(false);
+ return nullptr;
+}
diff --git a/third_party/skia/src/ports/SkFontConfigInterface_direct.h b/third_party/skia/src/ports/SkFontConfigInterface_direct.h
--- a/third_party/skia/src/ports/SkFontConfigInterface_direct.h
+++ b/third_party/skia/src/ports/SkFontConfigInterface_direct.h
@@ -29,6 +29,7 @@ public:
SkFontStyle* outStyle) override;

SkStreamAsset* openStream(const FontIdentity&) override;
+ SkStreamAsset* openStreamFromName(const char* filename) override;

protected:
virtual bool isAccessible(const char* filename);
diff --git a/third_party/skia/src/ports/SkFontMgr_android.cpp b/third_party/skia/src/ports/SkFontMgr_android.cpp
--- a/third_party/skia/src/ports/SkFontMgr_android.cpp
+++ b/third_party/skia/src/ports/SkFontMgr_android.cpp
Expand Down

0 comments on commit b7ca0a9

Please sign in to comment.