Ejemplo n.º 1
0
void setCairoFontOptionsFromFontConfigPattern(cairo_font_options_t* options, FcPattern* pattern)
{
    FcBool booleanResult;
    int integerResult;

    if (FcPatternGetInteger(pattern, FC_RGBA, 0, &integerResult) == FcResultMatch) {
        cairo_font_options_set_subpixel_order(options, convertFontConfigSubpixelOrder(integerResult));

        // Based on the logic in cairo-ft-font.c in the cairo source, a font with
        // a subpixel order implies that is uses subpixel antialiasing.
        if (integerResult != FC_RGBA_NONE)
            cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_SUBPIXEL);
    }

    if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &booleanResult) == FcResultMatch) {
        // Only override the anti-aliasing setting if was previously turned off. Otherwise
        // we'll override the preference which decides between gray anti-aliasing and
        // subpixel anti-aliasing.
        if (!booleanResult)
            cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_NONE);
        else if (cairo_font_options_get_antialias(options) == CAIRO_ANTIALIAS_NONE)
            cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
    }

    if (FcPatternGetInteger(pattern, FC_HINT_STYLE, 0, &integerResult) == FcResultMatch)
        cairo_font_options_set_hint_style(options, convertFontConfigHintStyle(integerResult));
    if (FcPatternGetBool(pattern, FC_HINTING, 0, &booleanResult) == FcResultMatch && !booleanResult)
        cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
}
Ejemplo n.º 2
0
static void
ar_card_theme_kde_paint_card (ArCardTheme *card_theme,
                              cairo_t *cr,
                              int card_id)
{
  ArCardThemePreimage *preimage_card_theme = (ArCardThemePreimage *) card_theme;
  ArCardThemeKDE *theme = (ArCardThemeKDE *) card_theme;
  ArSvg *svg = preimage_card_theme->cards_svg;
  char node[32];
  cairo_rectangle_t *card_extents;
  cairo_matrix_t matrix;
  cairo_font_options_t *font_options;

  if (G_UNLIKELY (card_id == AR_CARD_SLOT)) {
    ar_svg_render_cairo (preimage_card_theme->slot_preimage,
                                 cr,
                                 preimage_card_theme->card_size.width,
                                 preimage_card_theme->card_size.height);
    return;
  }

  if (theme->legacy)
    ar_card_get_legacy_node_by_id_snprintf (node, sizeof (node), card_id);
  else
    ar_card_get_node_by_id_snprintf (node, sizeof (node), card_id);

  card_extents = ar_card_theme_kde_get_card_extents (theme, card_id, node);
  if (!card_extents)
    return;

  cairo_save (cr);

  font_options = ar_svg_get_font_options (svg);
  if (font_options) {
    cairo_set_antialias (cr, cairo_font_options_get_antialias (font_options));
    cairo_set_font_options (cr, font_options);
  }

  cairo_matrix_init_identity (&matrix);
  cairo_matrix_scale (&matrix,
                      preimage_card_theme->card_size.width / card_extents->width,
                      preimage_card_theme->card_size.height / card_extents->height);
  cairo_matrix_translate (&matrix, -card_extents->x, -card_extents->y);

  cairo_set_matrix (cr, &matrix);

  rsvg_handle_render_cairo_sub (RSVG_HANDLE (svg), cr, node);

  cairo_restore (cr);
}
Ejemplo n.º 3
0
void
ScaledFontBase::GetGlyphDesignMetrics(const uint16_t* aGlyphs, uint32_t aNumGlyphs, GlyphMetrics* aGlyphMetrics)
{
#ifdef USE_CAIRO_SCALED_FONT
  if (mScaledFont) {
    for (uint32_t i = 0; i < aNumGlyphs; i++) {
      cairo_glyph_t glyph;
      cairo_text_extents_t extents;
      glyph.index = aGlyphs[i];
      glyph.x = 0;
      glyph.y = 0;

      cairo_scaled_font_glyph_extents(mScaledFont, &glyph, 1, &extents);

      aGlyphMetrics[i].mXBearing = extents.x_bearing;
      aGlyphMetrics[i].mXAdvance = extents.x_advance;
      aGlyphMetrics[i].mYBearing = extents.y_bearing;
      aGlyphMetrics[i].mYAdvance = extents.y_advance;
      aGlyphMetrics[i].mWidth = extents.width;
      aGlyphMetrics[i].mHeight = extents.height;

      cairo_font_options_t *options = cairo_font_options_create();
      cairo_scaled_font_get_font_options(mScaledFont, options);

      if (cairo_font_options_get_antialias(options) != CAIRO_ANTIALIAS_NONE) {
        if (cairo_scaled_font_get_type(mScaledFont) == CAIRO_FONT_TYPE_WIN32) {
          if (aGlyphMetrics[i].mWidth > 0 && aGlyphMetrics[i].mHeight > 0) {
            aGlyphMetrics[i].mWidth -= 3.0f;
            aGlyphMetrics[i].mXBearing += 1.0f;
          }
        }
#if defined(MOZ2D_HAS_MOZ_CAIRO) && defined(CAIRO_HAS_DWRITE_FONT)
        else if (cairo_scaled_font_get_type(mScaledFont) == CAIRO_FONT_TYPE_DWRITE) {
          if (aGlyphMetrics[i].mWidth > 0 && aGlyphMetrics[i].mHeight > 0) {
            aGlyphMetrics[i].mWidth -= 2.0f;
            aGlyphMetrics[i].mXBearing += 1.0f;
          }
        }
#endif
      }
      cairo_font_options_destroy(options);
    }

  }
#endif

  // Don't know how to get the glyph metrics...
  MOZ_CRASH("The specific backend type is not supported for GetGlyphDesignMetrics.");
}
Ejemplo n.º 4
0
	int lime_cairo_font_options_get_antialias (value handle) {
		
		return cairo_font_options_get_antialias ((cairo_font_options_t*)val_data (handle));
		
	}
Ejemplo n.º 5
0
static PyObject *
font_options_get_antialias (PycairoFontOptions *o)
{
    return PyInt_FromLong (cairo_font_options_get_antialias (o->font_options));
}
Ejemplo n.º 6
0
	int lime_cairo_font_options_get_antialias (double handle) {
		
		return cairo_font_options_get_antialias ((cairo_font_options_t*)(intptr_t)handle);
		
	}
Ejemplo n.º 7
0
int32_t FontOptions::getAntiAlias()
{
	return static_cast<int32_t>( cairo_font_options_get_antialias( mCairoFontOptions ) );
}
Ejemplo n.º 8
0
static VALUE
cr_options_get_antialias (VALUE self)
{
  return INT2NUM (cairo_font_options_get_antialias (_SELF (self)));
}
Ejemplo n.º 9
0
IoObject *IoCairoFontOptions_getAntialias(IoCairoFontOptions *self, IoObject *locals, IoMessage *m)
{
	return IONUMBER(cairo_font_options_get_antialias(OPTIONS(self)));
}