2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkFontDescriptor_DEFINED
9 #define SkFontDescriptor_DEFINED
13 #include "SkTypeface.h"
17 class SkFontDescriptor {
19 SkFontDescriptor(SkTypeface::Style = SkTypeface::kNormal);
20 SkFontDescriptor(SkStream*);
22 void serialize(SkWStream*);
24 SkTypeface::Style getStyle() { return fStyle; }
25 void setStyle(SkTypeface::Style style) { fStyle = style; }
27 const char* getFamilyName() const { return fFamilyName.c_str(); }
28 const char* getFullName() const { return fFullName.c_str(); }
29 const char* getPostscriptName() const { return fPostscriptName.c_str(); }
30 const char* getFontFileName() const { return fFontFileName.c_str(); }
31 SkStream* getFontData() const { return fFontData; }
32 int getFontIndex() const { return fFontIndex; }
34 void setFamilyName(const char* name) { fFamilyName.set(name); }
35 void setFullName(const char* name) { fFullName.set(name); }
36 void setPostscriptName(const char* name) { fPostscriptName.set(name); }
37 void setFontFileName(const char* name) { fFontFileName.set(name); }
38 /** Set the font data only if it is necessary for serialization.
39 * This method takes ownership of the stream (both reference and cursor).
41 void setFontData(SkStream* stream) { fFontData.reset(stream); }
42 void setFontIndex(int index) { fFontIndex = index; }
47 SkString fPostscriptName;
48 SkString fFontFileName;
49 SkAutoTUnref<SkStream> fFontData;
52 SkTypeface::Style fStyle;
55 #endif // SkFontDescriptor_DEFINED