LCOV - code coverage report
Current view: top level - muse/framework/draw - fontmetrics.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 63.3 % 49 31
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) 2021 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              : #include "fontmetrics.h"
      23              : 
      24              : using namespace muse;
      25              : using namespace muse::draw;
      26              : 
      27       288432 : FontMetrics::FontMetrics(const Font& font)
      28       288432 :     : m_font(font)
      29              : {
      30       288432 : }
      31              : 
      32        68572 : double FontMetrics::lineSpacing() const
      33              : {
      34        68572 :     return fontProvider()->lineSpacing(m_font);
      35              : }
      36              : 
      37         2157 : double FontMetrics::xHeight() const
      38              : {
      39         2157 :     return fontProvider()->xHeight(m_font);
      40              : }
      41              : 
      42            0 : double FontMetrics::height() const
      43              : {
      44            0 :     return fontProvider()->height(m_font);
      45              : }
      46              : 
      47        17733 : double FontMetrics::capHeight() const
      48              : {
      49        17733 :     return fontProvider()->capHeight(m_font);
      50              : }
      51              : 
      52         4154 : double FontMetrics::ascent() const
      53              : {
      54         4154 :     return fontProvider()->ascent(m_font);
      55              : }
      56              : 
      57            0 : double FontMetrics::descent() const
      58              : {
      59            0 :     return fontProvider()->descent(m_font);
      60              : }
      61              : 
      62            0 : double FontMetrics::underlinePos() const
      63              : {
      64            0 :     return fontProvider()->underlinePos(m_font);
      65              : }
      66              : 
      67            0 : double FontMetrics::lineWidth() const
      68              : {
      69            0 :     return fontProvider()->lineWidth(m_font);
      70              : }
      71              : 
      72            0 : double FontMetrics::strikeOutPos() const
      73              : {
      74            0 :     return fontProvider()->strikeOutPos(m_font);
      75              : }
      76              : 
      77        15077 : double FontMetrics::width(const String& string) const
      78              : {
      79        15077 :     return horizontalAdvance(string);
      80              : }
      81              : 
      82            0 : double FontMetrics::width(const Char& ch) const
      83              : {
      84            0 :     return horizontalAdvance(ch);
      85              : }
      86              : 
      87       235743 : double FontMetrics::horizontalAdvance(const String& string) const
      88              : {
      89       235743 :     return fontProvider()->horizontalAdvance(m_font, string);
      90              : }
      91              : 
      92            0 : double FontMetrics::horizontalAdvance(char32_t ucs4) const
      93              : {
      94            0 :     return fontProvider()->horizontalAdvance(m_font, ucs4);
      95              : }
      96              : 
      97           51 : RectF FontMetrics::boundingRect(const String& string) const
      98              : {
      99           51 :     return fontProvider()->boundingRect(m_font, string);
     100              : }
     101              : 
     102            0 : RectF FontMetrics::boundingRect(char32_t ucs4) const
     103              : {
     104            0 :     return fontProvider()->boundingRect(m_font, ucs4);
     105              : }
     106              : 
     107       397871 : RectF FontMetrics::tightBoundingRect(const String& string) const
     108              : {
     109       397871 :     return fontProvider()->tightBoundingRect(m_font, string);
     110              : }
     111              : 
     112          288 : RectF FontMetrics::tightBoundingRect(const Char& ch) const
     113              : {
     114          288 :     return fontProvider()->tightBoundingRect(m_font, ch);
     115              : }
     116              : 
     117        11200 : bool FontMetrics::inFont(char32_t ucs4) const
     118              : {
     119        11200 :     return fontProvider()->inFont(m_font, ucs4);
     120              : }
     121              : 
     122              : // Static
     123              : 
     124        12814 : double FontMetrics::width(const Font& f, const String& string)
     125              : {
     126        12814 :     return FontMetrics(f).width(string);
     127              : }
     128              : 
     129            0 : RectF FontMetrics::boundingRect(const Font& f, const String& string)
     130              : {
     131            0 :     return FontMetrics(f).boundingRect(string);
     132              : }
     133              : 
     134        53538 : RectF FontMetrics::tightBoundingRect(const Font& f, const String& string)
     135              : {
     136        53538 :     return FontMetrics(f).tightBoundingRect(string);
     137              : }
     138              : 
     139            6 : double FontMetrics::ascent(const Font& f)
     140              : {
     141            6 :     return FontMetrics(f).ascent();
     142              : }
     143              : 
     144        17475 : double FontMetrics::capHeight(const Font& f)
     145              : {
     146        17475 :     return FontMetrics(f).capHeight();
     147              : }
        

Generated by: LCOV version 2.0-1