Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2008 Google Inc. | 2 * Copyright 2008 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 "SkFontConfigInterface.h" | 8 #include "SkFontConfigInterface.h" |
| 9 #include "SkFontConfigTypeface.h" | 9 #include "SkFontConfigTypeface.h" |
| 10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 SkTypeface::Style outStyle; | 105 SkTypeface::Style outStyle; |
| 106 if (!fci->matchFamilyName(familyName, style, &indentity, &outFamilyName, &ou tStyle)) { | 106 if (!fci->matchFamilyName(familyName, style, &indentity, &outFamilyName, &ou tStyle)) { |
| 107 return NULL; | 107 return NULL; |
| 108 } | 108 } |
| 109 | 109 |
| 110 // check if we, in fact, already have this. perhaps fontconfig aliased the | 110 // check if we, in fact, already have this. perhaps fontconfig aliased the |
| 111 // requested name to some other name we actually have... | 111 // requested name to some other name we actually have... |
| 112 rec.fFamilyName = outFamilyName.c_str(); | 112 rec.fFamilyName = outFamilyName.c_str(); |
| 113 rec.fStyle = SkFontStyle(outStyle); | 113 rec.fStyle = SkFontStyle(outStyle); |
| 114 face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec); | 114 face = SkTypefaceCache::FindByProcAndRef(find_proc, &rec); |
| 115 if (face) { | 115 if (face) { |
|
Jun Mukai
2015/01/12 23:50:43
You'll have to put the face_orig to the cache in t
kochi
2015/01/13 04:25:01
Thanks for your further investigation!
Applied you
| |
| 116 return face; | 116 return face; |
| 117 } | 117 } |
| 118 | 118 |
| 119 face = FontConfigTypeface::Create(SkFontStyle(outStyle), indentity, outFamil yName); | 119 face = FontConfigTypeface::Create(SkFontStyle(outStyle), indentity, outFamil yName); |
| 120 SkTypefaceCache::Add(face, requestedStyle); | 120 SkTypefaceCache::Add(face, requestedStyle); |
| 121 // If any aliased name is returned for the requested family, cache SkTypefac e | |
| 122 // with the original family name so the following lookups will hit the cache . | |
| 123 if (!outFamilyName.equals(familyName)) { | |
| 124 SkTypeface* face_orig = | |
| 125 FontConfigTypeface::Create(SkFontStyle(outStyle), indentity, SkS tring(familyName)); | |
| 126 SkTypefaceCache::Add(face_orig, requestedStyle); | |
| 127 } | |
| 121 //SkDebugf("add face <%s> <%s> %p [%d]\n", | 128 //SkDebugf("add face <%s> <%s> %p [%d]\n", |
| 122 // familyName, outFamilyName.c_str(), | 129 // familyName, outFamilyName.c_str(), |
| 123 // face, face->getRefCnt()); | 130 // face, face->getRefCnt()); |
| 124 return face; | 131 return face; |
| 125 } | 132 } |
| 126 | 133 |
| 127 /////////////////////////////////////////////////////////////////////////////// | 134 /////////////////////////////////////////////////////////////////////////////// |
| 128 | 135 |
| 129 SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const { | 136 SkStream* FontConfigTypeface::onOpenStream(int* ttcIndex) const { |
| 130 SkStream* stream = this->getLocalStream(); | 137 SkStream* stream = this->getLocalStream(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 void FontConfigTypeface::onGetFamilyName(SkString* familyName) const { | 176 void FontConfigTypeface::onGetFamilyName(SkString* familyName) const { |
| 170 *familyName = this->getFamilyName(); | 177 *familyName = this->getFamilyName(); |
| 171 } | 178 } |
| 172 | 179 |
| 173 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 180 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
| 174 bool* isLocalStream) const { | 181 bool* isLocalStream) const { |
| 175 desc->setFamilyName(this->getFamilyName()); | 182 desc->setFamilyName(this->getFamilyName()); |
| 176 desc->setFontIndex(this->getIdentity().fTTCIndex); | 183 desc->setFontIndex(this->getIdentity().fTTCIndex); |
| 177 *isLocalStream = SkToBool(this->getLocalStream()); | 184 *isLocalStream = SkToBool(this->getLocalStream()); |
| 178 } | 185 } |
| OLD | NEW |