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

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

Issue 567013002: Serialize the font index. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update the Custom FontMgr also. Created 6 years, 3 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
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 class SkTypeface_stream : public SkTypeface_FreeType { 383 class SkTypeface_stream : public SkTypeface_FreeType {
384 public: 384 public:
385 /** @param stream does not take ownership of the reference, does take owners hip of the stream.*/ 385 /** @param stream does not take ownership of the reference, does take owners hip of the stream.*/
386 SkTypeface_stream(SkTypeface::Style style, bool fixedWidth, int ttcIndex, Sk StreamAsset* stream) 386 SkTypeface_stream(SkTypeface::Style style, bool fixedWidth, int ttcIndex, Sk StreamAsset* stream)
387 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) 387 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth)
388 , fStream(SkRef(stream)) 388 , fStream(SkRef(stream))
389 , fIndex(ttcIndex) 389 , fIndex(ttcIndex)
390 { }; 390 { };
391 391
392 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) co nst SK_OVERRIDE { 392 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) co nst SK_OVERRIDE {
393 desc->setStyle(this->style()); 393 desc->setFontFileIndex(fIndex);
394 *serialize = true; 394 *serialize = true;
395 } 395 }
396 396
397 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { 397 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
398 *ttcIndex = fIndex; 398 *ttcIndex = fIndex;
399 return fStream->duplicate(); 399 return fStream->duplicate();
400 } 400 }
401 401
402 private: 402 private:
403 SkAutoTUnref<SkStreamAsset> fStream; 403 SkAutoTUnref<SkStreamAsset> fStream;
404 int fIndex; 404 int fIndex;
405 405
406 typedef SkTypeface_FreeType INHERITED; 406 typedef SkTypeface_FreeType INHERITED;
407 }; 407 };
408 408
409 class SkTypeface_fontconfig : public SkTypeface_FreeType { 409 class SkTypeface_fontconfig : public SkTypeface_FreeType {
410 public: 410 public:
411 /** @param pattern takes ownership of the reference. */ 411 /** @param pattern takes ownership of the reference. */
412 static SkTypeface_fontconfig* Create(FcPattern* pattern) { 412 static SkTypeface_fontconfig* Create(FcPattern* pattern) {
413 return SkNEW_ARGS(SkTypeface_fontconfig, (pattern)); 413 return SkNEW_ARGS(SkTypeface_fontconfig, (pattern));
414 } 414 }
415 mutable SkAutoFcPattern fPattern; 415 mutable SkAutoFcPattern fPattern;
416 416
417 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) co nst SK_OVERRIDE { 417 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) co nst SK_OVERRIDE {
418 FCLocker lock; 418 FCLocker lock;
419 desc->setFamilyName(get_string(fPattern, FC_FAMILY)); 419 desc->setFamilyName(get_string(fPattern, FC_FAMILY));
420 desc->setFontFileName(get_string(fPattern, FC_FILE));
421 desc->setFullName(get_string(fPattern, FC_FULLNAME)); 420 desc->setFullName(get_string(fPattern, FC_FULLNAME));
422 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME)); 421 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME));
423 desc->setStyle(this->style()); 422 desc->setFontFileName(get_string(fPattern, FC_FILE));
423 desc->setFontFileIndex(get_int(fPattern, FC_INDEX, 0));
424 *serialize = false; 424 *serialize = false;
425 } 425 }
426 426
427 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE { 427 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
428 FCLocker lock; 428 FCLocker lock;
429 *ttcIndex = get_int(fPattern, FC_INDEX, 0); 429 *ttcIndex = get_int(fPattern, FC_INDEX, 0);
430 return SkStream::NewFromFile(get_string(fPattern, FC_FILE)); 430 return SkStream::NewFromFile(get_string(fPattern, FC_FILE));
431 } 431 }
432 432
433 virtual ~SkTypeface_fontconfig() { 433 virtual ~SkTypeface_fontconfig() {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
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

Powered by Google App Engine
This is Rietveld 408576698