@@ -1520,25 +1520,26 @@ impl<'a, T: ProcessScene> SceneBuilder<'a, T> {
1520
1520
} ;
1521
1521
let geometry = clipped_target. translate ( offset) . round ( ) ;
1522
1522
let origin = ( geometry. origin - offset. round ( ) ) . round ( ) . cast :: < i16 > ( ) ;
1523
- let actual_x = ( origin. x - target_rect. origin . x as i16 ) as usize ;
1524
- let actual_y = ( origin. y - target_rect. origin . y as i16 ) as usize ;
1523
+ let off_x = origin. x - target_rect. origin . x as i16 ;
1524
+ let off_y = origin. y - target_rect. origin . y as i16 ;
1525
1525
let pixel_stride = glyph. pixel_stride ;
1526
1526
let mut geometry = geometry. cast ( ) ;
1527
- if geometry. size . width > glyph. width . get ( ) - ( actual_x as i16 ) {
1528
- geometry. size . width = glyph. width . get ( ) - ( actual_x as i16 )
1527
+ if geometry. size . width > glyph. width . get ( ) - off_x {
1528
+ geometry. size . width = glyph. width . get ( ) - off_x
1529
1529
}
1530
- if geometry. size . height > glyph. height . get ( ) - ( actual_y as i16 ) {
1531
- geometry. size . height = glyph. height . get ( ) - ( actual_y as i16 )
1530
+ if geometry. size . height > glyph. height . get ( ) - off_y {
1531
+ geometry. size . height = glyph. height . get ( ) - off_y
1532
1532
}
1533
1533
let source_size = geometry. size ;
1534
1534
if source_size. is_empty ( ) {
1535
1535
continue ;
1536
1536
}
1537
+
1537
1538
match & glyph. alpha_map {
1538
1539
fonts:: GlyphAlphaMap :: Static ( data) => {
1539
1540
let texture = if !glyph. sdf {
1540
1541
SceneTexture {
1541
- data : & data [ actual_x + actual_y * pixel_stride as usize .. ] ,
1542
+ data,
1542
1543
pixel_stride,
1543
1544
format : PixelFormat :: AlphaMap ,
1544
1545
extra : SceneTextureExtra {
@@ -1548,8 +1549,8 @@ impl<'a, T: ProcessScene> SceneBuilder<'a, T> {
1548
1549
rotation : self . rotation . orientation ,
1549
1550
dx : Fixed :: from_integer ( 1 ) ,
1550
1551
dy : Fixed :: from_integer ( 1 ) ,
1551
- off_x : Fixed :: from_integer ( 0 ) ,
1552
- off_y : Fixed :: from_integer ( 0 ) ,
1552
+ off_x : Fixed :: from_integer ( off_x as u16 ) ,
1553
+ off_y : Fixed :: from_integer ( off_y as u16 ) ,
1553
1554
} ,
1554
1555
}
1555
1556
} else {
@@ -1558,12 +1559,10 @@ impl<'a, T: ProcessScene> SceneBuilder<'a, T> {
1558
1559
let dy = Fixed :: from_integer (
1559
1560
( data. len ( ) as u16 - 1 ) / pixel_stride - 1 ,
1560
1561
) / ( glyph. height . get ( ) as u16 - 1 ) ;
1561
- let off_x = Fixed :: < i32 , 8 > :: from_fixed ( dx)
1562
- * ( clipped_target. origin . x - target_rect. origin . x ) as i32 ;
1563
- let off_y = Fixed :: < i32 , 8 > :: from_fixed ( dy)
1564
- * ( clipped_target. origin . y - target_rect. origin . y ) as i32 ;
1562
+ let off_x = Fixed :: < i32 , 8 > :: from_fixed ( dx) * off_x as i32 ;
1563
+ let off_y = Fixed :: < i32 , 8 > :: from_fixed ( dy) * off_y as i32 ;
1565
1564
SceneTexture {
1566
- data : data ,
1565
+ data,
1567
1566
pixel_stride,
1568
1567
format : PixelFormat :: SignedDistanceField ,
1569
1568
extra : SceneTextureExtra {
@@ -1589,19 +1588,16 @@ impl<'a, T: ProcessScene> SceneBuilder<'a, T> {
1589
1588
data : data. clone ( ) ,
1590
1589
width : pixel_stride,
1591
1590
} ,
1592
- source_rect : PhysicalRect :: new (
1593
- PhysicalPoint :: new ( actual_x as _ , actual_y as _ ) ,
1594
- source_size,
1595
- ) ,
1591
+ source_rect : PhysicalRect :: from_size ( source_size) ,
1596
1592
extra : SceneTextureExtra {
1597
1593
colorize : color,
1598
1594
// color already is mixed with global alpha
1599
1595
alpha : color. alpha ( ) ,
1600
1596
rotation : self . rotation . orientation ,
1601
1597
dx : Fixed :: from_integer ( 1 ) ,
1602
1598
dy : Fixed :: from_integer ( 1 ) ,
1603
- off_x : Fixed :: from_integer ( 0 ) ,
1604
- off_y : Fixed :: from_integer ( 0 ) ,
1599
+ off_x : Fixed :: from_integer ( off_x as u16 ) ,
1600
+ off_y : Fixed :: from_integer ( off_y as u16 ) ,
1605
1601
} ,
1606
1602
} ,
1607
1603
) ;
0 commit comments