PureSwift / Silica

Pure Swift CoreGraphics (Quartz2D) implementation (Supports Linux)
MIT License
107 stars 28 forks source link

Reference to CAIRO_HINT_METRICS_OFF when setting up FontOptions #8

Closed kevinvandenbreemen closed 4 years ago

kevinvandenbreemen commented 4 years ago

Hello there, In trying to build the latest version of the library on Ubuntu 18.04 I get an error when compiling CGFont. Error is

/my/path/to/Silica/Sources/Silica/CGFont.swift:52:35: error: cannot assign value of type '_cairo_hint_metrics' to type 'FontHintMetrics'
            options.hintMetrics = CAIRO_HINT_METRICS_OFF
                                  ^~~~~~~~~~~~~~~~~~~~~~

The specific part of the code is this in CGFont.swift, in the init() function:

... let face = FontFace(fontConfigPattern: fontConfigPattern)

        let options = FontOptions()

        //  TODO    Does not compile...
        options.hintMetrics = CAIRO_HINT_METRICS_OFF

...

The definition of FontOptions appears to be found in cairo.h, specifically struct _cairo_cont_options. Actually setting the hint metrics for a FontOptions appears to be defined in cairo.h, here:

cairo_font_options_set_hint_metrics (cairo_font_options_t *options,
                     cairo_hint_metrics_t  hint_metrics);

The hint metrics type along with member CAIRO_HINT_METRICS_OFF, appears to be in the same file, here:

   typedef enum _cairo_hint_metrics {
       CAIRO_HINT_METRICS_DEFAULT,
       CAIRO_HINT_METRICS_OFF,
       CAIRO_HINT_METRICS_ON
   } cairo_hint_metrics_t;

If these definitions are all here and supported by the API then why should this error occur?

kevinvandenbreemen commented 4 years ago

Issue resolved in #10