<commit_before>// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_SRC_FGAS_INCLUDE_FX_FNT_H_
#define XFA_SRC_FGAS_INCLUDE_FX_FNT_H_

#include "core/include/fxge/fx_font.h"
#include "xfa/src/fgas/include/fx_stm.h"

#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#include "xfa/src/fgas/include/fx_mem.h"
#include "xfa/src/fgas/include/fx_utl.h"
#endif  // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_

class IFX_Font;
class IFX_FontMgr;

#define FX_FONTSTYLE_Normal 0x00
#define FX_FONTSTYLE_FixedPitch 0x01
#define FX_FONTSTYLE_Serif 0x02
#define FX_FONTSTYLE_Symbolic 0x04
#define FX_FONTSTYLE_Script 0x08
#define FX_FONTSTYLE_Italic 0x40
#define FX_FONTSTYLE_Bold 0x40000
#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic)
#define FX_FONTSTYLE_ExactMatch 0x80000000
#define FX_FONTDECORATION_Underline 0x00000001
#define FX_FONTDECORATION_Strikeout 0x00000002
#define FX_FONTDECORATION_Overline 0x00000004
#define FX_FONTDECORATION_Emphasis 0x00000008
#define FX_FONTDECORATION_Superscript 0x00000010
#define FX_FONTDECORATION_Subscript 0x00000020
#define FX_FONTDECORATION_SmallCapital 0x00000040
#define FX_FONTDECORATION_Capital 0x00000080
#define FX_FONTDECORATION_Lowercase 0x000000C0
#define FX_FONTDECORATION_Raised 0x00000100
#define FX_FONTDECORATION_Sunken 0x00000200
#define FX_FONTDECORATION_Shadow 0x00000400
#define FX_FONTDECORATION_BoundingShape 0x20000000
#define FX_FONTDECORATION_Hide 0x40000000
#define FX_FONTDECORATION_StrokeFill 0x80000000
#define FX_BOUNDINGSHAPE_None 0
#define FX_BOUNDINGSHAPE_Circle 1
#define FX_BOUNDINGSHAPE_Square 2
#define FX_BOUNDINGSHAPE_Triangle 3
#define FX_BOUNDINGSHAPE_Diamond 4

class IFX_FontProvider {
 public:
  virtual ~IFX_FontProvider() {}
  virtual FX_BOOL GetCharWidth(IFX_Font* pFont,
                               FX_WCHAR wUnicode,
                               int32_t& iWidth,
                               FX_BOOL bCharCode = FALSE) = 0;
};

class IFX_Font {
 public:
  static IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
                            FX_DWORD dwFontStyles,
                            FX_WORD wCodePage,
                            IFX_FontMgr* pFontMgr);
  static IFX_Font* LoadFont(const uint8_t* pBuffer,
                            int32_t iLength,
                            IFX_FontMgr* pFontMgr);
  static IFX_Font* LoadFont(const FX_WCHAR* pszFileName, IFX_FontMgr* pFontMgr);
  static IFX_Font* LoadFont(IFX_Stream* pFontStream,
                            IFX_FontMgr* pFontMgr,
                            FX_BOOL bSaveStream = FALSE);
  static IFX_Font* LoadFont(CFX_Font* pExtFont,
                            IFX_FontMgr* pFontMgr,
                            FX_BOOL bTakeOver = FALSE);
  virtual ~IFX_Font() {}
  virtual void Release() = 0;
  virtual IFX_Font* Retain() = 0;
  virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0) = 0;
  virtual void GetFamilyName(CFX_WideString& wsFamily) const = 0;
  virtual void GetPsName(CFX_WideString& wsName) const = 0;
  virtual FX_DWORD GetFontStyles() const = 0;
  virtual uint8_t GetCharSet() const = 0;
  virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
                               int32_t& iWidth,
                               FX_BOOL bCharCode = FALSE) = 0;
  virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode,
                                FX_BOOL bCharCode = FALSE) = 0;
  virtual int32_t GetAscent() const = 0;
  virtual int32_t GetDescent() const = 0;
  virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
                              CFX_Rect& bbox,
                              FX_BOOL bCharCode = FALSE) = 0;
  virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0;
  virtual int32_t GetItalicAngle() const = 0;
  virtual void Reset() = 0;
  virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const = 0;
  virtual void* GetDevFont() const = 0;
  virtual void SetFontProvider(IFX_FontProvider* pProvider) = 0;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
  virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) = 0;
#endif
};
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
struct FX_FONTMATCHPARAMS {
  const FX_WCHAR* pwsFamily;
  FX_DWORD dwFontStyles;
  FX_DWORD dwUSB;
  FX_DWORD dwMatchFlags;
  FX_WCHAR wUnicode;
  FX_WORD wCodePage;
} FX_FONTMATCHPARAMS;
typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS;
typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS;

struct FX_FONTSIGNATURE {
  FX_DWORD fsUsb[4];
  FX_DWORD fsCsb[2];
};
inline bool operator==(const FX_FONTSIGNATURE& left,
                       const FX_FONTSIGNATURE& right) {
  return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] &&
         left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] &&<commit_msg>Fix build breakage at 69af2a34f211<commit_after>// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_SRC_FGAS_INCLUDE_FX_FNT_H_
#define XFA_SRC_FGAS_INCLUDE_FX_FNT_H_

#include "core/include/fxge/fx_font.h"
#include "xfa/src/fgas/include/fx_stm.h"

#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
#include "xfa/src/fgas/include/fx_mem.h"
#include "xfa/src/fgas/include/fx_utl.h"
#endif  // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_

class IFX_Font;
class IFX_FontMgr;

#define FX_FONTSTYLE_Normal 0x00
#define FX_FONTSTYLE_FixedPitch 0x01
#define FX_FONTSTYLE_Serif 0x02
#define FX_FONTSTYLE_Symbolic 0x04
#define FX_FONTSTYLE_Script 0x08
#define FX_FONTSTYLE_Italic 0x40
#define FX_FONTSTYLE_Bold 0x40000
#define FX_FONTSTYLE_BoldItalic (FX_FONTSTYLE_Bold | FX_FONTSTYLE_Italic)
#define FX_FONTSTYLE_ExactMatch 0x80000000
#define FX_FONTDECORATION_Underline 0x00000001
#define FX_FONTDECORATION_Strikeout 0x00000002
#define FX_FONTDECORATION_Overline 0x00000004
#define FX_FONTDECORATION_Emphasis 0x00000008
#define FX_FONTDECORATION_Superscript 0x00000010
#define FX_FONTDECORATION_Subscript 0x00000020
#define FX_FONTDECORATION_SmallCapital 0x00000040
#define FX_FONTDECORATION_Capital 0x00000080
#define FX_FONTDECORATION_Lowercase 0x000000C0
#define FX_FONTDECORATION_Raised 0x00000100
#define FX_FONTDECORATION_Sunken 0x00000200
#define FX_FONTDECORATION_Shadow 0x00000400
#define FX_FONTDECORATION_BoundingShape 0x20000000
#define FX_FONTDECORATION_Hide 0x40000000
#define FX_FONTDECORATION_StrokeFill 0x80000000
#define FX_BOUNDINGSHAPE_None 0
#define FX_BOUNDINGSHAPE_Circle 1
#define FX_BOUNDINGSHAPE_Square 2
#define FX_BOUNDINGSHAPE_Triangle 3
#define FX_BOUNDINGSHAPE_Diamond 4

class IFX_FontProvider {
 public:
  virtual ~IFX_FontProvider() {}
  virtual FX_BOOL GetCharWidth(IFX_Font* pFont,
                               FX_WCHAR wUnicode,
                               int32_t& iWidth,
                               FX_BOOL bCharCode = FALSE) = 0;
};

class IFX_Font {
 public:
  static IFX_Font* LoadFont(const FX_WCHAR* pszFontFamily,
                            FX_DWORD dwFontStyles,
                            FX_WORD wCodePage,
                            IFX_FontMgr* pFontMgr);
  static IFX_Font* LoadFont(const uint8_t* pBuffer,
                            int32_t iLength,
                            IFX_FontMgr* pFontMgr);
  static IFX_Font* LoadFont(const FX_WCHAR* pszFileName, IFX_FontMgr* pFontMgr);
  static IFX_Font* LoadFont(IFX_Stream* pFontStream,
                            IFX_FontMgr* pFontMgr,
                            FX_BOOL bSaveStream = FALSE);
  static IFX_Font* LoadFont(CFX_Font* pExtFont,
                            IFX_FontMgr* pFontMgr,
                            FX_BOOL bTakeOver = FALSE);
  virtual ~IFX_Font() {}
  virtual void Release() = 0;
  virtual IFX_Font* Retain() = 0;
  virtual IFX_Font* Derive(FX_DWORD dwFontStyles, FX_WORD wCodePage = 0) = 0;
  virtual void GetFamilyName(CFX_WideString& wsFamily) const = 0;
  virtual void GetPsName(CFX_WideString& wsName) const = 0;
  virtual FX_DWORD GetFontStyles() const = 0;
  virtual uint8_t GetCharSet() const = 0;
  virtual FX_BOOL GetCharWidth(FX_WCHAR wUnicode,
                               int32_t& iWidth,
                               FX_BOOL bCharCode = FALSE) = 0;
  virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode,
                                FX_BOOL bCharCode = FALSE) = 0;
  virtual int32_t GetAscent() const = 0;
  virtual int32_t GetDescent() const = 0;
  virtual FX_BOOL GetCharBBox(FX_WCHAR wUnicode,
                              CFX_Rect& bbox,
                              FX_BOOL bCharCode = FALSE) = 0;
  virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0;
  virtual int32_t GetItalicAngle() const = 0;
  virtual void Reset() = 0;
  virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const = 0;
  virtual void* GetDevFont() const = 0;
  virtual void SetFontProvider(IFX_FontProvider* pProvider) = 0;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
  virtual void SetLogicalFontStyle(FX_DWORD dwLogFontStyle) = 0;
#endif
};
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
struct FX_FONTMATCHPARAMS {
  const FX_WCHAR* pwsFamily;
  FX_DWORD dwFontStyles;
  FX_DWORD dwUSB;
  FX_DWORD dwMatchFlags;
  FX_WCHAR wUnicode;
  FX_WORD wCodePage;
};
typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS;
typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS;

struct FX_FONTSIGNATURE {
  FX_DWORD fsUsb[4];
  FX_DWORD fsCsb[2];
};
inline bool operator==(const FX_FONTSIGNATURE& left,
                       const FX_FONTSIGNATURE& right) {
  return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] &&
         left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] &&
{'fraction_non_alphanumeric': 0.06913379422529484, 'fraction_numerical': 0.04737698251321675, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 16, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5191255', 'n_tokens_mistral': 4113, 'n_tokens_neox': 3566, 'n_words': 755}