| 458 | } |
| 459 | |
| 460 | int renderGlyphsCairo(imageObj *img,double x, double y, labelStyleObj *style, char *text) { |
| 461 | cairo_renderer *r = CAIRO_RENDERER(img); |
| 462 | cairoCacheData *cache = MS_IMAGE_RENDERER_CACHE(img); |
| 463 | faceCacheObj *face = getFontFace(cache,style->font); |
| 464 | |
| 465 | char *utfptr=text; |
| 466 | int i,has_kerning,unicode; |
| 467 | unsigned long previdx=0; |
| 468 | int numglyphs = msGetNumGlyphs(text); |
| 469 | cairo_glyph_t glyph; |
| 470 | cairo_text_extents_t extents; |
| 471 | double px=0,py=0; |
| 472 | |
| 473 | if(face == NULL) { |
| 474 | return MS_FAILURE; |
| 475 | } |
| 476 | |
| 477 | cairo_set_font_face(r->cr,face->face); |
| 478 | cairo_set_font_size(r->cr,style->size*96/72.0); |
| 479 | |
| 480 | cairo_save(r->cr); |
| 481 | cairo_translate(r->cr,MS_NINT(x),MS_NINT(y)); |
| 482 | if(style->rotation != 0.0) |
| 483 | cairo_rotate(r->cr, -style->rotation); |
| 484 | |
| 485 | has_kerning = FT_HAS_KERNING((face->ftface)); |
| 486 | for(i=0;i<numglyphs;i++) { |
| 487 | utfptr+=msUTF8ToUniChar(utfptr, &unicode); |
| 488 | glyph.x=px; |
| 489 | glyph.y=py; |
| 490 | if(unicode=='\n') { |
| 491 | py += ceil(style->size*CAIROLINESPACE); |
| 492 | px = 0; |
| 493 | previdx=0; |
| 494 | continue; |
| 495 | } |
| 496 | glyph.index = FT_Get_Char_Index(face->ftface, unicode); |
| 497 | if( has_kerning && previdx ) { |
| 498 | FT_Vector delta; |
| 499 | FT_Get_Kerning( face->ftface, previdx, glyph.index, FT_KERNING_DEFAULT, &delta ); |
| 500 | px += delta.x / 64.; |
| 501 | } |
| 502 | cairo_glyph_extents(r->cr,&glyph,1,&extents); |
| 503 | cairo_glyph_path(r->cr,&glyph,1); |
| 504 | px += extents.x_advance; |
| 505 | previdx=glyph.index; |
| 506 | } |
| 507 | |
| 508 | if (style->outlinewidth > 0) { |
| 509 | cairo_save(r->cr); |
| 510 | msCairoSetSourceColor(r->cr, style->outlinecolor); |
| 511 | cairo_set_line_width(r->cr, style->outlinewidth + 1); |
| 512 | cairo_stroke_preserve(r->cr); |
| 513 | cairo_restore(r->cr); |
| 514 | } |
| 515 | if(style->color) { |
| 516 | msCairoSetSourceColor(r->cr, style->color); |
| 517 | cairo_fill(r->cr); |
nothing calls this directly
no test coverage detected