| 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 "core/fxge/ge/fx_text_int.h" | 7 #include "core/fxge/ge/fx_text_int.h" |
| 8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
| 9 #include "core/include/fxge/fx_freetype.h" | 9 #include "core/include/fxge/fx_freetype.h" |
| 10 #include "core/include/fxge/fx_ge.h" | 10 #include "core/include/fxge/fx_ge.h" |
| (...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 const CFX_SubstFont* pSubstFont = pFont->GetSubstFont(); | 1529 const CFX_SubstFont* pSubstFont = pFont->GetSubstFont(); |
| 1530 if (pSubstFont) { | 1530 if (pSubstFont) { |
| 1531 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle; | 1531 bUseCJKSubFont = pSubstFont->m_bSubstOfCJK && bFontStyle; |
| 1532 int skew = 0; | 1532 int skew = 0; |
| 1533 if (bUseCJKSubFont) { | 1533 if (bUseCJKSubFont) { |
| 1534 skew = pSubstFont->m_bItlicCJK ? -15 : 0; | 1534 skew = pSubstFont->m_bItlicCJK ? -15 : 0; |
| 1535 } else { | 1535 } else { |
| 1536 skew = pSubstFont->m_ItalicAngle; | 1536 skew = pSubstFont->m_ItalicAngle; |
| 1537 } | 1537 } |
| 1538 if (skew) { | 1538 if (skew) { |
| 1539 skew = skew <= -ANGLESKEW_ARRAY_SIZE ? -58 : -g_AngleSkew[-skew]; | 1539 // skew is nonpositive so -skew is used as the index. |
| 1540 if (pFont->IsVertical()) { | 1540 skew = -skew <= static_cast<int>(ANGLESKEW_ARRAY_SIZE) |
| 1541 ? -58 |
| 1542 : -g_AngleSkew[-skew]; |
| 1543 if (pFont->IsVertical()) |
| 1541 ft_matrix.yx += ft_matrix.yy * skew / 100; | 1544 ft_matrix.yx += ft_matrix.yy * skew / 100; |
| 1542 } else { | 1545 else |
| 1543 ft_matrix.xy += -ft_matrix.xx * skew / 100; | 1546 ft_matrix.xy += -ft_matrix.xx * skew / 100; |
| 1544 } | |
| 1545 } | 1547 } |
| 1546 if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { | 1548 if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { |
| 1547 pFont->AdjustMMParams(glyph_index, dest_width, | 1549 pFont->AdjustMMParams(glyph_index, dest_width, |
| 1548 pFont->GetSubstFont()->m_Weight); | 1550 pFont->GetSubstFont()->m_Weight); |
| 1549 } | 1551 } |
| 1550 } | 1552 } |
| 1551 ScopedFontTransform scoped_transform(m_Face, &ft_matrix); | 1553 ScopedFontTransform scoped_transform(m_Face, &ft_matrix); |
| 1552 int load_flags = (m_Face->face_flags & FT_FACE_FLAG_SFNT) | 1554 int load_flags = (m_Face->face_flags & FT_FACE_FLAG_SFNT) |
| 1553 ? FXFT_LOAD_NO_BITMAP | 1555 ? FXFT_LOAD_NO_BITMAP |
| 1554 : (FXFT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); | 1556 : (FXFT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1567 } | 1569 } |
| 1568 } | 1570 } |
| 1569 int weight = 0; | 1571 int weight = 0; |
| 1570 if (bUseCJKSubFont) { | 1572 if (bUseCJKSubFont) { |
| 1571 weight = pSubstFont->m_WeightCJK; | 1573 weight = pSubstFont->m_WeightCJK; |
| 1572 } else { | 1574 } else { |
| 1573 weight = pSubstFont ? pSubstFont->m_Weight : 0; | 1575 weight = pSubstFont ? pSubstFont->m_Weight : 0; |
| 1574 } | 1576 } |
| 1575 if (pSubstFont && !(pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) && | 1577 if (pSubstFont && !(pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) && |
| 1576 weight > 400) { | 1578 weight > 400) { |
| 1577 int index = (weight - 400) / 10; | 1579 uint32_t index = (weight - 400) / 10; |
| 1578 if (index >= WEIGHTPOW_ARRAY_SIZE) { | 1580 if (index >= WEIGHTPOW_ARRAY_SIZE) |
| 1579 return NULL; | 1581 return NULL; |
| 1580 } | |
| 1581 int level = 0; | 1582 int level = 0; |
| 1582 if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) { | 1583 if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) { |
| 1583 level = | 1584 level = |
| 1584 g_WeightPow_SHIFTJIS[index] * 2 * | 1585 g_WeightPow_SHIFTJIS[index] * 2 * |
| 1585 (FXSYS_abs((int)(ft_matrix.xx)) + FXSYS_abs((int)(ft_matrix.xy))) / | 1586 (FXSYS_abs((int)(ft_matrix.xx)) + FXSYS_abs((int)(ft_matrix.xy))) / |
| 1586 36655; | 1587 36655; |
| 1587 } else { | 1588 } else { |
| 1588 level = g_WeightPow_11[index] * (FXSYS_abs((int)(ft_matrix.xx)) + | 1589 level = g_WeightPow_11[index] * (FXSYS_abs((int)(ft_matrix.xx)) + |
| 1589 FXSYS_abs((int)(ft_matrix.xy))) / | 1590 FXSYS_abs((int)(ft_matrix.xy))) / |
| 1590 36655; | 1591 36655; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 }; | 1795 }; |
| 1795 CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { | 1796 CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { |
| 1796 if (!m_Face) { | 1797 if (!m_Face) { |
| 1797 return NULL; | 1798 return NULL; |
| 1798 } | 1799 } |
| 1799 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); | 1800 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); |
| 1800 FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; | 1801 FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; |
| 1801 if (m_pSubstFont) { | 1802 if (m_pSubstFont) { |
| 1802 if (m_pSubstFont->m_ItalicAngle) { | 1803 if (m_pSubstFont->m_ItalicAngle) { |
| 1803 int skew = m_pSubstFont->m_ItalicAngle; | 1804 int skew = m_pSubstFont->m_ItalicAngle; |
| 1804 skew = skew <= -ANGLESKEW_ARRAY_SIZE ? -58 : -g_AngleSkew[-skew]; | 1805 // skew is nonpositive so -skew is used as the index. |
| 1805 if (m_bVertical) { | 1806 skew = -skew <= static_cast<int>(ANGLESKEW_ARRAY_SIZE) |
| 1807 ? -58 |
| 1808 : -g_AngleSkew[-skew]; |
| 1809 if (m_bVertical) |
| 1806 ft_matrix.yx += ft_matrix.yy * skew / 100; | 1810 ft_matrix.yx += ft_matrix.yy * skew / 100; |
| 1807 } else { | 1811 else |
| 1808 ft_matrix.xy += -ft_matrix.xx * skew / 100; | 1812 ft_matrix.xy += -ft_matrix.xx * skew / 100; |
| 1809 } | |
| 1810 } | 1813 } |
| 1811 if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { | 1814 if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) { |
| 1812 AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight); | 1815 AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight); |
| 1813 } | 1816 } |
| 1814 } | 1817 } |
| 1815 ScopedFontTransform scoped_transform(m_Face, &ft_matrix); | 1818 ScopedFontTransform scoped_transform(m_Face, &ft_matrix); |
| 1816 int load_flags = FXFT_LOAD_NO_BITMAP; | 1819 int load_flags = FXFT_LOAD_NO_BITMAP; |
| 1817 if (!(m_Face->face_flags & FT_FACE_FLAG_SFNT) || !FT_IS_TRICKY(m_Face)) { | 1820 if (!(m_Face->face_flags & FT_FACE_FLAG_SFNT) || !FT_IS_TRICKY(m_Face)) { |
| 1818 load_flags |= FT_LOAD_NO_HINTING; | 1821 load_flags |= FT_LOAD_NO_HINTING; |
| 1819 } | 1822 } |
| 1820 int error = FXFT_Load_Glyph(m_Face, glyph_index, load_flags); | 1823 if (FXFT_Load_Glyph(m_Face, glyph_index, load_flags)) |
| 1821 if (error) { | |
| 1822 return NULL; | 1824 return NULL; |
| 1823 } | |
| 1824 if (m_pSubstFont && !(m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) && | 1825 if (m_pSubstFont && !(m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) && |
| 1825 m_pSubstFont->m_Weight > 400) { | 1826 m_pSubstFont->m_Weight > 400) { |
| 1826 int index = (m_pSubstFont->m_Weight - 400) / 10; | 1827 uint32_t index = (m_pSubstFont->m_Weight - 400) / 10; |
| 1827 if (index >= WEIGHTPOW_ARRAY_SIZE) | 1828 if (index >= WEIGHTPOW_ARRAY_SIZE) |
| 1828 index = WEIGHTPOW_ARRAY_SIZE - 1; | 1829 index = WEIGHTPOW_ARRAY_SIZE - 1; |
| 1829 int level = 0; | 1830 int level = 0; |
| 1830 if (m_pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) { | 1831 if (m_pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) |
| 1831 level = g_WeightPow_SHIFTJIS[index] * 2 * 65536 / 36655; | 1832 level = g_WeightPow_SHIFTJIS[index] * 2 * 65536 / 36655; |
| 1832 } else { | 1833 else |
| 1833 level = g_WeightPow[index] * 2; | 1834 level = g_WeightPow[index] * 2; |
| 1834 } | |
| 1835 FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), level); | 1835 FXFT_Outline_Embolden(FXFT_Get_Glyph_Outline(m_Face), level); |
| 1836 } | 1836 } |
| 1837 FXFT_Outline_Funcs funcs; | 1837 FXFT_Outline_Funcs funcs; |
| 1838 funcs.move_to = _Outline_MoveTo; | 1838 funcs.move_to = _Outline_MoveTo; |
| 1839 funcs.line_to = _Outline_LineTo; | 1839 funcs.line_to = _Outline_LineTo; |
| 1840 funcs.conic_to = _Outline_ConicTo; | 1840 funcs.conic_to = _Outline_ConicTo; |
| 1841 funcs.cubic_to = _Outline_CubicTo; | 1841 funcs.cubic_to = _Outline_CubicTo; |
| 1842 funcs.shift = 0; | 1842 funcs.shift = 0; |
| 1843 funcs.delta = 0; | 1843 funcs.delta = 0; |
| 1844 OUTLINE_PARAMS params; | 1844 OUTLINE_PARAMS params; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1866 void _CFX_UniqueKeyGen::Generate(int count, ...) { | 1866 void _CFX_UniqueKeyGen::Generate(int count, ...) { |
| 1867 va_list argList; | 1867 va_list argList; |
| 1868 va_start(argList, count); | 1868 va_start(argList, count); |
| 1869 for (int i = 0; i < count; i++) { | 1869 for (int i = 0; i < count; i++) { |
| 1870 int p = va_arg(argList, int); | 1870 int p = va_arg(argList, int); |
| 1871 ((uint32_t*)m_Key)[i] = p; | 1871 ((uint32_t*)m_Key)[i] = p; |
| 1872 } | 1872 } |
| 1873 va_end(argList); | 1873 va_end(argList); |
| 1874 m_KeyLen = count * sizeof(uint32_t); | 1874 m_KeyLen = count * sizeof(uint32_t); |
| 1875 } | 1875 } |
| OLD | NEW |