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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, | 131 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, |
132 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, | 132 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, |
133 214, 215, 216, 217, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, | 133 214, 215, 216, 217, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, |
134 228, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 239, 240, | 134 228, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 239, 240, |
135 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 250, 251, 252, 253, 254, | 135 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 250, 251, 252, 253, 254, |
136 255, | 136 255, |
137 }; | 137 }; |
138 #define ADJUST_ALPHA(background, foreground, src_alpha, text_flags, a) \ | 138 #define ADJUST_ALPHA(background, foreground, src_alpha, text_flags, a) \ |
139 src_alpha = g_TextGammaAdjust[(uint8_t)src_alpha]; | 139 src_alpha = g_TextGammaAdjust[(uint8_t)src_alpha]; |
140 void _Color2Argb(FX_ARGB& argb, | 140 void _Color2Argb(FX_ARGB& argb, |
141 FX_DWORD color, | 141 uint32_t color, |
142 int alpha_flag, | 142 int alpha_flag, |
143 void* pIccTransform) { | 143 void* pIccTransform) { |
144 if (!pIccTransform && !FXGETFLAG_COLORTYPE(alpha_flag)) { | 144 if (!pIccTransform && !FXGETFLAG_COLORTYPE(alpha_flag)) { |
145 argb = color; | 145 argb = color; |
146 return; | 146 return; |
147 } | 147 } |
148 if (!CFX_GEModule::Get()->GetCodecModule() || | 148 if (!CFX_GEModule::Get()->GetCodecModule() || |
149 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { | 149 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { |
150 pIccTransform = NULL; | 150 pIccTransform = NULL; |
151 } | 151 } |
(...skipping 18 matching lines...) Expand all Loading... |
170 bgra[3] = (alpha_flag >> 24) ? FXGETFLAG_ALPHA_FILL(alpha_flag) | 170 bgra[3] = (alpha_flag >> 24) ? FXGETFLAG_ALPHA_FILL(alpha_flag) |
171 : FXGETFLAG_ALPHA_STROKE(alpha_flag); | 171 : FXGETFLAG_ALPHA_STROKE(alpha_flag); |
172 argb = FXARGB_MAKE(bgra[3], bgra[2], bgra[1], bgra[0]); | 172 argb = FXARGB_MAKE(bgra[3], bgra[2], bgra[1], bgra[0]); |
173 } | 173 } |
174 FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, | 174 FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, |
175 const FXTEXT_CHARPOS* pCharPos, | 175 const FXTEXT_CHARPOS* pCharPos, |
176 CFX_Font* pFont, | 176 CFX_Font* pFont, |
177 CFX_FontCache* pCache, | 177 CFX_FontCache* pCache, |
178 FX_FLOAT font_size, | 178 FX_FLOAT font_size, |
179 const CFX_Matrix* pText2Device, | 179 const CFX_Matrix* pText2Device, |
180 FX_DWORD fill_color, | 180 uint32_t fill_color, |
181 FX_DWORD text_flags, | 181 uint32_t text_flags, |
182 int alpha_flag, | 182 int alpha_flag, |
183 void* pIccTransform) { | 183 void* pIccTransform) { |
184 int nativetext_flags = text_flags; | 184 int nativetext_flags = text_flags; |
185 if (m_DeviceClass != FXDC_DISPLAY) { | 185 if (m_DeviceClass != FXDC_DISPLAY) { |
186 if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { | 186 if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { |
187 bool should_call_draw_device_text = true; | 187 bool should_call_draw_device_text = true; |
188 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 188 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
189 if ((text_flags & FXFONT_CIDFONT) || | 189 if ((text_flags & FXFONT_CIDFONT) || |
190 (pFont->GetPsName().Find(CFX_WideString::FromLocal("+ZJHL")) != -1) || | 190 (pFont->GetPsName().Find(CFX_WideString::FromLocal("+ZJHL")) != -1) || |
191 (pFont->GetPsName() == CFX_WideString::FromLocal("CNAAJI+cmex10"))) { | 191 (pFont->GetPsName() == CFX_WideString::FromLocal("CNAAJI+cmex10"))) { |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 return TRUE; | 1107 return TRUE; |
1108 } | 1108 } |
1109 FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars, | 1109 FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars, |
1110 const FXTEXT_CHARPOS* pCharPos, | 1110 const FXTEXT_CHARPOS* pCharPos, |
1111 CFX_Font* pFont, | 1111 CFX_Font* pFont, |
1112 CFX_FontCache* pCache, | 1112 CFX_FontCache* pCache, |
1113 FX_FLOAT font_size, | 1113 FX_FLOAT font_size, |
1114 const CFX_Matrix* pText2User, | 1114 const CFX_Matrix* pText2User, |
1115 const CFX_Matrix* pUser2Device, | 1115 const CFX_Matrix* pUser2Device, |
1116 const CFX_GraphStateData* pGraphState, | 1116 const CFX_GraphStateData* pGraphState, |
1117 FX_DWORD fill_color, | 1117 uint32_t fill_color, |
1118 FX_ARGB stroke_color, | 1118 FX_ARGB stroke_color, |
1119 CFX_PathData* pClippingPath, | 1119 CFX_PathData* pClippingPath, |
1120 int nFlag, | 1120 int nFlag, |
1121 int alpha_flag, | 1121 int alpha_flag, |
1122 void* pIccTransform, | 1122 void* pIccTransform, |
1123 int blend_type) { | 1123 int blend_type) { |
1124 if (!pCache) { | 1124 if (!pCache) { |
1125 pCache = CFX_GEModule::Get()->GetFontCache(); | 1125 pCache = CFX_GEModule::Get()->GetFontCache(); |
1126 } | 1126 } |
1127 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); | 1127 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 } | 1249 } |
1250 m_PathMap.clear(); | 1250 m_PathMap.clear(); |
1251 } | 1251 } |
1252 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1252 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
1253 void CFX_FaceCache::InitPlatform() {} | 1253 void CFX_FaceCache::InitPlatform() {} |
1254 #endif | 1254 #endif |
1255 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( | 1255 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap( |
1256 CFX_Font* pFont, | 1256 CFX_Font* pFont, |
1257 const CFX_Matrix* pMatrix, | 1257 const CFX_Matrix* pMatrix, |
1258 CFX_ByteStringC& FaceGlyphsKey, | 1258 CFX_ByteStringC& FaceGlyphsKey, |
1259 FX_DWORD glyph_index, | 1259 uint32_t glyph_index, |
1260 FX_BOOL bFontStyle, | 1260 FX_BOOL bFontStyle, |
1261 int dest_width, | 1261 int dest_width, |
1262 int anti_alias) { | 1262 int anti_alias) { |
1263 CFX_SizeGlyphCache* pSizeCache; | 1263 CFX_SizeGlyphCache* pSizeCache; |
1264 auto it = m_SizeMap.find(FaceGlyphsKey); | 1264 auto it = m_SizeMap.find(FaceGlyphsKey); |
1265 if (it == m_SizeMap.end()) { | 1265 if (it == m_SizeMap.end()) { |
1266 pSizeCache = new CFX_SizeGlyphCache; | 1266 pSizeCache = new CFX_SizeGlyphCache; |
1267 m_SizeMap[FaceGlyphsKey] = pSizeCache; | 1267 m_SizeMap[FaceGlyphsKey] = pSizeCache; |
1268 } else { | 1268 } else { |
1269 pSizeCache = it->second; | 1269 pSizeCache = it->second; |
1270 } | 1270 } |
1271 auto it2 = pSizeCache->m_GlyphMap.find(glyph_index); | 1271 auto it2 = pSizeCache->m_GlyphMap.find(glyph_index); |
1272 if (it2 != pSizeCache->m_GlyphMap.end()) | 1272 if (it2 != pSizeCache->m_GlyphMap.end()) |
1273 return it2->second; | 1273 return it2->second; |
1274 | 1274 |
1275 CFX_GlyphBitmap* pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, | 1275 CFX_GlyphBitmap* pGlyphBitmap = RenderGlyph(pFont, glyph_index, bFontStyle, |
1276 pMatrix, dest_width, anti_alias); | 1276 pMatrix, dest_width, anti_alias); |
1277 if (!pGlyphBitmap) | 1277 if (!pGlyphBitmap) |
1278 return nullptr; | 1278 return nullptr; |
1279 | 1279 |
1280 pSizeCache->m_GlyphMap[glyph_index] = pGlyphBitmap; | 1280 pSizeCache->m_GlyphMap[glyph_index] = pGlyphBitmap; |
1281 return pGlyphBitmap; | 1281 return pGlyphBitmap; |
1282 } | 1282 } |
1283 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, | 1283 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, |
1284 FX_DWORD glyph_index, | 1284 uint32_t glyph_index, |
1285 FX_BOOL bFontStyle, | 1285 FX_BOOL bFontStyle, |
1286 const CFX_Matrix* pMatrix, | 1286 const CFX_Matrix* pMatrix, |
1287 int dest_width, | 1287 int dest_width, |
1288 int anti_alias, | 1288 int anti_alias, |
1289 int& text_flags) { | 1289 int& text_flags) { |
1290 if (glyph_index == (FX_DWORD)-1) { | 1290 if (glyph_index == (uint32_t)-1) { |
1291 return NULL; | 1291 return NULL; |
1292 } | 1292 } |
1293 _CFX_UniqueKeyGen keygen; | 1293 _CFX_UniqueKeyGen keygen; |
1294 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 1294 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
1295 if (pFont->GetSubstFont()) | 1295 if (pFont->GetSubstFont()) |
1296 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), | 1296 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), |
1297 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), | 1297 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), |
1298 dest_width, anti_alias, pFont->GetSubstFont()->m_Weight, | 1298 dest_width, anti_alias, pFont->GetSubstFont()->m_Weight, |
1299 pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical()); | 1299 pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical()); |
1300 else | 1300 else |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 if (temp > 255) { | 1505 if (temp > 255) { |
1506 temp = 255; | 1506 temp = 255; |
1507 } else if (temp < 0) { | 1507 } else if (temp < 0) { |
1508 temp = 0; | 1508 temp = 0; |
1509 } | 1509 } |
1510 *pDstRow++ = (uint8_t)temp; | 1510 *pDstRow++ = (uint8_t)temp; |
1511 } | 1511 } |
1512 } | 1512 } |
1513 } | 1513 } |
1514 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, | 1514 CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, |
1515 FX_DWORD glyph_index, | 1515 uint32_t glyph_index, |
1516 FX_BOOL bFontStyle, | 1516 FX_BOOL bFontStyle, |
1517 const CFX_Matrix* pMatrix, | 1517 const CFX_Matrix* pMatrix, |
1518 int dest_width, | 1518 int dest_width, |
1519 int anti_alias) { | 1519 int anti_alias) { |
1520 if (!m_Face) { | 1520 if (!m_Face) { |
1521 return NULL; | 1521 return NULL; |
1522 } | 1522 } |
1523 FXFT_Matrix ft_matrix; | 1523 FXFT_Matrix ft_matrix; |
1524 ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); | 1524 ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); |
1525 ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536); | 1525 ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 } else { | 1640 } else { |
1641 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, | 1641 _ContrastAdjust(pSrcBuf, pDestBuf, bmwidth, bmheight, src_pitch, |
1642 dest_pitch); | 1642 dest_pitch); |
1643 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, | 1643 _GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, |
1644 CFX_GEModule::Get()->GetTextGammaTable()); | 1644 CFX_GEModule::Get()->GetTextGammaTable()); |
1645 } | 1645 } |
1646 } | 1646 } |
1647 return pGlyphBitmap; | 1647 return pGlyphBitmap; |
1648 } | 1648 } |
1649 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, | 1649 const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, |
1650 FX_DWORD glyph_index, | 1650 uint32_t glyph_index, |
1651 int dest_width) { | 1651 int dest_width) { |
1652 if (!m_Face || glyph_index == (FX_DWORD)-1) | 1652 if (!m_Face || glyph_index == (uint32_t)-1) |
1653 return nullptr; | 1653 return nullptr; |
1654 | 1654 |
1655 FX_DWORD key = glyph_index; | 1655 uint32_t key = glyph_index; |
1656 if (pFont->GetSubstFont()) { | 1656 if (pFont->GetSubstFont()) { |
1657 key += (((pFont->GetSubstFont()->m_Weight / 16) << 15) + | 1657 key += (((pFont->GetSubstFont()->m_Weight / 16) << 15) + |
1658 ((pFont->GetSubstFont()->m_ItalicAngle / 2) << 21) + | 1658 ((pFont->GetSubstFont()->m_ItalicAngle / 2) << 21) + |
1659 ((dest_width / 16) << 25) + (pFont->IsVertical() << 31)); | 1659 ((dest_width / 16) << 25) + (pFont->IsVertical() << 31)); |
1660 } | 1660 } |
1661 auto it = m_PathMap.find(key); | 1661 auto it = m_PathMap.find(key); |
1662 if (it != m_PathMap.end()) | 1662 if (it != m_PathMap.end()) |
1663 return it->second; | 1663 return it->second; |
1664 | 1664 |
1665 CFX_PathData* pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); | 1665 CFX_PathData* pGlyphPath = pFont->LoadGlyphPath(glyph_index, dest_width); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 param->m_pPoints[param->m_PointCount + 2].m_PointY = | 1785 param->m_pPoints[param->m_PointCount + 2].m_PointY = |
1786 to->y / param->m_CoordUnit; | 1786 to->y / param->m_CoordUnit; |
1787 param->m_pPoints[param->m_PointCount + 2].m_Flag = FXPT_BEZIERTO; | 1787 param->m_pPoints[param->m_PointCount + 2].m_Flag = FXPT_BEZIERTO; |
1788 param->m_CurX = to->x; | 1788 param->m_CurX = to->x; |
1789 param->m_CurY = to->y; | 1789 param->m_CurY = to->y; |
1790 } | 1790 } |
1791 param->m_PointCount += 3; | 1791 param->m_PointCount += 3; |
1792 return 0; | 1792 return 0; |
1793 } | 1793 } |
1794 }; | 1794 }; |
1795 CFX_PathData* CFX_Font::LoadGlyphPath(FX_DWORD glyph_index, int dest_width) { | 1795 CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { |
1796 if (!m_Face) { | 1796 if (!m_Face) { |
1797 return NULL; | 1797 return NULL; |
1798 } | 1798 } |
1799 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); | 1799 FXFT_Set_Pixel_Sizes(m_Face, 0, 64); |
1800 FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; | 1800 FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; |
1801 if (m_pSubstFont) { | 1801 if (m_pSubstFont) { |
1802 if (m_pSubstFont->m_ItalicAngle) { | 1802 if (m_pSubstFont->m_ItalicAngle) { |
1803 int skew = m_pSubstFont->m_ItalicAngle; | 1803 int skew = m_pSubstFont->m_ItalicAngle; |
1804 skew = skew <= -ANGLESKEW_ARRAY_SIZE ? -58 : -g_AngleSkew[-skew]; | 1804 skew = skew <= -ANGLESKEW_ARRAY_SIZE ? -58 : -g_AngleSkew[-skew]; |
1805 if (m_bVertical) { | 1805 if (m_bVertical) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 if (params.m_PointCount) { | 1861 if (params.m_PointCount) { |
1862 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; | 1862 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; |
1863 } | 1863 } |
1864 return pPath; | 1864 return pPath; |
1865 } | 1865 } |
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 ((FX_DWORD*)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(FX_DWORD); | 1874 m_KeyLen = count * sizeof(uint32_t); |
1875 } | 1875 } |
OLD | NEW |