Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: core/src/fxge/ge/fx_ge_text.cpp

Issue 1291213003: OutputText() is dead code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/include/fxge/fx_font.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 } 1636 }
1637 } else { 1637 } else {
1638 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, 1638 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch,
1639 dest_pitch); 1639 dest_pitch);
1640 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, 1640 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch,
1641 CFX_GEModule::Get()->GetTextGammaTable()); 1641 CFX_GEModule::Get()->GetTextGammaTable());
1642 } 1642 }
1643 } 1643 }
1644 return pGlyphBitmap; 1644 return pGlyphBitmap;
1645 } 1645 }
1646 FX_BOOL _OutputGlyph(void* dib,
1647 int x,
1648 int y,
1649 CFX_Font* pFont,
1650 int glyph_index,
1651 FX_ARGB argb) {
1652 CFX_DIBitmap* pDib = (CFX_DIBitmap*)dib;
1653 FXFT_Face face = pFont->GetFace();
1654 int error = FXFT_Load_Glyph(face, glyph_index, FXFT_LOAD_NO_BITMAP);
1655 if (error) {
1656 return FALSE;
1657 }
1658 error = FXFT_Render_Glyph(face, FXFT_RENDER_MODE_NORMAL);
1659 if (error) {
1660 return FALSE;
1661 }
1662 int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(face));
1663 int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(face));
1664 int left = FXFT_Get_Glyph_BitmapLeft(face);
1665 int top = FXFT_Get_Glyph_BitmapTop(face);
1666 const uint8_t* src_buf =
1667 (const uint8_t*)FXFT_Get_Bitmap_Buffer(FXFT_Get_Glyph_Bitmap(face));
1668 int src_pitch = FXFT_Get_Bitmap_Pitch(FXFT_Get_Glyph_Bitmap(face));
1669 CFX_DIBitmap mask;
1670 mask.Create(bmwidth, bmheight, FXDIB_8bppMask);
1671 uint8_t* dest_buf = mask.GetBuffer();
1672 int dest_pitch = mask.GetPitch();
1673 for (int row = 0; row < bmheight; row++) {
1674 const uint8_t* src_scan = src_buf + row * src_pitch;
1675 uint8_t* dest_scan = dest_buf + row * dest_pitch;
1676 FXSYS_memcpy(dest_scan, src_scan, dest_pitch);
1677 }
1678 pDib->CompositeMask(x + left, y - top, bmwidth, bmheight, &mask, argb, 0, 0);
1679 return TRUE;
1680 }
1681 FX_BOOL OutputText(void* dib,
1682 int x,
1683 int y,
1684 CFX_Font* pFont,
1685 double font_size,
1686 CFX_AffineMatrix* pText_matrix,
1687 unsigned short const* text,
1688 unsigned long argb) {
1689 if (!pFont) {
1690 return FALSE;
1691 }
1692 FXFT_Face face = pFont->GetFace();
1693 FXFT_Select_Charmap(pFont->m_Face, FXFT_ENCODING_UNICODE);
1694 if (pText_matrix) {
1695 FXFT_Matrix ft_matrix;
1696 ft_matrix.xx = (signed long)(pText_matrix->a / 64 * 65536);
1697 ft_matrix.xy = (signed long)(pText_matrix->c / 64 * 65536);
1698 ft_matrix.yx = (signed long)(pText_matrix->b / 64 * 65536);
1699 ft_matrix.yy = (signed long)(pText_matrix->d / 64 * 65536);
1700 FXFT_Set_Transform(face, &ft_matrix, 0);
1701 }
1702 FX_FLOAT x_pos = 0;
1703 for (; *text != 0; text++) {
1704 FX_WCHAR unicode = *text;
1705 int glyph_index = FXFT_Get_Char_Index(pFont->m_Face, unicode);
1706 if (glyph_index <= 0) {
1707 continue;
1708 }
1709 int err = FXFT_Load_Glyph(
1710 pFont->m_Face, glyph_index,
1711 FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH);
1712 if (err) {
1713 continue;
1714 }
1715 int w = FXFT_Get_Glyph_HoriAdvance(pFont->m_Face);
1716 int em = FXFT_Get_Face_UnitsPerEM(pFont->m_Face);
1717 FX_FLOAT x1, y1;
1718 pText_matrix->Transform(x_pos, 0, x1, y1);
1719 _OutputGlyph(dib, (int)x1 + x, (int)-y1 + y, pFont, glyph_index, argb);
1720 x_pos += (FX_FLOAT)w / em;
1721 }
1722 if (pText_matrix)
1723 ResetTransform(face);
1724 return TRUE;
1725 }
1726 FX_BOOL OutputGlyph(void* dib,
1727 int x,
1728 int y,
1729 CFX_Font* pFont,
1730 double font_size,
1731 CFX_AffineMatrix* pMatrix,
1732 unsigned long glyph_index,
1733 unsigned long argb) {
1734 FXFT_Matrix ft_matrix;
1735 if (pMatrix) {
1736 ft_matrix.xx = (signed long)(pMatrix->a * font_size / 64 * 65536);
1737 ft_matrix.xy = (signed long)(pMatrix->c * font_size / 64 * 65536);
1738 ft_matrix.yx = (signed long)(pMatrix->b * font_size / 64 * 65536);
1739 ft_matrix.yy = (signed long)(pMatrix->d * font_size / 64 * 65536);
1740 } else {
1741 ft_matrix.xx = (signed long)(font_size / 64 * 65536);
1742 ft_matrix.xy = ft_matrix.yx = 0;
1743 ft_matrix.yy = (signed long)(font_size / 64 * 65536);
1744 }
1745 ScopedFontTransform scoped_transform(pFont->m_Face, &ft_matrix);
1746 FX_BOOL ret = _OutputGlyph(dib, x, y, pFont, glyph_index, argb);
1747 return ret;
1748 }
1749 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, 1646 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont,
1750 FX_DWORD glyph_index, 1647 FX_DWORD glyph_index,
1751 int dest_width) { 1648 int dest_width) {
1752 if (m_Face == NULL || glyph_index == (FX_DWORD)-1) { 1649 if (m_Face == NULL || glyph_index == (FX_DWORD)-1) {
1753 return NULL; 1650 return NULL;
1754 } 1651 }
1755 CFX_PathData* pGlyphPath = NULL; 1652 CFX_PathData* pGlyphPath = NULL;
1756 void* key; 1653 void* key;
1757 if (pFont->GetSubstFont()) 1654 if (pFont->GetSubstFont())
1758 key = (void*)(uintptr_t)( 1655 key = (void*)(uintptr_t)(
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 void _CFX_UniqueKeyGen::Generate(int count, ...) { 1866 void _CFX_UniqueKeyGen::Generate(int count, ...) {
1970 va_list argList; 1867 va_list argList;
1971 va_start(argList, count); 1868 va_start(argList, count);
1972 for (int i = 0; i < count; i++) { 1869 for (int i = 0; i < count; i++) {
1973 int p = va_arg(argList, int); 1870 int p = va_arg(argList, int);
1974 ((FX_DWORD*)m_Key)[i] = p; 1871 ((FX_DWORD*)m_Key)[i] = p;
1975 } 1872 }
1976 va_end(argList); 1873 va_end(argList);
1977 m_KeyLen = count * sizeof(FX_DWORD); 1874 m_KeyLen = count * sizeof(FX_DWORD);
1978 } 1875 }
OLDNEW
« no previous file with comments | « core/include/fxge/fx_font.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698