mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +03:00 
			
		
		
		
	Added multiline text example [ci skip]
This commit is contained in:
		
							parent
							
								
									27e8592298
								
							
						
					
					
						commit
						b2f187c4ec
					
				| 
						 | 
					@ -100,6 +100,25 @@ Example: Draw Partial Opacity Text
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    out.show()
 | 
					    out.show()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Example: Draw Multiline Text
 | 
				
			||||||
 | 
					----------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. code-block:: python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    from PIL import Image, ImageDraw, ImageFont
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # create an image
 | 
				
			||||||
 | 
					    out = Image.new("RGB", (150, 100), (255, 255, 255))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # get a font
 | 
				
			||||||
 | 
					    fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40)
 | 
				
			||||||
 | 
					    # get a drawing context
 | 
				
			||||||
 | 
					    d = ImageDraw.Draw(out)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # draw multiline text
 | 
				
			||||||
 | 
					    d.multiline_text((10,10), "Hello\nWorld", font=fnt, fill=(0, 0, 0))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    out.show()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Functions
 | 
					Functions
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user