1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/graphite2/src/gr_font.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* GRAPHITE2 LICENSING 1.5 + 1.6 + Copyright 2010, SIL International 1.7 + All rights reserved. 1.8 + 1.9 + This library is free software; you can redistribute it and/or modify 1.10 + it under the terms of the GNU Lesser General Public License as published 1.11 + by the Free Software Foundation; either version 2.1 of License, or 1.12 + (at your option) any later version. 1.13 + 1.14 + This program is distributed in the hope that it will be useful, 1.15 + but WITHOUT ANY WARRANTY; without even the implied warranty of 1.16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1.17 + Lesser General Public License for more details. 1.18 + 1.19 + You should also have received a copy of the GNU Lesser General Public 1.20 + License along with this library in the file named "LICENSE". 1.21 + If not, write to the Free Software Foundation, 51 Franklin Street, 1.22 + Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 1.23 + internet at http://www.fsf.org/licenses/lgpl.html. 1.24 + 1.25 +Alternatively, the contents of this file may be used under the terms of the 1.26 +Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public 1.27 +License, as published by the Free Software Foundation, either version 2 1.28 +of the License or (at your option) any later version. 1.29 +*/ 1.30 +#include "graphite2/Font.h" 1.31 +#include "inc/Font.h" 1.32 + 1.33 + 1.34 +using namespace graphite2; 1.35 + 1.36 +extern "C" { 1.37 + 1.38 +void gr_engine_version(int *nMajor, int *nMinor, int *nBugFix) 1.39 +{ 1.40 + if (nMajor) *nMajor = GR2_VERSION_MAJOR; 1.41 + if (nMinor) *nMinor = GR2_VERSION_MINOR; 1.42 + if (nBugFix) *nBugFix = GR2_VERSION_BUGFIX; 1.43 +} 1.44 + 1.45 +gr_font* gr_make_font(float ppm/*pixels per em*/, const gr_face *face) 1.46 +{ 1.47 + return gr_make_font_with_advance_fn(ppm, 0, 0, face); 1.48 +} 1.49 + 1.50 + 1.51 +gr_font* gr_make_font_with_ops(float ppm/*pixels per em*/, const void* appFontHandle/*non-NULL*/, const gr_font_ops * font_ops, const gr_face * face/*needed for scaling*/) 1.52 +{ //the appFontHandle must stay alive all the time when the gr_font is alive. When finished with the gr_font, call destroy_gr_font 1.53 + if (face == 0) return 0; 1.54 + 1.55 + Font * const res = new Font(ppm, *face, appFontHandle, font_ops); 1.56 + return static_cast<gr_font*>(res); 1.57 +} 1.58 + 1.59 +gr_font* gr_make_font_with_advance_fn(float ppm/*pixels per em*/, const void* appFontHandle/*non-NULL*/, gr_advance_fn getAdvance, const gr_face * face/*needed for scaling*/) 1.60 +{ 1.61 + const gr_font_ops ops = {sizeof(gr_font_ops), getAdvance, NULL}; 1.62 + return gr_make_font_with_ops(ppm, appFontHandle, &ops, face); 1.63 +} 1.64 + 1.65 +void gr_font_destroy(gr_font *font) 1.66 +{ 1.67 + delete font; 1.68 +} 1.69 + 1.70 + 1.71 +} // extern "C" 1.72 + 1.73 + 1.74 + 1.75 +