Path: blob/master/thirdparty/graphite/src/gr_font.cpp
9903 views
// SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later1// Copyright 2010, SIL International, All rights reserved.23#include "graphite2/Font.h"4#include "inc/Font.h"567using namespace graphite2;89extern "C" {1011void gr_engine_version(int *nMajor, int *nMinor, int *nBugFix)12{13if (nMajor) *nMajor = GR2_VERSION_MAJOR;14if (nMinor) *nMinor = GR2_VERSION_MINOR;15if (nBugFix) *nBugFix = GR2_VERSION_BUGFIX;16}1718gr_font* gr_make_font(float ppm/*pixels per em*/, const gr_face *face)19{20return gr_make_font_with_advance_fn(ppm, 0, 0, face);21}222324gr_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*/)25{ //the appFontHandle must stay alive all the time when the gr_font is alive. When finished with the gr_font, call destroy_gr_font26if (face == 0 || ppm <= 0) return 0;2728Font * const res = new Font(ppm, *face, appFontHandle, font_ops);29if (*res)30return static_cast<gr_font*>(res);31else32{33delete res;34return 0;35}36}3738gr_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*/)39{40const gr_font_ops ops = {sizeof(gr_font_ops), getAdvance, NULL};41return gr_make_font_with_ops(ppm, appFontHandle, &ops, face);42}4344void gr_font_destroy(gr_font *font)45{46delete static_cast<Font*>(font);47}484950} // extern "C"515253