Index: src/core/SkFontDescriptor.h |
diff --git a/src/core/SkFontDescriptor.h b/src/core/SkFontDescriptor.h |
index 13f9cb7257d8abdc023685face5dac6f4ed0004d..8a837ae46fbf0efa274e349f05e759f04e079f06 100644 |
--- a/src/core/SkFontDescriptor.h |
+++ b/src/core/SkFontDescriptor.h |
@@ -12,6 +12,29 @@ |
#include "SkString.h" |
#include "SkTypeface.h" |
+class SkFontData { |
+public: |
+ /** This takes ownership of 'stream'. Makes a copy of the data in 'axis'. */ |
+ SkFontData(SkStreamAsset* stream, int index, int axisCount, const SkFixed axis[]) |
+ : fStream(stream), fIndex(index), fAxisCount(axisCount), fAxis(axisCount) |
+ { |
+ for (int i = 0; i < axisCount; ++i) { |
+ fAxis[i] = axis[i]; |
+ } |
+ } |
+ bool hasStream() const { return fStream.get() != NULL; } |
+ SkStreamAsset* transferStream() { return fStream.detach(); } |
+ int getIndex() const { return fIndex; } |
+ int getAxisCount() const { return fAxisCount; } |
+ const SkFixed* getAxis() const { return fAxis.get(); } |
+ |
+private: |
+ SkAutoTDelete<SkStreamAsset> fStream; |
+ int fIndex; |
+ int fAxisCount; |
+ SkAutoSTMalloc<4, SkFixed> fAxis; |
+}; |
+ |
class SkFontDescriptor { |
public: |
SkFontDescriptor(SkTypeface::Style = SkTypeface::kNormal); |
@@ -26,29 +49,22 @@ public: |
const char* getFamilyName() const { return fFamilyName.c_str(); } |
const char* getFullName() const { return fFullName.c_str(); } |
const char* getPostscriptName() const { return fPostscriptName.c_str(); } |
- const char* getFontFileName() const { return fFontFileName.c_str(); } |
bool hasFontData() const { return fFontData.get() != NULL; } |
// Transfers ownership to the caller. |
- SkStreamAsset* transferFontData() { return fFontData.detach(); } |
- int getFontIndex() const { return fFontIndex; } |
+ SkFontData* getFontData() { return fFontData.get(); } |
void setFamilyName(const char* name) { fFamilyName.set(name); } |
void setFullName(const char* name) { fFullName.set(name); } |
void setPostscriptName(const char* name) { fPostscriptName.set(name); } |
- void setFontFileName(const char* name) { fFontFileName.set(name); } |
/** Set the font data only if it is necessary for serialization. |
- * This method takes ownership of the stream (both reference and cursor). |
- */ |
- void setFontData(SkStreamAsset* stream) { fFontData.reset(stream); } |
- void setFontIndex(int index) { fFontIndex = index; } |
+ * This method takes ownership of the font data. */ |
+ void setFontData(SkFontData* data) { fFontData.reset(data); } |
private: |
SkString fFamilyName; |
SkString fFullName; |
SkString fPostscriptName; |
- SkString fFontFileName; |
- SkAutoTDelete<SkStreamAsset> fFontData; |
- int fFontIndex; |
+ SkAutoTDelete<SkFontData> fFontData; |
SkTypeface::Style fStyle; |
}; |