| 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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
| 8 #include "../../../include/fxge/fx_freetype.h" | 8 #include "../../../include/fxge/fx_freetype.h" |
| 9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
| 10 #include "text_int.h" | 10 #include "text_int.h" |
| (...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 } | 1610 } |
| 1611 } else { | 1611 } else { |
| 1612 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, | 1612 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, |
| 1613 dest_pitch); | 1613 dest_pitch); |
| 1614 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, | 1614 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, |
| 1615 CFX_GEModule::Get()->GetTextGammaTable()); | 1615 CFX_GEModule::Get()->GetTextGammaTable()); |
| 1616 } | 1616 } |
| 1617 } | 1617 } |
| 1618 return pGlyphBitmap; | 1618 return pGlyphBitmap; |
| 1619 } | 1619 } |
| 1620 FX_BOOL _OutputGlyph(void* dib, | |
| 1621 int x, | |
| 1622 int y, | |
| 1623 CFX_Font* pFont, | |
| 1624 int glyph_index, | |
| 1625 FX_ARGB argb) { | |
| 1626 CFX_DIBitmap* pDib = (CFX_DIBitmap*)dib; | |
| 1627 FXFT_Face face = pFont->GetFace(); | |
| 1628 int error = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_BITMAP); | |
| 1629 if (error) { | |
| 1630 return FALSE; | |
| 1631 } | |
| 1632 error = FXFT_Render_Glyph(face, FXFT_RENDER_MODE_NORMAL); | |
| 1633 if (error) { | |
| 1634 return FALSE; | |
| 1635 } | |
| 1636 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(face)); | |
| 1637 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(face)); | |
| 1638 int left = FXFT_Get_Glyph_BitmapLeft(face); | |
| 1639 int top = FXFT_Get_Glyph_BitmapTop(face); | |
| 1640 const uint8_t* src_buf = | |
| 1641 (const uint8_t*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Glyph_Bitmap(face)); | |
| 1642 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(face)); | |
| 1643 CFX_DIBitmap mask; | |
| 1644 mask.Create(bmwidth, bmheight, FXDIB_8bppMask); | |
| 1645 uint8_t* dest_buf = mask.GetBuffer(); | |
| 1646 int dest_pitch = mask.GetPitch(); | |
| 1647 for (int row = 0; row < bmheight; row++) { | |
| 1648 const uint8_t* src_scan = src_buf + row * src_pitch; | |
| 1649 uint8_t* dest_scan = dest_buf + row * dest_pitch; | |
| 1650 FXSYS_memcpy(dest_scan, src_scan, dest_pitch); | |
| 1651 } | |
| 1652 pDib->CompositeMask(x + left, y - top, bmwidth, bmheight, &mask, argb, 0, 0); | |
| 1653 return TRUE; | |
| 1654 } | |
| 1655 FX_BOOL OutputText(void* dib, | |
| 1656 int x, | |
| 1657 int y, | |
| 1658 CFX_Font* pFont, | |
| 1659 double font_size, | |
| 1660 CFX_AffineMatrix* pText_matrix, | |
| 1661 unsigned short const* text, | |
| 1662 unsigned long argb) { | |
| 1663 if (!pFont) { | |
| 1664 return FALSE; | |
| 1665 } | |
| 1666 FXFT_Face face = pFont->GetFace(); | |
| 1667 FXFT_Select_Charmap(pFont->m_Face, FXFT_ENCODING_UNICODE); | |
| 1668 if (pText_matrix) { | |
| 1669 FXFT_Matrix ft_matrix; | |
| 1670 ft_matrix.xx = (signed long)(pText_matrix->a / 64 * 65536); | |
| 1671 ft_matrix.xy = (signed long)(pText_matrix->c / 64 * 65536); | |
| 1672 ft_matrix.yx = (signed long)(pText_matrix->b / 64 * 65536); | |
| 1673 ft_matrix.yy = (signed long)(pText_matrix->d / 64 * 65536); | |
| 1674 FXFT_Set_Transform(face, &ft_matrix, 0); | |
| 1675 } | |
| 1676 FX_FLOAT x_pos = 0; | |
| 1677 for (; *text != 0; text++) { | |
| 1678 FX_WCHAR unicode = *text; | |
| 1679 int glyph_index = FXFT_Get_Char_Index(pFont->m_Face, unicode); | |
| 1680 if (glyph_index <= 0) { | |
| 1681 continue; | |
| 1682 } | |
| 1683 int err = FXFT_Load_Glyph( | |
| 1684 pFont->m_Face, glyph_index, | |
| 1685 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH); | |
| 1686 if (err) { | |
| 1687 continue; | |
| 1688 } | |
| 1689 int w = FXFT_Get_Glyph_HoriAdvance(pFont->m_Face); | |
| 1690 int em = FXFT_Get_Face_UnitsPerEM(pFont->m_Face); | |
| 1691 FX_FLOAT x1, y1; | |
| 1692 pText_matrix->Transform(x_pos, 0, x1, y1); | |
| 1693 _OutputGlyph(dib, (int)x1 + x, (int)-y1 + y, pFont, glyph_index, argb); | |
| 1694 x_pos += (FX_FLOAT)w / em; | |
| 1695 } | |
| 1696 return TRUE; | |
| 1697 } | |
| 1698 FX_BOOL OutputGlyph(void* dib, | |
| 1699 int x, | |
| 1700 int y, | |
| 1701 CFX_Font* pFont, | |
| 1702 double font_size, | |
| 1703 CFX_AffineMatrix* pMatrix, | |
| 1704 unsigned long glyph_index, | |
| 1705 unsigned long argb) { | |
| 1706 FXFT_Matrix ft_matrix; | |
| 1707 if (pMatrix) { | |
| 1708 ft_matrix.xx = (signed long)(pMatrix->a * font_size / 64 * 65536); | |
| 1709 ft_matrix.xy = (signed long)(pMatrix->c * font_size / 64 * 65536); | |
| 1710 ft_matrix.yx = (signed long)(pMatrix->b * font_size / 64 * 65536); | |
| 1711 ft_matrix.yy = (signed long)(pMatrix->d * font_size / 64 * 65536); | |
| 1712 } else { | |
| 1713 ft_matrix.xx = (signed long)(font_size / 64 * 65536); | |
| 1714 ft_matrix.xy = ft_matrix.yx = 0; | |
| 1715 ft_matrix.yy = (signed long)(font_size / 64 * 65536); | |
| 1716 } | |
| 1717 FXFT_Set_Transform(pFont->m_Face, &ft_matrix, 0); | |
| 1718 FX_BOOL ret = _OutputGlyph(dib, x, y, pFont, glyph_index, argb); | |
| 1719 return ret; | |
| 1720 } | |
| 1721 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, | 1620 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, |
| 1722 FX_DWORD glyph_index, | 1621 FX_DWORD glyph_index, |
| 1723 int dest_width) { | 1622 int dest_width) { |
| 1724 if (m_Face == NULL || glyph_index == (FX_DWORD)-1) { | 1623 if (m_Face == NULL || glyph_index == (FX_DWORD)-1) { |
| 1725 return NULL; | 1624 return NULL; |
| 1726 } | 1625 } |
| 1727 CFX_PathData* pGlyphPath = NULL; | 1626 CFX_PathData* pGlyphPath = NULL; |
| 1728 void* key; | 1627 void* key; |
| 1729 if (pFont->GetSubstFont()) | 1628 if (pFont->GetSubstFont()) |
| 1730 key = (void*)(uintptr_t)( | 1629 key = (void*)(uintptr_t)( |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1944 void _CFX_UniqueKeyGen::Generate(int count, ...) { | 1843 void _CFX_UniqueKeyGen::Generate(int count, ...) { |
| 1945 va_list argList; | 1844 va_list argList; |
| 1946 va_start(argList, count); | 1845 va_start(argList, count); |
| 1947 for (int i = 0; i < count; i++) { | 1846 for (int i = 0; i < count; i++) { |
| 1948 int p = va_arg(argList, int); | 1847 int p = va_arg(argList, int); |
| 1949 ((FX_DWORD*)m_Key)[i] = p; | 1848 ((FX_DWORD*)m_Key)[i] = p; |
| 1950 } | 1849 } |
| 1951 va_end(argList); | 1850 va_end(argList); |
| 1952 m_KeyLen = count * sizeof(FX_DWORD); | 1851 m_KeyLen = count * sizeof(FX_DWORD); |
| 1953 } | 1852 } |
| OLD | NEW |