// Copyright (c) 2014-2021 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE // // @license: http://www.opensource.org/licenses/mit-license.php // @author: see AUTHORS file #pragma once #include #include #include #include namespace xlnt { class style; /// /// Describes the font style of a particular cell. /// class XLNT_API font { public: /// /// Text can be underlined in the enumerated ways /// enum class underline_style { none, double_, double_accounting, single, single_accounting }; /// /// Constructs a default font. Calibri, size 12 /// font(); /// /// Sets the bold state of the font to bold and returns a reference to the font. /// font &bold(bool bold); /// /// Returns the bold state of the font. /// bool bold() const; /// /// Sets the vertical alignment of the font to subscript and returns a reference to the font. /// font &subscript(bool value); /// /// Returns true if this font has a vertical alignment of subscript. /// bool subscript() const; /// /// Sets the vertical alignment of the font to superscript and returns a reference to the font. /// font &superscript(bool value); /// /// Returns true if this font has a vertical alignment of superscript. /// bool superscript() const; /// /// Sets the bold state of the font to bold and returns a reference to the font. /// font &italic(bool italic); /// /// Returns true if this font has italics applied. /// bool italic() const; /// /// Sets the bold state of the font to bold and returns a reference to the font. /// font &strikethrough(bool strikethrough); /// /// Returns true if this font has a strikethrough applied. /// bool strikethrough() const; /// /// Sets the bold state of the font to bold and returns a reference to the font. /// font &outline(bool outline); /// /// Returns true if this font has an outline applied. /// bool outline() const; /// /// Sets the shadow state of the font to shadow and returns a reference to the font. /// font &shadow(bool shadow); /// /// Returns true if this font has a shadow applied. /// bool shadow() const; /// /// Sets the underline state of the font to new_underline and returns a reference to the font. /// font &underline(underline_style new_underline); /// /// Returns true if this font has any type of underline applied. /// bool underlined() const; /// /// Returns the particular style of underline this font has applied. /// underline_style underline() const; /// /// Returns true if this font has a defined size. /// bool has_size() const; /// /// Sets the size of the font to size and returns a reference to the font. /// font &size(double size); /// /// Returns the size of the font. /// double size() const; /// /// Returns true if this font has a particular face applied (e.g. "Comic Sans"). /// bool has_name() const; /// /// Sets the font face to name and returns a reference to the font. /// font &name(const std::string &name); /// /// Returns the name of the font face. /// const std::string &name() const; /// /// Returns true if this font has a color applied. /// bool has_color() const; /// /// Sets the color of the font to c and returns a reference to the font. /// font &color(const color &c); /// /// Returns the color that this font is using. /// xlnt::color color() const; /// /// Returns true if this font has a family defined. /// bool has_family() const; /// /// Sets the family index of the font to family and returns a reference to the font. /// font &family(std::size_t family); /// /// Returns the family index for the font. /// std::size_t family() const; /// /// Returns true if this font has a charset defined. /// bool has_charset() const; // TODO: charset should be an enum, not a number /// /// Sets the charset of the font to charset and returns a reference to the font. /// font &charset(std::size_t charset); /// /// Returns the charset of the font. /// std::size_t charset() const; /// /// Returns true if this font has a scheme. /// bool has_scheme() const; /// /// Sets the scheme of the font to scheme and returns a reference to the font. /// font &scheme(const std::string &scheme); /// /// Returns the scheme of this font. /// const std::string &scheme() const; /// /// Returns true if left is exactly equal to right. /// bool operator==(const font &other) const; /// /// Returns true if left is not exactly equal to right. /// bool operator!=(const font &other) const { return !operator==(other); } private: friend class style; /// /// The name of the font /// optional name_; /// /// size /// optional size_; /// /// bold /// bool bold_ = false; /// /// italic /// bool italic_ = false; /// /// superscript /// bool superscript_ = false; /// /// subscript /// bool subscript_ = false; /// /// strikethrough /// bool strikethrough_ = false; /// /// outline /// bool outline_ = false; /// /// shadow /// bool shadow_ = false; /// /// underline style /// underline_style underline_ = underline_style::none; /// /// color /// optional color_; /// /// family /// optional family_; /// /// charset /// optional charset_; /// /// scheme /// optional scheme_; }; } // namespace xlnt