OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAdvancedTypefaceMetrics.h" | 9 #include "SkAdvancedTypefaceMetrics.h" |
10 #include "SkBase64.h" | 10 #include "SkBase64.h" |
(...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 path->close(); | 1574 path->close(); |
1575 } | 1575 } |
1576 return true; | 1576 return true; |
1577 } | 1577 } |
1578 | 1578 |
1579 DWORD SkScalerContext_GDI::getGDIGlyphPath(const SkGlyph& glyph, UINT flags, | 1579 DWORD SkScalerContext_GDI::getGDIGlyphPath(const SkGlyph& glyph, UINT flags, |
1580 SkAutoSTMalloc<BUFFERSIZE, uint8_
t>* glyphbuf) | 1580 SkAutoSTMalloc<BUFFERSIZE, uint8_
t>* glyphbuf) |
1581 { | 1581 { |
1582 GLYPHMETRICS gm; | 1582 GLYPHMETRICS gm; |
1583 | 1583 |
1584 DWORD total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, BU
FFERSIZE, glyphbuf->get(), &fMat22); | 1584 DWORD total_size = GetGlyphOutlineW(fDDC, glyph.fID, flags, &gm, BUFFERSIZE,
glyphbuf->get(), &fMat22); |
1585 // Sometimes GetGlyphOutlineW returns a number larger than BUFFERSIZE even i
f BUFFERSIZE > 0. | 1585 // Sometimes GetGlyphOutlineW returns a number larger than BUFFERSIZE even i
f BUFFERSIZE > 0. |
1586 // It has been verified that this does not involve a buffer overrun. | 1586 // It has been verified that this does not involve a buffer overrun. |
1587 if (GDI_ERROR == total_size || total_size > BUFFERSIZE) { | 1587 if (GDI_ERROR == total_size || total_size > BUFFERSIZE) { |
1588 // GDI_ERROR because the BUFFERSIZE was too small, or because the data w
as not accessible. | 1588 // GDI_ERROR because the BUFFERSIZE was too small, or because the data w
as not accessible. |
1589 // When the data is not accessable GetGlyphOutlineW fails rather quickly
, | 1589 // When the data is not accessable GetGlyphOutlineW fails rather quickly
, |
1590 // so just try to get the size. If that fails then ensure the data is ac
cessible. | 1590 // so just try to get the size. If that fails then ensure the data is ac
cessible. |
1591 total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, 0, N
ULL, &fMat22); | 1591 total_size = GetGlyphOutlineW(fDDC, glyph.fID, flags, &gm, 0, NULL, &fMa
t22); |
1592 if (GDI_ERROR == total_size) { | 1592 if (GDI_ERROR == total_size) { |
1593 LogFontTypeface::EnsureAccessible(this->getTypeface()); | 1593 LogFontTypeface::EnsureAccessible(this->getTypeface()); |
1594 total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm,
0, NULL, &fMat22); | 1594 total_size = GetGlyphOutlineW(fDDC, glyph.fID, flags, &gm, 0, NULL,
&fMat22); |
1595 if (GDI_ERROR == total_size) { | 1595 if (GDI_ERROR == total_size) { |
1596 // GetGlyphOutlineW is known to fail for some characters, such a
s spaces. | 1596 // GetGlyphOutlineW is known to fail for some characters, such a
s spaces. |
1597 // In these cases, just return that the glyph does not have a sh
ape. | 1597 // In these cases, just return that the glyph does not have a sh
ape. |
1598 return 0; | 1598 return 0; |
1599 } | 1599 } |
1600 } | 1600 } |
1601 | 1601 |
1602 glyphbuf->reset(total_size); | 1602 glyphbuf->reset(total_size); |
1603 | 1603 |
1604 DWORD ret = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, total
_size, glyphbuf->get(), &fMat22); | 1604 DWORD ret = GetGlyphOutlineW(fDDC, glyph.fID, flags, &gm, total_size, gl
yphbuf->get(), &fMat22); |
1605 if (GDI_ERROR == ret) { | 1605 if (GDI_ERROR == ret) { |
1606 LogFontTypeface::EnsureAccessible(this->getTypeface()); | 1606 LogFontTypeface::EnsureAccessible(this->getTypeface()); |
1607 ret = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, total_s
ize, glyphbuf->get(), &fMat22); | 1607 ret = GetGlyphOutlineW(fDDC, glyph.fID, flags, &gm, total_size, glyp
hbuf->get(), &fMat22); |
1608 if (GDI_ERROR == ret) { | 1608 if (GDI_ERROR == ret) { |
1609 SkASSERT(false); | 1609 SkASSERT(false); |
1610 return 0; | 1610 return 0; |
1611 } | 1611 } |
1612 } | 1612 } |
1613 } | 1613 } |
1614 return total_size; | 1614 return total_size; |
1615 } | 1615 } |
1616 | 1616 |
1617 void SkScalerContext_GDI::generatePath(const SkGlyph& glyph, SkPath* path) { | 1617 void SkScalerContext_GDI::generatePath(const SkGlyph& glyph, SkPath* path) { |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 | 2513 |
2514 private: | 2514 private: |
2515 SkTDArray<ENUMLOGFONTEX> fLogFontArray; | 2515 SkTDArray<ENUMLOGFONTEX> fLogFontArray; |
2516 }; | 2516 }; |
2517 | 2517 |
2518 /////////////////////////////////////////////////////////////////////////////// | 2518 /////////////////////////////////////////////////////////////////////////////// |
2519 | 2519 |
2520 SkFontMgr* SkFontMgr_New_GDI() { | 2520 SkFontMgr* SkFontMgr_New_GDI() { |
2521 return SkNEW(SkFontMgrGDI); | 2521 return SkNEW(SkFontMgrGDI); |
2522 } | 2522 } |
OLD | NEW |