# Fix warnings for deprecated Font constructor

**URL:** <https://forum.juce.com/t/fix-warnings-for-deprecated-font-constructor/65073>\
**Category:** The Projucer\
**Created:** [February 2, 2025, 3:35pm UTC](https://forum.juce.com/t/fix-warnings-for-deprecated-font-constructor/65073 "2025-02-02T15:35:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ring2](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@ring2](https://forum.juce.com/u/ring2)\
**Post date:** [February 2, 2025, 3:35pm UTC](https://forum.juce.com/t/fix-warnings-for-deprecated-font-constructor/65073/1 "2025-02-02T15:35:21Z")

</div>

I’m not sure how many people here are still using Projucer with GUI Editor though, I’m still using and made a fix to stop warnings for generating Font constructor code.

In jucer\_FontPropertyComponent.h, here is the code to generate Font constructor.

```auto
    static String getCompleteFontCode (const Font& font, const String& typefaceName)
    {
        String s;

        s << "juce::Font ("
          << getTypefaceNameCode (typefaceName)
          << CodeHelpers::floatLiteral (font.getHeight(), 2)
          << ", ";

        if (font.getAvailableStyles().contains (font.getTypefaceStyle()))
            s << "juce::Font::plain).withTypefaceStyle ("
              << CodeHelpers::stringLiteral (font.getTypefaceStyle())
              << ")";
        else
            s << getFontStyleCode (font)
              << ")";

        if (! approximatelyEqual (font.getExtraKerningFactor(), 0.0f))
            s << ".withExtraKerningFactor ("
              << CodeHelpers::floatLiteral (font.getExtraKerningFactor(), 3)
              << ")";

        return s;
    }

```

Change it to

```auto
    static String getCompleteFontCode (const Font& font, const String& typefaceName)
    {
        String s;

        s << "juce::Font (juce::FontOptions ("
          << CodeHelpers::floatLiteral (font.getHeight(), 2)
          << ", ";

        // スタイルの判定
        if (typefaceName == "Bold Italic")
            s << "juce::Font::bold | juce::Font::italic";
        else if (typefaceName == "Bold")
            s << "juce::Font::bold";
        else if (typefaceName == "Italic")
            s << "juce::Font::italic";
        else
            s << "juce::Font::plain"; // "Regular" に相当

        s << "))";

        if (! approximatelyEqual (font.getExtraKerningFactor(), 0.0f))
            s << ".withExtraKerningFactor ("
              << CodeHelpers::floatLiteral (font.getExtraKerningFactor(), 3)
              << ")";

        return s;
    }

```

HTH.
