OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkFontMgr_indirect.h" | 8 #include "SkFontMgr_indirect.h" |
9 | 9 |
10 #include "SkDataTable.h" | 10 #include "SkDataTable.h" |
11 #include "SkFontStyle.h" | 11 #include "SkFontStyle.h" |
12 #include "SkOnce.h" | 12 #include "SkOnce.h" |
13 #include "SkStream.h" | 13 #include "SkStream.h" |
14 #include "SkTSearch.h" | 14 #include "SkTSearch.h" |
15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
16 | 16 |
17 class SkData; | 17 class SkData; |
18 class SkString; | 18 class SkString; |
19 | 19 |
20 class SkStyleSet_Indirect : public SkFontStyleSet { | 20 class SkStyleSet_Indirect : public SkFontStyleSet { |
21 public: | 21 public: |
22 /** Takes ownership of the SkRemotableFontIdentitySet. */ | 22 /** Takes ownership of the SkRemotableFontIdentitySet. */ |
23 SkStyleSet_Indirect(const SkFontMgr_Indirect* owner, int familyIndex, | 23 SkStyleSet_Indirect(const SkFontMgr_Indirect* owner, int familyIndex, |
24 SkRemotableFontIdentitySet* data) | 24 SkRemotableFontIdentitySet* data) |
25 : fOwner(SkRef(owner)), fFamilyIndex(familyIndex), fData(data) | 25 : fOwner(SkRef(owner)), fFamilyIndex(familyIndex), fData(data) |
26 { } | 26 { } |
27 | 27 |
28 virtual int count() SK_OVERRIDE { return fData->count(); } | 28 int count() SK_OVERRIDE { return fData->count(); } |
29 | 29 |
30 virtual void getStyle(int index, SkFontStyle* fs, SkString* style) SK_OVERRI
DE { | 30 void getStyle(int index, SkFontStyle* fs, SkString* style) SK_OVERRIDE { |
31 if (fs) { | 31 if (fs) { |
32 *fs = fData->at(index).fFontStyle; | 32 *fs = fData->at(index).fFontStyle; |
33 } | 33 } |
34 if (style) { | 34 if (style) { |
35 // TODO: is this useful? Current locale? | 35 // TODO: is this useful? Current locale? |
36 style->reset(); | 36 style->reset(); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 virtual SkTypeface* createTypeface(int index) SK_OVERRIDE { | 40 SkTypeface* createTypeface(int index) SK_OVERRIDE { |
41 return fOwner->createTypefaceFromFontId(fData->at(index)); | 41 return fOwner->createTypefaceFromFontId(fData->at(index)); |
42 } | 42 } |
43 | 43 |
44 virtual SkTypeface* matchStyle(const SkFontStyle& pattern) SK_OVERRIDE { | 44 SkTypeface* matchStyle(const SkFontStyle& pattern) SK_OVERRIDE { |
45 if (fFamilyIndex >= 0) { | 45 if (fFamilyIndex >= 0) { |
46 SkFontIdentity id = fOwner->fProxy->matchIndexStyle(fFamilyIndex, pa
ttern); | 46 SkFontIdentity id = fOwner->fProxy->matchIndexStyle(fFamilyIndex, pa
ttern); |
47 return fOwner->createTypefaceFromFontId(id); | 47 return fOwner->createTypefaceFromFontId(id); |
48 } | 48 } |
49 | 49 |
50 // If this SkStyleSet was created via onMatchFamily we would need a call
like | 50 // If this SkStyleSet was created via onMatchFamily we would need a call
like |
51 // fOwner->fProxy->matchNameStyle(fFamilyName, pattern); | 51 // fOwner->fProxy->matchNameStyle(fFamilyName, pattern); |
52 // but would not activate fonts (only consider fonts which would come ba
ck from matchName). | 52 // but would not activate fonts (only consider fonts which would come ba
ck from matchName). |
53 | 53 |
54 // CSS policy sounds good. | 54 // CSS policy sounds good. |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 face.reset(this->matchFamilyStyle(NULL, style)); | 290 face.reset(this->matchFamilyStyle(NULL, style)); |
291 } | 291 } |
292 | 292 |
293 if (NULL == face.get()) { | 293 if (NULL == face.get()) { |
294 SkFontIdentity fontId = this->fProxy->matchIndexStyle(0, style); | 294 SkFontIdentity fontId = this->fProxy->matchIndexStyle(0, style); |
295 face.reset(this->createTypefaceFromFontId(fontId)); | 295 face.reset(this->createTypefaceFromFontId(fontId)); |
296 } | 296 } |
297 | 297 |
298 return face.detach(); | 298 return face.detach(); |
299 } | 299 } |
OLD | NEW |