forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_font_selector.cc
50 lines (38 loc) · 1.7 KB
/
test_font_selector.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/runtime/test_font_selector.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/runtime/test_font_data.h"
#include "flutter/sky/engine/platform/fonts/SimpleFontData.h"
namespace blink {
void TestFontSelector::Install() {
auto font_selector = adoptRef(new TestFontSelector());
UIDartState::Current()->set_font_selector(font_selector);
}
TestFontSelector::TestFontSelector() = default;
TestFontSelector::~TestFontSelector() = default;
PassRefPtr<FontData> TestFontSelector::getFontData(
const FontDescription& fontDescription,
const AtomicString& familyName) {
if (!test_typeface_) {
test_typeface_ = SkTypeface::MakeFromStream(GetTestFontData().release());
}
bool syntheticBold = (fontDescription.weight() >= FontWeight600 ||
fontDescription.isSyntheticBold());
bool syntheticItalic =
(fontDescription.style() || fontDescription.isSyntheticItalic());
FontPlatformData platform_data(
test_typeface_, GetTestFontFamilyName().c_str(),
fontDescription.effectiveFontSize(), syntheticBold, syntheticItalic,
fontDescription.orientation(), fontDescription.useSubpixelPositioning());
return SimpleFontData::create(platform_data, CustomFontData::create());
}
void TestFontSelector::willUseFontData(const FontDescription&,
const AtomicString& familyName,
UChar32) {}
unsigned TestFontSelector::version() const {
return 0;
}
void TestFontSelector::fontCacheInvalidated() {}
} // namespace blink