# \[BR\] Incorrect typeface name when loading font files

**URL:** <https://forum.juce.com/t/br-incorrect-typeface-name-when-loading-font-files/61583>\
**Category:** General JUCE discussion\
**Created:** [May 29, 2024, 10:52am UTC](https://forum.juce.com/t/br-incorrect-typeface-name-when-loading-font-files/61583 "2024-05-29T10:52:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImJimmi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/imjimmi/32/10843_2.png) [@ImJimmi](https://forum.juce.com/u/ImJimmi)\
**Post date:** [May 29, 2024, 10:52am UTC](https://forum.juce.com/t/br-incorrect-typeface-name-when-loading-font-files/61583/1 "2024-05-29T10:52:12Z")

</div>

Creating a `juce::Typeface` from a static font file using `juce::Typeface::createSystemTypefaceFor()` results in the typeface name including the font’s style.

E.g.

```cpp
const auto notoSansJP = juce::Typeface::createSystemTypefaceFor (NotoSansJPRegular_ttf, NotoSansJPRegular_ttfSize);
DBG(notoSansJP->getName());

```

Outputs:

```auto
Noto Sans JP Regular

```

This has a knock-on effect on Windows where a `juce::WindowsDirectWriteTypeface` fails to load the font as `IDWriteFontCollection::FindFamilyName()` ([here](https://github.com/juce-framework/JUCE/blob/4f43011b96eb0636104cb3e433894cda98243626/modules/juce_graphics/native/juce_DirectWriteTypeface_windows.cpp#L154)) is expecting just the family name (i.e. it expects `"Noto Sans JP"`, not `"Noto Sans JP Regular"`).

For non-latin fonts, this means `juce::TextLayout` fails to create a native layout and so tries to create the layout itself which appears to be very flawed.

---

<div class="post-metadata">

**Author:** ![ibisum](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ibisum/32/21288_2.png) [@ibisum](https://forum.juce.com/u/ibisum)\
**Post date:** [May 29, 2024, 11:13am UTC](https://forum.juce.com/t/br-incorrect-typeface-name-when-loading-font-files/61583/2 "2024-05-29T11:13:15Z")

</div>

I think the guilty party is “ **TTFNameExtractor** ”, and its a Windows thing, because on MacOS it seems Name and Style are treated uniquely, whereas on Windows some hack is required to get the name … although I don’t see where the Style is being globbed into the string, so it could also be Font-specific? Does it do this with all fonts?

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [May 29, 2024, 11:47am UTC](https://forum.juce.com/t/br-incorrect-typeface-name-when-loading-font-files/61583/3 "2024-05-29T11:47:33Z")

</div>

> [@ImJimmi](#):
>
> Creating a `juce::Typeface` from a static font file using `juce::Typeface::createSystemTypefaceFor()` results in the typeface name including the font’s style.

Lots has changed in the font handling on the JUCE 8 branch, especially around fonts loaded from memory on Windows, so I’d recommend upgrading and testing again. At this point we’re only fixing critical bugs on the JUCE 7 branch.

> [@ImJimmi](#):
>
> For non-latin fonts, this means `juce::TextLayout` fails to create a native layout and so tries to create the layout itself which appears to be very flawed.

JUCE 8 uses HarfBuzz for text shaping, and will remove the support for DirectWrite and CoreText ‘native’ layouts. This means that the same text shaping engine will be used on all platforms, improving layout consistency. At time of writing, only GlyphArrangement has been updated to use the new HarfBuzz shaper, and TextLayout is yet to be updated, though I expect this change to be made public in a few days.

---

<div class="post-metadata">

**Author:** ![ImJimmi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/imjimmi/32/10843_2.png) [@ImJimmi](https://forum.juce.com/u/ImJimmi)\
**Post date:** [May 29, 2024, 12:51pm UTC](https://forum.juce.com/t/br-incorrect-typeface-name-when-loading-font-files/61583/4 "2024-05-29T12:51:39Z")

</div>

Yeah I thought that might be the case! Gave it a quick spin on JUCE 8 and it looks like `juce::Typeface::getName()` is correctly only giving the font family name (on macOS, with the handful of font’s we’re using, at least).
