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

Side by Side Diff: src/core/SkFontDescriptor.h

Issue 1027373002: Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkFontDescriptor_DEFINED 8 #ifndef SkFontDescriptor_DEFINED
9 #define SkFontDescriptor_DEFINED 9 #define SkFontDescriptor_DEFINED
10 10
11 #include "SkStream.h" 11 #include "SkStream.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 #include "SkTypeface.h" 13 #include "SkTypeface.h"
14 14
15 class SkFontParameters {
bungeman-skia 2015/03/23 21:59:05 So this class is pragmatic, but also represents th
16 public:
17 SkFontParameters() : fIndex(0) { }
18 int fIndex;
19 SkAutoSTArray<4, SkFixed> fAxis;
20 };
21
15 class SkFontDescriptor { 22 class SkFontDescriptor {
16 public: 23 public:
17 SkFontDescriptor(SkTypeface::Style = SkTypeface::kNormal); 24 SkFontDescriptor(SkTypeface::Style = SkTypeface::kNormal);
18 // Does not affect ownership of SkStream. 25 // Does not affect ownership of SkStream.
19 SkFontDescriptor(SkStream*); 26 SkFontDescriptor(SkStream*);
20 27
21 void serialize(SkWStream*); 28 void serialize(SkWStream*);
22 29
23 SkTypeface::Style getStyle() { return fStyle; } 30 SkTypeface::Style getStyle() { return fStyle; }
24 void setStyle(SkTypeface::Style style) { fStyle = style; } 31 void setStyle(SkTypeface::Style style) { fStyle = style; }
25 32
26 const char* getFamilyName() const { return fFamilyName.c_str(); } 33 const char* getFamilyName() const { return fFamilyName.c_str(); }
27 const char* getFullName() const { return fFullName.c_str(); } 34 const char* getFullName() const { return fFullName.c_str(); }
28 const char* getPostscriptName() const { return fPostscriptName.c_str(); } 35 const char* getPostscriptName() const { return fPostscriptName.c_str(); }
29 const char* getFontFileName() const { return fFontFileName.c_str(); } 36 const char* getFontFileName() const { return fFontFileName.c_str(); }
30 bool hasFontData() const { return fFontData.get() != NULL; } 37 bool hasFontData() const { return fFontData.get() != NULL; }
31 // Transfers ownership to the caller. 38 // Transfers ownership to the caller.
32 SkStreamAsset* transferFontData() { return fFontData.detach(); } 39 SkStreamAsset* transferFontData() { return fFontData.detach(); }
33 int getFontIndex() const { return fFontIndex; } 40 SkFontParameters& getFontParameters() { return fFontParameters; }
34 41
35 void setFamilyName(const char* name) { fFamilyName.set(name); } 42 void setFamilyName(const char* name) { fFamilyName.set(name); }
36 void setFullName(const char* name) { fFullName.set(name); } 43 void setFullName(const char* name) { fFullName.set(name); }
37 void setPostscriptName(const char* name) { fPostscriptName.set(name); } 44 void setPostscriptName(const char* name) { fPostscriptName.set(name); }
38 void setFontFileName(const char* name) { fFontFileName.set(name); } 45 void setFontFileName(const char* name) { fFontFileName.set(name); }
39 /** Set the font data only if it is necessary for serialization. 46 /** Set the font data only if it is necessary for serialization.
40 * This method takes ownership of the stream (both reference and cursor). 47 * This method takes ownership of the stream (both reference and cursor).
41 */ 48 */
42 void setFontData(SkStreamAsset* stream) { fFontData.reset(stream); } 49 void setFontData(SkStreamAsset* stream) { fFontData.reset(stream); }
43 void setFontIndex(int index) { fFontIndex = index; }
44 50
45 private: 51 private:
46 SkString fFamilyName; 52 SkString fFamilyName;
47 SkString fFullName; 53 SkString fFullName;
48 SkString fPostscriptName; 54 SkString fPostscriptName;
49 SkString fFontFileName; 55 SkString fFontFileName;
50 SkAutoTDelete<SkStreamAsset> fFontData; 56 SkAutoTDelete<SkStreamAsset> fFontData;
51 int fFontIndex; 57 SkFontParameters fFontParameters;
52 58
53 SkTypeface::Style fStyle; 59 SkTypeface::Style fStyle;
54 }; 60 };
55 61
56 #endif // SkFontDescriptor_DEFINED 62 #endif // SkFontDescriptor_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698