OLD | NEW |
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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 } | 570 } |
571 } | 571 } |
572 | 572 |
573 info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, | 573 info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, |
574 face->bbox.xMax, face->bbox.yMin); | 574 face->bbox.xMax, face->bbox.yMin); |
575 | 575 |
576 if (!FT_IS_SCALABLE(face)) { | 576 if (!FT_IS_SCALABLE(face)) { |
577 perGlyphInfo = kNo_PerGlyphInfo; | 577 perGlyphInfo = kNo_PerGlyphInfo; |
578 } | 578 } |
579 | 579 |
580 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { | |
581 info->setGlyphWidths( | |
582 face->num_glyphs, | |
583 glyphIDs, | |
584 glyphIDsCount, | |
585 SkAdvancedTypefaceMetrics::GetAdvance([face](int gId, int16_t* data)
{ | |
586 FT_Fixed advance = 0; | |
587 if (FT_Get_Advances(face, gId, 1, FT_LOAD_NO_SCALE, &advance)) { | |
588 return false; | |
589 } | |
590 SkASSERT(data); | |
591 *data = advance; | |
592 return true; | |
593 }) | |
594 ); | |
595 } | |
596 | |
597 if (perGlyphInfo & kVAdvance_PerGlyphInfo && FT_HAS_VERTICAL(face)) { | |
598 SkASSERT(false); // Not implemented yet. | |
599 } | |
600 | |
601 if (perGlyphInfo & kGlyphNames_PerGlyphInfo && | 580 if (perGlyphInfo & kGlyphNames_PerGlyphInfo && |
602 info->fType == SkAdvancedTypefaceMetrics::kType1_Font) | 581 info->fType == SkAdvancedTypefaceMetrics::kType1_Font) |
603 { | 582 { |
604 // Postscript fonts may contain more than 255 glyphs, so we end up | 583 // Postscript fonts may contain more than 255 glyphs, so we end up |
605 // using multiple font descriptions with a glyph ordering. Record | 584 // using multiple font descriptions with a glyph ordering. Record |
606 // the name of each glyph. | 585 // the name of each glyph. |
607 info->fGlyphNames.reset(new SkAutoTArray<SkString>(face->num_glyphs)); | 586 info->fGlyphNames.reset(face->num_glyphs); |
608 for (int gID = 0; gID < face->num_glyphs; gID++) { | 587 for (int gID = 0; gID < face->num_glyphs; gID++) { |
609 char glyphName[128]; // PS limit for names is 127 bytes. | 588 char glyphName[128]; // PS limit for names is 127 bytes. |
610 FT_Get_Glyph_Name(face, gID, glyphName, 128); | 589 FT_Get_Glyph_Name(face, gID, glyphName, 128); |
611 info->fGlyphNames->get()[gID].set(glyphName); | 590 info->fGlyphNames[gID].set(glyphName); |
612 } | 591 } |
613 } | 592 } |
614 | 593 |
615 if (perGlyphInfo & kToUnicode_PerGlyphInfo && | 594 if (perGlyphInfo & kToUnicode_PerGlyphInfo && |
616 info->fType != SkAdvancedTypefaceMetrics::kType1_Font && | 595 info->fType != SkAdvancedTypefaceMetrics::kType1_Font && |
617 face->num_charmaps) | 596 face->num_charmaps) |
618 { | 597 { |
619 populate_glyph_to_unicode(face, &(info->fGlyphToUnicode)); | 598 populate_glyph_to_unicode(face, &(info->fGlyphToUnicode)); |
620 } | 599 } |
621 | 600 |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n", | 1771 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n", |
1793 name.c_str(), | 1772 name.c_str(), |
1794 (skTag >> 24) & 0xFF, | 1773 (skTag >> 24) & 0xFF, |
1795 (skTag >> 16) & 0xFF, | 1774 (skTag >> 16) & 0xFF, |
1796 (skTag >> 8) & 0xFF, | 1775 (skTag >> 8) & 0xFF, |
1797 (skTag) & 0xFF)); | 1776 (skTag) & 0xFF)); |
1798 } | 1777 } |
1799 } | 1778 } |
1800 ) | 1779 ) |
1801 } | 1780 } |
OLD | NEW |