| OLD | NEW |
| 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 SkFontDescriptor { | 15 class SkFontDescriptor { |
| 16 public: | 16 public: |
| 17 SkFontDescriptor(SkTypeface::Style = SkTypeface::kNormal); | 17 SkFontDescriptor(SkTypeface::Style = SkTypeface::kNormal); |
| 18 // Does not affect ownership of SkStream. | 18 // Does not affect ownership of SkStream. |
| 19 SkFontDescriptor(SkStream*); | 19 SkFontDescriptor(SkStream*); |
| 20 | 20 |
| 21 void serialize(SkWStream*); | 21 void serialize(SkWStream*); |
| 22 | 22 |
| 23 SkTypeface::Style getStyle() { return fStyle; } | 23 SkTypeface::Style getStyle() { return fStyle; } |
| 24 void setStyle(SkTypeface::Style style) { fStyle = style; } | 24 void setStyle(SkTypeface::Style style) { fStyle = style; } |
| 25 | 25 |
| 26 const char* getFamilyName() const { return fFamilyName.c_str(); } | 26 const char* getFamilyName() const { return fFamilyName.c_str(); } |
| 27 const char* getFullName() const { return fFullName.c_str(); } | 27 const char* getFullName() const { return fFullName.c_str(); } |
| 28 const char* getPostscriptName() const { return fPostscriptName.c_str(); } | 28 const char* getPostscriptName() const { return fPostscriptName.c_str(); } |
| 29 const char* getFontFileName() const { return fFontFileName.c_str(); } | |
| 30 bool hasFontData() const { return fFontData.get() != NULL; } | 29 bool hasFontData() const { return fFontData.get() != NULL; } |
| 31 // Transfers ownership to the caller. | 30 // Transfers ownership to the caller. |
| 32 SkStreamAsset* transferFontData() { return fFontData.detach(); } | 31 SkStreamAsset* transferFontData() { return fFontData.detach(); } |
| 33 int getFontIndex() const { return fFontIndex; } | 32 int getFontIndex() const { return fFontIndex; } |
| 34 | 33 |
| 35 void setFamilyName(const char* name) { fFamilyName.set(name); } | 34 void setFamilyName(const char* name) { fFamilyName.set(name); } |
| 36 void setFullName(const char* name) { fFullName.set(name); } | 35 void setFullName(const char* name) { fFullName.set(name); } |
| 37 void setPostscriptName(const char* name) { fPostscriptName.set(name); } | 36 void setPostscriptName(const char* name) { fPostscriptName.set(name); } |
| 38 void setFontFileName(const char* name) { fFontFileName.set(name); } | |
| 39 /** Set the font data only if it is necessary for serialization. | 37 /** Set the font data only if it is necessary for serialization. |
| 40 * This method takes ownership of the stream (both reference and cursor). | 38 * This method takes ownership of the stream (both reference and cursor). |
| 41 */ | 39 */ |
| 42 void setFontData(SkStreamAsset* stream) { fFontData.reset(stream); } | 40 void setFontData(SkStreamAsset* stream) { fFontData.reset(stream); } |
| 43 void setFontIndex(int index) { fFontIndex = index; } | 41 void setFontIndex(int index) { fFontIndex = index; } |
| 44 | 42 |
| 45 private: | 43 private: |
| 46 SkString fFamilyName; | 44 SkString fFamilyName; |
| 47 SkString fFullName; | 45 SkString fFullName; |
| 48 SkString fPostscriptName; | 46 SkString fPostscriptName; |
| 49 SkString fFontFileName; | |
| 50 SkAutoTDelete<SkStreamAsset> fFontData; | 47 SkAutoTDelete<SkStreamAsset> fFontData; |
| 51 int fFontIndex; | 48 int fFontIndex; |
| 52 | 49 |
| 53 SkTypeface::Style fStyle; | 50 SkTypeface::Style fStyle; |
| 54 }; | 51 }; |
| 55 | 52 |
| 56 #endif // SkFontDescriptor_DEFINED | 53 #endif // SkFontDescriptor_DEFINED |
| OLD | NEW |