getTypefaceForFont Override problem

The following highlighted in bold:

 class FontLookAndFeel : public LookAndFeel
        {
        public:
            const Typeface::Ptr getTypefaceForFont (const Font& font);
     
        private:
            Typeface::Ptr customTypeface;
        }

 

is resulting in :


Error C2555:   return type is not identical to nor covariant with return type "juce::Typeface::Ptr" of overridden virtual function "juce::LookAndFeel::getTypefaceForFont"  

Can someone shed some light please?

Thanks in advance.

You need to get rid of that first const as the function your overriding is returning a non const type.

You probably ought to append the override specifier while you're at it.

Thank you for pointing that out, Andrew. However my override isn't being called. Here's what I have (just the font related bits):

 

midkontrol.h

public:
Typeface::Ptr getTypefaceForFont(const Font& font) override;​

private:
Typeface::Ptr customTypeface;

midikontrol.cpp

//in the constructor
ScopedPointer<MemoryInputStream> fontStream(new MemoryInputStream(Images::MidiKontrolFont_ttf, Images::MidiKontrolFont_ttfSize,    false));
        if (fontStream != nullptr)
            customTypeface = new CustomTypeface(*fontStream);
....

Typeface::Ptr MidiKontrol::getTypefaceForFont(const Font& font)
{
    printf("Test");
    if (customTypeface != nullptr && font.getTypefaceName() == customTypeface->getName())
    {
        return customTypeface;
    }

    return LookAndFeel::getTypefaceForFont(font);
}

What am I doing wrong?

Have you set the look and feel of the component? Maybe take a look through this for some hints: http://www.juce.com/forum/topic/use-embeded-font

Good luck, and don't be afraid to sing out if you're still having trouble with it!