Changeset 215461 in webkit


Ignore:
Timestamp:
Apr 18, 2017 9:15:32 AM (7 years ago)
Author:
pvollan@apple.com
Message:

Add fallback fonts to video captions stylesheet.
https://bugs.webkit.org/show_bug.cgi?id=170495

Reviewed by Eric Carlson.

The kCTFontCascadeListAttribute key is used to obtain the cascade list for a font reference.

I have not added a test, since CaptionUserPreferences::testingMode() returns true when running tests,
preventing this code path from being executed.

  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS):

  • platform/spi/win/CoreTextSPIWin.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r215458 r215461  
     12017-04-18  Per Arne Vollan  <pvollan@apple.com>
     2
     3        Add fallback fonts to video captions stylesheet.
     4        https://bugs.webkit.org/show_bug.cgi?id=170495
     5
     6        Reviewed by Eric Carlson.
     7
     8        The kCTFontCascadeListAttribute key is used to obtain the cascade list for a font reference.
     9
     10        I have not added a test, since CaptionUserPreferences::testingMode() returns true when running tests,
     11        preventing this code path from being executed.
     12
     13        * page/CaptionUserPreferencesMediaAF.cpp:
     14        (WebCore::CaptionUserPreferencesMediaAF::captionsDefaultFontCSS):
     15        * platform/spi/win/CoreTextSPIWin.h:
     16
    1172017-04-18  Miguel Gomez  <magomez@igalia.com>
    218
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r215185 r215461  
    3333
    3434#include "AudioTrackList.h"
     35#if PLATFORM(WIN)
     36#include "CoreTextSPIWin.h"
     37#endif
    3538#include "FloatConversion.h"
    3639#include "HTMLMediaElement.h"
     
    7982#define SOFT_LINK_AVF_FRAMEWORK_IMPORT_OPTIONAL(Lib, Fun, ReturnType, Arguments) SOFT_LINK_DLL_IMPORT_OPTIONAL(Lib, Fun, ReturnType, __cdecl, Arguments)
    8083
    81 // CoreText only needs to be soft-linked on Windows.
    82 SOFT_LINK_AVF_FRAMEWORK(CoreText)
    83 SOFT_LINK_AVF_FRAMEWORK_IMPORT(CoreText, CTFontDescriptorCopyAttribute,  CFTypeRef, (CTFontDescriptorRef descriptor, CFStringRef attribute), (descriptor, attribute));
    84 SOFT_LINK_AVF_POINTER(CoreText, kCTFontNameAttribute, CFStringRef)
    85 #define kCTFontNameAttribute getkCTFontNameAttribute()
    86 
    87 #define CTFontDescriptorCopyAttribute softLink_CTFontDescriptorCopyAttribute
    88 
    8984SOFT_LINK_AVF_FRAMEWORK(CoreMedia)
    9085SOFT_LINK_AVF_FRAMEWORK_IMPORT_OPTIONAL(CoreMedia, MTEnableCaption2015Behavior, Boolean, ())
     
    425420    if (!name)
    426421        return emptyString();
    427    
     422
    428423    StringBuilder builder;
    429424   
     
    432427    builder.append(static_cast<CFStringRef>(name.get()));
    433428    builder.append('"');
     429
     430    auto cascadeList = adoptCF(static_cast<CFArrayRef>(CTFontDescriptorCopyAttribute(font.get(), kCTFontCascadeListAttribute)));
     431
     432    if (cascadeList) {
     433        for (CFIndex i = 0; i < CFArrayGetCount(cascadeList.get()); i++) {
     434            auto fontCascade = static_cast<CTFontDescriptorRef>(CFArrayGetValueAtIndex(cascadeList.get(), i));
     435            if (!fontCascade)
     436                continue;
     437            auto fontCascadeName = adoptCF(CTFontDescriptorCopyAttribute(fontCascade, kCTFontNameAttribute));
     438            if (!fontCascadeName)
     439                continue;
     440            builder.append(", \"");
     441            builder.append(static_cast<CFStringRef>(fontCascadeName.get()));
     442            builder.append('"');
     443        }
     444    }
     445   
    434446    if (behavior == kMACaptionAppearanceBehaviorUseValue)
    435447        builder.appendLiteral(" !important");
  • trunk/Source/WebCore/platform/spi/win/CoreTextSPIWin.h

    r213227 r215461  
    3838
    3939CT_EXPORT const CFStringRef kCTFontAttributeName;
     40CT_EXPORT const CFStringRef kCTFontCascadeListAttribute;
     41CT_EXPORT const CFStringRef kCTFontNameAttribute;
    4042CT_EXPORT const CFStringRef kCTForegroundColorFromContextAttributeName;
    4143CT_EXPORT const CFStringRef kCTStrokeWidthAttributeName;
Note: See TracChangeset for help on using the changeset viewer.