JUCE 8 (possibly dumb) FontOptions question

I’m updating from JUCE 7 to JUCE 8, and dealing with the fact that the default Font::Font() is deprecated.

You now should specify a FontOptions class as an argument.

Maybe I’m just having a brain fart, or some C++ thing I don’t understand, but…

A FontOptions object is not a Font, and yet in several places in JUCE code it is used as if it is.

For example, in this code from CoreGraphicsContext:

    CGContextSetShouldAntialias (context.get(), true);
    CGContextSetBlendMode (context.get(), kCGBlendModeNormal);
    rgbColourSpace.reset (CGColorSpaceCreateWithName (kCGColorSpaceSRGB));
    greyColourSpace.reset (CGColorSpaceCreateWithName (kCGColorSpaceGenericGrayGamma2_2));
    setFont (FontOptions());

Why is it not:

    setFont (Font(FontOptions()));

CoreGraphicsContext::SetFont(const Font&) takes a Font Reference; not a FontOptions reference…

Or for example, with a CodeEditorComponent, it does not matter which of these I use:

    codeEditorComponent->setFont(Font(FontOptions("SF Mono", 13, Font::plain)));

    codeEditorComponent->setFont(FontOptions("SF Mono", 13, Font::plain));

https://en.cppreference.com/w/cpp/language/cast_operator

1 Like

Font has a single-argument non-explicit constructor taking a FontOptions, which allows for implicit conversions from FontOptions to Font.

1 Like