7#ifndef CORE_FPDFAPI_FONT_CPDF_FONT_H_
8#define CORE_FPDFAPI_FONT_CPDF_FONT_H_
16#include "build/build_config.h"
17#include "core/fpdfapi/parser/cpdf_dictionary.h"
18#include "core/fpdfapi/parser/cpdf_stream_acc.h"
19#include "core/fxcrt/fx_coordinates.h"
20#include "core/fxcrt/fx_string.h"
21#include "core/fxcrt/observed_ptr.h"
22#include "core/fxcrt/retain_ptr.h"
23#include "core/fxcrt/unowned_ptr.h"
24#include "core/fxge/cfx_font.h"
25#include "core/fxge/freetype/fx_freetype.h"
26#include "third_party/abseil-cpp/absl/types/optional.h"
31class CPDF_TrueTypeFont;
59 RetainPtr<CPDF_Dictionary> pPageResources,
70 ByteStringView fontname);
82 virtual const CPDF_CIDFont*
AsCIDFont()
const;
88 virtual uint32_t
GetNextChar(ByteStringView pString, size_t* pOffset)
const;
90 virtual int AppendChar(
char* buf, uint32_t charcode)
const;
92#if BUILDFLAG(IS_APPLE)
101 bool IsEmbedded()
const {
return IsType3Font() || m_pFontFile !=
nullptr; }
106 return m_pFontDict == pThat;
110 bool HasFace()
const {
return !!m_Font.GetFace(); }
111 void AppendChar(ByteString* str, uint32_t charcode)
const;
160 const std::vector<ByteString>& charnames,
float GetLineDashPhase() const
float GetLineWidth() const
CFX_GraphStateData::LineCap GetLineCap() const
CFX_GraphStateData::LineJoin GetLineJoin() const
const CPDF_Color * GetStrokeColor() const
const CPDF_Color * GetFillColor() const
bool GetRGB(int *R, int *G, int *B) const
bool IsColorSpaceRGB() const
const ByteString & GetName() const
const ByteString & GetPropertyName() const
ParamType GetParamType() const
int GetItalicAngle() const
virtual FX_RECT GetCharBBox(uint32_t charcode)=0
virtual bool IsTrueTypeFont() const
virtual const CPDF_CIDFont * AsCIDFont() const
UnownedPtr< CPDF_Document > const m_pDocument
virtual int GetCharWidthF(uint32_t charcode)=0
const FX_RECT & GetFontBBox() const
virtual void WillBeDestroyed()
int GetTypeDescent() const
static bool UseTTCharmapMSSymbol(const RetainPtr< CFX_Face > &face)
int FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode)
void LoadFontDescriptor(const CPDF_Dictionary *pFontDesc)
virtual CPDF_CIDFont * AsCIDFont()
RetainPtr< CPDF_Dictionary > m_pFontDict
static constexpr uint32_t kInvalidCharCode
static int TT2PDF(FT_Pos m, const RetainPtr< CFX_Face > &face)
absl::optional< FX_Charset > GetSubstFontCharset() const
virtual bool IsType1Font() const
virtual bool IsVertWriting() const
RetainPtr< CPDF_StreamAcc > m_pFontFile
CPDF_Font(CPDF_Document *pDocument, RetainPtr< CPDF_Dictionary > pFontDict)
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 int GlyphFromCharCode(uint32_t charcode, bool *pVertGlyph)=0
static bool UseTTCharmapMacRoman(const RetainPtr< CFX_Face > &face)
const CFX_Font * GetFont() const
static bool UseTTCharmapMSUnicode(const RetainPtr< CFX_Face > &face)
virtual const CPDF_TrueTypeFont * AsTrueTypeFont() const
virtual const CPDF_Type1Font * AsType1Font() const
std::unique_ptr< CPDF_ToUnicodeMap > m_pToUnicodeMap
RetainPtr< const CPDF_Dictionary > GetFontDict() const
void SetResourceName(const ByteString &name)
virtual bool IsCIDFont() const
std::vector< std::unique_ptr< CFX_Font > > m_FontFallbacks
virtual WideString UnicodeFromCharCode(uint32_t charcode) const
virtual const CPDF_Type3Font * AsType3Font() const
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)
RetainPtr< CPDF_Dictionary > GetMutableFontDict()
virtual CPDF_Type1Font * AsType1Font()
ByteString m_BaseFontName
ByteString GetBaseFontName() const
virtual bool HasFontWidths() const
virtual bool IsType3Font() const
virtual CPDF_Type3Font * AsType3Font()
bool FontDictIs(const CPDF_Dictionary *pThat) const
static const char * GetAdobeCharName(FontEncoding base_encoding, const std::vector< ByteString > &charnames, uint32_t charcode)
ByteString m_ResourceName
virtual CPDF_TrueTypeFont * AsTrueTypeFont()
const ByteString & GetResourceName() const
int GetFontWeight() const
virtual int AppendChar(char *buf, uint32_t charcode) const
uint32_t GetFontDictObjNum() const
virtual uint32_t GetNextChar(ByteStringView pString, size_t *pOffset) const
uint32_t FallbackFontFromCharcode(uint32_t charcode)
virtual bool IsUnicodeCompatible() const =0
bool IsStandardFont() const
static FX_RECT GetCharBBoxForFace(const RetainPtr< CFX_Face > &face)
CPDF_Document * GetDocument() const
int GetTypeAscent() const
CFX_Font * GetFontFallback(int position)
float GetStrokeAlpha() const
float GetFillAlpha() const
BlendMode GetBlendType() const
ByteString GetBlendMode() const
void SetImage(RetainPtr< CPDF_Image > pImage)
const CFX_Matrix & matrix() const
bool ProcessPageObjects(fxcrt::ostringstream *buf)
CPDF_PageContentGenerator(CPDF_PageObjectHolder *pObjHolder)
~CPDF_PageContentGenerator()
void UpdateStream(size_t stream_index, fxcrt::ostringstream *buf)
size_t AddStream(fxcrt::ostringstream *buf)
~CPDF_PageContentManager()
CPDF_PageContentManager(CPDF_PageObjectHolder *page_obj_holder, CPDF_Document *document)
const CPDF_ColorState & color_state() const
void SetDirty(bool value)
const CPDF_GeneralState & general_state() const
const ByteString & GetResourceName() const
const CPDF_ClipPath & clip_path() const
virtual Type GetType() const =0
CPDF_GeneralState & mutable_general_state()
const CPDF_ContentMarks * GetContentMarks() const
void SetResourceName(const ByteString &resource_name)
const CFX_GraphState & graph_state() const
bool has_winding_filltype() const
const CFX_Matrix & matrix() const
bool has_alternate_filltype() const
bool has_no_filltype() const
CPDF_SimpleFont(CPDF_Document *pDocument, RetainPtr< CPDF_Dictionary > pFontDict)
std::vector< ByteString > m_CharNames
~CPDF_SimpleFont() override
uint16_t m_GlyphIndex[kInternalTableSize]
int GlyphFromCharCode(uint32_t charcode, bool *pVertGlyph) override
static constexpr size_t kInternalTableSize
int GetCharWidthF(uint32_t charcode) override
void LoadCharMetrics(int charcode)
CPDF_FontEncoding m_Encoding
uint32_t CharCodeFromUnicode(wchar_t Unicode) const override
bool IsUnicodeCompatible() const override
void LoadCharWidths(const CPDF_Dictionary *font_desc)
FX_RECT m_CharBBox[kInternalTableSize]
FX_RECT GetCharBBox(uint32_t charcode) override
void LoadPDFEncoding(bool bEmbedded, bool bTrueType)
uint16_t m_CharWidth[kInternalTableSize]
FontEncoding m_BaseEncoding
bool HasFontWidths() const override
void LoadDifferences(const CPDF_Dictionary *encoding)
const CPDF_FontEncoding * GetEncoding() const
WideString UnicodeFromCharCode(uint32_t charcode) const override
virtual void LoadGlyphMap()=0
~CPDF_StringArchiveStream() override
CPDF_StringArchiveStream(fxcrt::ostringstream *stream)
FX_FILESIZE CurrentOffset() const override
bool WriteBlock(pdfium::span< const uint8_t > buffer) override
CFX_Matrix GetTextMatrix() const
float GetFontSize() const
TextRenderingMode GetTextRenderMode() const
bool IsTrueTypeFont() const override
void LoadGlyphMap() override
CPDF_TrueTypeFont * AsTrueTypeFont() override
const CPDF_TrueTypeFont * AsTrueTypeFont() const override
~CPDF_TrueTypeFont() override
static ByteString Format(const char *pFormat,...)
ByteString & operator=(ByteString &&that) noexcept
CharType operator[](const size_t index) const
ByteString PDF_NameEncode(const ByteString &orig)
#define CONSTRUCT_VIA_MAKE_RETAIN