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_tounicodemap.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_TOUNICODEMAP_H_
8#define CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_
9
10#include <map>
11#include <set>
12#include <vector>
13
14#include "core/fxcrt/fx_string.h"
15#include "core/fxcrt/retain_ptr.h"
16#include "core/fxcrt/unowned_ptr.h"
17#include "third_party/abseil-cpp/absl/types/optional.h"
18
21class CPDF_Stream;
22
24 public:
25 explicit CPDF_ToUnicodeMap(RetainPtr<const CPDF_Stream> pStream);
27
28 WideString Lookup(uint32_t charcode) const;
29 uint32_t ReverseLookup(wchar_t unicode) const;
30
31 size_t GetUnicodeCountByCharcodeForTesting(uint32_t charcode) const;
32
33 private:
34 friend class cpdf_tounicodemap_StringToCode_Test;
35 friend class cpdf_tounicodemap_StringToWideString_Test;
36
37 static absl::optional<uint32_t> StringToCode(ByteStringView input);
38 static WideString StringToWideString(ByteStringView str);
39
40 void Load(RetainPtr<const CPDF_Stream> pStream);
41 void HandleBeginBFChar(CPDF_SimpleParser* pParser);
42 void HandleBeginBFRange(CPDF_SimpleParser* pParser);
43 uint32_t GetMultiCharIndexIndicator() const;
44 void SetCode(uint32_t srccode, WideString destcode);
45
46 // Inserts a new entry which hasn't not been inserted into `m_Multimap`
47 // before.
48 void InsertIntoMultimap(uint32_t code, uint32_t destcode);
49
50 std::map<uint32_t, std::set<uint32_t>> m_Multimap;
51 UnownedPtr<const CPDF_CID2UnicodeMap> m_pBaseMap;
52 std::vector<WideString> m_MultiCharVec;
53};
54
55#endif // CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_
FX_Charset m_Charset
bool KeyExist(const ByteString &key) const
int GetIntegerFor(const ByteString &key) const
RetainPtr< const CPDF_Stream > GetStreamFor(const ByteString &key) const
int GetIntegerFor(const ByteString &key, int default_int) const
static CPDF_FontGlobals * GetInstance()
virtual FX_RECT GetCharBBox(uint32_t charcode)=0
virtual bool IsTrueTypeFont() const
Definition cpdf_font.cpp:67
virtual const CPDF_CIDFont * AsCIDFont() const
int m_ItalicAngle
Definition cpdf_font.h:182
virtual void WillBeDestroyed()
int FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode)
void LoadFontDescriptor(const CPDF_Dictionary *pFontDesc)
virtual CPDF_CIDFont * AsCIDFont()
absl::optional< FX_Charset > GetSubstFontCharset() const
virtual bool IsType1Font() const
Definition cpdf_font.cpp:63
virtual bool IsVertWriting() const
CPDF_Font(CPDF_Document *pDocument, RetainPtr< CPDF_Dictionary > pFontDict)
Definition cpdf_font.cpp:52
~CPDF_Font() override
Definition cpdf_font.cpp:58
void LoadUnicodeMap() const
static RetainPtr< CPDF_Font > Create(CPDF_Document *pDoc, RetainPtr< CPDF_Dictionary > pFontDict, FormFactoryIface *pFactory)
virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const
virtual const CPDF_TrueTypeFont * AsTrueTypeFont() const
Definition cpdf_font.cpp:87
virtual const CPDF_Type1Font * AsType1Font() const
Definition cpdf_font.cpp:79
int m_Flags
Definition cpdf_font.h:178
virtual bool IsCIDFont() const
Definition cpdf_font.cpp:75
int m_StemV
Definition cpdf_font.h:179
virtual WideString UnicodeFromCharCode(uint32_t charcode) const
virtual const CPDF_Type3Font * AsType3Font() const
Definition cpdf_font.cpp:95
static RetainPtr< CPDF_Font > GetStockFont(CPDF_Document *pDoc, ByteStringView fontname)
static bool UseTTCharmap(const RetainPtr< CFX_Face > &face, int platform_id, int encoding_id)
virtual size_t CountChar(ByteStringView pString) const
void AppendChar(ByteString *str, uint32_t charcode) const
int GetStringWidth(ByteStringView pString)
virtual CPDF_Type1Font * AsType1Font()
Definition cpdf_font.cpp:83
virtual bool HasFontWidths() const
virtual bool IsType3Font() const
Definition cpdf_font.cpp:71
virtual CPDF_Type3Font * AsType3Font()
Definition cpdf_font.cpp:99
virtual CPDF_TrueTypeFont * AsTrueTypeFont()
Definition cpdf_font.cpp:91
FX_RECT m_FontBBox
Definition cpdf_font.h:183
int GetFontWeight() const
virtual int AppendChar(char *buf, uint32_t charcode) const
int m_Ascent
Definition cpdf_font.h:180
int m_Descent
Definition cpdf_font.h:181
virtual uint32_t GetNextChar(ByteStringView pString, size_t *pOffset) const
bool m_bToUnicodeLoaded
Definition cpdf_font.h:177
uint32_t FallbackFontFromCharcode(uint32_t charcode)
bool IsStandardFont() const
static FX_RECT GetCharBBoxForFace(const RetainPtr< CFX_Face > &face)
void CheckFontMetrics()
CFX_Font * GetFontFallback(int position)
size_t GetUnicodeCountByCharcodeForTesting(uint32_t charcode) const
uint32_t ReverseLookup(wchar_t unicode) const
CPDF_ToUnicodeMap(RetainPtr< const CPDF_Stream > pStream)
WideString Lookup(uint32_t charcode) const
bool IsBase14Font() const
bool operator==(const ByteString &other) const
bool operator==(const char *ptr) const
CharType operator[](const size_t index) const
Definition widestring.h:146
bool IsEmpty() const
Definition widestring.h:118
const char * CharNameFromPredefinedCharSet(FontEncoding encoding, uint8_t charcode)
FontEncoding
#define FXFONT_USEEXTERNATTR
Definition fx_font.h:39
#define FXFONT_NONSYMBOLIC
Definition fx_font.h:32
#define FXFONT_FW_NORMAL
Definition fx_font.h:22
#define FXFONT_ITALIC
Definition fx_font.h:33
#define FXFT_Get_Glyph_Width(face)
Definition fx_freetype.h:58
#define FXFT_Get_Glyph_Height(face)
Definition fx_freetype.h:59
#define FXFT_Get_Glyph_HoriBearingX(face)
Definition fx_freetype.h:56
#define FXFT_Get_Glyph_HoriBearingY(face)
Definition fx_freetype.h:57
FX_RECT & operator=(const FX_RECT &that)=default
int32_t bottom
int32_t right
int32_t top
int32_t left