chromium/third_party/pdfium/core/fxge/cfx_face.cpp

// Copyright 2019 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "core/fxge/cfx_face.h"

#include <algorithm>
#include <array>
#include <limits>
#include <memory>
#include <utility>
#include <vector>

#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/notreached.h"
#include "core/fxcrt/numerics/clamped_math.h"
#include "core/fxcrt/numerics/safe_conversions.h"
#include "core/fxcrt/numerics/safe_math.h"
#include "core/fxcrt/span.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxge/cfx_font.h"
#include "core/fxge/cfx_fontmgr.h"
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_glyphbitmap.h"
#include "core/fxge/cfx_path.h"
#include "core/fxge/cfx_substfont.h"
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/dib/fx_dib.h"
#include "core/fxge/fx_font.h"
#include "core/fxge/fx_fontencoding.h"
#include "core/fxge/scoped_font_transform.h"

#define EM_ADJUST(em, a)

namespace {

struct OUTLINE_PARAMS {};

constexpr int kThousandthMinInt =;
constexpr int kThousandthMaxInt =;

constexpr int kMaxGlyphDimension =;

// Boundary value to avoid integer overflow when adding 1/64th of the value.
constexpr int kMaxRectTop =;

constexpr auto kWeightPow =;

constexpr auto kWeightPow11 =;

constexpr auto kWeightPowShiftJis =;

constexpr size_t kWeightPowArraySize =;
static_assert;
static_assert;
static_assert;

constexpr auto kAngleSkew =;

// Returns negative values on failure.
int GetWeightLevel(FX_Charset charset, size_t index) {}

int GetSkewFromAngle(int angle) {}

int FTPosToCBoxInt(FT_Pos pos) {}

void Outline_CheckEmptyContour(OUTLINE_PARAMS* param) {}

int Outline_MoveTo(const FT_Vector* to, void* user) {}

int Outline_LineTo(const FT_Vector* to, void* user) {}

int Outline_ConicTo(const FT_Vector* control, const FT_Vector* to, void* user) {}

int Outline_CubicTo(const FT_Vector* control1,
                    const FT_Vector* control2,
                    const FT_Vector* to,
                    void* user) {}

FT_Encoding ToFTEncoding(fxge::FontEncoding encoding) {}

fxge::FontEncoding ToFontEncoding(uint32_t ft_encoding) {}

}  // namespace

// static
RetainPtr<CFX_Face> CFX_Face::New(FT_Library library,
                                  RetainPtr<Retainable> pDesc,
                                  pdfium::span<const FT_Byte> data,
                                  FT_Long face_index) {}

// static
RetainPtr<CFX_Face> CFX_Face::Open(FT_Library library,
                                   const FT_Open_Args* args,
                                   FT_Long face_index) {}

bool CFX_Face::HasGlyphNames() const {}

bool CFX_Face::IsTtOt() const {}

bool CFX_Face::IsTricky() const {}

bool CFX_Face::IsFixedWidth() const {}

#if defined(PDF_ENABLE_XFA)
bool CFX_Face::IsScalable() const {}

void CFX_Face::ClearExternalStream() {}
#endif

bool CFX_Face::IsItalic() const {}

bool CFX_Face::IsBold() const {}

ByteString CFX_Face::GetFamilyName() const {}

ByteString CFX_Face::GetStyleName() const {}

FX_RECT CFX_Face::GetBBox() const {}

uint16_t CFX_Face::GetUnitsPerEm() const {}

int16_t CFX_Face::GetAscender() const {}

int16_t CFX_Face::GetDescender() const {}

#if BUILDFLAG(IS_ANDROID)
int16_t CFX_Face::GetHeight() const {
  return pdfium::checked_cast<int16_t>(GetRec()->height);
}
#endif

pdfium::span<uint8_t> CFX_Face::GetData() const {}

size_t CFX_Face::GetSfntTable(uint32_t table, pdfium::span<uint8_t> buffer) {}

std::optional<std::array<uint32_t, 4>> CFX_Face::GetOs2UnicodeRange() {}

std::optional<std::array<uint32_t, 2>> CFX_Face::GetOs2CodePageRange() {}

std::optional<std::array<uint8_t, 2>> CFX_Face::GetOs2Panose() {}

int CFX_Face::GetGlyphCount() const {}

std::unique_ptr<CFX_GlyphBitmap> CFX_Face::RenderGlyph(const CFX_Font* pFont,
                                                       uint32_t glyph_index,
                                                       bool bFontStyle,
                                                       const CFX_Matrix& matrix,
                                                       int dest_width,
                                                       int anti_alias) {}

std::unique_ptr<CFX_Path> CFX_Face::LoadGlyphPath(
    uint32_t glyph_index,
    int dest_width,
    bool is_vertical,
    const CFX_SubstFont* subst_font) {}

int CFX_Face::GetGlyphWidth(uint32_t glyph_index,
                            int dest_width,
                            int weight,
                            const CFX_SubstFont* subst_font) {}

ByteString CFX_Face::GetGlyphName(uint32_t glyph_index) {}

int CFX_Face::GetCharIndex(uint32_t code) {}

int CFX_Face::GetNameIndex(const char* name) {}

FX_RECT CFX_Face::GetCharBBox(uint32_t code, int glyph_index) {}

FX_RECT CFX_Face::GetGlyphBBox() const {}

std::vector<CFX_Face::CharCodeAndIndex> CFX_Face::GetCharCodesAndIndices(
    char32_t max_char) {}

CFX_Face::CharMap CFX_Face::GetCurrentCharMap() const {}

std::optional<fxge::FontEncoding> CFX_Face::GetCurrentCharMapEncoding() const {}

int CFX_Face::GetCharMapPlatformIdByIndex(size_t index) const {}

int CFX_Face::GetCharMapEncodingIdByIndex(size_t index) const {}

fxge::FontEncoding CFX_Face::GetCharMapEncodingByIndex(size_t index) const {}

size_t CFX_Face::GetCharMapCount() const {}

void CFX_Face::SetCharMap(CharMap map) {}

void CFX_Face::SetCharMapByIndex(size_t index) {}

bool CFX_Face::SelectCharMap(fxge::FontEncoding encoding) {}

bool CFX_Face::SetPixelSize(uint32_t width, uint32_t height) {}

#if BUILDFLAG(IS_WIN)
bool CFX_Face::CanEmbed() {
  FT_UShort fstype = FT_Get_FSType_Flags(GetRec());
  return (fstype & (FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING |
                    FT_FSTYPE_BITMAP_EMBEDDING_ONLY)) == 0;
}
#endif

CFX_Face::CFX_Face(FXFT_FaceRec* rec, RetainPtr<Retainable> pDesc)
    :{}

CFX_Face::~CFX_Face() = default;

void CFX_Face::AdjustVariationParams(int glyph_index,
                                     int dest_width,
                                     int weight) {}