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

273 commits

Author SHA1 Message Date
Anthony Nicholls
5b0a2b9b80 Font: Cache HarfBuzz fonts and font details 2025-09-25 14:56:34 +01:00
Anthony Nicholls
c0f164ee28 Text: Cache the display language 2025-09-25 14:56:34 +01:00
Oli
8dc4dcd56b TextLayout: Implement better line balancing algorithm
The previous implementation was unstable when 'by character' line
breaking was used on long lines of text.

Co-authored-by: Tom Poole <tom@juce.com>
2025-08-13 14:20:20 +01:00
Oliver James
7a30354ce9 TextLayout: Enforce character wrapping attribute 2025-08-13 14:20:20 +01:00
Anthony Nicholls
36d07a6ce3 Docs: Replace doxygen preprocessor conditionals with @cond and @endconds 2025-07-21 18:11:43 +02:00
Oliver James
fc80bb29ca GlyphArrangement: Extend glyph bounds to encapsulate ligature characters
Previously, bounds for text with ligatures were miscalculated, leading to
incorrect positioning and getStringWidth values.
2025-07-15 14:01:58 +01:00
Oliver James
d651f6740c Fonts: Add OpenType feature support 2025-06-17 12:38:20 +01:00
reuk
a3d64c7784
Typeface: Enable advanced colour glyph rendering on Android
Android 15+ removed the 'legacy' png-based emoji font. Modern Android
versions may include only a COLR-v1-based font, which JUCE cannot
render itself.

As a workaround, on Android, we use a Canvas object to render each emoji
glyph into a bitmap, and then render that bitmap in the same way as a
legacy png-based glyph. This won't look as crisp as rendering COLRv1
glyphs directly, especially at larger sizes, but this is a sufficient
stop-gap for the time being.
2025-06-16 16:59:55 +01:00
Anthony Nicholls
b6d6ec573d GlyphArrangement: Add documentation tag 2025-06-10 16:13:33 +01:00
reuk
5208b3ffc0
GlyphArrangement: Use portable string trimming 2025-06-03 16:12:00 +01:00
attila
0e4287df52 ShapedTextOptions: Rename maxWidth to wordWrapWidth
The old name didn't communicate it clearly enough what the parameter was
used for. This started to show when alignmentWidth was added.
2025-05-21 17:47:20 +02:00
attila
94fc24e41a iOS: Fix compiling juce_audio_devices when juce_graphics isn't added 2025-05-16 18:08:54 +02: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
attila
283ea12958 Fix addFittedText overflowing the bounds when line spacing and height multiple is non-default 2025-05-13 18:32:01 +02:00
attila
b9458fb240 GlyphArrangementOptions: Add missing JUCE_API annotation 2025-05-13 18:32:01 +02:00
attila
c61158ed3a Add GlyphArrangementOptions for addFittedText and drawFittedText
The new options can be used to affect line spacing.
2025-05-09 13:39:11 +02:00
attila
787f7a4694 Use ShapedTextOptions::withAdditiveLineSpacing where appropriate
After reviewing the NSAttributedString API it seems justified to have
two different functions for additive and multiplicative line spacing
settings. For NSAttributedString they are setLineSpacing and
setLineHeightMultiple.

Using this function, when appropriate, exercises it lessening the
likelihood of code rot.
2025-05-09 13:39:11 +02:00
attila
427852836c ShapedText: Break ligatures into multiple iterable placeholder glyphs 2025-03-13 12:16:16 +01:00
attila
bc093fa64c Ranges: ShapedText: Use out params for improving TextEditor performance 2025-03-13 12:16:16 +01:00
attila
a07098d479 Add ShapedText::getHeight() 2025-03-13 12:16:16 +01:00
attila
2d24504cd1 Change the return type of RangedValues::getIntersectionsWith
This is to avoid converting the returned value to RangedValues at the
call site.
2025-03-13 12:16:16 +01:00
attila
ef840b7472 Use detail::RangedValues<Font> on ShapedText related interfaces
Previously using the FontForRange type was motivated by hiding the
RangedValues type in case we wanted to expose the ShapedText API. This
introduced unnecessary conversions between FontForRange and
RangedValues<Font>.
2025-03-13 12:16:16 +01:00
attila
fab1de34ab Add ShapedText::accessTogetherWith and remove ShapedText::access
Since the original function template has been exposed, we can now use it
directly. Also ShapedText::Detail has been removed, because it wouldn't
work across module boundaries.
2025-03-13 12:16:16 +01:00
attila
1b595311d0 Move ShapedText to the detail namespace and expose it in the headers
This makes it accessible for the new TextEditor implementation in
juce_gui_basics.
2025-03-13 12:16:16 +01: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
ad3457434e SimpleShapedText: Prevent running tests when no default typefaces can be found 2024-12-18 17:55:27 +00:00
attila
9dd8a2af13 Fix SimpleShapedText::getTextRange() when the input text contains hard breaks
The issue prior to this commit would be observable when using the
GlyphArrangement functions e.g. addFittedText.

This is a fix for a regression introduced in
9223805b9c.
2024-12-17 18:27:30 +01:00
attila
6f4a2f6b6a Upgrade to harfbuzz 10.1.0 2024-12-10 13:43:51 +01:00
attila
9223805b9c Refactor shaping to eliminate false soft break points at shaping parameter boundaries
Prior to this a soft break could occur between two characters printed in
different fonts, even though there was no break opportunity there in the
Unicode string.
2024-12-04 16:52:57 +01:00
Anthony Nicholls
5e803ded5f Deprecations: Add ignore deprecation warning macros 2024-11-27 11:07:04 +00:00
無常
a784d5776b TextLayout: Fix getStringBounds of empty strings 2024-10-24 19:40:42 +01:00
attila
82080f9372 ShapedText: Apply the horizontal scaling to the extra kerning
This fixes an undesired behaviour where squashing the text using
GlyphArrangement::addFittedText would only squash the visible glyphs but
not the additional kerning space between them.
2024-10-21 15:34:42 +02:00
attila
8693507ead ShapedText: Apply extra kerning only before clusters
This avoids inserting tracking between glyphs in a single cluster e.g. a
base glyph and diacritic marks.
2024-10-21 15:34:42 +02:00
attila
503788fd0c ShapedText: Fix falsely marking glyphs with missing extent information as whitespace 2024-10-21 15:34:42 +02:00
attila
bd14d47211 SimpleShapedText: Restore and tidy up earlier line breaking logic
This commit isn't fixing any known bugs, but restores the soft break
iteration logic to its state prior to
5e4016b4fb, which accidentally changed it.
2024-10-21 15:34:42 +02:00
attila
b545b79cb3 GlyphArrangement: Make drawFittedText squashing behaviour more similar to JUCE 7
This commit fixes a regression added during the ShapedText based rewrite
of the class. The minimumHorizontalScale parameter was mistakenly
interpreted as an absolute scale, whereas its meaning in the old
implementation was a relative scalar applied to the Font's horizontal
scale.
2024-10-21 15:34:42 +02: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
Anthony Nicholls
0e608f77fa SimpleShapedText: Avoid MSVC compiler bug for C++20 builds
There appears to be a bug in the MSVC compiler relating to cpaturing
a instance of a struct defined inside a lambda
2024-09-20 17:29:05 +01:00
attila
5e4016b4fb GlyphArrangement::addFittedText: Break words across multiple lines if necessary
This behaviour, previously available in JUCE 7, was missing since the
JUCE 8 changes related to Unicode text drawing.

With this commit, words that are too long to fit in a line are again
broken up, with the caveat, that we can expect this approach to produce
quirks with bidirectional text. We don't expect that such a feature
could be satisfactorily provided for bidirectional text, so this is a
stopgap measure for legacy applications.
2024-09-19 15:35:53 +02:00
attila
7cbdd14da9 GlyphArrangement::addFittedText: Fix scaling and squashing behaviour 2024-09-19 15:35:53 +02:00
reuk
29213e07a1
Font: Deprecate getStringWidth and getGlyphPositions 2024-09-18 19:13:09 +01:00
reuk
9076639742
UnicodeBidi: Replace implementation with SheenBidi 2024-09-18 19:13:08 +01:00
reuk
ee8d310e69
ShapedText: Refactor Impl constructor 2024-09-18 19:13:08 +01:00
reuk
a3a4813107
HarfBuzz: Add missing COPYING file 2024-09-18 19:13:08 +01:00
Anthony Nicholls
1dd2b3c90e Formatting: Whitespace 2024-09-06 15:40:39 +00:00
attila
04d9d36b15 TextLayout: Fix ignored AttributedText::getLineSpacing() parameter 2024-07-22 13:16:06 +02:00
reuk
b35688d9a4
SimpleShapedText: Avoid wrapping when WordWrap::none is requested 2024-07-11 18:00:07 +01:00