kulkalkul / bevy_mod_billboard

Billboard text and texture support for bevy
Apache License 2.0
89 stars 14 forks source link

Unable to use multiple fonts in a BillboardTextBundle #27

Open picoHz opened 3 months ago

picoHz commented 3 months ago

When I use different fonts in each section, only one font is displayed, seemingly depending on the loading order. For example, the following code displays either "IMPORTANT" or "text".

fn setup_billboard(mut commands: Commands, asset_server: Res<AssetServer>) {
    let fira_sans_regular_handle = asset_server.load("FiraSans-Regular.ttf");
    let jersey_20_regular_handle = asset_server.load("Jersey20-Regular.ttf");
    commands.spawn(BillboardTextBundle {
        transform: Transform::from_scale(Vec3::splat(0.0085)),
        text: Text::from_sections([
            TextSection {
                value: "IMPORTANT".to_string(),
                style: TextStyle {
                    font_size: 60.0,
                    font: fira_sans_regular_handle.clone(),
                    color: Color::ORANGE,
                },
            },
            TextSection {
                value: " text".to_string(),
                style: TextStyle {
                    font_size: 60.0,
                    font: jersey_20_regular_handle.clone(),
                    color: Color::WHITE,
                },
            },
        ])
        .with_justify(JustifyText::Center),
        ..default()
    });
}
bevy_mod_billboard
kulkalkul commented 3 months ago

Yup, I can reproduce this easily. I investigated for an hour, I know the reason but workarounds I tried didn't work out. image

So, here, I do 1:N mapping of entity -> render world entity. There is a bug there, where I overwrite the same entity because it is insert_or_spawn_batch. Changing it to spawn_batch doesn't help, there are two theories I have regarding that:

In any case I'm stuck. I'm leaning more into the first case, if that's the case, I think maybe there is a workaround. So I'll be asking that in bevy #rendering channel.

kulkalkul commented 3 months ago

I was wrong, I think I figured the real reason: visible entities. It is the thing that has mismatch. Though I don't know how to solve it for 1:N case without causing any extra indirections. I might check it out during 0.14 upgrade, though no promises. Have to much work, so little time, sorry!