pdfium/core/fxge/cfx_standardfont.h
Tom Sepez 61c94a7d3a Replace CFX_StandardFont::kNumStandardFonts sentinel with std::optional.
In CFX_FontMapper, replace the usage of kNumStandardFonts (cast to
Index) as a sentinel value with std::optional<Index>.

TAG=agy
CONV=83149187-887e-49ee-8743-7f5c2b102308

Change-Id: Ia47d0b14636fe11150ac7b4921c1cf9fa22ab6ab
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/150871
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2026-06-25 13:50:13 -07:00

49 lines
1.2 KiB
C++

// Copyright 2026 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CORE_FXGE_CFX_STANDARDFONT_H_
#define CORE_FXGE_CFX_STANDARDFONT_H_
#include <stdint.h>
#include <optional>
#include "core/fxcrt/bytestring.h"
#include "core/fxcrt/span.h"
class CFX_StandardFont {
public:
enum Index : uint8_t {
kCourier = 0,
kCourierBold,
kCourierBoldOblique,
kCourierOblique,
kHelvetica,
kHelveticaBold,
kHelveticaBoldOblique,
kHelveticaOblique,
kTimes,
kTimesBold,
kTimesBoldOblique,
kTimesOblique,
kSymbol,
kDingbats,
kLast = kDingbats,
};
static constexpr int kNumStandardFonts = 14;
static std::optional<Index> GetStandardFontIndex(const ByteString& name);
static ByteString GetCanonicalFontName(Index font);
static bool IsStandardFontName(const ByteString& name);
static bool IsSymbolicFont(Index font);
static bool IsFixedFont(Index font);
static pdfium::span<const uint8_t> GetFontData(Index font);
static pdfium::span<const uint8_t> GetGenericSansFontData();
static pdfium::span<const uint8_t> GetGenericSerifFontData();
};
#endif // CORE_FXGE_CFX_STANDARDFONT_H_