Bump version to 24.04.3.4
[LibreOffice.git] / external / skia / fontconfig-get-typeface.patch.0
blob20c3f5b9cbe09ef0c1d966054d49f39720b83211
1 diff --git a/include/ports/SkFontMgr_fontconfig.h b/include/ports/SkFontMgr_fontconfig.h
2 index 4b2bb2d297..2b82cbfedd 100644
3 --- include/ports/SkFontMgr_fontconfig.h
4 +++ include/ports/SkFontMgr_fontconfig.h
5 @@ -19,4 +19,9 @@ class SkFontMgr;
6   */
7  SK_API sk_sp<SkFontMgr> SkFontMgr_New_FontConfig(FcConfig* fc);
8  
9 +struct _FcPattern;
10 +typedef struct _FcPattern FcPattern;
11 +class SkTypeface;
12 +SK_API sk_sp<SkTypeface> SkFontMgr_createTypefaceFromFcPattern(const sk_sp<SkFontMgr>& mgr, FcPattern* pattern);
14  #endif // #ifndef SkFontMgr_fontconfig_DEFINED
15 diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
16 index c2da39b28f..28483faf02 100644
17 --- src/ports/SkFontMgr_fontconfig.cpp
18 +++ src/ports/SkFontMgr_fontconfig.cpp
19 @@ -690,6 +690,7 @@ class SkFontMgr_fontconfig : public SkFontMgr {
20      /** Creates a typeface using a typeface cache.
21       *  @param pattern a complete pattern from FcFontRenderPrepare.
22       */
23 +public:
24      sk_sp<SkTypeface> createTypefaceFromFcPattern(SkAutoFcPattern pattern) const {
25          if (!pattern) {
26              return nullptr;
27 @@ -1043,3 +1044,13 @@ protected:
28  SK_API sk_sp<SkFontMgr> SkFontMgr_New_FontConfig(FcConfig* fc) {
29      return sk_make_sp<SkFontMgr_fontconfig>(fc);
30  }
32 +SK_API sk_sp<SkTypeface> SkFontMgr_createTypefaceFromFcPattern(const sk_sp<SkFontMgr>& mgr, FcPattern* pattern)
34 +    SkAutoFcPattern p([pattern]() {
35 +        FCLocker lock;
36 +        FcPatternReference(pattern);
37 +        return pattern;
38 +    }());
39 +    return static_cast<SkFontMgr_fontconfig*>(mgr.get())->createTypefaceFromFcPattern(std::move(p));