• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "SkTypeface.h"
2 #include "SkFontHost.h"
3 
UniqueID(const SkTypeface * face)4 uint32_t SkTypeface::UniqueID(const SkTypeface* face) {
5     if (face) {
6         return face->uniqueID();
7     }
8 
9     // We cache the default fontID, assuming it will not change during a boot
10     // The initial value of 0 is fine, since a typeface's uniqueID should not
11     // be zero.
12     static uint32_t gDefaultFontID;
13 
14     if (0 == gDefaultFontID) {
15         SkTypeface* defaultFace = SkFontHost::CreateTypeface(NULL, NULL,
16                                                     SkTypeface::kNormal);
17         SkASSERT(defaultFace);
18         gDefaultFontID = defaultFace->uniqueID();
19         defaultFace->unref();
20     }
21     return gDefaultFontID;
22 }
23 
Equal(const SkTypeface * facea,const SkTypeface * faceb)24 bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) {
25     return SkTypeface::UniqueID(facea) == SkTypeface::UniqueID(faceb);
26 }
27 
28 ///////////////////////////////////////////////////////////////////////////////
29 
CreateFromName(const char name[],Style style)30 SkTypeface* SkTypeface::CreateFromName(const char name[], Style style) {
31     return SkFontHost::CreateTypeface(NULL, name, style);
32 }
33 
CreateFromTypeface(const SkTypeface * family,Style s)34 SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style s) {
35     return SkFontHost::CreateTypeface(family, NULL, s);
36 }
37 
CreateFromStream(SkStream * stream)38 SkTypeface* SkTypeface::CreateFromStream(SkStream* stream) {
39     return SkFontHost::CreateTypefaceFromStream(stream);
40 }
41 
CreateFromFile(const char path[])42 SkTypeface* SkTypeface::CreateFromFile(const char path[]) {
43     return SkFontHost::CreateTypefaceFromFile(path);
44 }
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 
serialize(SkWStream * stream) const48 void SkTypeface::serialize(SkWStream* stream) const {
49     SkFontHost::Serialize(this, stream);
50 }
51 
Deserialize(SkStream * stream)52 SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
53     return SkFontHost::Deserialize(stream);
54 }
55 
56 
57