| 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 |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 RECT bbox; | 439 RECT bbox; |
| 440 HRVM(glyphRunAnalysis->GetAlphaTextureBounds(fTextureType, &bbox), | 440 HRVM(glyphRunAnalysis->GetAlphaTextureBounds(fTextureType, &bbox), |
| 441 "Could not get texture bounds."); | 441 "Could not get texture bounds."); |
| 442 | 442 |
| 443 glyph->fWidth = SkToU16(bbox.right - bbox.left); | 443 glyph->fWidth = SkToU16(bbox.right - bbox.left); |
| 444 glyph->fHeight = SkToU16(bbox.bottom - bbox.top); | 444 glyph->fHeight = SkToU16(bbox.bottom - bbox.top); |
| 445 glyph->fLeft = SkToS16(bbox.left); | 445 glyph->fLeft = SkToS16(bbox.left); |
| 446 glyph->fTop = SkToS16(bbox.top); | 446 glyph->fTop = SkToS16(bbox.top); |
| 447 } | 447 } |
| 448 | 448 |
| 449 void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* mx, | 449 void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) { |
| 450 SkPaint::FontMetrics* my) { | 450 if (NULL == metrics) { |
| 451 if (!(mx || my)) | |
| 452 return; | 451 return; |
| 452 } |
| 453 | 453 |
| 454 if (mx) { | 454 sk_bzero(metrics, sizeof(*metrics)); |
| 455 sk_bzero(mx, sizeof(*mx)); | |
| 456 } | |
| 457 if (my) { | |
| 458 sk_bzero(my, sizeof(*my)); | |
| 459 } | |
| 460 | 455 |
| 461 DWRITE_FONT_METRICS dwfm; | 456 DWRITE_FONT_METRICS dwfm; |
| 462 if (DWRITE_MEASURING_MODE_GDI_CLASSIC == fMeasuringMode || | 457 if (DWRITE_MEASURING_MODE_GDI_CLASSIC == fMeasuringMode || |
| 463 DWRITE_MEASURING_MODE_GDI_NATURAL == fMeasuringMode) | 458 DWRITE_MEASURING_MODE_GDI_NATURAL == fMeasuringMode) |
| 464 { | 459 { |
| 465 fTypeface->fDWriteFontFace->GetGdiCompatibleMetrics( | 460 fTypeface->fDWriteFontFace->GetGdiCompatibleMetrics( |
| 466 fTextSizeRender, | 461 fTextSizeRender, |
| 467 1.0f, // pixelsPerDip | 462 1.0f, // pixelsPerDip |
| 468 &fXform, | 463 &fXform, |
| 469 &dwfm); | 464 &dwfm); |
| 470 } else { | 465 } else { |
| 471 fTypeface->fDWriteFontFace->GetMetrics(&dwfm); | 466 fTypeface->fDWriteFontFace->GetMetrics(&dwfm); |
| 472 } | 467 } |
| 473 | 468 |
| 474 SkScalar upem = SkIntToScalar(dwfm.designUnitsPerEm); | 469 SkScalar upem = SkIntToScalar(dwfm.designUnitsPerEm); |
| 475 if (mx) { | |
| 476 mx->fTop = -fTextSizeRender * SkIntToScalar(dwfm.ascent) / upem; | |
| 477 mx->fAscent = mx->fTop; | |
| 478 mx->fDescent = fTextSizeRender * SkIntToScalar(dwfm.descent) / upem; | |
| 479 mx->fBottom = mx->fDescent; | |
| 480 mx->fLeading = fTextSizeRender * SkIntToScalar(dwfm.lineGap) / upem; | |
| 481 mx->fXHeight = fTextSizeRender * SkIntToScalar(dwfm.xHeight) / upem; | |
| 482 mx->fUnderlineThickness = fTextSizeRender * SkIntToScalar(dwfm.underline
Thickness) / upem; | |
| 483 mx->fUnderlinePosition = -(fTextSizeRender * SkIntToScalar(dwfm.underlin
ePosition) / upem); | |
| 484 | 470 |
| 485 mx->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; | 471 metrics->fTop = -fTextSizeRender * SkIntToScalar(dwfm.ascent) / upem; |
| 486 mx->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; | 472 metrics->fAscent = metrics->fTop; |
| 487 } | 473 metrics->fDescent = fTextSizeRender * SkIntToScalar(dwfm.descent) / upem; |
| 474 metrics->fBottom = metrics->fDescent; |
| 475 metrics->fLeading = fTextSizeRender * SkIntToScalar(dwfm.lineGap) / upem; |
| 476 metrics->fXHeight = fTextSizeRender * SkIntToScalar(dwfm.xHeight) / upem; |
| 477 metrics->fUnderlineThickness = fTextSizeRender * SkIntToScalar(dwfm.underlin
eThickness) / upem; |
| 478 metrics->fUnderlinePosition = -(fTextSizeRender * SkIntToScalar(dwfm.underli
nePosition) / upem); |
| 488 | 479 |
| 489 if (my) { | 480 metrics->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; |
| 490 my->fTop = -fTextSizeRender * SkIntToScalar(dwfm.ascent) / upem; | 481 metrics->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; |
| 491 my->fAscent = my->fTop; | |
| 492 my->fDescent = fTextSizeRender * SkIntToScalar(dwfm.descent) / upem; | |
| 493 my->fBottom = my->fDescent; | |
| 494 my->fLeading = fTextSizeRender * SkIntToScalar(dwfm.lineGap) / upem; | |
| 495 my->fXHeight = fTextSizeRender * SkIntToScalar(dwfm.xHeight) / upem; | |
| 496 my->fUnderlineThickness = fTextSizeRender * SkIntToScalar(dwfm.underline
Thickness) / upem; | |
| 497 my->fUnderlinePosition = -(fTextSizeRender * SkIntToScalar(dwfm.underlin
ePosition) / upem); | |
| 498 | |
| 499 my->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; | |
| 500 my->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; | |
| 501 } | |
| 502 } | 482 } |
| 503 | 483 |
| 504 /////////////////////////////////////////////////////////////////////////////// | 484 /////////////////////////////////////////////////////////////////////////////// |
| 505 | 485 |
| 506 #include "SkColorPriv.h" | 486 #include "SkColorPriv.h" |
| 507 | 487 |
| 508 static void bilevel_to_bw(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph)
{ | 488 static void bilevel_to_bw(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph)
{ |
| 509 const int width = glyph.fWidth; | 489 const int width = glyph.fWidth; |
| 510 const size_t dstRB = (width + 7) >> 3; | 490 const size_t dstRB = (width + 7) >> 3; |
| 511 uint8_t* SK_RESTRICT dst = static_cast<uint8_t*>(glyph.fImage); | 491 uint8_t* SK_RESTRICT dst = static_cast<uint8_t*>(glyph.fImage); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 NULL, //advances | 686 NULL, //advances |
| 707 NULL, //offsets | 687 NULL, //offsets |
| 708 1, //num glyphs | 688 1, //num glyphs |
| 709 FALSE, //sideways | 689 FALSE, //sideways |
| 710 FALSE, //rtl | 690 FALSE, //rtl |
| 711 geometryToPath.get()), | 691 geometryToPath.get()), |
| 712 "Could not create glyph outline."); | 692 "Could not create glyph outline."); |
| 713 | 693 |
| 714 path->transform(fSkXform); | 694 path->transform(fSkXform); |
| 715 } | 695 } |
| OLD | NEW |