diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild
index 0202ed3..2d8fbdf 100644
--- a/config/system-headers.mozbuild
+++ b/config/system-headers.mozbuild
@@ -1321,6 +1321,19 @@ if CONFIG["MOZ_SYSTEM_AV1"]:
         "dav1d/dav1d.h",
     ]
 
+if CONFIG['MOZ_SYSTEM_GRAPHITE2']:
+    system_headers += [
+        'graphite2/Font.h',
+        'graphite2/Segment.h',
+    ]
+
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    system_headers += [
+        'harfbuzz/hb-glib.h',
+        'harfbuzz/hb-ot.h',
+        'harfbuzz/hb.h',
+    ]
+
 if CONFIG["MOZ_SYSTEM_ICU"]:
     system_headers += [
         "unicode/calendar.h",
diff --git a/dom/base/moz.build b/dom/base/moz.build
index 7e8d942..93b1822 100644
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -610,6 +610,9 @@ FINAL_LIBRARY = "xul"
 if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
     CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"]
 
+if CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
+    CXXFLAGS += CONFIG["MOZ_HARFBUZZ_CFLAGS"]
+
 GeneratedFile(
     "UseCounterList.h",
     script="gen-usecounters.py",
diff --git a/gfx/graphite2/geckoextra/moz.build b/gfx/graphite2/geckoextra/moz.build
new file mode 100644
index 0000000..e0c5c51
--- /dev/null
+++ b/gfx/graphite2/geckoextra/moz.build
@@ -0,0 +1,25 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+EXPORTS.graphite2 += [
+    'include/GraphiteExtra.h',
+    'include/GraphiteStructsForRLBox.h',
+]
+
+UNIFIED_SOURCES += [
+    '../geckoextra/src/GraphiteExtra.cpp',
+]
+
+CXXFLAGS += CONFIG['MOZ_GRAPHITE2_CFLAGS']
+
+if CONFIG["MOZ_SYSTEM_GRAPHITE2"]:
+    OS_LIBS += CONFIG["MOZ_GRAPHITE2_LIBS"]
+
+
+# Match bundled graphite2 configuration
+AllowCompilerWarnings()
+
+FINAL_LIBRARY = 'xul'
diff --git a/gfx/moz.build b/gfx/moz.build
index 853d855..bdcbb48 100644
--- a/gfx/moz.build
+++ b/gfx/moz.build
@@ -8,6 +8,14 @@ with Files("**"):
 with Files("wr/**"):
     BUG_COMPONENT = ("Core", "Graphics: WebRender")
 
+if CONFIG["MOZ_SYSTEM_GRAPHITE2"]:
+    DIRS += ["graphite2/geckoextra"]
+else:
+    DIRS += ["graphite2/src" ]
+
+if not CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
+    DIRS += ["harfbuzz/src"]
+
 DIRS += [
     "cairo",
     "2d",
@@ -17,8 +25,6 @@ DIRS += [
     "qcms",
     "gl",
     "layers",
-    "graphite2/src",
-    "harfbuzz/src",
     "ots/src",
     "thebes",
     "ipc",
diff --git a/gfx/skia/generate_mozbuild.py b/gfx/skia/generate_mozbuild.py
index c9332ae..e593f2d 100755
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -98,6 +98,9 @@ LOCAL_INCLUDES += [
     "/gfx/harfbuzz/src",
 ]
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk', 'android'):
     LOCAL_INCLUDES += [
         "/gfx/cairo/cairo/src",
diff --git a/gfx/skia/moz.build b/gfx/skia/moz.build
index 4f0f150..c74ac83 100644
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -651,6 +651,9 @@ LOCAL_INCLUDES += [
     "/gfx/harfbuzz/src",
 ]
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk', 'android'):
     LOCAL_INCLUDES += [
         "/gfx/cairo/cairo/src",
diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build
index 2bb893d..d69c722 100644
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -294,7 +294,13 @@ if CONFIG["MOZ_WAYLAND"]:
 
 LOCAL_INCLUDES += CONFIG["SKIA_INCLUDES"]
 
-DEFINES["GRAPHITE2_STATIC"] = True
+if CONFIG["MOZ_SYSTEM_GRAPHITE2"]:
+    CXXFLAGS += CONFIG["MOZ_GRAPHITE2_CFLAGS"]
+else:
+    DEFINES["GRAPHITE2_STATIC"] = True
+
+if CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
+    CXXFLAGS += CONFIG["MOZ_HARFBUZZ_CFLAGS"]
 
 COMPILE_FLAGS["WARNINGS_CXXFLAGS"] += ["-Werror=switch"]
 
diff --git a/intl/unicharutil/util/moz.build b/intl/unicharutil/util/moz.build
index c936134..3528895 100644
--- a/intl/unicharutil/util/moz.build
+++ b/intl/unicharutil/util/moz.build
@@ -22,6 +22,9 @@ UNIFIED_SOURCES += [
     "nsUnicodeProperties.cpp",
 ]
 
+if CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
+    CXXFLAGS += CONFIG["MOZ_HARFBUZZ_CFLAGS"]
+
 include("/ipc/chromium/chromium-config.mozbuild")
 
 GeneratedFile(
diff --git a/netwerk/dns/moz.build b/netwerk/dns/moz.build
index 2369794..186d279 100644
--- a/netwerk/dns/moz.build
+++ b/netwerk/dns/moz.build
@@ -105,6 +105,9 @@ GeneratedFile(
     "etld_data.inc", script="prepare_tlds.py", inputs=["effective_tld_names.dat"]
 )
 
+if CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
+    CXXFLAGS += CONFIG["MOZ_HARFBUZZ_CFLAGS"]
+
 # need to include etld_data.inc
 LOCAL_INCLUDES += [
     "/netwerk/base",
diff --git a/security/rlbox/moz.build b/security/rlbox/moz.build
index 64545f5..a8f9235 100644
--- a/security/rlbox/moz.build
+++ b/security/rlbox/moz.build
@@ -45,6 +45,9 @@ if CONFIG["MOZ_WASM_SANDBOXING_GRAPHITE"]:
     for k, v in graphite_defines:
         WASM_DEFINES[k] = v
     LOCAL_INCLUDES += ["/gfx/graphite2/src"]
+    if CONFIG["MOZ_SYSTEM_GRAPHITE2"]:
+      OS_LIBS += CONFIG["MOZ_GRAPHITE2_LIBS"]
+      WASM_CXXFLAGS += CONFIG["MOZ_GRAPHITE2_CFLAGS"]
 
 if CONFIG["MOZ_WASM_SANDBOXING_OGG"]:
     include("/media/libogg/sources.mozbuild")
diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build
index 08de21d..1214623 100644
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -293,6 +293,12 @@ if CONFIG["MOZ_SYSTEM_PNG"]:
 if CONFIG["MOZ_SYSTEM_WEBP"]:
     OS_LIBS += CONFIG["MOZ_WEBP_LIBS"]
 
+if CONFIG["MOZ_SYSTEM_GRAPHITE2"]:
+    OS_LIBS += CONFIG["MOZ_GRAPHITE2_LIBS"]
+
+if CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
+    OS_LIBS += CONFIG["MOZ_HARFBUZZ_LIBS"]
+
 if CONFIG["MOZ_SYSTEM_LIBEVENT"]:
     OS_LIBS += CONFIG["MOZ_LIBEVENT_LIBS"]
 
diff --git a/toolkit/moz.configure b/toolkit/moz.configure
index 75e99bb..30058b3 100644
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -1341,6 +1341,26 @@ def enable_cairo_ft(target, tree_freetype, freetype2_info):
 set_config("MOZ_ENABLE_CAIRO_FT", True, when=enable_cairo_ft)
 set_config("CAIRO_FT_CFLAGS", ft2_info.cflags, when=enable_cairo_ft)
 
+# Graphite2
+# ==============================================================
+option("--with-system-graphite2",
+       help="Use system graphite2 (located with pkgconfig)")
+
+system_graphite2 = pkg_check_modules("MOZ_GRAPHITE2", "graphite2",
+                                     when="--with-system-graphite2")
+
+set_config("MOZ_SYSTEM_GRAPHITE2", depends_if(system_graphite2)(lambda _: True))
+
+# HarfBuzz
+# ==============================================================
+option("--with-system-harfbuzz",
+       help="Use system harfbuzz (located with pkgconfig)")
+
+system_harfbuzz = pkg_check_modules("MOZ_HARFBUZZ", "harfbuzz >= 2.7.4",
+                                    when="--with-system-harfbuzz")
+
+set_config("MOZ_SYSTEM_HARFBUZZ", depends_if(system_harfbuzz)(lambda _: True))
+
 
 # WebDriver (HTTP / BiDi)
 # ==============================================================
