Repository: bevyengine/bevy
File: crates/bevy_text/src/pipeline.rs (Rust)

Code before:
                        let font = fonts.get(handle.id()).ok_or(TextError::NoSuchFont)?;
                        Family::Name(font.family_name.as_str())
                    }
                    FontSource::Family(family) => Family::Name(family.as_str()),
                    FontSource::Serif => Family::Serif,
                    FontSource::SansSerif => Family::SansSerif,
                    FontSource::Cursive => Family::Cursive,
                    FontSource::Fantasy => Family::Fantasy,
                    FontSource::Monospace => Family::Monospace,
                };

                // Save spans that aren't zero-sized.
                if text_font.font_size <= 0.0 {
                    warn_once!(
                        "Text span {entity} has a font size <= 0.0. Nothing will be displayed.",
                    );

                    continue;
                }

                const WARN_FONT_SIZE: f32 = 1000.0;
                if text_font.font_size > WARN_FONT_SIZE {
                    warn_once!(
                        "Text span {entity} has an excessively large font size ({}). \
                        Font sizes larger than {} will cause performance issues with font atlas \
                        generation and high memory usage.",
                        text_font.font_size,
                        WARN_FONT_SIZE,
                    );
                }

                let attrs = get_attrs(span_index, text_font, line_height, family, scale_factor);

                sections.push((span, attrs));
            }

            // Update the Cosmic Text buffer.
            let cosmic_buffer = &mut computed.buffer;

            // Set the metrics hinting strategy
            cosmic_buffer.set_hinting(font_system, hinting.into());

            cosmic_buffer.set_wrap(
                font_system,
                match linebreak {
                    LineBreak::WordBoundary => Wrap::Word,
                    LineBreak::AnyCharacter => Wrap::Glyph,
                    LineBreak::WordOrCharacter => Wrap::WordOrGlyph,
                    LineBreak::NoWrap => Wrap::None,
                },
            );

Review comment (performance):
This implies that a font size of 1000 is some sort of threshold, but it's just a practical limit beyond which we're choosing to emit this warning. Users may be able to get away with larger font sizes, and they may run into problems with smaller sizes if they generate a lot of glyphs or are running on a system with limited memory. 

```suggestion
                        Extremely large font sizes will cause performance issues with font atlas \
                        generation and high memory usage.",
```



Code after:
                        let font = fonts.get(handle.id()).ok_or(TextError::NoSuchFont)?;
                        Family::Name(font.family_name.as_str())
                    }
                    FontSource::Family(family) => Family::Name(family.as_str()),
                    FontSource::Serif => Family::Serif,
                    FontSource::SansSerif => Family::SansSerif,
                    FontSource::Cursive => Family::Cursive,
                    FontSource::Fantasy => Family::Fantasy,
                    FontSource::Monospace => Family::Monospace,
                };

                // Save spans that aren't zero-sized.
                if text_font.font_size <= 0.0 {
                    warn_once!(
                        "Text span {entity} has a font size <= 0.0. Nothing will be displayed.",
                    );

                    continue;
                }

                const WARN_FONT_SIZE: f32 = 1000.0;
                if text_font.font_size * scale_factor as f32 > WARN_FONT_SIZE {
                    warn_once!(
                        "Text span {entity} has an excessively large font size ({} with scale factor {}). \
                        Extremely large font sizes will cause performance issues with font atlas \
                        generation and high memory usage.",
                        text_font.font_size,
                        scale_factor,
                    );
                }

                let attrs = get_attrs(span_index, text_font, line_height, family, scale_factor);

                sections.push((span, attrs));
            }

            // Update the Cosmic Text buffer.
            let cosmic_buffer = &mut computed.buffer;

            // Set the metrics hinting strategy
            cosmic_buffer.set_hinting(font_system, hinting.into());

            cosmic_buffer.set_wrap(
                font_system,
                match linebreak {
                    LineBreak::WordBoundary => Wrap::Word,
                    LineBreak::AnyCharacter => Wrap::Glyph,
                    LineBreak::WordOrCharacter => Wrap::WordOrGlyph,
                    LineBreak::NoWrap => Wrap::None,
                },
            );