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

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

Issue 12593013: remove SkFontHost::CreateScalerContext (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_none.cpp ('k') | src/ports/SkFontHost_win.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 /* 2 /*
3 * Copyright 2011 The Android Open Source Project 3 * Copyright 2011 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkFontHost.h" 10 #include "SkFontHost.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 387
388 // these globals are assigned (once) by load_system_fonts() 388 // these globals are assigned (once) by load_system_fonts()
389 static FamilyRec* gDefaultFamily; 389 static FamilyRec* gDefaultFamily;
390 static SkTypeface* gDefaultNormal; 390 static SkTypeface* gDefaultNormal;
391 391
392 /* This is sized conservatively, assuming that it will never be a size issue. 392 /* This is sized conservatively, assuming that it will never be a size issue.
393 It will be initialized in load_system_fonts(), and will be filled with the 393 It will be initialized in load_system_fonts(), and will be filled with the
394 fontIDs that can be used for fallback consideration, in sorted order (sorted 394 fontIDs that can be used for fallback consideration, in sorted order (sorted
395 meaning element[0] should be used first, then element[1], etc. When we hit 395 meaning element[0] should be used first, then element[1], etc. When we hit
396 a fontID==0 in the array, the list is done, hence our allocation size is 396 a fontID==0 in the array, the list is done, hence our allocation size is
397 +1 the total number of possible system fonts. Also see NextLogicalFont(). 397 +1 the total number of possible system fonts. Also see NextLogicalTypeface() .
398 */ 398 */
399 static uint32_t gFallbackFonts[SK_ARRAY_COUNT(gSystemFonts)+1]; 399 static uint32_t gFallbackFonts[SK_ARRAY_COUNT(gSystemFonts)+1];
400 400
401 /* Called once (ensured by the sentinel check at the beginning of our body). 401 /* Called once (ensured by the sentinel check at the beginning of our body).
402 Initializes all the globals, and register the system fonts. 402 Initializes all the globals, and register the system fonts.
403 */ 403 */
404 static void load_system_fonts() { 404 static void load_system_fonts() {
405 // check if we've already be called 405 // check if we've already be called
406 if (NULL != gDefaultNormal) { 406 if (NULL != gDefaultNormal) {
407 return; 407 return;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 577 }
578 if (index) { 578 if (index) {
579 *index = 0; // we don't have collections (yet) 579 *index = 0; // we don't have collections (yet)
580 } 580 }
581 return size; 581 return size;
582 } else { 582 } else {
583 return 0; 583 return 0;
584 } 584 }
585 } 585 }
586 586
587 SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { 587 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFo ntID) {
588 load_system_fonts(); 588 load_system_fonts();
589 589
590 /* First see if fontID is already one of our fallbacks. If so, return 590 /* First see if fontID is already one of our fallbacks. If so, return
591 its successor. If fontID is not in our list, then return the first one 591 its successor. If fontID is not in our list, then return the first one
592 in our list. Note: list is zero-terminated, and returning zero means 592 in our list. Note: list is zero-terminated, and returning zero means
593 we have no more fonts to use for fallbacks. 593 we have no more fonts to use for fallbacks.
594 */ 594 */
595 const uint32_t* list = gFallbackFonts; 595 const uint32_t* list = gFallbackFonts;
596 for (int i = 0; list[i] != 0; i++) { 596 for (int i = 0; list[i] != 0; i++) {
597 if (list[i] == currFontID) { 597 if (list[i] == currFontID) {
598 return list[i+1]; 598 return SkSafeRef(find_from_uniqueID(list[i+1]));
599 } 599 }
600 } 600 }
601 return list[0]; 601 return SkSafeRef(list[0]);
602 } 602 }
603 603
604 /////////////////////////////////////////////////////////////////////////////// 604 ///////////////////////////////////////////////////////////////////////////////
605 605
606 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) { 606 SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
607 if (NULL == stream || stream->getLength() <= 0) { 607 if (NULL == stream || stream->getLength() <= 0) {
608 return NULL; 608 return NULL;
609 } 609 }
610 610
611 SkTypeface::Style style; 611 SkTypeface::Style style;
612 if (find_name_and_attributes(stream, NULL, &style, NULL)) { 612 if (find_name_and_attributes(stream, NULL, &style, NULL)) {
613 return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream)); 613 return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream));
614 } else { 614 } else {
615 return NULL; 615 return NULL;
616 } 616 }
617 } 617 }
618 618
619 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { 619 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
620 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 620 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
621 return stream.get() ? SkFontHost::CreateTypefaceFromStream(stream) : NULL; 621 return stream.get() ? SkFontHost::CreateTypefaceFromStream(stream) : NULL;
622 } 622 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_none.cpp ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698