alexheretic / glyph-brush

Fast GPU cached text rendering
Apache License 2.0
673 stars 52 forks source link

glyph_brush_layout: Options for Text Tracking and Line Height #132

Open anlumo opened 3 years ago

anlumo commented 3 years ago

Is there a chance that the layouting could allow adjusting the tracking (changing glyph spacing after kerning) and line height?

I guess I can try adjusting those by scaling X/Y of the glyph positions after layouting, but I'm afraid that it might break the layout in some way (for example if there are some glyphs that should stick together, like combining characters).

alexheretic commented 3 years ago

Yes I think it would be nice to support this.

Perhaps having configurable tracking & line-height adjustment values per "section".

pub struct SectionText<'a> {
    pub text: &'a str,
    pub scale: PxScale,
    pub font_id: FontId,
    pub tracking_adjust: f32, // new 
    pub line_height_adjust: f32, // new
}

Would something like that work?

anlumo commented 3 years ago

Yes, that would be great!

Ideally, line_height_adjust would be a scaling factor to the regular line height of the chosen font. So, 1 would be the default, 2 would be double line height, etc.

alexheretic commented 3 years ago

I'd like them to behave as least surprisingly as possible. GIMP calls these "letter spacing" & "line spacing", they both seem to be floating point pixel values. So line-spacing 1.5 means +1.5px. They might be better/more intuitive names too, I'm not sure.

pub letter_spacing: f32,
pub line_spacing: f32,
mattzque commented 1 year ago

Is there any update on this? I was looking for line spacing adjustment in bevy which uses this library I believe.

alexheretic commented 1 year ago

I believe the next step here would be a concrete PR proposal.