1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00
Commit graph

90 commits

Author SHA1 Message Date
Anthony Nicholls
5b0a2b9b80 Font: Cache HarfBuzz fonts and font details 2025-09-25 14:56:34 +01:00
Oliver James
d651f6740c Fonts: Add OpenType feature support 2025-06-17 12:38:20 +01:00
attila
724221081b Change the value returned by Font::getAscentInPoints and getDescentInPoints
Prior to this commit the returned values were always normalised to the
value returned by getHeightInPoints().
I.e. getAscentInPoints() + getDescentInPoints() would always equal
getHeightInPoints(), even if ascent or descent overrides were in place.

With this change in place getAscentInPoints() + getDescentInPoints()
will always equal
getHeightInPoints() * (getAscentOverride() + getDescentOverride())

JUCE classes don't use this value for layout logic, so this commit
causes no visible changes in how JUCE draws text.
2025-05-13 18:32:01 +02:00
reuk
a381fdf81d
Font: Allow overriding typeface ascent and descent metrics 2025-01-29 13:36:28 +00:00
attila
d73b1768a7 Fall back to default sans serif font if resolution would fail otherwise
This restores the JUCE 7 behaviour when the JUCE 8 font fallback
mechanism fails to resolve a non-null Typeface::Ptr. This behaviour is
significant when the base font specified is not available on the system.
2025-01-07 17:29:43 +01:00
attila
ba61c9edb9 Fix crash when no valid Typeface::Ptr can be resolved 2025-01-07 17:29:43 +01:00
Anthony Nicholls
5e803ded5f Deprecations: Add ignore deprecation warning macros 2024-11-27 11:07:04 +00:00
reuk
80ac9a78a0
Singleton: Add new macros to simplify singleton creation
The INLINE macros allow singletons to be declared and defined in one
line, without requiring a separate JUCE_IMPLEMENT_SINGLETON statement.
2024-10-16 10:36:52 +01:00
Tom Poole
0f3bad8152 Font: Avoid a crash on systems with no fonts installed 2024-10-15 14:27:23 +01:00
reuk
29213e07a1
Font: Deprecate getStringWidth and getGlyphPositions 2024-09-18 19:13:09 +01:00
attila
4828bd886d Fix assertion during Font fallback
Since 4122427748 assertions are guarding
the FontOptions::withName, withStyle and withTypeface member functions.

Since then the only way to replace an existing typeface without hitting
these assertions is to clear all three fields before calling
withTypeface, which then sets all three values. It is always legal to
just clear an existing Typeface and rely on the name and style fields.
2024-06-20 08:45:17 +00:00
reuk
4122427748
FontOptions: Add some assertions to warn about misuse 2024-06-11 11:34:04 +01:00
reuk
d69dee0f5b
Font: Return correct result from getStringWidth after setting size in points
Previously, code such as the following would return a smaller string
width for larger tracking values:

    juce::Font f { juce::FontOptions{}.withPointHeight (16.0f) };
    const auto g = f.withExtraKerningFactor (1.0f);

    const auto a = f.getStringWidth ("foobar");
    const auto b = g.getStringWidth ("foobar");

With this change applied, the width 'b' is greater than the width 'a',
as expected.
2024-06-11 11:34:04 +01:00
reuk
6b89bb6f91
Font: Fix result of getDescent(), which was incorrect when font height was set in points 2024-05-20 12:49:56 +01:00
reuk
365e8a235d
Font: Remove unnecessary conversion from point-height to juce-height when using FontOptions 2024-05-20 12:49:56 +01:00
reuk
56d5445f8a
FontOptions: Make it easier to specify font sizes in points 2024-04-29 16:08:22 +01:00
reuk
c5a9e26960
Typeface: Add support for querying the default system UI typeface 2024-04-29 16:08:21 +01:00
reuk
19061e6d17
Direct2D: Add initial support 2024-04-18 14:16:02 +01:00
reuk
c2fce879c5
Font: Allow switching between legacy non-portable metrics, and new portable metrics 2024-04-18 14:16:00 +01:00
reuk
4f2c287f9b
Font: Deprecate old Font constructors 2024-04-18 14:16:00 +01:00
reuk
2ed9b84070
Font: Add new FontOptions type 2024-04-18 14:16:00 +01:00
reuk
d406d51ad0
TypefaceCache: Refactor to make more concise 2024-04-18 14:16:00 +01:00
reuk
6c4c78baac
Typeface: Fix advances for Apple Color Emoji
The glyph spacing for this font does not scale linearly with the font
size; at smaller font sizes, the spacing is relatively larger.

Typeface::getStringWidth, Typeface::getGlyphPositions, and the
equivalent Font member functions now take the font size and horizontal
scale into account when computing advances on Apple platforms.
2024-04-18 14:15:59 +01:00
reuk
a1b23c0248
Font: Add support for querying fallbacks 2024-04-18 14:15:58 +01:00
reuk
0d2e34f34c
Typeface: Implement platform typefaces using Harfbuzz hb_font_t 2024-04-17 14:41:00 +01:00
Tom Poole
94d98a2b10 Update licensing information 2024-04-16 11:39:35 +01:00
Tom Poole
6bf9bb9a2e Add final specifiers in implementation files 2023-10-10 16:12:38 +01:00
Tom Poole
4153d59e39 Formatting 2023-10-02 15:42:20 +01:00
Tom Poole
ff0cb4ad5b Use NullCheckedInvocation in more places 2023-10-02 13:40:10 +01:00
reuk
28414a6af8
Global: Avoid floating-point equality checks where possible 2023-04-04 19:55:11 +01:00
Tom Poole
2ec861d99e Update licensing banners to JUCE 7 2022-05-16 17:55:48 +01:00
Tom Poole
68514d626c Graphics: Added a global GlyphArrangement cache 2022-04-04 12:36:33 +01:00
Tom Poole
dea3fe60e4 Update copyright banners 2022-04-04 12:36:32 +01:00
reuk
3768349a05
Font: Make Font and TypefaceCache threadsafe
Previously, it wasn't safe to access Font instances from multiple
threads because there was a chance that they might reference the same
shared internal state. In this case, calling getTypeface() or getAscent from
two threads simultaneously would cause a race on the typeface and ascent
data members, even though the Font instances appeared to be disjoint.

With this change in place, it is now safe to use Font instances from
multiple threads simultaneously.

It is still an error to modify the same Font instance from multiple
threads without synchronization!

    // Fine:
    Font a;
    Font b = a;

    auto futureA = std::async (std::launch::async, [&a] { /* do something with a */ });
    auto futureB = std::async (std::launch::async, [&b] { /* do something with b */ });

    // Bad idea:
    Font f;

    auto futureA = std::async (std::launch::async, [&f] { /* do something with f */ });
    auto futureB = std::async (std::launch::async, [&f] { /* do something with f */ });
2021-09-23 10:28:47 +01:00
reuk
394c4fd475 Clang: Fix warnings when building with clang 10 2020-07-01 10:00:43 +01:00
ed
009d685179 Updated all license headers 2020-06-29 08:30:22 +01:00
reuk
3a9e26b26c
Font: Fix deadlock in findTypefaceFor 2020-06-11 12:38:11 +01:00
Tom Poole
894e7d2bd2 Updated all license headers 2020-04-23 17:30:39 +01:00
reuk
327f817b9b Copyrights: Update commercial/gpl headers to be gpl-only 2020-04-09 15:22:56 +01:00
ed
eaf0f990d4 Replaced all uses of static_cast<Type&&> with std::move 2018-11-28 17:29:20 +00:00
jules
1e6bbb8da9 Added some methods to allow ReferenceCountedObjectPtrs to be constructed or copied from references as well as pointers - as well as increasing safety, this actually makes things a bit more efficient as it skips a nullptr check. Updated lots of places in the code that could take advantage of this 2018-07-03 11:51:13 +01:00
jules
49aa9c9db4 Added flag JUCE_STRICT_REFCOUNTEDPOINTER which is recommended to avoid accidental leaks when using ref-counted pointers. Enabled this flag in the demo projects, and used it to help tidy up some dubious smart-pointer use 2018-06-26 14:06:52 +01:00
jules
87042769b6 Tidied up some more old typedefs 2018-05-11 14:44:51 +01:00
jules
58a99ff139 Dragged the singleton macros into the 21st century.. Cleaned up their implementation and gave them new upper-case names to match juce official style. The old names are still defined to avoid breaking old code, but please update before they get deprecated! 2017-12-12 16:24:40 +00:00
jules
2fcb8fa71b Added some prototype function definitions to avoid compiler warnings for people who enable the "missing prototype" flag 2017-10-09 15:39:22 +01:00
jules
3d7c777238 Some light modernisation of a bunch of old code 2017-10-04 12:47:43 +01:00
jules
eda613c6db Moved all "namespace juce" declarations from module headers to the individual .h and .cpp source files. This makes life a lot easier for Intellisense and other IDE autocompletion tools 2017-09-08 08:59:55 +01:00
jules
66fa7e7411 Added some assertions to catch use of some Font methods on background threads 2017-07-06 11:45:26 +01:00
hogliux
b5afccc37c Updated file headers and the README with the JUCE 5 license 2017-04-27 14:43:04 +01:00
jules
bf94ab0e4c Made a few minor tweaks to reduce the number of pedantic -Wfloat-equals warnings 2017-04-21 15:09:35 +01:00