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

Code before:
                }

                let family: Family = match &text_font.font {
                    FontSource::Handle(handle) => {
                        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,

Review comment (suggestion):
This isn't quite right, I should have been more specific when I wrote up this issue. It's the physical font size that matters, which is the final value that corresponds to size of the glyph images, not the logical font size stored in `TextFont`. If the logical font size is 600 but the user has a HiDPI screen (with a scale factor of 2), then the physical font size could be 1200.

So we need to multiply the logical `text_font.font_size` by the scale factor here, to get a physical font size to use for the comparison:
```suggestion 
                if text_font.font_size * scale_factor as f32 > WARN_FONT_SIZE {
```

Code after:
                }

                let family: Family = match &text_font.font {
                    FontSource::Handle(handle) => {
                        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,