Index: src/ports/SkScalerContext_win_dw.cpp |
diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp |
index e72746a520e42b3093313940df64487de7f68d2b..7884b13259c42f1ef11eaded9792394aba6d75d0 100644 |
--- a/src/ports/SkScalerContext_win_dw.cpp |
+++ b/src/ports/SkScalerContext_win_dw.cpp |
@@ -26,7 +26,9 @@ |
#include "SkTypeface_win_dw.h" |
#include <dwrite.h> |
-#include <dwrite_1.h> |
+#if SK_HAS_DWRITE_1_H |
+# include <dwrite_1.h> |
+#endif |
static bool isLCD(const SkScalerContext::Rec& rec) { |
return SkMask::kLCD16_Format == rec.fMaskFormat || |
@@ -524,6 +526,7 @@ void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) { |
metrics->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; |
metrics->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; |
+#if SK_HAS_DWRITE_1_H |
if (fTypeface->fDWriteFontFace1.get()) { |
DWRITE_FONT_METRICS1 dwfm1; |
fTypeface->fDWriteFontFace1->GetMetrics(&dwfm1); |
@@ -533,23 +536,28 @@ void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* metrics) { |
metrics->fXMax = fTextSizeRender * SkIntToScalar(dwfm1.glyphBoxRight) / upem; |
metrics->fMaxCharWidth = metrics->fXMax - metrics->fXMin; |
- } else { |
- AutoTDWriteTable<SkOTTableHead> head(fTypeface->fDWriteFontFace.get()); |
- if (head.fExists && |
- head.fSize >= sizeof(SkOTTableHead) && |
- head->version == SkOTTableHead::version1) |
- { |
- metrics->fTop = -fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->yMax) / upem; |
- metrics->fBottom = -fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->yMin) / upem; |
- metrics->fXMin = fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->xMin) / upem; |
- metrics->fXMax = fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->xMax) / upem; |
+ return; |
+ } |
+#else |
+# pragma message("No dwrite_1.h is available, font metrics may be affected.") |
+#endif |
- metrics->fMaxCharWidth = metrics->fXMax - metrics->fXMin; |
- } else { |
- metrics->fTop = metrics->fAscent; |
- metrics->fBottom = metrics->fDescent; |
- } |
+ AutoTDWriteTable<SkOTTableHead> head(fTypeface->fDWriteFontFace.get()); |
+ if (head.fExists && |
+ head.fSize >= sizeof(SkOTTableHead) && |
+ head->version == SkOTTableHead::version1) |
+ { |
+ metrics->fTop = -fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->yMax) / upem; |
+ metrics->fBottom = -fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->yMin) / upem; |
+ metrics->fXMin = fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->xMin) / upem; |
+ metrics->fXMax = fTextSizeRender * (int16_t)SkEndian_SwapBE16(head->xMax) / upem; |
+ |
+ metrics->fMaxCharWidth = metrics->fXMax - metrics->fXMin; |
+ return; |
} |
+ |
+ metrics->fTop = metrics->fAscent; |
+ metrics->fBottom = metrics->fDescent; |
} |
/////////////////////////////////////////////////////////////////////////////// |