Skip to content

Commit e79c8fb

Browse files
committed
Update Cairo block for macOS/Linux compatibility
1 parent 3c5ffcf commit e79c8fb

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎blocks/Cairo/include/cinder/cairo/Cairo.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@
4040
#include <ApplicationServices/ApplicationServices.h>
4141
#endif
4242

43+
#if defined(CINDER_LINUX)
44+
#include <cairo/cairo.h>
45+
#include <cairo/cairo-svg.h>
46+
#include <cairo/cairo-pdf.h>
47+
#include <cairo/cairo-ps.h>
48+
#elif defined(CINDER_MAC)
49+
#include "macosx/cairo.h"
50+
#include "macosx/cairo-svg.h"
51+
#include "macosx/cairo-pdf.h"
52+
#include "macosx/cairo-ps.h"
53+
#include "macosx/cairo-quartz.h"
54+
#endif
55+
4356
#include <string>
4457
#include <vector>
4558
#include <iomanip>

‎blocks/Cairo/src/Cairo.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ SurfaceEps::SurfaceEps( const fs::path &filePath, double widthInPoints, double h
351351
: SurfaceBase( (int32_t)widthInPoints, (int32_t)heightInPoints )
352352
{
353353
mCairoSurface = cairo_ps_surface_create( filePath.string().c_str(), widthInPoints, heightInPoints );
354-
cairo_ps_surface_set_eps( mCairoSurface, TRUE );
354+
cairo_ps_surface_set_eps( mCairoSurface, 1 );
355355
cairo_ps_surface_restrict_to_level( mCairoSurface, ( enableLevel3 ) ? CAIRO_PS_LEVEL_3 : CAIRO_PS_LEVEL_2 );
356356
}
357357

@@ -1750,6 +1750,10 @@ void Context::setFont( const cinder::Font &font )
17501750
cairo_font_face_t *cairoFont = cairo_quartz_font_face_create_for_cgfont( font.getCgFontRef() );
17511751
#elif defined( CINDER_MSW )
17521752
cairo_font_face_t *cairoFont = cairo_win32_font_face_create_for_logfontw( const_cast<LOGFONTW*>( (const LOGFONTW*)font.getLogfont() ) );
1753+
#elif defined( CINDER_LINUX )
1754+
cairo_select_font_face( mCairo, font.getName().c_str(), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL );
1755+
cairo_font_face_t *cairoFont = cairo_get_font_face( mCairo );
1756+
cairo_font_face_reference( cairoFont );
17531757
#endif
17541758
cairo_set_font_face( mCairo, cairoFont );
17551759
cairo_set_font_size( mCairo, font.getSize() );
@@ -2061,7 +2065,7 @@ class SvgRendererCairo : public svg::Renderer {
20612065
fontMatrix *= rotationMatrix;
20622066
mCtx.setFontMatrix( fontMatrix );
20632067
TextBox tbox = TextBox().font( *font ).text( span.getString() );
2064-
std::vector<std::pair<uint16_t,vec2> > glyphs = tbox.measureGlyphs();
2068+
auto glyphs = tbox.measureGlyphs();
20652069
vec2 curPoint = mCtx.getCurrentPoint();
20662070
for( size_t g = 0; g < glyphs.size(); ++g ) {
20672071
mCtx.save();

0 commit comments

Comments
 (0)