# Adding back check for CAIRO 1.8, in rbpangocairo.c

**URL:** <https://www.ruby-forum.com/t/adding-back-check-for-cairo-1-8-in-rbpangocairo-c/239019>\
**Category:** Ruby-Gnome 2\
**Created:** [February 7, 2014, 8:36pm UTC](https://www.ruby-forum.com/t/adding-back-check-for-cairo-1-8-in-rbpangocairo-c/239019 "2014-02-07T20:36:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [February 7, 2014, 8:36pm UTC](https://www.ruby-forum.com/t/adding-back-check-for-cairo-1-8-in-rbpangocairo-c/239019/1 "2014-02-07T20:36:28Z")

</div>

So after some rework I see done in pango, I see Kou had pulled out some  
old checks for CAIRO 1.8.

I’m sadly still stuck on RHEL 5, which using Cairo 1.2.4

Before I submitted a pull request I thought I would ask if you even  
wanted this change, I can just hang on to the code in my local build  
area.

My change that I was going to make, was for rbpangocairo.c, adding the  
check back in for rg\_s\_create() but in a little different manner.

So the rg\_s\_create() function would look like:

static VALUE  
rg\_s\_create(int argc, VALUE \*argv, G\_GNUC\_UNUSED VALUE klass)  
{  
#if CAIRO\_CHECK\_VERSION(1, 8, 0)  
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);

```

#else  
return GOBJ2RVAL(pango\_cairo\_font\_map\_new());  
#endif  
}

---

<div class="post-metadata">

**Author:** ![grantspeelman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/da6949/32.png) [@grantspeelman](https://www.ruby-forum.com/u/grantspeelman)\
**Post date:** [February 8, 2014, 5:46am UTC](https://www.ruby-forum.com/t/adding-back-check-for-cairo-1-8-in-rbpangocairo-c/239019/2 "2014-02-08T05:46:19Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] Adding back check for CAIRO 1.8, in  
rbpangocairo.c” on Fri, 07 Feb 2014 20:36:28 +0100,  
Grant S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My change that I was going to make, was for rbpangocairo.c, adding the  
> check back in for rg\_s\_create() but in a little different manner.

Thanks for your report!

I’ve added PANGO\_CHECK\_VERSION(1, 18, 0) check instead of  
CAIRO\_CHECK\_VERSION() check. It will solve the problem.

## Thanks,

kou
