| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | |
| 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" | |
| 11 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | |
| 12 #include "core/fpdfdoc/cpvt_provider.h" | |
| 13 #include "core/fpdfdoc/doc_utils.h" | |
| 14 #include "core/fpdfdoc/pdf_vt.h" | |
| 15 #include "core/include/fpdfdoc/fpdf_doc.h" | |
| 16 #include "core/include/fpdfdoc/fpdf_vt.h" | |
| 17 | |
| 18 CPVT_Provider::CPVT_Provider(IPVT_FontMap* pFontMap) : m_pFontMap(pFontMap) { | |
| 19 ASSERT(m_pFontMap); | |
| 20 } | |
| 21 CPVT_Provider::~CPVT_Provider() {} | |
| 22 int32_t CPVT_Provider::GetCharWidth(int32_t nFontIndex, | |
| 23 uint16_t word, | |
| 24 int32_t nWordStyle) { | |
| 25 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | |
| 26 uint32_t charcode = pPDFFont->CharCodeFromUnicode(word); | |
| 27 if (charcode != CPDF_Font::kInvalidCharCode) { | |
| 28 return pPDFFont->GetCharWidthF(charcode); | |
| 29 } | |
| 30 } | |
| 31 return 0; | |
| 32 } | |
| 33 int32_t CPVT_Provider::GetTypeAscent(int32_t nFontIndex) { | |
| 34 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | |
| 35 return pPDFFont->GetTypeAscent(); | |
| 36 } | |
| 37 return 0; | |
| 38 } | |
| 39 int32_t CPVT_Provider::GetTypeDescent(int32_t nFontIndex) { | |
| 40 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { | |
| 41 return pPDFFont->GetTypeDescent(); | |
| 42 } | |
| 43 return 0; | |
| 44 } | |
| 45 int32_t CPVT_Provider::GetWordFontIndex(uint16_t word, | |
| 46 int32_t charset, | |
| 47 int32_t nFontIndex) { | |
| 48 if (CPDF_Font* pDefFont = m_pFontMap->GetPDFFont(0)) { | |
| 49 if (pDefFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) { | |
| 50 return 0; | |
| 51 } | |
| 52 } | |
| 53 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) { | |
| 54 if (pSysFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) { | |
| 55 return 1; | |
| 56 } | |
| 57 } | |
| 58 return -1; | |
| 59 } | |
| 60 FX_BOOL CPVT_Provider::IsLatinWord(uint16_t word) { | |
| 61 if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || | |
| 62 word == 0x2D || word == 0x27) { | |
| 63 return TRUE; | |
| 64 } | |
| 65 return FALSE; | |
| 66 } | |
| 67 int32_t CPVT_Provider::GetDefaultFontIndex() { | |
| 68 return 0; | |
| 69 } | |
| 70 | |
| OLD | NEW |