Skip to content

Commit

Permalink
[Freetype] Add basic implementation of FontCustomPlatformData::suppor…
Browse files Browse the repository at this point in the history
…tsTechnology

https://bugs.webkit.org/show_bug.cgi?id=256310

Reviewed by Michael Catanzaro.

Instead of unconditionally returning true this explicitly handles the technologies.

* Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
(WebCore::FontCustomPlatformData::supportsTechnology):
* Source/cmake/FindHarfBuzz.cmake:

Canonical link: https://commits.webkit.org/273584@main
  • Loading branch information
TingPing committed Jan 27, 2024
1 parent 9707cf7 commit dda504f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
#include FT_MODULE_H
#include <mutex>

#ifdef HAVE_HB_FEATURES_H
// Workaround https://github.com/harfbuzz/harfbuzz/commit/30c5402e3d0cc156fd5f04560864a88723173cf2
#define HB_NO_SINGLE_HEADER_ERROR
#include <hb-features.h>
#undef HB_NO_SINGLE_HEADER_ERROR
#endif

namespace WebCore {

static cairo_user_data_key_t freeTypeFaceKey;
Expand Down Expand Up @@ -166,10 +173,36 @@ bool FontCustomPlatformData::supportsFormat(const String& format)
|| equalLettersIgnoringASCIICase(format, "svg"_s);
}

bool FontCustomPlatformData::supportsTechnology(const FontTechnology&)
bool FontCustomPlatformData::supportsTechnology(const FontTechnology& technology)
{
// FIXME: define supported technologies for this platform (webkit.org/b/256310).
return true;
#if USE(HARFBUZZ)
// https://harfbuzz.github.io/what-does-harfbuzz-do.html
// Many of these features *could* be disabled but hb doesn't easily expose
// this and it is unlikely.
switch (technology) {
case FontTechnology::ColorCbdt:
case FontTechnology::ColorColrv0:
case FontTechnology::ColorColrv1:
case FontTechnology::ColorSbix:
case FontTechnology::ColorSvg:
case FontTechnology::FeaturesAat:
case FontTechnology::FeaturesOpentype:
case FontTechnology::Incremental:
case FontTechnology::Palettes:
case FontTechnology::Variations:
return true;
case FontTechnology::Invalid:
return false;
case FontTechnology::FeaturesGraphite:
#ifdef HB_HAS_GRAPHITE
return true;
#else
return false;
#endif
}
#endif

return false;
}

}
6 changes: 6 additions & 0 deletions Source/cmake/FindHarfBuzz.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS)
endif ()
endif ()

# Workaround https://github.com/harfbuzz/harfbuzz/pull/4562
if (HarfBuzz_INCLUDE_DIR AND EXISTS "${HarfBuzz_INCLUDE_DIR}/hb-features.h")
list(APPEND HarfBuzz_COMPILE_OPTIONS "-DHAVE_HB_FEATURES_H")
message(STATUS "Found hb-features.h")
endif ()

if (NOT HarfBuzz_FIND_QUIETLY)
if (HarfBuzz_LIBS_FOUND)
message(STATUS "Found the following HarfBuzz libraries:")
Expand Down

0 comments on commit dda504f

Please sign in to comment.