michael@0: /* GRAPHITE2 LICENSING michael@0: michael@0: Copyright 2010, SIL International michael@0: All rights reserved. michael@0: michael@0: This library is free software; you can redistribute it and/or modify michael@0: it under the terms of the GNU Lesser General Public License as published michael@0: by the Free Software Foundation; either version 2.1 of License, or michael@0: (at your option) any later version. michael@0: michael@0: This program is distributed in the hope that it will be useful, michael@0: but WITHOUT ANY WARRANTY; without even the implied warranty of michael@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU michael@0: Lesser General Public License for more details. michael@0: michael@0: You should also have received a copy of the GNU Lesser General Public michael@0: License along with this library in the file named "LICENSE". michael@0: If not, write to the Free Software Foundation, 51 Franklin Street, michael@0: Suite 500, Boston, MA 02110-1335, USA or visit their web page on the michael@0: internet at http://www.fsf.org/licenses/lgpl.html. michael@0: michael@0: Alternatively, the contents of this file may be used under the terms of the michael@0: Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public michael@0: License, as published by the Free Software Foundation, either version 2 michael@0: of the License or (at your option) any later version. michael@0: */ michael@0: #include "graphite2/Segment.h" michael@0: #include "inc/Segment.h" michael@0: #include "inc/Slot.h" michael@0: #include "inc/Font.h" michael@0: michael@0: michael@0: extern "C" { michael@0: michael@0: michael@0: const gr_slot* gr_slot_next_in_segment(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return static_cast(p->next()); michael@0: } michael@0: michael@0: const gr_slot* gr_slot_prev_in_segment(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return static_cast(p->prev()); michael@0: } michael@0: michael@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 michael@0: { michael@0: assert(p); michael@0: return static_cast(p->attachedTo()); michael@0: } michael@0: michael@0: michael@0: const gr_slot* gr_slot_first_attachment(const gr_slot* p/*not NULL*/) //returns NULL iff no attachments. michael@0: { //if slot_first_attachment(p) is not NULL, then slot_attached_to(slot_first_attachment(p))==p. michael@0: assert(p); michael@0: return static_cast(p->firstChild()); michael@0: } michael@0: michael@0: michael@0: const gr_slot* gr_slot_next_sibling_attachment(const gr_slot* p/*not NULL*/) //returns NULL iff no more attachments. michael@0: { //if slot_next_sibling_attachment(p) is not NULL, then slot_attached_to(slot_next_sibling_attachment(p))==slot_attached_to(p). michael@0: assert(p); michael@0: return static_cast(p->nextSibling()); michael@0: } michael@0: michael@0: michael@0: unsigned short gr_slot_gid(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return p->glyph(); michael@0: } michael@0: michael@0: michael@0: float gr_slot_origin_X(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return p->origin().x; michael@0: } michael@0: michael@0: michael@0: float gr_slot_origin_Y(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return p->origin().y; michael@0: } michael@0: michael@0: michael@0: float gr_slot_advance_X(const gr_slot* p/*not NULL*/, const gr_face *face, const gr_font *font) michael@0: { michael@0: assert(p); michael@0: float scale = 1.0; michael@0: float res = p->advance(); michael@0: if (font) michael@0: { michael@0: scale = font->scale(); michael@0: if (face && font->isHinted()) michael@0: res = (res - face->glyphs().glyph(p->gid())->theAdvance().x) * scale + font->advance(p->gid()); michael@0: else michael@0: res = res * scale; michael@0: } michael@0: return res; michael@0: } michael@0: michael@0: float gr_slot_advance_Y(const gr_slot *p/*not NULL*/, const gr_face *face, const gr_font *font) michael@0: { michael@0: assert(p); michael@0: float res = p->advancePos().y; michael@0: if (font && (face || !face)) michael@0: return res * font->scale(); michael@0: else michael@0: return res; michael@0: } michael@0: michael@0: int gr_slot_before(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return p->before(); michael@0: } michael@0: michael@0: michael@0: int gr_slot_after(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return p->after(); michael@0: } michael@0: michael@0: unsigned int gr_slot_index(const gr_slot *p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return p->index(); michael@0: } michael@0: michael@0: int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, gr_attrCode index, gr_uint8 subindex) michael@0: { michael@0: assert(p); michael@0: return p->getAttr(pSeg, index, subindex); michael@0: } michael@0: michael@0: michael@0: int gr_slot_can_insert_before(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return (p->isInsertBefore())? 1 : 0; michael@0: } michael@0: michael@0: michael@0: int gr_slot_original(const gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: return p->original(); michael@0: } michael@0: michael@0: void gr_slot_linebreak_before(gr_slot* p/*not NULL*/) michael@0: { michael@0: assert(p); michael@0: gr_slot *prev = (gr_slot *)p->prev(); michael@0: prev->sibling(NULL); michael@0: prev->next(NULL); michael@0: p->prev(NULL); michael@0: } michael@0: michael@0: #if 0 //what should this be michael@0: size_t id(const gr_slot* p/*not NULL*/) michael@0: { michael@0: return (size_t)p->id(); michael@0: } michael@0: #endif michael@0: michael@0: michael@0: } // extern "C" michael@0: