LCOV - code coverage report
Current view: top level - gfx/graphite2/src - gr_features.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 50 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*  GRAPHITE2 LICENSING
       2             : 
       3             :     Copyright 2010, SIL International
       4             :     All rights reserved.
       5             : 
       6             :     This library is free software; you can redistribute it and/or modify
       7             :     it under the terms of the GNU Lesser General Public License as published
       8             :     by the Free Software Foundation; either version 2.1 of 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 GNU
      14             :     Lesser General Public License for more details.
      15             : 
      16             :     You should also have received a copy of the GNU Lesser General Public
      17             :     License along with this library in the file named "LICENSE".
      18             :     If not, write to the Free Software Foundation, 51 Franklin Street, 
      19             :     Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 
      20             :     internet at http://www.fsf.org/licenses/lgpl.html.
      21             : 
      22             : Alternatively, the contents of this file may be used under the terms of the
      23             : Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
      24             : License, as published by the Free Software Foundation, either version 2
      25             : of the License or (at your option) any later version.
      26             : */
      27             : #include "graphite2/Font.h"
      28             : #include "inc/Face.h"
      29             : #include "inc/FeatureMap.h"
      30             : #include "inc/FeatureVal.h"
      31             : #include "inc/NameTable.h"
      32             : 
      33             : using namespace graphite2;
      34             : 
      35             : extern "C" {
      36             : 
      37             : 
      38           0 : gr_uint16 gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats)    //returns 0 if either pointer is NULL
      39             : {
      40           0 :     if (!pfeatureref || !feats) return 0;
      41             : 
      42           0 :     return pfeatureref->getFeatureVal(*feats);
      43             : }
      44             : 
      45             : 
      46           0 : int gr_fref_set_feature_value(const gr_feature_ref* pfeatureref, gr_uint16 val, gr_feature_val* pDest)
      47             : {
      48           0 :     if (!pfeatureref || !pDest) return 0;
      49             :     
      50           0 :     return pfeatureref->applyValToFeature(val, *pDest);
      51             : }
      52             : 
      53             : 
      54           0 : gr_uint32 gr_fref_id(const gr_feature_ref* pfeatureref)    //returns 0 if pointer is NULL
      55             : {
      56           0 :   if (!pfeatureref)
      57           0 :     return 0;
      58             :   
      59           0 :   return pfeatureref->getId();
      60             : }
      61             : 
      62             : 
      63           0 : gr_uint16 gr_fref_n_values(const gr_feature_ref* pfeatureref)
      64             : {
      65           0 :     if(!pfeatureref)
      66           0 :         return 0;
      67           0 :     return pfeatureref->getNumSettings();
      68             : }
      69             : 
      70             : 
      71           0 : gr_int16 gr_fref_value(const gr_feature_ref* pfeatureref, gr_uint16 settingno)
      72             : {
      73           0 :     if(!pfeatureref || (settingno >= pfeatureref->getNumSettings()))
      74             :     {
      75           0 :         return 0;
      76             :     }
      77           0 :     return pfeatureref->getSettingValue(settingno);
      78             : }
      79             : 
      80             : 
      81           0 : void* gr_fref_label(const gr_feature_ref* pfeatureref, gr_uint16 *langId, gr_encform utf, gr_uint32 *length)
      82             : {
      83           0 :     if(!pfeatureref || !pfeatureref->getFace())
      84             :     {
      85           0 :         langId = 0;
      86           0 :         length = 0;
      87           0 :         return NULL;
      88             :     }
      89           0 :     uint16 label = pfeatureref->getNameId();
      90           0 :     NameTable * names = pfeatureref->getFace()->nameTable();
      91           0 :     if (!names)
      92             :     {
      93           0 :         langId = 0;
      94           0 :         length = 0;
      95           0 :         return NULL;
      96             :     }
      97           0 :     return names->getName(*langId, label, utf, *length);
      98             : }
      99             : 
     100             : 
     101           0 : void* gr_fref_value_label(const gr_feature_ref*pfeatureref, gr_uint16 setting,
     102             :     gr_uint16 *langId, gr_encform utf, gr_uint32 *length)
     103             : {
     104           0 :     if(!pfeatureref || (setting >= pfeatureref->getNumSettings()) || !pfeatureref->getFace())
     105             :     {
     106           0 :         langId = 0;
     107           0 :         length = 0;
     108           0 :         return NULL;
     109             :     }
     110           0 :     uint16 label = pfeatureref->getSettingName(setting);
     111           0 :     NameTable * names = pfeatureref->getFace()->nameTable();
     112           0 :     if (!names)
     113             :     {
     114           0 :         langId = 0;
     115           0 :         length = 0;
     116           0 :         return NULL;
     117             :     }
     118           0 :     return names->getName(*langId, label, utf, *length);
     119             : }
     120             : 
     121             : 
     122           0 : void gr_label_destroy(void * label)
     123             : {
     124           0 :     free(label);
     125           0 : }
     126             : 
     127           0 : gr_feature_val* gr_featureval_clone(const gr_feature_val* pfeatures/*may be NULL*/)
     128             : {                      //When finished with the Features, call features_destroy    
     129           0 :     return static_cast<gr_feature_val*>(pfeatures ? new Features(*pfeatures) : new Features);
     130             : }
     131             :   
     132           0 : void gr_featureval_destroy(gr_feature_val *p)
     133             : {
     134           0 :     delete p;
     135           0 : }
     136             : 
     137             : 
     138             : } // extern "C"

Generated by: LCOV version 1.13