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/include/fx_font.h" | 7 #include "core/fxge/include/fx_font.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
10 #include "core/fxge/ge/fx_text_int.h" | 10 #include "core/fxge/ge/fx_text_int.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 (FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)) * | 439 (FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face)) * |
440 1000 / em; | 440 1000 / em; |
441 bbox.right = | 441 bbox.right = |
442 (FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)) * | 442 (FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face)) * |
443 1000 / em; | 443 1000 / em; |
444 bbox.bottom = (FXFT_Get_Glyph_HoriBearingY(m_Face)) * 1000 / em; | 444 bbox.bottom = (FXFT_Get_Glyph_HoriBearingY(m_Face)) * 1000 / em; |
445 } | 445 } |
446 return TRUE; | 446 return TRUE; |
447 } | 447 } |
448 | 448 |
449 FX_BOOL CFX_Font::IsItalic() const { | 449 bool CFX_Font::IsItalic() const { |
450 if (!m_Face) | 450 if (!m_Face) |
451 return FALSE; | 451 return false; |
452 | 452 |
453 FX_BOOL ret = FXFT_Is_Face_Italic(m_Face) == FXFT_STYLE_FLAG_ITALIC; | 453 if (FXFT_Is_Face_Italic(m_Face) == FXFT_STYLE_FLAG_ITALIC) |
454 if (!ret) { | 454 return true; |
455 CFX_ByteString str(FXFT_Get_Face_Style_Name(m_Face)); | 455 CFX_ByteString str(FXFT_Get_Face_Style_Name(m_Face)); |
456 str.MakeLower(); | 456 str.MakeLower(); |
457 if (str.Find("italic") != -1) | 457 return str.Find("italic") != -1; |
458 ret = TRUE; | |
459 } | |
460 return ret; | |
461 } | 458 } |
462 | 459 |
463 FX_BOOL CFX_Font::IsBold() const { | 460 bool CFX_Font::IsBold() const { |
464 if (!m_Face) | 461 if (!m_Face) |
465 return FALSE; | 462 return false; |
466 return FXFT_Is_Face_Bold(m_Face) == FXFT_STYLE_FLAG_BOLD; | 463 return FXFT_Is_Face_Bold(m_Face) == FXFT_STYLE_FLAG_BOLD; |
467 } | 464 } |
468 | 465 |
469 FX_BOOL CFX_Font::IsFixedWidth() const { | 466 bool CFX_Font::IsFixedWidth() const { |
470 if (!m_Face) | 467 if (!m_Face) |
471 return FALSE; | 468 return false; |
472 return FXFT_Is_Face_fixedwidth(m_Face); | 469 return FXFT_Is_Face_fixedwidth(m_Face) != 0; |
473 } | 470 } |
474 | 471 |
475 CFX_ByteString CFX_Font::GetPsName() const { | 472 CFX_ByteString CFX_Font::GetPsName() const { |
476 if (!m_Face) | 473 if (!m_Face) |
477 return CFX_ByteString(); | 474 return CFX_ByteString(); |
478 | 475 |
479 CFX_ByteString psName = FXFT_Get_Postscript_Name(m_Face); | 476 CFX_ByteString psName = FXFT_Get_Postscript_Name(m_Face); |
480 if (psName.IsEmpty()) | 477 if (psName.IsEmpty()) |
481 psName = "Untitled"; | 478 psName = "Untitled"; |
482 return psName; | 479 return psName; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 params.m_pPoints = pPath->GetPoints(); | 655 params.m_pPoints = pPath->GetPoints(); |
659 params.m_CurX = params.m_CurY = 0; | 656 params.m_CurX = params.m_CurY = 0; |
660 params.m_CoordUnit = 64 * 64.0; | 657 params.m_CoordUnit = 64 * 64.0; |
661 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); | 658 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); |
662 Outline_CheckEmptyContour(¶ms); | 659 Outline_CheckEmptyContour(¶ms); |
663 pPath->TrimPoints(params.m_PointCount); | 660 pPath->TrimPoints(params.m_PointCount); |
664 if (params.m_PointCount) | 661 if (params.m_PointCount) |
665 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; | 662 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; |
666 return pPath; | 663 return pPath; |
667 } | 664 } |
OLD | NEW |