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/include/fxge/fx_freetype.h" | 7 #include "core/include/fxge/fx_freetype.h" |
8 #include "core/include/fxge/fx_ge.h" | 8 #include "core/include/fxge/fx_ge.h" |
9 #include "text_int.h" | 9 #include "text_int.h" |
10 | 10 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 return FXFT_Is_Face_Bold(m_Face) == FXFT_STYLE_FLAG_BOLD; | 219 return FXFT_Is_Face_Bold(m_Face) == FXFT_STYLE_FLAG_BOLD; |
220 } | 220 } |
221 | 221 |
222 FX_BOOL CFX_Font::IsFixedWidth() const { | 222 FX_BOOL CFX_Font::IsFixedWidth() const { |
223 if (!m_Face) | 223 if (!m_Face) |
224 return FALSE; | 224 return FALSE; |
225 return FXFT_Is_Face_fixedwidth(m_Face); | 225 return FXFT_Is_Face_fixedwidth(m_Face); |
226 } | 226 } |
227 | 227 |
228 CFX_WideString CFX_Font::GetPsName() const { | 228 CFX_WideString CFX_Font::GetPsName() const { |
229 if (m_Face == NULL) { | 229 if (!m_Face) { |
230 return CFX_WideString(); | 230 return CFX_WideString(); |
231 } | 231 } |
232 CFX_WideString psName = | 232 CFX_WideString psName = |
233 CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m_Face)); | 233 CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m_Face)); |
234 if (psName.IsEmpty()) { | 234 if (psName.IsEmpty()) { |
235 psName = CFX_WideString::FromLocal("Untitled"); | 235 psName = CFX_WideString::FromLocal("Untitled"); |
236 } | 236 } |
237 return psName; | 237 return psName; |
238 } | 238 } |
239 CFX_ByteString CFX_Font::GetFamilyName() const { | 239 CFX_ByteString CFX_Font::GetFamilyName() const { |
240 if (m_Face == NULL && m_pSubstFont == NULL) { | 240 if (!m_Face && !m_pSubstFont) { |
241 return CFX_ByteString(); | 241 return CFX_ByteString(); |
242 } | 242 } |
243 if (m_Face) { | 243 if (m_Face) { |
244 return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); | 244 return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); |
245 } | 245 } |
246 return m_pSubstFont->m_Family; | 246 return m_pSubstFont->m_Family; |
247 } | 247 } |
248 CFX_ByteString CFX_Font::GetFaceName() const { | 248 CFX_ByteString CFX_Font::GetFaceName() const { |
249 if (m_Face == NULL && m_pSubstFont == NULL) { | 249 if (!m_Face && !m_pSubstFont) { |
250 return CFX_ByteString(); | 250 return CFX_ByteString(); |
251 } | 251 } |
252 if (m_Face) { | 252 if (m_Face) { |
253 CFX_ByteString facename; | 253 CFX_ByteString facename; |
254 CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face)); | 254 CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face)); |
255 facename = GetFamilyName(); | 255 facename = GetFamilyName(); |
256 if (facename.IsEmpty()) { | 256 if (facename.IsEmpty()) { |
257 facename = "Untitled"; | 257 facename = "Untitled"; |
258 } | 258 } |
259 if (!style.IsEmpty() && style != "Regular") { | 259 if (!style.IsEmpty() && style != "Regular") { |
260 facename += " " + style; | 260 facename += " " + style; |
261 } | 261 } |
262 return facename; | 262 return facename; |
263 } | 263 } |
264 return m_pSubstFont->m_Family; | 264 return m_pSubstFont->m_Family; |
265 } | 265 } |
266 FX_BOOL CFX_Font::GetBBox(FX_RECT& bbox) { | 266 FX_BOOL CFX_Font::GetBBox(FX_RECT& bbox) { |
267 if (m_Face == NULL) { | 267 if (!m_Face) { |
268 return FALSE; | 268 return FALSE; |
269 } | 269 } |
270 int em = FXFT_Get_Face_UnitsPerEM(m_Face); | 270 int em = FXFT_Get_Face_UnitsPerEM(m_Face); |
271 if (em == 0) { | 271 if (em == 0) { |
272 bbox.left = FXFT_Get_Face_xMin(m_Face); | 272 bbox.left = FXFT_Get_Face_xMin(m_Face); |
273 bbox.bottom = FXFT_Get_Face_yMax(m_Face); | 273 bbox.bottom = FXFT_Get_Face_yMax(m_Face); |
274 bbox.top = FXFT_Get_Face_yMin(m_Face); | 274 bbox.top = FXFT_Get_Face_yMin(m_Face); |
275 bbox.right = FXFT_Get_Face_xMax(m_Face); | 275 bbox.right = FXFT_Get_Face_xMax(m_Face); |
276 } else { | 276 } else { |
277 bbox.left = FXFT_Get_Face_xMin(m_Face) * 1000 / em; | 277 bbox.left = FXFT_Get_Face_xMin(m_Face) * 1000 / em; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 330 |
331 if (m_pFont->GetSubstFont() && m_pFont->GetSubstFont()->m_Charset == 2) { | 331 if (m_pFont->GetSubstFont() && m_pFont->GetSubstFont()->m_Charset == 2) { |
332 FX_DWORD index = 0; | 332 FX_DWORD index = 0; |
333 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) | 333 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) |
334 index = FXFT_Get_Char_Index(face, charcode); | 334 index = FXFT_Get_Char_Index(face, charcode); |
335 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) | 335 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) |
336 return FXFT_Get_Char_Index(face, charcode); | 336 return FXFT_Get_Char_Index(face, charcode); |
337 } | 337 } |
338 return charcode; | 338 return charcode; |
339 } | 339 } |
OLD | NEW |