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

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

Issue 1129283003: Make SkAdvancedTypefaceMetrics private. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/pdf/SkPDFFont.cpp ('k') | src/ports/SkFontHost_FreeType_common.h » ('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 "SkAdvancedTypefaceMetrics.h" 8 #include "SkAdvancedTypefaceMetrics.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 charCode = FT_Get_Next_Char(face, charCode, &glyphIndex)) { 453 charCode = FT_Get_Next_Char(face, charCode, &glyphIndex)) {
454 if (charCode && 454 if (charCode &&
455 ((*glyphToUnicode)[glyphIndex] == 0 || preferredMap)) { 455 ((*glyphToUnicode)[glyphIndex] == 0 || preferredMap)) {
456 (*glyphToUnicode)[glyphIndex] = charCode; 456 (*glyphToUnicode)[glyphIndex] = charCode;
457 } 457 }
458 } 458 }
459 } 459 }
460 } 460 }
461 461
462 SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics( 462 SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
463 SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, 463 PerGlyphInfo perGlyphInfo,
464 const uint32_t* glyphIDs, 464 const uint32_t* glyphIDs,
465 uint32_t glyphIDsCount) const { 465 uint32_t glyphIDsCount) const {
466 #if defined(SK_BUILD_FOR_MAC) 466 #if defined(SK_BUILD_FOR_MAC)
467 return NULL; 467 return NULL;
468 #else 468 #else
469 AutoFTAccess fta(this); 469 AutoFTAccess fta(this);
470 FT_Face face = fta.face(); 470 FT_Face face = fta.face();
471 if (!face) { 471 if (!face) {
472 return NULL; 472 return NULL;
473 } 473 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 } else { 580 } else {
581 // Last resort, use the ascent. 581 // Last resort, use the ascent.
582 info->fCapHeight = info->fAscent; 582 info->fCapHeight = info->fAscent;
583 } 583 }
584 } 584 }
585 585
586 info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, 586 info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax,
587 face->bbox.xMax, face->bbox.yMin); 587 face->bbox.xMax, face->bbox.yMin);
588 588
589 if (!FT_IS_SCALABLE(face)) { 589 if (!FT_IS_SCALABLE(face)) {
590 perGlyphInfo = SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo; 590 perGlyphInfo = kNo_PerGlyphInfo;
591 } 591 }
592 592
593 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) { 593 if (perGlyphInfo & kHAdvance_PerGlyphInfo) {
594 if (FT_IS_FIXED_WIDTH(face)) { 594 if (FT_IS_FIXED_WIDTH(face)) {
595 appendRange(&info->fGlyphWidths, 0); 595 appendRange(&info->fGlyphWidths, 0);
596 int16_t advance = face->max_advance_width; 596 int16_t advance = face->max_advance_width;
597 info->fGlyphWidths->fAdvance.append(1, &advance); 597 info->fGlyphWidths->fAdvance.append(1, &advance);
598 finishRange(info->fGlyphWidths.get(), 0, 598 finishRange(info->fGlyphWidths.get(), 0,
599 SkAdvancedTypefaceMetrics::WidthRange::kDefault); 599 SkAdvancedTypefaceMetrics::WidthRange::kDefault);
600 } else if (!cid) { 600 } else if (!cid) {
601 appendRange(&info->fGlyphWidths, 0); 601 appendRange(&info->fGlyphWidths, 0);
602 // So as to not blow out the stack, get advances in batches. 602 // So as to not blow out the stack, get advances in batches.
603 for (int gID = 0; gID < face->num_glyphs; gID += 128) { 603 for (int gID = 0; gID < face->num_glyphs; gID += 128) {
(...skipping 13 matching lines...) Expand all
617 } else { 617 } else {
618 info->fGlyphWidths.reset( 618 info->fGlyphWidths.reset(
619 getAdvanceData(face, 619 getAdvanceData(face,
620 face->num_glyphs, 620 face->num_glyphs,
621 glyphIDs, 621 glyphIDs,
622 glyphIDsCount, 622 glyphIDsCount,
623 &getWidthAdvance)); 623 &getWidthAdvance));
624 } 624 }
625 } 625 }
626 626
627 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kVAdvance_PerGlyphInfo && 627 if (perGlyphInfo & kVAdvance_PerGlyphInfo &&
628 FT_HAS_VERTICAL(face)) { 628 FT_HAS_VERTICAL(face)) {
629 SkASSERT(false); // Not implemented yet. 629 SkASSERT(false); // Not implemented yet.
630 } 630 }
631 631
632 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo && 632 if (perGlyphInfo & kGlyphNames_PerGlyphInfo &&
633 info->fType == SkAdvancedTypefaceMetrics::kType1_Font) { 633 info->fType == SkAdvancedTypefaceMetrics::kType1_Font) {
634 // Postscript fonts may contain more than 255 glyphs, so we end up 634 // Postscript fonts may contain more than 255 glyphs, so we end up
635 // using multiple font descriptions with a glyph ordering. Record 635 // using multiple font descriptions with a glyph ordering. Record
636 // the name of each glyph. 636 // the name of each glyph.
637 info->fGlyphNames.reset( 637 info->fGlyphNames.reset(
638 new SkAutoTArray<SkString>(face->num_glyphs)); 638 new SkAutoTArray<SkString>(face->num_glyphs));
639 for (int gID = 0; gID < face->num_glyphs; gID++) { 639 for (int gID = 0; gID < face->num_glyphs; gID++) {
640 char glyphName[128]; // PS limit for names is 127 bytes. 640 char glyphName[128]; // PS limit for names is 127 bytes.
641 FT_Get_Glyph_Name(face, gID, glyphName, 128); 641 FT_Get_Glyph_Name(face, gID, glyphName, 128);
642 info->fGlyphNames->get()[gID].set(glyphName); 642 info->fGlyphNames->get()[gID].set(glyphName);
643 } 643 }
644 } 644 }
645 645
646 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo && 646 if (perGlyphInfo & kToUnicode_PerGlyphInfo &&
647 info->fType != SkAdvancedTypefaceMetrics::kType1_Font && 647 info->fType != SkAdvancedTypefaceMetrics::kType1_Font &&
648 face->num_charmaps) { 648 face->num_charmaps) {
649 populate_glyph_to_unicode(face, &(info->fGlyphToUnicode)); 649 populate_glyph_to_unicode(face, &(info->fGlyphToUnicode));
650 } 650 }
651 651
652 return info; 652 return info;
653 #endif 653 #endif
654 } 654 }
655 655
656 /////////////////////////////////////////////////////////////////////////// 656 ///////////////////////////////////////////////////////////////////////////
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 if (style) { 1722 if (style) {
1723 *style = SkFontStyle(weight, width, slant); 1723 *style = SkFontStyle(weight, width, slant);
1724 } 1724 }
1725 if (isFixedPitch) { 1725 if (isFixedPitch) {
1726 *isFixedPitch = FT_IS_FIXED_WIDTH(face); 1726 *isFixedPitch = FT_IS_FIXED_WIDTH(face);
1727 } 1727 }
1728 1728
1729 FT_Done_Face(face); 1729 FT_Done_Face(face);
1730 return true; 1730 return true;
1731 } 1731 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFFont.cpp ('k') | src/ports/SkFontHost_FreeType_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698