Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Unified Diff: third_party/WebKit/Source/platform/fonts/opentype/FontSettings.h

Issue 2547923002: Create a representation for OpenType variation settings (Closed)
Patch Set: Windows linkage fixed by removing additional export declspecs Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontFeatureSettings.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/fonts/opentype/FontSettings.h
diff --git a/third_party/WebKit/Source/platform/fonts/opentype/FontSettings.h b/third_party/WebKit/Source/platform/fonts/opentype/FontSettings.h
new file mode 100644
index 0000000000000000000000000000000000000000..c64693529b1bb4b21b8454b0de5b1d1d08e60220
--- /dev/null
+++ b/third_party/WebKit/Source/platform/fonts/opentype/FontSettings.h
@@ -0,0 +1,90 @@
+// 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.
+
+#ifndef FontSettings_h
+#define FontSettings_h
+
+#include "platform/PlatformExport.h"
+#include "wtf/Allocator.h"
+#include "wtf/PassRefPtr.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
+#include "wtf/text/AtomicString.h"
+
+namespace blink {
+
+template <typename T>
+class FontTagValuePair {
+ DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
+
+ public:
+ FontTagValuePair(const AtomicString& tag, T value)
+ : m_tag(tag), m_value(value){};
+ bool operator==(const FontTagValuePair& other) const {
+ return m_tag == other.m_tag && m_value == other.m_value;
+ };
+
+ const AtomicString& tag() const { return m_tag; }
+ T value() const { return m_value; }
+
+ private:
+ AtomicString m_tag;
+ const T m_value;
+};
+
+template <typename T>
+class FontSettings {
+ WTF_MAKE_NONCOPYABLE(FontSettings);
+
+ public:
+ void append(const T& feature) { m_list.append(feature); }
+ size_t size() const { return m_list.size(); }
+ const T& operator[](int index) const { return m_list[index]; }
+ const T& at(size_t index) const { return m_list.at(index); }
+ bool operator==(const FontSettings& other) const {
+ return m_list == other.m_list;
+ };
+
+ protected:
+ FontSettings(){};
+
+ private:
+ Vector<T> m_list;
+};
+
+using FontFeature = FontTagValuePair<int>;
+using FontVariationAxis = FontTagValuePair<float>;
+
+class PLATFORM_EXPORT FontFeatureSettings
+ : public FontSettings<FontFeature>,
+ public RefCounted<FontFeatureSettings> {
+ WTF_MAKE_NONCOPYABLE(FontFeatureSettings);
+
+ public:
+ static PassRefPtr<FontFeatureSettings> create() {
+ return adoptRef(new FontFeatureSettings);
+ }
+
+ private:
+ FontFeatureSettings() = default;
+};
+
+class PLATFORM_EXPORT FontVariationSettings
+ : public FontSettings<FontVariationAxis>,
+ public RefCounted<FontVariationSettings> {
+ WTF_MAKE_NONCOPYABLE(FontVariationSettings);
+
+ public:
+ static PassRefPtr<FontVariationSettings> create() {
+ return adoptRef(new FontVariationSettings());
+ };
+
+ private:
+ FontVariationSettings() = default;
+};
+
+} // namespace blink
+
+#endif // FontSettings_h
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontFeatureSettings.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698