blob: f64bef492e842cb4dbf2a9e73f76bc85e14d332a [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include "flutter/fml/macros.h"
#include "impeller/typographer/text_run.h"
namespace impeller {
//------------------------------------------------------------------------------
/// @brief Represents a collection of shaped text runs.
///
/// This object is typically the entrypoint in the Impeller type
/// rendering subsystem.
///
class TextFrame {
public:
TextFrame();
~TextFrame();
//----------------------------------------------------------------------------
/// @brief The conservative bounding box for this text frame.
///
/// @return The bounds rectangle. If there are no glyphs in this text
/// frame, std::nullopt is returned.
///
std::optional<Rect> GetBounds() const;
//----------------------------------------------------------------------------
/// @brief The number of runs in this text frame.
///
/// @return The run count.
///
size_t GetRunCount() const;
//----------------------------------------------------------------------------
/// @brief Adds a new text run to the text frame.
///
/// @param[in] run The run
///
/// @return If the text run could be added to this frame.
///
bool AddTextRun(const TextRun& run);
//----------------------------------------------------------------------------
/// @brief Returns a reference to all the text runs in this frame.
///
/// @return The runs in this frame.
///
const std::vector<TextRun>& GetRuns() const;
//----------------------------------------------------------------------------
/// @brief Whether any run in this frame has color.
bool HasColor() const;
private:
std::vector<TextRun> runs_;
bool has_color_ = false;
};
} // namespace impeller