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

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

Issue 1027373002: Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« src/core/SkTypeface.cpp ('K') | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) 380 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth)
381 , fStream(stream) 381 , fStream(stream)
382 , fIndex(index) 382 , fIndex(index)
383 { }; 383 { };
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->getFontParameters().fIndex = fIndex;
391 *serialize = true; 391 *serialize = true;
392 } 392 }
393 393
394 SkStreamAsset* 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 SkStreamAsset* onOpenStream2(SkFontParameters* fontParams) const SK_OVERRIDE {
bungeman-skia 2015/03/23 21:59:05 Temporary implementation to just muck about with t
400 fontParams->fIndex = fIndex;
401 fontParams->fAxis.reset(1);
402 fontParams->fAxis[0] = SK_Fixed1;
403 return fStream->duplicate();
404 };
405
399 private: 406 private:
400 SkAutoTDelete<SkStreamAsset> fStream; 407 SkAutoTDelete<SkStreamAsset> fStream;
401 int fIndex; 408 int fIndex;
402 409
403 typedef SkTypeface_FreeType INHERITED; 410 typedef SkTypeface_FreeType INHERITED;
404 }; 411 };
405 412
406 class SkTypeface_fontconfig : public SkTypeface_FreeType { 413 class SkTypeface_fontconfig : public SkTypeface_FreeType {
407 public: 414 public:
408 /** @param pattern takes ownership of the reference. */ 415 /** @param pattern takes ownership of the reference. */
409 static SkTypeface_fontconfig* Create(FcPattern* pattern) { 416 static SkTypeface_fontconfig* Create(FcPattern* pattern) {
410 return SkNEW_ARGS(SkTypeface_fontconfig, (pattern)); 417 return SkNEW_ARGS(SkTypeface_fontconfig, (pattern));
411 } 418 }
412 mutable SkAutoFcPattern fPattern; 419 mutable SkAutoFcPattern fPattern;
413 420
414 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE { 421 void onGetFamilyName(SkString* familyName) const SK_OVERRIDE {
415 *familyName = get_string(fPattern, FC_FAMILY); 422 *familyName = get_string(fPattern, FC_FAMILY);
416 } 423 }
417 424
418 void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const SK_O VERRIDE { 425 void onGetFontDescriptor(SkFontDescriptor* desc, bool* serialize) const SK_O VERRIDE {
419 FCLocker lock; 426 FCLocker lock;
420 desc->setFamilyName(get_string(fPattern, FC_FAMILY)); 427 desc->setFamilyName(get_string(fPattern, FC_FAMILY));
421 desc->setFullName(get_string(fPattern, FC_FULLNAME)); 428 desc->setFullName(get_string(fPattern, FC_FULLNAME));
422 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME)); 429 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME));
423 desc->setFontFileName(get_string(fPattern, FC_FILE)); 430 desc->setFontFileName(get_string(fPattern, FC_FILE));
424 desc->setFontIndex(get_int(fPattern, FC_INDEX, 0)); 431 desc->getFontParameters().fIndex = get_int(fPattern, FC_INDEX, 0);
425 *serialize = false; 432 *serialize = false;
426 } 433 }
427 434
428 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE { 435 SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
429 FCLocker lock; 436 FCLocker lock;
430 *ttcIndex = get_int(fPattern, FC_INDEX, 0); 437 *ttcIndex = get_int(fPattern, FC_INDEX, 0);
431 return SkStream::NewFromFile(get_string(fPattern, FC_FILE)); 438 return SkStream::NewFromFile(get_string(fPattern, FC_FILE));
432 } 439 }
433 440
434 virtual ~SkTypeface_fontconfig() { 441 virtual ~SkTypeface_fontconfig() {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 return typeface.detach(); 855 return typeface.detach();
849 } 856 }
850 857
851 return this->matchFamilyStyle(NULL, style); 858 return this->matchFamilyStyle(NULL, style);
852 } 859 }
853 }; 860 };
854 861
855 SkFontMgr* SkFontMgr::Factory() { 862 SkFontMgr* SkFontMgr::Factory() {
856 return SkNEW(SkFontMgr_fontconfig); 863 return SkNEW(SkFontMgr_fontconfig);
857 } 864 }
OLDNEW
« src/core/SkTypeface.cpp ('K') | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698