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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 # define FT_LOAD_COLOR ( 1L << 20 ) | 51 # define FT_LOAD_COLOR ( 1L << 20 ) |
52 # define FT_PIXEL_MODE_BGRA 7 | 52 # define FT_PIXEL_MODE_BGRA 7 |
53 #endif | 53 #endif |
54 | 54 |
55 //#define ENABLE_GLYPH_SPEW // for tracing calls | 55 //#define ENABLE_GLYPH_SPEW // for tracing calls |
56 //#define DUMP_STRIKE_CREATION | 56 //#define DUMP_STRIKE_CREATION |
57 //#define SK_FONTHOST_FREETYPE_USE_NORMAL_LCD_FILTER | 57 //#define SK_FONTHOST_FREETYPE_USE_NORMAL_LCD_FILTER |
58 //#define SK_FONTHOST_FREETYPE_RUNTIME_VERSION | 58 //#define SK_FONTHOST_FREETYPE_RUNTIME_VERSION |
59 //#define SK_GAMMA_APPLY_TO_A8 | 59 //#define SK_GAMMA_APPLY_TO_A8 |
60 | 60 |
61 using namespace skia_advanced_typeface_metrics_utils; | |
62 | |
63 static bool isLCD(const SkScalerContext::Rec& rec) { | 61 static bool isLCD(const SkScalerContext::Rec& rec) { |
64 return SkMask::kLCD16_Format == rec.fMaskFormat; | 62 return SkMask::kLCD16_Format == rec.fMaskFormat; |
65 } | 63 } |
66 | 64 |
67 ////////////////////////////////////////////////////////////////////////// | 65 ////////////////////////////////////////////////////////////////////////// |
68 | 66 |
69 extern "C" { | 67 extern "C" { |
70 static void* sk_ft_alloc(FT_Memory, long size) { | 68 static void* sk_ft_alloc(FT_Memory, long size) { |
71 return sk_malloc_throw(size); | 69 return sk_malloc_throw(size); |
72 } | 70 } |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 | 582 |
585 info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, | 583 info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, |
586 face->bbox.xMax, face->bbox.yMin); | 584 face->bbox.xMax, face->bbox.yMin); |
587 | 585 |
588 if (!FT_IS_SCALABLE(face)) { | 586 if (!FT_IS_SCALABLE(face)) { |
589 perGlyphInfo = kNo_PerGlyphInfo; | 587 perGlyphInfo = kNo_PerGlyphInfo; |
590 } | 588 } |
591 | 589 |
592 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { | 590 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { |
593 if (FT_IS_FIXED_WIDTH(face)) { | 591 if (FT_IS_FIXED_WIDTH(face)) { |
594 appendRange(&info->fGlyphWidths, 0); | 592 SkAdvancedTypefaceMetrics::WidthRange range(0); |
595 int16_t advance = face->max_advance_width; | 593 int16_t advance = face->max_advance_width; |
596 info->fGlyphWidths->fAdvance.append(1, &advance); | 594 range.fAdvance.append(1, &advance); |
597 finishRange(info->fGlyphWidths.get(), 0, | 595 SkAdvancedTypefaceMetrics::FinishRange( |
598 SkAdvancedTypefaceMetrics::WidthRange::kDefault); | 596 &range, 0, SkAdvancedTypefaceMetrics::WidthRange::kDefault); |
| 597 info->fGlyphWidths.emplace_back(std::move(range)); |
599 } else if (!cid) { | 598 } else if (!cid) { |
600 appendRange(&info->fGlyphWidths, 0); | 599 SkAdvancedTypefaceMetrics::WidthRange range(0); |
601 // So as to not blow out the stack, get advances in batches. | 600 // So as to not blow out the stack, get advances in batches. |
602 for (int gID = 0; gID < face->num_glyphs; gID += 128) { | 601 for (int gID = 0; gID < face->num_glyphs; gID += 128) { |
603 FT_Fixed advances[128]; | 602 FT_Fixed advances[128]; |
604 int advanceCount = 128; | 603 int advanceCount = 128; |
605 if (gID + advanceCount > face->num_glyphs) { | 604 if (gID + advanceCount > face->num_glyphs) { |
606 advanceCount = face->num_glyphs - gID; | 605 advanceCount = face->num_glyphs - gID; |
607 } | 606 } |
608 FT_Get_Advances(face, gID, advanceCount, FT_LOAD_NO_SCALE, advan
ces); | 607 FT_Get_Advances(face, gID, advanceCount, FT_LOAD_NO_SCALE, advan
ces); |
609 for (int i = 0; i < advanceCount; i++) { | 608 for (int i = 0; i < advanceCount; i++) { |
610 int16_t advance = advances[i]; | 609 int16_t advance = advances[i]; |
611 info->fGlyphWidths->fAdvance.append(1, &advance); | 610 range.fAdvance.append(1, &advance); |
612 } | 611 } |
613 } | 612 } |
614 finishRange(info->fGlyphWidths.get(), face->num_glyphs - 1, | 613 SkAdvancedTypefaceMetrics::FinishRange( |
615 SkAdvancedTypefaceMetrics::WidthRange::kRange); | 614 &range, face->num_glyphs - 1, |
| 615 SkAdvancedTypefaceMetrics::WidthRange::kRange); |
| 616 info->fGlyphWidths.emplace_back(std::move(range)); |
616 } else { | 617 } else { |
617 info->fGlyphWidths.reset( | 618 info->setGlyphWidths(face, face->num_glyphs, glyphIDs, |
618 getAdvanceData(face, | 619 glyphIDsCount, &getWidthAdvance); |
619 face->num_glyphs, | |
620 glyphIDs, | |
621 glyphIDsCount, | |
622 &getWidthAdvance)); | |
623 } | 620 } |
624 } | 621 } |
625 | 622 |
626 if (perGlyphInfo & kVAdvance_PerGlyphInfo && | 623 if (perGlyphInfo & kVAdvance_PerGlyphInfo && |
627 FT_HAS_VERTICAL(face)) { | 624 FT_HAS_VERTICAL(face)) { |
628 SkASSERT(false); // Not implemented yet. | 625 SkASSERT(false); // Not implemented yet. |
629 } | 626 } |
630 | 627 |
631 if (perGlyphInfo & kGlyphNames_PerGlyphInfo && | 628 if (perGlyphInfo & kGlyphNames_PerGlyphInfo && |
632 info->fType == SkAdvancedTypefaceMetrics::kType1_Font) { | 629 info->fType == SkAdvancedTypefaceMetrics::kType1_Font) { |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1819 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n", | 1816 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n", |
1820 name.c_str(), | 1817 name.c_str(), |
1821 (skTag >> 24) & 0xFF, | 1818 (skTag >> 24) & 0xFF, |
1822 (skTag >> 16) & 0xFF, | 1819 (skTag >> 16) & 0xFF, |
1823 (skTag >> 8) & 0xFF, | 1820 (skTag >> 8) & 0xFF, |
1824 (skTag) & 0xFF)); | 1821 (skTag) & 0xFF)); |
1825 } | 1822 } |
1826 } | 1823 } |
1827 ) | 1824 ) |
1828 } | 1825 } |
OLD | NEW |