@@ -10,7 +10,7 @@ use glyphon::{
1010use log:: warn;
1111use wgpu:: { Device , Queue , include_wgsl, util:: DeviceExt } ;
1212
13- use crate :: text:: { PreparedText , StaggerEdge , stagger_alpha} ;
13+ use crate :: text:: { PreparedText , REFERENCE_HEIGHT , StaggerEdge , stagger_alpha} ;
1414
1515#[ derive( PartialEq ) ]
1616struct ShapeKey {
@@ -507,7 +507,7 @@ impl TextLayer {
507507 // the editor genuinely wrapped too.
508508 let output_width = output_px[ 0 ] ;
509509 let wrap_width = if width < output_width * 0.98 {
510- ( width * 1.05 + 4.0 ) . min ( output_width. max ( width) )
510+ ( width * 1.05 + 4.0 * output_px [ 1 ] / REFERENCE_HEIGHT ) . min ( output_width. max ( width) )
511511 } else {
512512 width
513513 } ;
@@ -1015,6 +1015,26 @@ mod gpu_tests {
10151015 pixels[ index..index + 4 ] . try_into ( ) . unwrap ( )
10161016 }
10171017
1018+ #[ test]
1019+ #[ ignore = "requires a working wgpu adapter" ]
1020+ fn text_wrap_width_scales_with_output_resolution ( ) {
1021+ let ( device, queue) = device ( ) . expect ( "A working wgpu adapter is required for this test" ) ;
1022+ let mut layer = TextLayer :: new ( & device, & queue) ;
1023+ let mut overlay = text ( [ 100.0 , 100.0 , 600.0 , 300.0 ] , [ 0.0 ; 4 ] ) ;
1024+ overlay. background_color = None ;
1025+ overlay. content = "A line of text near the wrap boundary" . to_string ( ) ;
1026+
1027+ layer. prepare ( & device, & queue, ( 1920 , 1080 ) , & [ overlay. clone ( ) ] ) ;
1028+ let width_1080 = layer. buffers [ 0 ] . size ( ) . 0 . unwrap ( ) ;
1029+
1030+ overlay. bounds = [ 200.0 , 200.0 , 1200.0 , 600.0 ] ;
1031+ overlay. font_size *= 2.0 ;
1032+ layer. prepare ( & device, & queue, ( 3840 , 2160 ) , & [ overlay] ) ;
1033+ let width_2160 = layer. buffers [ 0 ] . size ( ) . 0 . unwrap ( ) ;
1034+
1035+ assert_eq ! ( width_2160, width_1080 * 2.0 ) ;
1036+ }
1037+
10181038 #[ test]
10191039 #[ ignore = "requires a working wgpu adapter" ]
10201040 fn reused_shaping_renders_exactly_like_fresh_shaping_and_follows_edits ( ) {
0 commit comments