mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Round box position to integer when pasting embedded color
This commit is contained in:
		
							parent
							
								
									4c59f77e37
								
							
						
					
					
						commit
						54b01f55f8
					
				
							
								
								
									
										
											BIN
										
									
								
								Tests/images/standard_embedded_multiline_centered.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/standard_embedded_multiline_centered.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 2.9 KiB  | 
| 
						 | 
					@ -960,6 +960,21 @@ class TestImageFont:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        assert_image_similar_tofile(im, "Tests/images/standard_embedded.png", 6.2)
 | 
					        assert_image_similar_tofile(im, "Tests/images/standard_embedded.png", 6.2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_multiline_centered_embedded_color(self):
 | 
				
			||||||
 | 
					        txt = "Hello\nWorld!"
 | 
				
			||||||
 | 
					        ttf = ImageFont.truetype(FONT_PATH, 40, layout_engine=self.LAYOUT_ENGINE)
 | 
				
			||||||
 | 
					        ttf.getbbox(txt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        im = Image.new("RGB", (160, 96), "white")
 | 
				
			||||||
 | 
					        d = ImageDraw.Draw(im)
 | 
				
			||||||
 | 
					        d.multiline_text(
 | 
				
			||||||
 | 
					            (10, 10), txt, font=ttf, fill="#fa6", align="center", embedded_color=True
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        assert_image_similar_tofile(
 | 
				
			||||||
 | 
					            im, "Tests/images/standard_embedded_multiline_centered.png", 6.2
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_cbdt(self):
 | 
					    def test_cbdt(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            font = ImageFont.truetype(
 | 
					            font = ImageFont.truetype(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -482,6 +482,7 @@ class ImageDraw:
 | 
				
			||||||
                # extract mask and set text alpha
 | 
					                # extract mask and set text alpha
 | 
				
			||||||
                color, mask = mask, mask.getband(3)
 | 
					                color, mask = mask, mask.getband(3)
 | 
				
			||||||
                color.fillband(3, (ink >> 24) & 0xFF)
 | 
					                color.fillband(3, (ink >> 24) & 0xFF)
 | 
				
			||||||
 | 
					                coord = tuple(int(c) for c in coord)
 | 
				
			||||||
                coord2 = coord[0] + mask.size[0], coord[1] + mask.size[1]
 | 
					                coord2 = coord[0] + mask.size[0], coord[1] + mask.size[1]
 | 
				
			||||||
                self.im.paste(color, coord + coord2, mask)
 | 
					                self.im.paste(color, coord + coord2, mask)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user