| 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 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 CFX_PathData* pPath; | 1063 CFX_PathData* pPath; |
| 1064 while (pos) { | 1064 while (pos) { |
| 1065 m_PathMap.GetNextAssoc(pos, key1, (FX_LPVOID&)pPath); | 1065 m_PathMap.GetNextAssoc(pos, key1, (FX_LPVOID&)pPath); |
| 1066 delete pPath; | 1066 delete pPath; |
| 1067 } | 1067 } |
| 1068 if (m_pBitmap) { | 1068 if (m_pBitmap) { |
| 1069 delete m_pBitmap; | 1069 delete m_pBitmap; |
| 1070 } | 1070 } |
| 1071 m_PathMap.RemoveAll(); | 1071 m_PathMap.RemoveAll(); |
| 1072 } | 1072 } |
| 1073 #if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_)) | 1073 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1074 void CFX_FaceCache::InitPlatform() | 1074 void CFX_FaceCache::InitPlatform() |
| 1075 { | 1075 { |
| 1076 } | 1076 } |
| 1077 #endif | 1077 #endif |
| 1078 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff
ineMatrix* pMatrix, | 1078 CFX_GlyphBitmap* CFX_FaceCache::LookUpGlyphBitmap(CFX_Font* pFont, const CFX_Aff
ineMatrix* pMatrix, |
| 1079 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle
, | 1079 CFX_ByteStringC& FaceGlyphsKey, FX_DWORD glyph_index, FX_BOOL bFontStyle
, |
| 1080 int dest_width, int anti_alias) | 1080 int dest_width, int anti_alias) |
| 1081 { | 1081 { |
| 1082 CFX_SizeGlyphCache* pSizeCache = NULL; | 1082 CFX_SizeGlyphCache* pSizeCache = NULL; |
| 1083 if (!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1083 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); | 1098 pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)glyph_index, pGlyphBitma
p); |
| 1099 return pGlyphBitmap; | 1099 return pGlyphBitmap; |
| 1100 } | 1100 } |
| 1101 const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD
glyph_index, FX_BOOL bFontStyle, const CFX_AffineMatrix* pMatrix, | 1101 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) | 1102 int dest_width, int anti_alias, int& text_flags) |
| 1103 { | 1103 { |
| 1104 if (glyph_index == (FX_DWORD) - 1) { | 1104 if (glyph_index == (FX_DWORD) - 1) { |
| 1105 return NULL; | 1105 return NULL; |
| 1106 } | 1106 } |
| 1107 _CFX_UniqueKeyGen keygen; | 1107 _CFX_UniqueKeyGen keygen; |
| 1108 #if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_)) | 1108 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1109 if (pFont->GetSubstFont()) | 1109 if (pFont->GetSubstFont()) |
| 1110 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), | 1110 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, | 1111 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de
st_width, anti_alias, |
| 1112 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->
m_ItalicAngle, pFont->IsVertical()); | 1112 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->
m_ItalicAngle, pFont->IsVertical()); |
| 1113 else | 1113 else |
| 1114 keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), | 1114 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); | 1115 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), de
st_width, anti_alias); |
| 1116 #else | 1116 #else |
| 1117 if (text_flags & FXTEXT_NO_NATIVETEXT) { | 1117 if (text_flags & FXTEXT_NO_NATIVETEXT) { |
| 1118 if (pFont->GetSubstFont()) | 1118 if (pFont->GetSubstFont()) |
| 1119 keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), | 1119 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, | 1120 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, |
| 1121 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical()); | 1121 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical()); |
| 1122 else | 1122 else |
| 1123 keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), | 1123 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); | 1124 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias); |
| 1125 } else { | 1125 } else { |
| 1126 if (pFont->GetSubstFont()) | 1126 if (pFont->GetSubstFont()) |
| 1127 keygen.Generate(10, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10
000), | 1127 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, | 1128 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, |
| 1129 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical(), 3); | 1129 pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont
()->m_ItalicAngle, pFont->IsVertical(), 3); |
| 1130 else | 1130 else |
| 1131 keygen.Generate(7, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 100
00), | 1131 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); | 1132 (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000)
, dest_width, anti_alias, 3); |
| 1133 } | 1133 } |
| 1134 #endif | 1134 #endif |
| 1135 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); | 1135 CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); |
| 1136 #if ((_FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_)|| defined(_FPDFAPI_MINI_)) | 1136 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
| 1137 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontSt
yle, dest_width, anti_alias); | 1137 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontSt
yle, dest_width, anti_alias); |
| 1138 #else | 1138 #else |
| 1139 if (text_flags & FXTEXT_NO_NATIVETEXT) { | 1139 if (text_flags & FXTEXT_NO_NATIVETEXT) { |
| 1140 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFo
ntStyle, dest_width, anti_alias); | 1140 return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFo
ntStyle, dest_width, anti_alias); |
| 1141 } else { | 1141 } else { |
| 1142 CFX_GlyphBitmap* pGlyphBitmap; | 1142 CFX_GlyphBitmap* pGlyphBitmap; |
| 1143 CFX_SizeGlyphCache* pSizeCache = NULL; | 1143 CFX_SizeGlyphCache* pSizeCache = NULL; |
| 1144 if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { | 1144 if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { |
| 1145 if (pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(FX_UINTPTR)glyph_index
, (void*&)pGlyphBitmap)) { | 1145 if (pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(FX_UINTPTR)glyph_index
, (void*&)pGlyphBitmap)) { |
| 1146 return pGlyphBitmap; | 1146 return pGlyphBitmap; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 { | 1179 { |
| 1180 FX_POSITION pos = m_GlyphMap.GetStartPosition(); | 1180 FX_POSITION pos = m_GlyphMap.GetStartPosition(); |
| 1181 FX_LPVOID Key; | 1181 FX_LPVOID Key; |
| 1182 CFX_GlyphBitmap* pGlyphBitmap = NULL; | 1182 CFX_GlyphBitmap* pGlyphBitmap = NULL; |
| 1183 while(pos) { | 1183 while(pos) { |
| 1184 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); | 1184 m_GlyphMap.GetNextAssoc(pos, Key, (void*&)pGlyphBitmap); |
| 1185 delete pGlyphBitmap; | 1185 delete pGlyphBitmap; |
| 1186 } | 1186 } |
| 1187 m_GlyphMap.RemoveAll(); | 1187 m_GlyphMap.RemoveAll(); |
| 1188 } | 1188 } |
| 1189 #if defined(_FPDFAPI_MINI_) | |
| 1190 #define CONTRAST_RAMP_STEP 16 | |
| 1191 #else | |
| 1192 #define CONTRAST_RAMP_STEP 1 | 1189 #define CONTRAST_RAMP_STEP 1 |
| 1193 #endif | |
| 1194 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) | 1190 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) |
| 1195 { | 1191 { |
| 1196 FXFT_MM_Var pMasters = NULL; | 1192 FXFT_MM_Var pMasters = NULL; |
| 1197 FXFT_Get_MM_Var(m_Face, &pMasters); | 1193 FXFT_Get_MM_Var(m_Face, &pMasters); |
| 1198 if (pMasters == NULL) { | 1194 if (pMasters == NULL) { |
| 1199 return; | 1195 return; |
| 1200 } | 1196 } |
| 1201 long coords[2]; | 1197 long coords[2]; |
| 1202 if (weight == 0) { | 1198 if (weight == 0) { |
| 1203 coords[0] = FXFT_Get_MM_Axis_Def(FXFT_Get_MM_Axis(pMasters, 0)) / 65536; | 1199 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 { | 1702 { |
| 1707 va_list argList; | 1703 va_list argList; |
| 1708 va_start(argList, count); | 1704 va_start(argList, count); |
| 1709 for (int i = 0; i < count; i ++) { | 1705 for (int i = 0; i < count; i ++) { |
| 1710 int p = va_arg(argList, int); | 1706 int p = va_arg(argList, int); |
| 1711 ((FX_DWORD*)m_Key)[i] = p; | 1707 ((FX_DWORD*)m_Key)[i] = p; |
| 1712 } | 1708 } |
| 1713 va_end(argList); | 1709 va_end(argList); |
| 1714 m_KeyLen = count * sizeof(FX_DWORD); | 1710 m_KeyLen = count * sizeof(FX_DWORD); |
| 1715 } | 1711 } |
| OLD | NEW |