LCOV - code coverage report
Current view: directory - gfx/graphite2/src - gr_slot.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 65 0 0.0 %
Date: 2012-06-02 Functions: 17 0 0.0 %

       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/Segment.h"
      28                 : #include "inc/Segment.h"
      29                 : #include "inc/Slot.h"
      30                 : #include "inc/Font.h"
      31                 : 
      32                 : 
      33                 : extern "C" {
      34                 : 
      35                 : 
      36               0 : const gr_slot* gr_slot_next_in_segment(const gr_slot* p/*not NULL*/)
      37                 : {
      38               0 :     assert(p);
      39               0 :     return static_cast<const gr_slot*>(p->next());
      40                 : }
      41                 : 
      42               0 : const gr_slot* gr_slot_prev_in_segment(const gr_slot* p/*not NULL*/)
      43                 : {
      44               0 :     assert(p);
      45               0 :     return static_cast<const gr_slot*>(p->prev());
      46                 : }
      47                 : 
      48               0 : const gr_slot* gr_slot_attached_to(const gr_slot* p/*not NULL*/)        //returns NULL iff base. If called repeatedly on result, will get to a base
      49                 : {
      50               0 :     assert(p);
      51               0 :     return static_cast<const gr_slot*>(p->attachedTo());
      52                 : }
      53                 : 
      54                 : 
      55               0 : const gr_slot* gr_slot_first_attachment(const gr_slot* p/*not NULL*/)        //returns NULL iff no attachments.
      56                 : {        //if slot_first_attachment(p) is not NULL, then slot_attached_to(slot_first_attachment(p))==p.
      57               0 :     assert(p);
      58               0 :     return static_cast<const gr_slot*>(p->firstChild());
      59                 : }
      60                 : 
      61                 :     
      62               0 : const gr_slot* gr_slot_next_sibling_attachment(const gr_slot* p/*not NULL*/)        //returns NULL iff no more attachments.
      63                 : {        //if slot_next_sibling_attachment(p) is not NULL, then slot_attached_to(slot_next_sibling_attachment(p))==slot_attached_to(p).
      64               0 :     assert(p);
      65               0 :     return static_cast<const gr_slot*>(p->nextSibling());
      66                 : }
      67                 : 
      68                 : 
      69               0 : unsigned short gr_slot_gid(const gr_slot* p/*not NULL*/)
      70                 : {
      71               0 :     assert(p);
      72               0 :     return p->glyph();
      73                 : }
      74                 : 
      75                 : 
      76               0 : float gr_slot_origin_X(const gr_slot* p/*not NULL*/)
      77                 : {
      78               0 :     assert(p);
      79               0 :     return p->origin().x;
      80                 : }
      81                 : 
      82                 : 
      83               0 : float gr_slot_origin_Y(const gr_slot* p/*not NULL*/)
      84                 : {
      85               0 :     assert(p);
      86               0 :     return p->origin().y;
      87                 : }
      88                 : 
      89                 : 
      90               0 : float gr_slot_advance_X(const gr_slot* p/*not NULL*/, const gr_face *face, const gr_font *font)
      91                 : {
      92               0 :     assert(p);
      93               0 :     float scale = 1.0;
      94               0 :     float res = p->advance();
      95               0 :     if (font)
      96                 :     {
      97               0 :         scale = font->scale();
      98               0 :         if (face && font->isHinted())
      99               0 :             res = (res - face->advance(p->gid())) * scale + font->advance(p->gid());
     100                 :         else
     101               0 :             res = res * scale;
     102                 :     }
     103               0 :     return res;
     104                 : }
     105                 : 
     106               0 : float gr_slot_advance_Y(const gr_slot *p/*not NULL*/, const gr_face *face, const gr_font *font)
     107                 : {
     108               0 :     assert(p);
     109               0 :     float res = p->advancePos().y;
     110               0 :     if (font && (face || !face))
     111               0 :         return res * font->scale();
     112                 :     else
     113               0 :         return res;
     114                 : }
     115                 :         
     116               0 : int gr_slot_before(const gr_slot* p/*not NULL*/)
     117                 : {
     118               0 :     assert(p);
     119               0 :     return p->before();
     120                 : }
     121                 : 
     122                 : 
     123               0 : int gr_slot_after(const gr_slot* p/*not NULL*/)
     124                 : {
     125               0 :     assert(p);
     126               0 :     return p->after();
     127                 : }
     128                 : 
     129               0 : unsigned int gr_slot_index(const gr_slot *p/*not NULL*/)
     130                 : {
     131               0 :     assert(p);
     132               0 :     return p->index();
     133                 : }
     134                 : 
     135               0 : int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, gr_attrCode index, gr_uint8 subindex)
     136                 : {
     137               0 :     assert(p);
     138               0 :     return p->getAttr(pSeg, index, subindex);
     139                 : }
     140                 : 
     141                 : 
     142               0 : int gr_slot_can_insert_before(const gr_slot* p/*not NULL*/)
     143                 : {
     144               0 :     assert(p);
     145               0 :     return (p->isInsertBefore())? 1 : 0;
     146                 : }
     147                 : 
     148                 : 
     149               0 : int gr_slot_original(const gr_slot* p/*not NULL*/)
     150                 : {
     151               0 :     assert(p);
     152               0 :     return p->original();
     153                 : }
     154                 : 
     155               0 : void gr_slot_linebreak_before(gr_slot* p/*not NULL*/)
     156                 : {
     157               0 :     assert(p);
     158               0 :     gr_slot *prev = (gr_slot *)p->prev();
     159               0 :     prev->sibling(NULL);
     160               0 :     prev->next(NULL);
     161               0 :     p->prev(NULL);
     162               0 : }
     163                 : 
     164                 : #if 0       //what should this be
     165                 : size_t id(const gr_slot* p/*not NULL*/)
     166                 : {
     167                 :     return (size_t)p->id();
     168                 : }
     169                 : #endif
     170                 : 
     171                 : 
     172                 : } // extern "C"
     173                 : 

Generated by: LCOV version 1.7