| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 CFX_Font* pFont, CFX_FontCache* pCache, | 128 CFX_Font* pFont, CFX_FontCache* pCache, |
| 129 FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device, | 129 FX_FLOAT font_size, const CFX_AffineMatrix* pText2Device, |
| 130 FX_DWORD fill_color, FX_DWORD text_flags, | 130 FX_DWORD fill_color, FX_DWORD text_flags, |
| 131 int alpha_flag, void* pIccTransform) | 131 int alpha_flag, void* pIccTransform) |
| 132 { | 132 { |
| 133 int nativetext_flags = text_flags; | 133 int nativetext_flags = text_flags; |
| 134 if (m_DeviceClass != FXDC_DISPLAY) { | 134 if (m_DeviceClass != FXDC_DISPLAY) { |
| 135 if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { | 135 if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { |
| 136 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 136 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 137 if (!(text_flags & FXFONT_CIDFONT) && pFont->GetPsName().Find(CFX_Wi
deString::FromLocal("+ZJHL")) == -1) | 137 if (!(text_flags & FXFONT_CIDFONT) && pFont->GetPsName().Find(CFX_Wi
deString::FromLocal("+ZJHL")) == -1) |
| 138 #ifdef FOXIT_CHROME_BUILD | |
| 139 if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex
10")) | 138 if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex
10")) |
| 140 #endif | 139 #endif |
| 141 #endif | |
| 142 if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont,
pCache, pText2Device, font_size, fill_color, alpha_flag, pIccTransform)) { | 140 if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont,
pCache, pText2Device, font_size, fill_color, alpha_flag, pIccTransform)) { |
| 143 return TRUE; | 141 return TRUE; |
| 144 } | 142 } |
| 145 } | 143 } |
| 146 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha
_flag) : FXARGB_A(fill_color); | 144 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha
_flag) : FXARGB_A(fill_color); |
| 147 if (alpha < 255) { | 145 if (alpha < 255) { |
| 148 return FALSE; | 146 return FALSE; |
| 149 } | 147 } |
| 150 } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) { | 148 } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) { |
| 151 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 149 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 152 if (!(text_flags & FXFONT_CIDFONT)) | 150 if (!(text_flags & FXFONT_CIDFONT)) |
| 153 #ifdef FOXIT_CHROME_BUILD | |
| 154 if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex10")
) | 151 if (pFont->GetPsName() != CFX_WideString::FromLocal("CNAAJI+cmex10")
) |
| 155 #endif | 152 #endif |
| 156 #endif | |
| 157 if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCa
che, pText2Device, font_size, fill_color, alpha_flag, pIccTransform)) { | 153 if (m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pCa
che, pText2Device, font_size, fill_color, alpha_flag, pIccTransform)) { |
| 158 return TRUE; | 154 return TRUE; |
| 159 } | 155 } |
| 160 } | 156 } |
| 161 CFX_AffineMatrix char2device, deviceCtm, text2Device; | 157 CFX_AffineMatrix char2device, deviceCtm, text2Device; |
| 162 if (pText2Device) { | 158 if (pText2Device) { |
| 163 char2device = *pText2Device; | 159 char2device = *pText2Device; |
| 164 text2Device = *pText2Device; | 160 text2Device = *pText2Device; |
| 165 } | 161 } |
| 166 char2device.Scale(font_size, -font_size); | 162 char2device.Scale(font_size, -font_size); |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 CFX_PathData* pPath; | 1059 CFX_PathData* pPath; |
| 1064 while (pos) { | 1060 while (pos) { |
| 1065 m_PathMap.GetNextAssoc(pos, key1, (FX_LPVOID&)pPath); | 1061 m_PathMap.GetNextAssoc(pos, key1, (FX_LPVOID&)pPath); |
| 1066 delete pPath; | 1062 delete pPath; |
| 1067 } | 1063 } |
| 1068 if (m_pBitmap) { | 1064 if (m_pBitmap) { |
| 1069 delete m_pBitmap; | 1065 delete m_pBitmap; |
| 1070 } | 1066 } |
| 1071 m_PathMap.RemoveAll(); | 1067 m_PathMap.RemoveAll(); |
| 1072 } | 1068 } |
| 1073 #if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_)) | 1069 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1074 void CFX_FaceCache::InitPlatform() | 1070 void CFX_FaceCache::InitPlatform() |
| 1075 { | 1071 { |
| 1076 } | 1072 } |
| 1077 #endif | 1073 #endif |
| 1078 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff
ineMatrix* pMatrix, | 1074 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff
ineMatrix* pMatrix, |
| 1079 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle
, | 1075 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle
, |
| 1080 int dest_width, int anti_alias) | 1076 int dest_width, int anti_alias) |
| 1081 { | 1077 { |
| 1082 CFX_SizeGlyphCache* pSizeCache = NULL; | 1078 CFX_SizeGlyphCache* pSizeCache = NULL; |
| 1083 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1079 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1098 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)glyph_index, pGlyphBitma
p); | 1094 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)glyph_index, pGlyphBitma
p); |
| 1099 return pGlyphBitmap; | 1095 return pGlyphBitmap; |
| 1100 } | 1096 } |
| 1101 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, | 1097 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, |
| 1102 int dest_width, int anti_alias, int& text_flags) | 1098 int dest_width, int anti_alias, int& text_flags) |
| 1103 { | 1099 { |
| 1104 if (glyph_index == (FX_DWORD) - 1) { | 1100 if (glyph_index == (FX_DWORD) - 1) { |
| 1105 return NULL; | 1101 return NULL; |
| 1106 } | 1102 } |
| 1107 _CFX_UniqueKeyGen keygen; | 1103 _CFX_UniqueKeyGen keygen; |
| 1108 #if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_)) | 1104 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1109 if (pFont->GetSubstFont()) | 1105 if (pFont->GetSubstFont()) |
| 1110 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), | 1106 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), |
| 1111 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de
st_width, anti_alias, | 1107 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de
st_width, anti_alias, |
| 1112 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->
m_ItalicAngle, pFont->IsVertical()); | 1108 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->
m_ItalicAngle, pFont->IsVertical()); |
| 1113 else | 1109 else |
| 1114 keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), | 1110 keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), |
| 1115 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de
st_width, anti_alias); | 1111 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de
st_width, anti_alias); |
| 1116 #else | 1112 #else |
| 1117 if (text_flags & FXTEXT_NO_NATIVETEXT) { | 1113 if (text_flags & FXTEXT_NO_NATIVETEXT) { |
| 1118 if (pFont->GetSubstFont()) | 1114 if (pFont->GetSubstFont()) |
| 1119 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), | 1115 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), |
| 1120 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, | 1116 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, |
| 1121 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical()); | 1117 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical()); |
| 1122 else | 1118 else |
| 1123 keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), | 1119 keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), |
| 1124 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias); | 1120 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias); |
| 1125 } else { | 1121 } else { |
| 1126 if (pFont->GetSubstFont()) | 1122 if (pFont->GetSubstFont()) |
| 1127 keygen.Generate(10, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10
000), | 1123 keygen.Generate(10, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10
000), |
| 1128 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, | 1124 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, |
| 1129 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical(), 3); | 1125 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical(), 3); |
| 1130 else | 1126 else |
| 1131 keygen.Generate(7, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), | 1127 keygen.Generate(7, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), |
| 1132 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, 3); | 1128 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, 3); |
| 1133 } | 1129 } |
| 1134 #endif | 1130 #endif |
| 1135 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); | 1131 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); |
| 1136 #if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_)) | 1132 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1137 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontSt
yle, dest_width, anti_alias); | 1133 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontSt
yle, dest_width, anti_alias); |
| 1138 #else | 1134 #else |
| 1139 if (text_flags & FXTEXT_NO_NATIVETEXT) { | 1135 if (text_flags & FXTEXT_NO_NATIVETEXT) { |
| 1140 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFo
ntStyle, dest_width, anti_alias); | 1136 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFo
ntStyle, dest_width, anti_alias); |
| 1141 } else { | 1137 } else { |
| 1142 CFX_GlyphBitmap* pGlyphBitmap; | 1138 CFX_GlyphBitmap* pGlyphBitmap; |
| 1143 CFX_SizeGlyphCache* pSizeCache = NULL; | 1139 CFX_SizeGlyphCache* pSizeCache = NULL; |
| 1144 if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1140 if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { |
| 1145 if (pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(FX_UINTPTR)glyph_index
, (void*&)pGlyphBitmap)) { | 1141 if (pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(FX_UINTPTR)glyph_index
, (void*&)pGlyphBitmap)) { |
| 1146 return pGlyphBitmap; | 1142 return pGlyphBitmap; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 { | 1175 { |
| 1180 FX_POSITION pos = m_GlyphMap.GetStartPosition(); | 1176 FX_POSITION pos = m_GlyphMap.GetStartPosition(); |
| 1181 FX_LPVOID Key; | 1177 FX_LPVOID Key; |
| 1182 CFX_GlyphBitmap* pGlyphBitmap = NULL; | 1178 CFX_GlyphBitmap* pGlyphBitmap = NULL; |
| 1183 while(pos) { | 1179 while(pos) { |
| 1184 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); | 1180 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); |
| 1185 delete pGlyphBitmap; | 1181 delete pGlyphBitmap; |
| 1186 } | 1182 } |
| 1187 m_GlyphMap.RemoveAll(); | 1183 m_GlyphMap.RemoveAll(); |
| 1188 } | 1184 } |
| 1189 #if defined(_FPDFAPI_MINI_) | |
| 1190 #define CONTRAST_RAMP_STEP 16 | |
| 1191 #else | |
| 1192 #define CONTRAST_RAMP_STEP 1 | 1185 #define CONTRAST_RAMP_STEP 1 |
| 1193 #endif | |
| 1194 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) | 1186 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) |
| 1195 { | 1187 { |
| 1196 FXFT_MM_Var pMasters = NULL; | 1188 FXFT_MM_Var pMasters = NULL; |
| 1197 FXFT_Get_MM_Var(m_Face, &pMasters); | 1189 FXFT_Get_MM_Var(m_Face, &pMasters); |
| 1198 if (pMasters == NULL) { | 1190 if (pMasters == NULL) { |
| 1199 return; | 1191 return; |
| 1200 } | 1192 } |
| 1201 long coords[2]; | 1193 long coords[2]; |
| 1202 if (weight == 0) { | 1194 if (weight == 0) { |
| 1203 coords[0] = FXFT_Get_MM_Axis_Def(FXFT_Get_MM_Axis(pMasters, 0)) / 65536; | 1195 coords[0] = FXFT_Get_MM_Axis_Def(FXFT_Get_MM_Axis(pMasters, 0)) / 65536; |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 { | 1698 { |
| 1707 va_list argList; | 1699 va_list argList; |
| 1708 va_start(argList, count); | 1700 va_start(argList, count); |
| 1709 for (int i = 0; i < count; i ++) { | 1701 for (int i = 0; i < count; i ++) { |
| 1710 int p = va_arg(argList, int); | 1702 int p = va_arg(argList, int); |
| 1711 ((FX_DWORD*)m_Key)[i] = p; | 1703 ((FX_DWORD*)m_Key)[i] = p; |
| 1712 } | 1704 } |
| 1713 va_end(argList); | 1705 va_end(argList); |
| 1714 m_KeyLen = count * sizeof(FX_DWORD); | 1706 m_KeyLen = count * sizeof(FX_DWORD); |
| 1715 } | 1707 } |
| OLD | NEW |