OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
| 7 #include <limits> |
| 8 |
7 #include "core/fxcodec/include/fx_codec.h" | 9 #include "core/fxcodec/include/fx_codec.h" |
8 #include "core/fxge/ge/fx_text_int.h" | 10 #include "core/fxge/ge/fx_text_int.h" |
9 #include "core/fxge/include/fx_freetype.h" | 11 #include "core/fxge/include/fx_freetype.h" |
10 #include "core/fxge/include/fx_ge.h" | 12 #include "core/fxge/include/fx_ge.h" |
11 | 13 |
12 #ifdef _SKIA_SUPPORT_ | 14 #ifdef _SKIA_SUPPORT_ |
13 #include "third_party/skia/include/core/SkStream.h" | 15 #include "third_party/skia/include/core/SkStream.h" |
14 #include "third_party/skia/include/core/SkTypeface.h" | 16 #include "third_party/skia/include/core/SkTypeface.h" |
15 #endif | 17 #endif |
16 | 18 |
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 const CFX_SubstFont* pSubstFont = pFont->GetSubstFont(); | 1562 const CFX_SubstFont* pSubstFont = pFont->GetSubstFont(); |
1561 if (pSubstFont) { | 1563 if (pSubstFont) { |
1562 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle; | 1564 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle; |
1563 int skew = 0; | 1565 int skew = 0; |
1564 if (bUseCJKSubFont) { | 1566 if (bUseCJKSubFont) { |
1565 skew = pSubstFont->m_bItlicCJK ? -15 : 0; | 1567 skew = pSubstFont->m_bItlicCJK ? -15 : 0; |
1566 } else { | 1568 } else { |
1567 skew = pSubstFont->m_ItalicAngle; | 1569 skew = pSubstFont->m_ItalicAngle; |
1568 } | 1570 } |
1569 if (skew) { | 1571 if (skew) { |
1570 // skew is nonpositive so -skew is used as the index. | 1572 // |skew| is nonpositive so |-skew| is used as the index. We need to make |
1571 skew = -skew <= static_cast<int>(ANGLESKEW_ARRAY_SIZE) | 1573 // sure |skew| != INT_MIN since -INT_MIN is undefined. |
1572 ? -58 | 1574 if (skew <= 0 && skew != std::numeric_limits<int>::min() && |
1573 : -g_AngleSkew[-skew]; | 1575 static_cast<size_t>(-skew) < ANGLESKEW_ARRAY_SIZE) { |
| 1576 skew = -g_AngleSkew[-skew]; |
| 1577 } else { |
| 1578 skew = -58; |
| 1579 } |
1574 if (pFont->IsVertical()) | 1580 if (pFont->IsVertical()) |
1575 ft_matrix.yx += ft_matrix.yy * skew / 100; | 1581 ft_matrix.yx += ft_matrix.yy * skew / 100; |
1576 else | 1582 else |
1577 ft_matrix.xy += -ft_matrix.xx * skew / 100; | 1583 ft_matrix.xy += -ft_matrix.xx * skew / 100; |
1578 } | 1584 } |
1579 if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { | 1585 if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { |
1580 pFont->AdjustMMParams(glyph_index, dest_width, | 1586 pFont->AdjustMMParams(glyph_index, dest_width, |
1581 pFont->GetSubstFont()->m_Weight); | 1587 pFont->GetSubstFont()->m_Weight); |
1582 } | 1588 } |
1583 } | 1589 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 }; | 1832 }; |
1827 CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { | 1833 CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { |
1828 if (!m_Face) { | 1834 if (!m_Face) { |
1829 return NULL; | 1835 return NULL; |
1830 } | 1836 } |
1831 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); | 1837 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); |
1832 FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; | 1838 FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; |
1833 if (m_pSubstFont) { | 1839 if (m_pSubstFont) { |
1834 if (m_pSubstFont->m_ItalicAngle) { | 1840 if (m_pSubstFont->m_ItalicAngle) { |
1835 int skew = m_pSubstFont->m_ItalicAngle; | 1841 int skew = m_pSubstFont->m_ItalicAngle; |
1836 // skew is nonpositive so -skew is used as the index. | 1842 // |skew| is nonpositive so |-skew| is used as the index. We need to make |
1837 skew = -skew <= static_cast<int>(ANGLESKEW_ARRAY_SIZE) | 1843 // sure |skew| != INT_MIN since -INT_MIN is undefined. |
1838 ? -58 | 1844 if (skew <= 0 && skew != std::numeric_limits<int>::min() && |
1839 : -g_AngleSkew[-skew]; | 1845 static_cast<size_t>(-skew) < ANGLESKEW_ARRAY_SIZE) { |
| 1846 skew = -g_AngleSkew[-skew]; |
| 1847 } else { |
| 1848 skew = -58; |
| 1849 } |
1840 if (m_bVertical) | 1850 if (m_bVertical) |
1841 ft_matrix.yx += ft_matrix.yy * skew / 100; | 1851 ft_matrix.yx += ft_matrix.yy * skew / 100; |
1842 else | 1852 else |
1843 ft_matrix.xy += -ft_matrix.xx * skew / 100; | 1853 ft_matrix.xy += -ft_matrix.xx * skew / 100; |
1844 } | 1854 } |
1845 if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { | 1855 if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { |
1846 AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight); | 1856 AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight); |
1847 } | 1857 } |
1848 } | 1858 } |
1849 ScopedFontTransform scoped_transform(m_Face, &ft_matrix); | 1859 ScopedFontTransform scoped_transform(m_Face, &ft_matrix); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 void _CFX_UniqueKeyGen::Generate(int count, ...) { | 1907 void _CFX_UniqueKeyGen::Generate(int count, ...) { |
1898 va_list argList; | 1908 va_list argList; |
1899 va_start(argList, count); | 1909 va_start(argList, count); |
1900 for (int i = 0; i < count; i++) { | 1910 for (int i = 0; i < count; i++) { |
1901 int p = va_arg(argList, int); | 1911 int p = va_arg(argList, int); |
1902 ((uint32_t*)m_Key)[i] = p; | 1912 ((uint32_t*)m_Key)[i] = p; |
1903 } | 1913 } |
1904 va_end(argList); | 1914 va_end(argList); |
1905 m_KeyLen = count * sizeof(uint32_t); | 1915 m_KeyLen = count * sizeof(uint32_t); |
1906 } | 1916 } |
OLD | NEW |