Avoid potential negative array index access to cached text.
[LibreOffice.git] / external / skia / windows-typeface-directwrite.patch.0
blob56e8209cedb41f14e85d5171b999ab1d29eed9d4
1 --- ./include/ports/SkTypeface_win.h
2 +++ ./include/ports/SkTypeface_win.h
3 @@ -75,5 +75,13 @@ SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontM
4   */
5  SK_API sk_sp<SkRemotableFontMgr> SkRemotableFontMgr_New_DirectWrite();
6  
7 +struct IDWriteFontFace;
8 +struct IDWriteFont;
9 +struct IDWriteFontFamily;
10 +SK_API SkTypeface* SkCreateTypefaceDirectWrite(sk_sp<SkFontMgr> fontMgr,
11 +                                               IDWriteFontFace* fontFace,
12 +                                               IDWriteFont* font,
13 +                                               IDWriteFontFamily* fontFamily);
15  #endif  // SK_BUILD_FOR_WIN
16  #endif  // SkTypeface_win_DEFINED
17 --- ./src/ports/SkFontMgr_win_dw.cpp
18 +++ ./src/ports/SkFontMgr_win_dw.cpp
19 @@ -320,6 +320,10 @@ private:
21      friend class SkFontStyleSet_DirectWrite;
22      friend class FontFallbackRenderer;
23 +    friend SK_API SkTypeface* SkCreateTypefaceDirectWrite(sk_sp<SkFontMgr> fontMgr,
24 +                                               IDWriteFontFace* fontFace,
25 +                                               IDWriteFont* font,
26 +                                               IDWriteFontFamily* fontFamily);
27  };
29  class SkFontStyleSet_DirectWrite : public SkFontStyleSet {
30 @@ -1215,6 +1219,18 @@ SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
31                                               defaultFamilyName, defaultFamilyNameLen);
32  }
34 +SkTypeface* SkCreateTypefaceDirectWrite(sk_sp<SkFontMgr> fontMgr,
35 +                                        IDWriteFontFace* fontFace,
36 +                                        IDWriteFont* font,
37 +                                        IDWriteFontFamily* fontFamily)
39 +    SkFontMgr_DirectWrite* mgr = dynamic_cast<SkFontMgr_DirectWrite*>(fontMgr.get());
40 +    if(!mgr)
41 +        return nullptr;
42 +    sk_sp<SkTypeface> typeface = mgr->makeTypefaceFromDWriteFont(fontFace, font, fontFamily);
43 +    return typeface.release();
46  #include "include/ports/SkFontMgr_indirect.h"
47  SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr> proxy) {
48      sk_sp<SkFontMgr> impl(SkFontMgr_New_DirectWrite());