blob: b6ce472fca5ad8d43a2cc314805d60b70b439b20 [file] [log] [blame]
Dan Sinclair80c48782017-03-23 12:11:20 -04001// Copyright 2017 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
Dan Sinclairdb0312e2017-09-21 09:46:03 -04007#ifndef XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_
8#define XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_
Dan Sinclair80c48782017-03-23 12:11:20 -04009
10#include <map>
11
Dan Sinclair80c48782017-03-23 12:11:20 -040012#include "core/fpdfapi/parser/cpdf_document.h"
Dan Sinclair80c48782017-03-23 12:11:20 -040013#include "core/fxcrt/fx_string.h"
Dan Sinclair65ecca42017-09-21 15:25:32 -040014#include "core/fxcrt/observable.h"
Dan Sinclair0b950422017-09-21 15:49:49 -040015#include "core/fxcrt/retain_ptr.h"
Dan Sinclair80c48782017-03-23 12:11:20 -040016
Dan Sinclairdb0312e2017-09-21 09:46:03 -040017class CFGAS_FontMgr;
Tom Sepezd15ce4c2017-05-19 17:08:52 -070018class CFGAS_GEFont;
Dan Sinclairdb0312e2017-09-21 09:46:03 -040019class CPDF_Document;
Dan Sinclair80c48782017-03-23 12:11:20 -040020
Tom Sepez55865452018-08-27 20:18:04 +000021class CFGAS_PDFFontMgr final : public Observable<CFGAS_PDFFontMgr> {
Dan Sinclair80c48782017-03-23 12:11:20 -040022 public:
Dan Sinclairdb0312e2017-09-21 09:46:03 -040023 explicit CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr);
24 ~CFGAS_PDFFontMgr();
Dan Sinclair80c48782017-03-23 12:11:20 -040025
Dan Sinclair0b950422017-09-21 15:49:49 -040026 RetainPtr<CFGAS_GEFont> GetFont(const WideStringView& wsFontFamily,
27 uint32_t dwFontStyles,
Dan Sinclair0b950422017-09-21 15:49:49 -040028 bool bStrictMatch);
Dan Sinclair80c48782017-03-23 12:11:20 -040029
30 private:
Dan Sinclair0b950422017-09-21 15:49:49 -040031 RetainPtr<CFGAS_GEFont> FindFont(const ByteString& strFamilyName,
32 bool bBold,
33 bool bItalic,
Dan Sinclair0b950422017-09-21 15:49:49 -040034 bool bStrictMatch);
Ryan Harrison275e2602017-09-18 14:23:18 -040035 ByteString PsNameToFontName(const ByteString& strPsName,
36 bool bBold,
37 bool bItalic);
38 bool PsNameMatchDRFontName(const ByteStringView& bsPsName,
Dan Sinclair80c48782017-03-23 12:11:20 -040039 bool bBold,
40 bool bItalic,
Ryan Harrison275e2602017-09-18 14:23:18 -040041 const ByteString& bsDRFontName,
Dan Sinclair80c48782017-03-23 12:11:20 -040042 bool bStrictMatch);
43
Dan Sinclairaee0db02017-09-21 16:53:58 -040044 UnownedPtr<CPDF_Document> const m_pDoc;
45 UnownedPtr<CFGAS_FontMgr> const m_pFontMgr;
Dan Sinclair0b950422017-09-21 15:49:49 -040046 std::map<ByteString, RetainPtr<CFGAS_GEFont>> m_FontMap;
Dan Sinclair80c48782017-03-23 12:11:20 -040047};
48
Dan Sinclairdb0312e2017-09-21 09:46:03 -040049#endif // XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_