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
cfx_glyphcache.h
Go to the documentation of this file.
1// Copyright 2016 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_FXGE_CFX_GLYPHCACHE_H_
8#define CORE_FXGE_CFX_GLYPHCACHE_H_
9
10#include <map>
11#include <memory>
12#include <tuple>
13
14#include "core/fxcrt/bytestring.h"
15#include "core/fxcrt/observed_ptr.h"
16#include "core/fxcrt/retain_ptr.h"
17#include "core/fxge/cfx_face.h"
18
19#if defined(PDF_USE_SKIA)
20#include "core/fxge/fx_font.h"
21#include "third_party/skia/include/core/SkRefCnt.h" // nogncheck
22#endif
23
24class CFX_Font;
25class CFX_GlyphBitmap;
26class CFX_Matrix;
27class CFX_Path;
29
30class CFX_GlyphCache final : public Retainable, public Observable {
31 public:
33
34 const CFX_GlyphBitmap* LoadGlyphBitmap(const CFX_Font* pFont,
35 uint32_t glyph_index,
36 bool bFontStyle,
37 const CFX_Matrix& matrix,
38 int dest_width,
39 int anti_alias,
40 CFX_TextRenderOptions* text_options);
41 const CFX_Path* LoadGlyphPath(const CFX_Font* pFont,
42 uint32_t glyph_index,
43 int dest_width);
44 int GetGlyphWidth(const CFX_Font* font,
45 uint32_t glyph_index,
46 int dest_width,
47 int weight);
48
49 RetainPtr<CFX_Face> GetFace() { return m_Face; }
50
51#if defined(PDF_USE_SKIA)
52 CFX_TypeFace* GetDeviceCache(const CFX_Font* pFont);
53 static void InitializeGlobals();
54 static void DestroyGlobals();
55#endif
56
57 private:
58 explicit CFX_GlyphCache(RetainPtr<CFX_Face> face);
59 ~CFX_GlyphCache() override;
60
61 using SizeGlyphCache = std::map<uint32_t, std::unique_ptr<CFX_GlyphBitmap>>;
62 // <glyph_index, width, weight, angle, vertical>
63 using PathMapKey = std::tuple<uint32_t, int, int, int, bool>;
64 // <glyph_index, dest_width, weight>
65 using WidthMapKey = std::tuple<uint32_t, int, int>;
66
67 std::unique_ptr<CFX_GlyphBitmap> RenderGlyph(const CFX_Font* pFont,
68 uint32_t glyph_index,
69 bool bFontStyle,
70 const CFX_Matrix& matrix,
71 int dest_width,
72 int anti_alias);
73 std::unique_ptr<CFX_GlyphBitmap> RenderGlyph_Nativetext(
74 const CFX_Font* pFont,
75 uint32_t glyph_index,
76 const CFX_Matrix& matrix,
77 int dest_width,
78 int anti_alias);
79 CFX_GlyphBitmap* LookUpGlyphBitmap(const CFX_Font* pFont,
80 const CFX_Matrix& matrix,
81 const ByteString& FaceGlyphsKey,
82 uint32_t glyph_index,
83 bool bFontStyle,
84 int dest_width,
85 int anti_alias);
86 RetainPtr<CFX_Face> const m_Face;
87 std::map<ByteString, SizeGlyphCache> m_SizeMap;
88 std::map<PathMapKey, std::unique_ptr<CFX_Path>> m_PathMap;
89 std::map<WidthMapKey, int> m_WidthMap;
90#if defined(PDF_USE_SKIA)
91 sk_sp<SkTypeface> m_pTypeface;
92#endif
93};
94
95#endif // CORE_FXGE_CFX_GLYPHCACHE_H_
void Init() override
std::unique_ptr< SystemFontInfoIface > CreateDefaultSystemFontInfo() override
void * CreatePlatformFont(pdfium::span< const uint8_t > font_span) override
~CApplePlatform() override
ByteString GetPsName() const
Definition cfx_font.cpp:358
CFX_SubstFont * GetSubstFont() const
Definition cfx_font.h:82
bool IsBold() const
Definition cfx_font.cpp:343
PlatformIface * GetPlatform() const
static CFX_GEModule * Get()
const CFX_GlyphBitmap * LoadGlyphBitmap(const CFX_Font *pFont, uint32_t glyph_index, bool bFontStyle, const CFX_Matrix &matrix, int dest_width, int anti_alias, CFX_TextRenderOptions *text_options)
int GetGlyphWidth(const CFX_Font *font, uint32_t glyph_index, int dest_width, int weight)
const CFX_Path * LoadGlyphPath(const CFX_Font *pFont, uint32_t glyph_index, int dest_width)
RetainPtr< CFX_Face > GetFace()
~CFX_GlyphCache() override
void SetGraphicsTextMatrix(void *graphics, const CFX_Matrix &matrix)
void DestroyFont(void *pFont)
void DestroyGraphics(void *graphics)
void * CreateGraphics(const RetainPtr< CFX_DIBitmap > &bitmap)
bool DrawGraphicsString(void *graphics, void *font, float fontSize, pdfium::span< uint16_t > glyphIndices, pdfium::span< CGPoint > glyphPositions, FX_ARGB argb)
void * CreateFont(pdfium::span< const uint8_t > pFontData)
bool operator==(const char *ptr) const
bool DrawDeviceText(pdfium::span< const TextCharPos > pCharPos, CFX_Font *pFont, const CFX_Matrix &mtObject2Device, float font_size, uint32_t color, const CFX_TextRenderOptions &options) override
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:224