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

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

Issue 1027373002: Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 5 years, 7 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/SkFontHost_fontconfig.cpp ('k') | src/ports/SkFontHost_mac.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkFontHost_FreeType_common.h" 8 #include "SkFontHost_FreeType_common.h"
9 #include "SkFontDescriptor.h" 9 #include "SkFontDescriptor.h"
10 #include "SkFontMgr.h" 10 #include "SkFontMgr.h"
(...skipping 21 matching lines...) Expand all
32 32
33 bool isSysFont() const { return fIsSysFont; } 33 bool isSysFont() const { return fIsSysFont; }
34 34
35 protected: 35 protected:
36 void onGetFamilyName(SkString* familyName) const override { 36 void onGetFamilyName(SkString* familyName) const override {
37 *familyName = fFamilyName; 37 *familyName = fFamilyName;
38 } 38 }
39 39
40 void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const overri de { 40 void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const overri de {
41 desc->setFamilyName(fFamilyName.c_str()); 41 desc->setFamilyName(fFamilyName.c_str());
42 desc->setFontIndex(fIndex);
43 *isLocal = !this->isSysFont(); 42 *isLocal = !this->isSysFont();
44 } 43 }
45 44
46 int getIndex() const { return fIndex; } 45 int getIndex() const { return fIndex; }
47 46
48 private: 47 private:
49 const bool fIsSysFont; 48 const bool fIsSysFont;
50 const SkString fFamilyName; 49 const SkString fFamilyName;
51 const int fIndex; 50 const int fIndex;
52 51
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 298
300 SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) cons t override { 299 SkTypeface* onCreateFromStream(SkStreamAsset* bareStream, int ttcIndex) cons t override {
301 SkAutoTDelete<SkStreamAsset> stream(bareStream); 300 SkAutoTDelete<SkStreamAsset> stream(bareStream);
302 if (NULL == stream || stream->getLength() <= 0) { 301 if (NULL == stream || stream->getLength() <= 0) {
303 return NULL; 302 return NULL;
304 } 303 }
305 304
306 bool isFixedPitch; 305 bool isFixedPitch;
307 SkFontStyle style; 306 SkFontStyle style;
308 SkString name; 307 SkString name;
309 if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch)) { 308 if (fScanner.scanFont(stream, ttcIndex, &name, &style, &isFixedPitch, NU LL)) {
310 return SkNEW_ARGS(SkTypeface_Stream, (style, isFixedPitch, false, na me, 309 return SkNEW_ARGS(SkTypeface_Stream, (style, isFixedPitch, false, na me,
311 stream.detach(), ttcIndex)); 310 stream.detach(), ttcIndex));
312 } else { 311 } else {
313 return NULL; 312 return NULL;
314 } 313 }
315 } 314 }
316 315
317 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override { 316 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
318 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); 317 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
319 return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : NULL; 318 return stream.get() ? this->createFromStream(stream.detach(), ttcIndex) : NULL;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 int numFaces; 397 int numFaces;
399 if (!scanner.recognizedFont(stream, &numFaces)) { 398 if (!scanner.recognizedFont(stream, &numFaces)) {
400 SkDebugf("---- failed to open <%s> as a font\n", filename.c_str( )); 399 SkDebugf("---- failed to open <%s> as a font\n", filename.c_str( ));
401 continue; 400 continue;
402 } 401 }
403 402
404 for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) { 403 for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) {
405 bool isFixedPitch; 404 bool isFixedPitch;
406 SkString realname; 405 SkString realname;
407 SkFontStyle style = SkFontStyle(); // avoid uninitialized warnin g 406 SkFontStyle style = SkFontStyle(); // avoid uninitialized warnin g
408 if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isF ixedPitch)) { 407 if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isF ixedPitch, NULL)) {
409 SkDebugf("---- failed to open <%s> <%d> as a font\n", 408 SkDebugf("---- failed to open <%s> <%d> as a font\n",
410 filename.c_str(), faceIndex); 409 filename.c_str(), faceIndex);
411 continue; 410 continue;
412 } 411 }
413 412
414 SkTypeface_Custom* tf = SkNEW_ARGS(SkTypeface_File, ( 413 SkTypeface_Custom* tf = SkNEW_ARGS(SkTypeface_File, (
415 style, 414 style,
416 isFixedPitch, 415 isFixedPitch,
417 true, // system-font (canno t delete) 416 true, // system-font (canno t delete)
418 realname, 417 realname,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 int numFaces; 483 int numFaces;
485 if (!scanner.recognizedFont(stream, &numFaces)) { 484 if (!scanner.recognizedFont(stream, &numFaces)) {
486 SkDebugf("---- failed to open <%d> as a font\n", index); 485 SkDebugf("---- failed to open <%d> as a font\n", index);
487 return; 486 return;
488 } 487 }
489 488
490 for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) { 489 for (int faceIndex = 0; faceIndex < numFaces; ++faceIndex) {
491 bool isFixedPitch; 490 bool isFixedPitch;
492 SkString realname; 491 SkString realname;
493 SkFontStyle style = SkFontStyle(); // avoid uninitialized warning 492 SkFontStyle style = SkFontStyle(); // avoid uninitialized warning
494 if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixed Pitch)) { 493 if (!scanner.scanFont(stream, faceIndex, &realname, &style, &isFixed Pitch, NULL)) {
495 SkDebugf("---- failed to open <%d> <%d> as a font\n", index, fac eIndex); 494 SkDebugf("---- failed to open <%d> <%d> as a font\n", index, fac eIndex);
496 return; 495 return;
497 } 496 }
498 497
499 SkTypeface_Custom* tf = SkNEW_ARGS(SkTypeface_Stream, ( 498 SkTypeface_Custom* tf = SkNEW_ARGS(SkTypeface_Stream, (
500 style, 499 style,
501 isFixedPitch, 500 isFixedPitch,
502 true, // system-font (cannot de lete) 501 true, // system-font (cannot de lete)
503 realname, 502 realname,
504 stream.detach(), 503 stream.detach(),
(...skipping 21 matching lines...) Expand all
526 #else 525 #else
527 526
528 #ifndef SK_FONT_FILE_PREFIX 527 #ifndef SK_FONT_FILE_PREFIX
529 # define SK_FONT_FILE_PREFIX "/usr/share/fonts/" 528 # define SK_FONT_FILE_PREFIX "/usr/share/fonts/"
530 #endif 529 #endif
531 SkFontMgr* SkFontMgr::Factory() { 530 SkFontMgr* SkFontMgr::Factory() {
532 return new SkFontMgr_Custom(DirectorySystemFontLoader(SK_FONT_FILE_PREFIX)); 531 return new SkFontMgr_Custom(DirectorySystemFontLoader(SK_FONT_FILE_PREFIX));
533 } 532 }
534 533
535 #endif 534 #endif
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_fontconfig.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698