LCOV - code coverage report
Current view: top level - muse/framework/draw/internal - fontsdatabase.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 2 2
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2024 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : #pragma once
      23              : 
      24              : #include <memory>
      25              : #include <vector>
      26              : #include <map>
      27              : 
      28              : #include "ifontsdatabase.h"
      29              : 
      30              : namespace muse::draw {
      31              : class FontsDatabase : public IFontsDatabase
      32              : {
      33              : public:
      34           39 :     FontsDatabase() = default;
      35              : 
      36              :     void setDefaultFont(Font::Type type, const FontDataKey& key) override;
      37              :     void insertSubstitution(const String& f1, const String& substituteName) override;
      38              :     void removeSubstitutions(const String& f1, const std::vector<String>& substituteNames) override;
      39              : 
      40              :     int addFont(const FontDataKey& key, const io::path_t& path) override;
      41              :     int addFont(const FontDataKey& key, std::shared_ptr<io::IODevice> device) override;
      42              :     void removeFont(const FontDataKey& key) override;
      43              : 
      44              :     FontDataKey actualFont(const FontDataKey& requireKey, Font::Type type) const override;
      45              :     std::vector<FontDataKey> substitutionFonts(const FontDataKey& requireKey) const override;
      46              :     FontData fontData(const FontDataKey& requireKey, Font::Type type) const override;
      47              : 
      48              :     async::Notification changed() const override;
      49              : 
      50              : private:
      51              : 
      52              :     struct FontInfo {
      53              :         int id = -1;
      54              :         FontDataKey key;
      55              :         std::shared_ptr<io::IODevice> device;
      56              : 
      57          520 :         bool valid() const { return id > -1; }
      58              :     };
      59              : 
      60              :     const FontDataKey& defaultFont(Font::Type type) const;
      61              :     const FontInfo& fontInfo(const FontDataKey& key) const;
      62              :     void release(const FontInfo& fi);
      63              : 
      64              :     std::map<Font::Type, FontDataKey> m_defaults;
      65              :     std::map<FontDataKey, std::vector<FontDataKey> > m_familySubstitutions;
      66              :     std::map<FontDataKey, FontInfo> m_fonts;
      67              :     async::Notification m_changed;
      68              : };
      69              : }
        

Generated by: LCOV version 2.0-1