1 // Copyright 2016 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 #ifndef CORE_FPDFAPI_FONT_CPDF_TYPE3CHAR_H_
8 #define CORE_FPDFAPI_FONT_CPDF_TYPE3CHAR_H_
9 
10 #include <memory>
11 #include <utility>
12 
13 #include "core/fpdfapi/font/cpdf_font.h"
14 #include "core/fxcrt/fx_coordinates.h"
15 #include "core/fxcrt/fx_system.h"
16 #include "core/fxcrt/retain_ptr.h"
17 #include "third_party/base/optional.h"
18 
19 class CFX_DIBitmap;
20 
21 class CPDF_Type3Char {
22  public:
23   CPDF_Type3Char();
24   ~CPDF_Type3Char();
25 
26   static float TextUnitToGlyphUnit(float fTextUnit);
27   static void TextUnitRectToGlyphUnitRect(CFX_FloatRect* pRect);
28 
29   bool LoadBitmapFromSoleImageOfForm();
30   void InitializeFromStreamData(bool bColored, const float* pData);
31   void Transform(CPDF_Font::FormIface* pForm, const CFX_Matrix& matrix);
32   void WillBeDestroyed();
33 
34   RetainPtr<CFX_DIBitmap> GetBitmap();
35   const RetainPtr<CFX_DIBitmap>& GetBitmap() const;
36 
colored()37   bool colored() const { return m_bColored; }
width()38   int width() const { return m_Width; }
matrix()39   const CFX_Matrix& matrix() const { return m_ImageMatrix; }
bbox()40   const FX_RECT& bbox() const { return m_BBox; }
41 
form()42   const CPDF_Font::FormIface* form() const { return m_pForm.get(); }
43   void SetForm(std::unique_ptr<CPDF_Font::FormIface> pForm);
44 
45  private:
46   std::unique_ptr<CPDF_Font::FormIface> m_pForm;
47   RetainPtr<CFX_DIBitmap> m_pBitmap;
48   bool m_bColored = false;
49   int m_Width = 0;
50   CFX_Matrix m_ImageMatrix;
51   FX_RECT m_BBox;
52 };
53 
54 #endif  // CORE_FPDFAPI_FONT_CPDF_TYPE3CHAR_H_
55