<commit_before>/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
 *  Copyright (C) 2011  Ruby-GNOME2 Project Team
 *  Copyright (C) 2006  Ruby-GNOME2 Project Team
 *  Copyright (C) 2005  <NAME>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *  MA  02110-1301  USA
 */

#include "rbpangoprivate.h"

#define RG_TARGET_NAMESPACE cCairoFontMap
#define _SELF(self) (RVAL2PANGOCAIROFONTMAP(self))

#if CAIRO_CHECK_VERSION(1, 8, 0)
static VALUE
rg_s_create(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
{
    VALUE rb_font_type;
    PangoFontMap *font_map = NULL;

    rb_scan_args(argc, argv, "01", &rb_font_type);
    if (NIL_P(rb_font_type)) {
        font_map = pango_cairo_font_map_new();
    } else {
        cairo_font_type_t font_type = CAIRO_FONT_TYPE_USER;
        if (rbgutil_key_equal(rb_font_type, "ft") ||
            rbgutil_key_equal(rb_font_type, "freetype")) {
            font_type = CAIRO_FONT_TYPE_FT;
        } else if (rbgutil_key_equal(rb_font_type, "win32")) {
            font_type = CAIRO_FONT_TYPE_WIN32;
        } else if (rbgutil_key_equal(rb_font_type, "quartz")) {
            font_type = CAIRO_FONT_TYPE_QUARTZ;
        } else {
            rb_raise(rb_eArgError,
                     "font type must be one of "
                     ":ft, :freetype, :win32 or :quartz: %s",
                     RBG_INSPECT(rb_font_type));
        }
        font_map = pango_cairo_font_map_new_for_font_type(font_type);
    }

    return GOBJ2RVAL(font_map);
}
#endif

static VALUE
rg_s_default(G_GNUC_UNUSED VALUE klass)
{
    return GOBJ2RVAL(pango_cairo_font_map_get_default());
}

#if PANGO_CHECK_VERSION(1, 22, 0)
static VALUE
rg_s_set_default(VALUE klass, VALUE font_map)
{
    pango_cairo_font_map_set_default(RVAL2GOBJ(font_map));
    return klass;
}
#endif

static VALUE
rg_set_resolution(VALUE self, VALUE dpi)
{
    pango_cairo_font_map_set_resolution(_SELF(self), NUM2DBL(dpi));
    return self;
}

static VALUE
rg_resolution(VALUE self)
{<commit_msg>pango: drop Pango < 1.8<commit_after>/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
/*
 *  Copyright (C) 2006-2013  Ruby-GNOME2 Project Team
 *  Copyright (C) 2005  <NAME>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *  MA  02110-1301  USA
 */

#include "rbpangoprivate.h"

#define RG_TARGET_NAMESPACE cCairoFontMap
#define _SELF(self) (RVAL2PANGOCAIROFONTMAP(self))

static VALUE
rg_s_create(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
{
    VALUE rb_font_type;
    PangoFontMap *font_map = NULL;

    rb_scan_args(argc, argv, "01", &rb_font_type);
    if (NIL_P(rb_font_type)) {
        font_map = pango_cairo_font_map_new();
    } else {
        cairo_font_type_t font_type = CAIRO_FONT_TYPE_USER;
        if (rbgutil_key_equal(rb_font_type, "ft") ||
            rbgutil_key_equal(rb_font_type, "freetype")) {
            font_type = CAIRO_FONT_TYPE_FT;
        } else if (rbgutil_key_equal(rb_font_type, "win32")) {
            font_type = CAIRO_FONT_TYPE_WIN32;
        } else if (rbgutil_key_equal(rb_font_type, "quartz")) {
            font_type = CAIRO_FONT_TYPE_QUARTZ;
        } else {
            rb_raise(rb_eArgError,
                     "font type must be one of "
                     ":ft, :freetype, :win32 or :quartz: %s",
                     RBG_INSPECT(rb_font_type));
        }
        font_map = pango_cairo_font_map_new_for_font_type(font_type);
    }

    return GOBJ2RVAL(font_map);
}

static VALUE
rg_s_default(G_GNUC_UNUSED VALUE klass)
{
    return GOBJ2RVAL(pango_cairo_font_map_get_default());
}

#if PANGO_CHECK_VERSION(1, 22, 0)
static VALUE
rg_s_set_default(VALUE klass, VALUE font_map)
{
    pango_cairo_font_map_set_default(RVAL2GOBJ(font_map));
    return klass;
}
#endif

static VALUE
rg_set_resolution(VALUE self, VALUE dpi)
{
    pango_cairo_font_map_set_resolution(_SELF(self), NUM2DBL(dpi));
    return self;
}

static VALUE
rg_resolution(VALUE self)
{
{'fraction_non_alphanumeric': 0.08901515151515152, 'fraction_numerical': 0.017424242424242425, 'mean_word_length': 3.382572614107884, 'pattern_counts': {'":': 2, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1759181', 'n_tokens_mistral': 1941, 'n_tokens_neox': 1851, 'n_words': 490}