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