| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 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 "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #undef GetGlyphIndices | 9 #undef GetGlyphIndices |
| 10 | 10 |
| 11 #include "SkDWrite.h" | 11 #include "SkDWrite.h" |
| 12 #include "SkDWriteGeometrySink.h" | 12 #include "SkDWriteGeometrySink.h" |
| 13 #include "SkEndian.h" | 13 #include "SkEndian.h" |
| 14 #include "SkGlyph.h" | 14 #include "SkGlyph.h" |
| 15 #include "SkHRESULT.h" | 15 #include "SkHRESULT.h" |
| 16 #include "SkMaskGamma.h" | 16 #include "SkMaskGamma.h" |
| 17 #include "SkMatrix22.h" | 17 #include "SkMatrix22.h" |
| 18 #include "SkOTTable_EBLC.h" | 18 #include "SkOTTable_EBLC.h" |
| 19 #include "SkOTTable_EBSC.h" | 19 #include "SkOTTable_EBSC.h" |
| 20 #include "SkOTTable_gasp.h" | 20 #include "SkOTTable_gasp.h" |
| 21 #include "SkOTTable_maxp.h" | 21 #include "SkOTTable_maxp.h" |
| 22 #include "SkPath.h" | 22 #include "SkPath.h" |
| 23 #include "SkScalerContext.h" | 23 #include "SkScalerContext.h" |
| 24 #include "SkScalerContext_win_dw.h" | 24 #include "SkScalerContext_win_dw.h" |
| 25 #include "SkTScopedComPtr.h" | 25 #include "SkTScopedComPtr.h" |
| 26 #include "SkTypeface_win_dw.h" | 26 #include "SkTypeface_win_dw.h" |
| 27 | 27 |
| 28 #include <dwrite.h> | 28 #include <dwrite.h> |
| 29 #include <dwrite_1.h> | 29 #if SK_HAS_DWRITE_1_H |
| 30 # include <dwrite_1.h> |
| 31 #endif |
| 30 | 32 |
| 31 static bool isLCD(const SkScalerContext::Rec& rec) { | 33 static bool isLCD(const SkScalerContext::Rec& rec) { |
| 32 return SkMask::kLCD16_Format == rec.fMaskFormat || | 34 return SkMask::kLCD16_Format == rec.fMaskFormat || |
| 33 SkMask::kLCD32_Format == rec.fMaskFormat; | 35 SkMask::kLCD32_Format == rec.fMaskFormat; |
| 34 } | 36 } |
| 35 | 37 |
| 36 static bool is_hinted_without_gasp(DWriteFontTypeface* typeface) { | 38 static bool is_hinted_without_gasp(DWriteFontTypeface* typeface) { |
| 37 AutoTDWriteTable<SkOTTableMaximumProfile> maxp(typeface->fDWriteFontFace.get
()); | 39 AutoTDWriteTable<SkOTTableMaximumProfile> maxp(typeface->fDWriteFontFace.get
()); |
| 38 if (!maxp.fExists) { | 40 if (!maxp.fExists) { |
| 39 return false; | 41 return false; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 metrics->fAscent = -fTextSizeRender * SkIntToScalar(dwfm.ascent) / upem; | 519 metrics->fAscent = -fTextSizeRender * SkIntToScalar(dwfm.ascent) / upem; |
| 518 metrics->fDescent = fTextSizeRender * SkIntToScalar(dwfm.descent) / upem; | 520 metrics->fDescent = fTextSizeRender * SkIntToScalar(dwfm.descent) / upem; |
| 519 metrics->fLeading = fTextSizeRender * SkIntToScalar(dwfm.lineGap) / upem; | 521 metrics->fLeading = fTextSizeRender * SkIntToScalar(dwfm.lineGap) / upem; |
| 520 metrics->fXHeight = fTextSizeRender * SkIntToScalar(dwfm.xHeight) / upem; | 522 metrics->fXHeight = fTextSizeRender * SkIntToScalar(dwfm.xHeight) / upem; |
| 521 metrics->fUnderlineThickness = fTextSizeRender * SkIntToScalar(dwfm.underlin
eThickness) / upem; | 523 metrics->fUnderlineThickness = fTextSizeRender * SkIntToScalar(dwfm.underlin
eThickness) / upem; |
| 522 metrics->fUnderlinePosition = -(fTextSizeRender * SkIntToScalar(dwfm.underli
nePosition) / upem); | 524 metrics->fUnderlinePosition = -(fTextSizeRender * SkIntToScalar(dwfm.underli
nePosition) / upem); |
| 523 | 525 |
| 524 metrics->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; | 526 metrics->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; |
| 525 metrics->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; | 527 metrics->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; |
| 526 | 528 |
| 529 #if SK_HAS_DWRITE_1_H |
| 527 if (fTypeface->fDWriteFontFace1.get()) { | 530 if (fTypeface->fDWriteFontFace1.get()) { |
| 528 DWRITE_FONT_METRICS1 dwfm1; | 531 DWRITE_FONT_METRICS1 dwfm1; |
| 529 fTypeface->fDWriteFontFace1->GetMetrics(&dwfm1); | 532 fTypeface->fDWriteFontFace1->GetMetrics(&dwfm1); |
| 530 metrics->fTop = -fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxTop) / up
em; | 533 metrics->fTop = -fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxTop) / up
em; |
| 531 metrics->fBottom = -fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxBottom
) / upem; | 534 metrics->fBottom = -fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxBottom
) / upem; |
| 532 metrics->fXMin = fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxLeft) / u
pem; | 535 metrics->fXMin = fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxLeft) / u
pem; |
| 533 metrics->fXMax = fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxRight) /
upem; | 536 metrics->fXMax = fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxRight) /
upem; |
| 534 | 537 |
| 535 metrics->fMaxCharWidth = metrics->fXMax - metrics->fXMin; | 538 metrics->fMaxCharWidth = metrics->fXMax - metrics->fXMin; |
| 536 } else { | 539 return; |
| 537 AutoTDWriteTable<SkOTTableHead> head(fTypeface->fDWriteFontFace.get()); | 540 } |
| 538 if (head.fExists && | 541 #else |
| 539 head.fSize >= sizeof(SkOTTableHead) && | 542 # pragma message("No dwrite_1.h is available, font metrics may be affected.") |
| 540 head->version == SkOTTableHead::version1) | 543 #endif |
| 541 { | |
| 542 metrics->fTop = -fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->
yMax) / upem; | |
| 543 metrics->fBottom = -fTextSizeRender * (int16_t)SkEndian_SwapBE16(hea
d->yMin) / upem; | |
| 544 metrics->fXMin = fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->
xMin) / upem; | |
| 545 metrics->fXMax = fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->
xMax) / upem; | |
| 546 | 544 |
| 547 metrics->fMaxCharWidth = metrics->fXMax - metrics->fXMin; | 545 AutoTDWriteTable<SkOTTableHead> head(fTypeface->fDWriteFontFace.get()); |
| 548 } else { | 546 if (head.fExists && |
| 549 metrics->fTop = metrics->fAscent; | 547 head.fSize >= sizeof(SkOTTableHead) && |
| 550 metrics->fBottom = metrics->fDescent; | 548 head->version == SkOTTableHead::version1) |
| 551 } | 549 { |
| 550 metrics->fTop = -fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->yMax
) / upem; |
| 551 metrics->fBottom = -fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->y
Min) / upem; |
| 552 metrics->fXMin = fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->xMin
) / upem; |
| 553 metrics->fXMax = fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->xMax
) / upem; |
| 554 |
| 555 metrics->fMaxCharWidth = metrics->fXMax - metrics->fXMin; |
| 556 return; |
| 552 } | 557 } |
| 558 |
| 559 metrics->fTop = metrics->fAscent; |
| 560 metrics->fBottom = metrics->fDescent; |
| 553 } | 561 } |
| 554 | 562 |
| 555 /////////////////////////////////////////////////////////////////////////////// | 563 /////////////////////////////////////////////////////////////////////////////// |
| 556 | 564 |
| 557 #include "SkColorPriv.h" | 565 #include "SkColorPriv.h" |
| 558 | 566 |
| 559 static void bilevel_to_bw(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph)
{ | 567 static void bilevel_to_bw(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph)
{ |
| 560 const int width = glyph.fWidth; | 568 const int width = glyph.fWidth; |
| 561 const size_t dstRB = (width + 7) >> 3; | 569 const size_t dstRB = (width + 7) >> 3; |
| 562 uint8_t* SK_RESTRICT dst = static_cast<uint8_t*>(glyph.fImage); | 570 uint8_t* SK_RESTRICT dst = static_cast<uint8_t*>(glyph.fImage); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 NULL, //advances | 774 NULL, //advances |
| 767 NULL, //offsets | 775 NULL, //offsets |
| 768 1, //num glyphs | 776 1, //num glyphs |
| 769 FALSE, //sideways | 777 FALSE, //sideways |
| 770 FALSE, //rtl | 778 FALSE, //rtl |
| 771 geometryToPath.get()), | 779 geometryToPath.get()), |
| 772 "Could not create glyph outline."); | 780 "Could not create glyph outline."); |
| 773 | 781 |
| 774 path->transform(fSkXform); | 782 path->transform(fSkXform); |
| 775 } | 783 } |
| OLD | NEW |