LCOV - code coverage report
Current view: top level - tests - font.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 20 100.0 %
Date: 2022-01-29 21:33:29 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2021  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/ftmesh
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License along
      17             : // with this program; if not, write to the Free Software Foundation, Inc.,
      18             : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             : 
      20             : // self
      21             : //
      22             : #include    "main.h"
      23             : 
      24             : 
      25             : // ftmesh lib
      26             : //
      27             : #include    <ftmesh/font.h>
      28             : 
      29             : 
      30             : // snapdev lib
      31             : //
      32             : #include    <snapdev/not_reached.h>
      33             : 
      34             : 
      35             : // C lib
      36             : //
      37             : #include    <unistd.h>
      38             : 
      39             : 
      40             : // we're testing many of those here so ignore warnings
      41             : //
      42             : #pragma GCC diagnostic ignored "-Wfloat-equal"
      43             : 
      44             : 
      45           3 : CATCH_TEST_CASE("font", "[font]")
      46             : {
      47           2 :     CATCH_START_SECTION("Make sure font works")
      48             :     {
      49           2 :         ftmesh::font f("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf");
      50           1 :         f.set_size(78, 72, 72);
      51             : 
      52           2 :         ftmesh::mesh_string::pointer_t s(f.convert_string("FtMesh ij"));
      53          10 :         for(auto c : *s)
      54             :         {
      55          18 :             ftmesh::mesh::pointer_t m(c->get_mesh());
      56           9 :             ftmesh::point::vector_t const & p(m->get_points());
      57           9 :             ftmesh::mesh::index_vector_t const & i(m->get_indexes());
      58             : //std::cerr << "Mesh advance = " << c->get_advance() << " (" << i.size() << " indexes)\n";
      59          17 :             for(std::size_t j(0); j < i.size(); ++j)
      60             :             {
      61           8 :                 std::size_t const start(i[j]);
      62           8 :                 std::size_t const end(j + 1 >= i.size() ? p.size() : i[j + 1]);
      63           8 :                 std::size_t const size(end - start);
      64             : 
      65             : //std::cerr << "  " << size << " points: [" << start << ".." << end << "]\n ";
      66             : 
      67        1040 :                 for(std::size_t k(0); k < size; ++k)
      68             :                 {
      69        1032 : std::cerr << " (" << p[start + k].x() << ", " << p[start + k].y() << ")";
      70             :                 }
      71           8 : std::cerr << "\n";
      72             :             }
      73           9 :             int advance(c->get_advance());
      74           9 : std::cerr << "advance by " << advance << " to next glyph\n";
      75           9 :             CATCH_REQUIRE(advance > 0);
      76             :         }
      77             :     }
      78             :     CATCH_END_SECTION()
      79           7 : }
      80             : 
      81             : 
      82             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13