Skip to content

Conversation

@andrewfb
Copy link
Collaborator

This PR introduces Linux support for Cairo, and updates macOS Cairo library to the latest release, 1.8.4.

To use Cairo on Linux, you'll need to sudo apt install libcairo2-dev but the include cmake projects should build out of the box after that. This PR also includes documentation updates to that effect, and a FindCairo.cmake file.

image

On macOS, the included static libraries are "fat" binaries, supporting both x86_64 and arm64.

For both Linux and now macOS, the Cairo samples render to a gl::Texture rather than using Renderer2d. For Linux, an equivalent doesn't exist, and on macOS, Apple recently introduced some breaking changes that IMO mean we should probably deprecate that infrequently used code path.

Tested on Ubuntu 24.04, macOS 14.5, and Windows 11.

@andrewfb andrewfb requested a review from Copilot September 24, 2025 18:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces cross-platform Cairo support for Linux and updates macOS Cairo to version 1.8.4. The changes enable Cairo samples to work on Linux using system-installed Cairo libraries while maintaining compatibility with Windows and macOS through bundled libraries. Additionally, all Cairo samples are updated to use OpenGL rendering on Linux/macOS instead of the deprecated Renderer2d.

Key changes include:

  • Linux Cairo integration via FindCairo.cmake module and conditional CMakeLists.txt updates
  • macOS Cairo library update to version 1.8.4 with universal binary support
  • Platform-specific rendering path changes for Linux/macOS Cairo samples
  • Modernization of sample code (Twitter API → Mastodon API migration)

Reviewed Changes

Copilot reviewed 36 out of 39 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
samples//src/.cpp Updated Cairo samples to use conditional rendering paths (OpenGL for Linux/macOS, direct window surface for Windows)
samples/*/proj/cmake/CMakeLists.txt Added Linux-specific Cairo build configuration using system libraries
proj/cmake/modules/FindCairo.cmake New CMake module for locating system Cairo libraries on Linux
blocks/Cairo/src/Cairo.cpp Added Linux font handling and fixed compatibility issues
blocks/Cairo/include/ Updated macOS Cairo headers to version 1.8.4
docs/htmlsrc/guides/linux-notes/ Updated documentation for Cairo installation requirements

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

{
mCairoSurface = cairo_ps_surface_create( filePath.string().c_str(), widthInPoints, heightInPoints );
cairo_ps_surface_set_eps( mCairoSurface, TRUE );
cairo_ps_surface_set_eps( mCairoSurface, 1 );
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using magic number 1 instead of a boolean constant. Consider using true or defining a named constant to improve code readability and maintainability.

Suggested change
cairo_ps_surface_set_eps( mCairoSurface, 1 );
cairo_ps_surface_set_eps( mCairoSurface, true );

Copilot uses AI. Check for mistakes.
mCtx.setFontMatrix( fontMatrix );
TextBox tbox = TextBox().font( *font ).text( span.getString() );
std::vector<std::pair<uint16_t,vec2> > glyphs = tbox.measureGlyphs();
auto glyphs = tbox.measureGlyphs();
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using auto for type deduction where the explicit type would improve code clarity. Consider using the explicit return type from measureGlyphs() to make the code more self-documenting.

Suggested change
auto glyphs = tbox.measureGlyphs();
std::vector<std::pair<uint16_t, vec2>> glyphs = tbox.measureGlyphs();

Copilot uses AI. Check for mistakes.
@andrewfb
Copy link
Collaborator Author

One additional note, this PR fixes the GoodNightMorning sample, moving it off of a long-deprecated Twitter API and using a Mastadon API insead.

@andrewfb andrewfb merged commit 55a929b into cinder:master Sep 28, 2025
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant