Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: src/ports/SkFontMgr_fontconfig.cpp

Issue 869763002: SkTypeface to use SkStreamAsset. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkDataTable.h" 8 #include "SkDataTable.h"
9 #include "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontHost_FreeType_common.h" 10 #include "SkFontHost_FreeType_common.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE { 385 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE {
386 familyName->reset(); 386 familyName->reset();
387 } 387 }
388 388
389 void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const SK_O VERRIDE { 389 void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const SK_O VERRIDE {
390 desc->setFontIndex(fIndex); 390 desc->setFontIndex(fIndex);
391 *serialize = true; 391 *serialize = true;
392 } 392 }
393 393
394 SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { 394 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
395 *ttcIndex = fIndex; 395 *ttcIndex = fIndex;
396 return fStream->duplicate(); 396 return fStream->duplicate();
397 } 397 }
398 398
399 private: 399 private:
400 SkAutoTDelete<SkStreamAsset> fStream; 400 SkAutoTDelete<SkStreamAsset> fStream;
401 int fIndex; 401 int fIndex;
402 402
403 typedef SkTypeface_FreeType INHERITED; 403 typedef SkTypeface_FreeType INHERITED;
404 }; 404 };
(...skipping 13 matching lines...) Expand all
418 void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const SK_O VERRIDE { 418 void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const SK_O VERRIDE {
419 FCLocker lock; 419 FCLocker lock;
420 desc->setFamilyName(get_string(fPattern, FC_FAMILY)); 420 desc->setFamilyName(get_string(fPattern, FC_FAMILY));
421 desc->setFullName(get_string(fPattern, FC_FULLNAME)); 421 desc->setFullName(get_string(fPattern, FC_FULLNAME));
422 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME)); 422 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME));
423 desc->setFontFileName(get_string(fPattern, FC_FILE)); 423 desc->setFontFileName(get_string(fPattern, FC_FILE));
424 desc->setFontIndex(get_int(fPattern, FC_INDEX, 0)); 424 desc->setFontIndex(get_int(fPattern, FC_INDEX, 0));
425 *serialize = false; 425 *serialize = false;
426 } 426 }
427 427
428 SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { 428 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
429 FCLocker lock; 429 FCLocker lock;
430 *ttcIndex = get_int(fPattern, FC_INDEX, 0); 430 *ttcIndex = get_int(fPattern, FC_INDEX, 0);
431 return SkStream::NewFromFile(get_string(fPattern, FC_FILE)); 431 return SkStream::NewFromFile(get_string(fPattern, FC_FILE));
432 } 432 }
433 433
434 virtual ~SkTypeface_fontconfig() { 434 virtual ~SkTypeface_fontconfig() {
435 // Hold the lock while unrefing the pattern. 435 // Hold the lock while unrefing the pattern.
436 FCLocker lock; 436 FCLocker lock;
437 fPattern.reset(); 437 fPattern.reset();
438 } 438 }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 802
803 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* typeface, 803 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* typeface,
804 const SkFontStyle& style) const SK_OVER RIDE 804 const SkFontStyle& style) const SK_OVER RIDE
805 { 805 {
806 //TODO: should the SkTypeface_fontconfig know its family? 806 //TODO: should the SkTypeface_fontconfig know its family?
807 const SkTypeface_fontconfig* fcTypeface = 807 const SkTypeface_fontconfig* fcTypeface =
808 static_cast<const SkTypeface_fontconfig*>(typeface); 808 static_cast<const SkTypeface_fontconfig*>(typeface);
809 return this->matchFamilyStyle(get_string(fcTypeface->fPattern, FC_FAMILY ), style); 809 return this->matchFamilyStyle(get_string(fcTypeface->fPattern, FC_FAMILY ), style);
810 } 810 }
811 811
812 SkTypeface* onCreateFromStream(SkStream* inputStream, int ttcIndex) const SK _OVERRIDE { 812 SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) cons t SK_OVERRIDE {
813 SkAutoTDelete<SkStream> stream(inputStream); 813 SkAutoTDelete<SkStreamAsset> stream(bareStream);
814 const size_t length = stream->getLength(); 814 const size_t length = stream->getLength();
815 if (length <= 0 || (1u << 30) < length) { 815 if (length <= 0 || (1u << 30) < length) {
816 return NULL; 816 return NULL;
817 } 817 }
818 818
819 SkFontStyle style; 819 SkFontStyle style;
820 bool isFixedWidth = false; 820 bool isFixedWidth = false;
821 if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth)) { 821 if (!fScanner.scanFont(stream, ttcIndex, NULL, &style, &isFixedWidth)) {
822 return NULL; 822 return NULL;
823 } 823 }
(...skipping 24 matching lines...) Expand all
848 return typeface.detach(); 848 return typeface.detach();
849 } 849 }
850 850
851 return this->matchFamilyStyle(NULL, style); 851 return this->matchFamilyStyle(NULL, style);
852 } 852 }
853 }; 853 };
854 854
855 SkFontMgr* SkFontMgr::Factory() { 855 SkFontMgr* SkFontMgr::Factory() {
856 return SkNEW(SkFontMgr_fontconfig); 856 return SkNEW(SkFontMgr_fontconfig);
857 } 857 }
OLDNEW
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698