Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_cmap.h
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
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_CMAP_H_
8#define CORE_FPDFAPI_FONT_CPDF_CMAP_H_
9
10#include <stdint.h>
11
12#include <array>
13#include <vector>
14
15#include "core/fpdfapi/font/cpdf_cidfont.h"
16#include "core/fxcrt/fixed_size_data_vector.h"
17#include "core/fxcrt/retain_ptr.h"
18#include "core/fxcrt/span.h"
19#include "core/fxcrt/unowned_ptr.h"
20
21namespace fxcmap {
22struct CMap;
23}
24
35
36class CPDF_CMap final : public Retainable {
37 public:
38 static constexpr size_t kDirectMapTableSize = 65536;
39
46
47 struct CodeRange {
49 std::array<uint8_t, 4> m_Lower;
50 std::array<uint8_t, 4> m_Upper;
51 };
52
53 struct CIDRange {
54 uint32_t m_StartCode;
55 uint32_t m_EndCode;
56 uint16_t m_StartCID;
57 };
58
60
61 bool IsLoaded() const { return m_bLoaded; }
62 bool IsVertWriting() const { return m_bVertical; }
63
64 uint16_t CIDFromCharCode(uint32_t charcode) const;
65
66 int GetCharSize(uint32_t charcode) const;
67 uint32_t GetNextChar(ByteStringView pString, size_t* pOffset) const;
68 size_t CountChar(ByteStringView pString) const;
69 void AppendChar(ByteString* str, uint32_t charcode) const;
70
71 void SetVertical(bool vert) { m_bVertical = vert; }
72 void SetCodingScheme(CodingScheme scheme) { m_CodingScheme = scheme; }
73 void SetAdditionalMappings(std::vector<CIDRange> mappings);
74 void SetMixedFourByteLeadingRanges(std::vector<CodeRange> ranges);
75
76 CIDCoding GetCoding() const { return m_Coding; }
77 const fxcmap::CMap* GetEmbedMap() const { return m_pEmbedMap; }
78 CIDSet GetCharset() const { return m_Charset; }
79 void SetCharset(CIDSet set) { m_Charset = set; }
80
81 void SetDirectCharcodeToCIDTableRange(uint32_t start_code,
82 uint32_t end_code,
83 uint16_t start_cid);
85 return m_DirectCharcodeToCIDTable.empty();
86 }
87
88 private:
89 explicit CPDF_CMap(ByteStringView bsPredefinedName);
90 explicit CPDF_CMap(pdfium::span<const uint8_t> spEmbeddedData);
91 ~CPDF_CMap() override;
92
93 bool m_bLoaded = false;
94 bool m_bVertical = false;
95 CIDSet m_Charset = CIDSET_UNKNOWN;
96 CodingScheme m_CodingScheme = TwoBytes;
98 std::vector<bool> m_MixedTwoByteLeadingBytes;
99 std::vector<CodeRange> m_MixedFourByteLeadingRanges;
100 FixedSizeDataVector<uint16_t> m_DirectCharcodeToCIDTable;
101 std::vector<CIDRange> m_AdditionalCharcodeToCIDMappings;
102 UnownedPtr<const fxcmap::CMap> m_pEmbedMap;
103};
104
105#endif // CORE_FPDFAPI_FONT_CPDF_CMAP_H_
fxcrt::ByteString ByteString
Definition bytestring.h:180
#define DCHECK
Definition check.h:33
#define DCHECK_EQ(x, y)
Definition check_op.h:17
CFX_FloatRect(const FX_RECT &rect)
FX_RECT GetOuterRect() const
static constexpr uint32_t MakeTag(char c1, char c2, char c3, char c4)
CFX_FloatRect TransformRect(const CFX_FloatRect &rect) const
constexpr CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition cpdf_array.h:29
~CPDF_CIDFont() override
size_t CountChar(ByteStringView pString) const override
uint32_t GetNextChar(ByteStringView pString, size_t *pOffset) const override
bool IsCIDFont() const override
bool IsUnicodeCompatible() const override
CFX_Point16 GetVertOrigin(uint16_t cid) const
int GetCharWidthF(uint32_t charcode) override
const CPDF_CIDFont * AsCIDFont() const override
uint16_t CIDFromCharCode(uint32_t charcode) const
bool Load() override
const CIDTransform * GetCIDTransform(uint16_t cid) const
int GlyphFromCharCode(uint32_t charcode, bool *pVertGlyph) override
int16_t GetVertWidth(uint16_t cid) const
FX_RECT GetCharBBox(uint32_t charcode) override
static float CIDTransformToFloat(uint8_t ch)
void AppendChar(ByteString *str, uint32_t charcode) const override
bool IsVertWriting() const override
uint32_t CharCodeFromUnicode(wchar_t Unicode) const override
int GetCharSize(uint32_t charcode) const
WideString UnicodeFromCharCode(uint32_t charcode) const override
CPDF_CIDFont * AsCIDFont() override
static CIDSet CharsetFromOrdering(ByteStringView ordering)
bool IsVertWriting() const
Definition cpdf_cmap.h:62
void SetVertical(bool vert)
Definition cpdf_cmap.h:71
~CPDF_CMap() override
static constexpr size_t kDirectMapTableSize
Definition cpdf_cmap.h:38
CIDCoding GetCoding() const
Definition cpdf_cmap.h:76
size_t CountChar(ByteStringView pString) const
uint32_t GetNextChar(ByteStringView pString, size_t *pOffset) const
void SetCharset(CIDSet set)
Definition cpdf_cmap.h:79
bool IsLoaded() const
Definition cpdf_cmap.h:61
@ MixedTwoBytes
Definition cpdf_cmap.h:43
@ MixedFourBytes
Definition cpdf_cmap.h:44
const fxcmap::CMap * GetEmbedMap() const
Definition cpdf_cmap.h:77
uint16_t CIDFromCharCode(uint32_t charcode) const
void SetAdditionalMappings(std::vector< CIDRange > mappings)
int GetCharSize(uint32_t charcode) const
bool IsDirectCharcodeToCIDTableIsEmpty() const
Definition cpdf_cmap.h:84
void AppendChar(ByteString *str, uint32_t charcode) const
void SetMixedFourByteLeadingRanges(std::vector< CodeRange > ranges)
CIDSet GetCharset() const
Definition cpdf_cmap.h:78
void SetDirectCharcodeToCIDTableRange(uint32_t start_code, uint32_t end_code, uint16_t start_cid)
void SetCodingScheme(CodingScheme scheme)
Definition cpdf_cmap.h:72
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
static CPDF_FontGlobals * GetInstance()
void LoadFontDescriptor(const CPDF_Dictionary *pFontDesc)
virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const
static bool UseTTCharmapMacRoman(const RetainPtr< CFX_Face > &face)
Definition cpdf_font.h:147
static bool UseTTCharmapMSUnicode(const RetainPtr< CFX_Face > &face)
Definition cpdf_font.h:141
virtual WideString UnicodeFromCharCode(uint32_t charcode) const
void CheckFontMetrics()
bool IsEmbedded() const
Definition cpdf_font.h:100
bool operator==(const char *ptr) const
WideString(wchar_t ch)
WideString()=default
CIDSet
@ CIDSET_JAPAN1
@ CIDSET_UNKNOWN
@ CIDSET_GB1
@ CIDSET_NUM_SETS
CIDCoding
Definition cpdf_cmap.h:25
uint32_t CharCodeFromUnicodeForEncoding(fxge::FontEncoding encoding, wchar_t unicode)
FontEncoding
FX_CodePage
Definition fx_codepage.h:19
@ kChineseTraditional
Definition fx_codepage.h:42
CFX_PTemplate< int16_t > CFX_Point16
wchar_t UnicodeFromAdobeName(const char *name)
Definition fx_font.cpp:140
#define FXFONT_FW_NORMAL
Definition fx_font.h:24
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
constexpr wchar_t kBoxDrawingsLightVerical
Definition fx_unicode.h:102
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:222
fxcrt::ByteStringView ByteStringView
uint16_t cid
uint16_t m_StartCID
Definition cpdf_cmap.h:56
uint32_t m_StartCode
Definition cpdf_cmap.h:54
std::array< uint8_t, 4 > m_Upper
Definition cpdf_cmap.h:50
std::array< uint8_t, 4 > m_Lower
Definition cpdf_cmap.h:49
FX_RECT & operator=(const FX_RECT &that)=default
fxcrt::WideString WideString
Definition widestring.h:207