mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-01 00:17:27 +03:00 
			
		
		
		
	Merge pull request #5155 from nulano/sbix
This commit is contained in:
		
						commit
						8accaf0259
					
				
							
								
								
									
										2
									
								
								.github/workflows/test-windows.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/test-windows.yml
									
									
									
									
										vendored
									
									
								
							|  | @ -110,7 +110,7 @@ jobs: | ||||||
|       if: steps.build-cache.outputs.cache-hit != 'true' |       if: steps.build-cache.outputs.cache-hit != 'true' | ||||||
|       run: "& winbuild\\build\\build_dep_libwebp.cmd" |       run: "& winbuild\\build\\build_dep_libwebp.cmd" | ||||||
| 
 | 
 | ||||||
|     # for FreeType CBDT font support |     # for FreeType CBDT/SBIX font support | ||||||
|     - name: Build dependencies / libpng |     - name: Build dependencies / libpng | ||||||
|       if: steps.build-cache.outputs.cache-hit != 'true' |       if: steps.build-cache.outputs.cache-hit != 'true' | ||||||
|       run: "& winbuild\\build\\build_dep_libpng.cmd" |       run: "& winbuild\\build\\build_dep_libpng.cmd" | ||||||
|  |  | ||||||
|  | @ -15,6 +15,8 @@ FreeMono.ttf is licensed under GPLv3, with the GPL font exception. | ||||||
| 
 | 
 | ||||||
| OpenSansCondensed-LightItalic.tt, from https://fonts.google.com/specimen/Open+Sans, under Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | OpenSansCondensed-LightItalic.tt, from https://fonts.google.com/specimen/Open+Sans, under Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||||||
| 
 | 
 | ||||||
|  | chromacheck-sbix.woff, from https://github.com/RoelN/ChromaCheck, under The MIT License (MIT), Copyright (c) 2018 Roel Nieskens, https://pixelambacht.nl Copyright (c) 2018 Google LLC | ||||||
|  | 
 | ||||||
| KhmerOSBattambang-Regular.ttf is licensed under LGPL-2.1 or later. | KhmerOSBattambang-Regular.ttf is licensed under LGPL-2.1 or later. | ||||||
| 
 | 
 | ||||||
| FreeMono.ttf is licensed under GPLv3. | FreeMono.ttf is licensed under GPLv3. | ||||||
|  |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								Tests/fonts/chromacheck-sbix.woff
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/fonts/chromacheck-sbix.woff
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Tests/images/chromacheck-sbix.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/chromacheck-sbix.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.4 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Tests/images/chromacheck-sbix_mask.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Tests/images/chromacheck-sbix_mask.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.4 KiB | 
|  | @ -869,12 +869,12 @@ class TestImageFont: | ||||||
|             im = Image.new("RGB", (150, 150), "white") |             im = Image.new("RGB", (150, 150), "white") | ||||||
|             d = ImageDraw.Draw(im) |             d = ImageDraw.Draw(im) | ||||||
| 
 | 
 | ||||||
|             d.text((10, 10), "\U0001f469", embedded_color=True, font=font) |             d.text((10, 10), "\U0001f469", font=font, embedded_color=True) | ||||||
| 
 | 
 | ||||||
|             assert_image_similar_tofile(im, "Tests/images/cbdt_notocoloremoji.png", 6.2) |             assert_image_similar_tofile(im, "Tests/images/cbdt_notocoloremoji.png", 6.2) | ||||||
|         except IOError as e: |         except IOError as e:  # pragma: no cover | ||||||
|             assert str(e) in ("unimplemented feature", "unknown file format") |             assert str(e) in ("unimplemented feature", "unknown file format") | ||||||
|             pytest.skip("freetype compiled without libpng or unsupported") |             pytest.skip("freetype compiled without libpng or CBDT support") | ||||||
| 
 | 
 | ||||||
|     @skip_unless_feature_version("freetype2", "2.5.0") |     @skip_unless_feature_version("freetype2", "2.5.0") | ||||||
|     def test_cbdt_mask(self): |     def test_cbdt_mask(self): | ||||||
|  | @ -893,9 +893,47 @@ class TestImageFont: | ||||||
|             assert_image_similar_tofile( |             assert_image_similar_tofile( | ||||||
|                 im, "Tests/images/cbdt_notocoloremoji_mask.png", 6.2 |                 im, "Tests/images/cbdt_notocoloremoji_mask.png", 6.2 | ||||||
|             ) |             ) | ||||||
|         except IOError as e: |         except IOError as e:  # pragma: no cover | ||||||
|             assert str(e) in ("unimplemented feature", "unknown file format") |             assert str(e) in ("unimplemented feature", "unknown file format") | ||||||
|             pytest.skip("freetype compiled without libpng or unsupported") |             pytest.skip("freetype compiled without libpng or CBDT support") | ||||||
|  | 
 | ||||||
|  |     @skip_unless_feature_version("freetype2", "2.5.1") | ||||||
|  |     def test_sbix(self): | ||||||
|  |         try: | ||||||
|  |             font = ImageFont.truetype( | ||||||
|  |                 "Tests/fonts/chromacheck-sbix.woff", | ||||||
|  |                 size=300, | ||||||
|  |                 layout_engine=self.LAYOUT_ENGINE, | ||||||
|  |             ) | ||||||
|  | 
 | ||||||
|  |             im = Image.new("RGB", (400, 400), "white") | ||||||
|  |             d = ImageDraw.Draw(im) | ||||||
|  | 
 | ||||||
|  |             d.text((50, 50), "\uE901", font=font, embedded_color=True) | ||||||
|  | 
 | ||||||
|  |             assert_image_similar_tofile(im, "Tests/images/chromacheck-sbix.png", 1) | ||||||
|  |         except IOError as e:  # pragma: no cover | ||||||
|  |             assert str(e) in ("unimplemented feature", "unknown file format") | ||||||
|  |             pytest.skip("freetype compiled without libpng or SBIX support") | ||||||
|  | 
 | ||||||
|  |     @skip_unless_feature_version("freetype2", "2.5.1") | ||||||
|  |     def test_sbix_mask(self): | ||||||
|  |         try: | ||||||
|  |             font = ImageFont.truetype( | ||||||
|  |                 "Tests/fonts/chromacheck-sbix.woff", | ||||||
|  |                 size=300, | ||||||
|  |                 layout_engine=self.LAYOUT_ENGINE, | ||||||
|  |             ) | ||||||
|  | 
 | ||||||
|  |             im = Image.new("RGB", (400, 400), "white") | ||||||
|  |             d = ImageDraw.Draw(im) | ||||||
|  | 
 | ||||||
|  |             d.text((50, 50), "\uE901", (100, 0, 0), font=font) | ||||||
|  | 
 | ||||||
|  |             assert_image_similar_tofile(im, "Tests/images/chromacheck-sbix_mask.png", 1) | ||||||
|  |         except IOError as e:  # pragma: no cover | ||||||
|  |             assert str(e) in ("unimplemented feature", "unknown file format") | ||||||
|  |             pytest.skip("freetype compiled without libpng or SBIX support") | ||||||
| 
 | 
 | ||||||
|     @skip_unless_feature_version("freetype2", "2.10.0") |     @skip_unless_feature_version("freetype2", "2.10.0") | ||||||
|     def test_colr(self): |     def test_colr(self): | ||||||
|  | @ -908,7 +946,7 @@ class TestImageFont: | ||||||
|         im = Image.new("RGB", (300, 75), "white") |         im = Image.new("RGB", (300, 75), "white") | ||||||
|         d = ImageDraw.Draw(im) |         d = ImageDraw.Draw(im) | ||||||
| 
 | 
 | ||||||
|         d.text((15, 5), "Bungee", embedded_color=True, font=font) |         d.text((15, 5), "Bungee", font=font, embedded_color=True) | ||||||
| 
 | 
 | ||||||
|         assert_image_similar_tofile(im, "Tests/images/colr_bungee.png", 21) |         assert_image_similar_tofile(im, "Tests/images/colr_bungee.png", 21) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -352,7 +352,7 @@ Methods | ||||||
| 
 | 
 | ||||||
|         .. versionadded:: 6.2.0 |         .. versionadded:: 6.2.0 | ||||||
| 
 | 
 | ||||||
|     :param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT). |     :param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX). | ||||||
| 
 | 
 | ||||||
|                     .. versionadded:: 8.0.0 |                     .. versionadded:: 8.0.0 | ||||||
| 
 | 
 | ||||||
|  | @ -413,7 +413,7 @@ Methods | ||||||
| 
 | 
 | ||||||
|                      .. versionadded:: 6.2.0 |                      .. versionadded:: 6.2.0 | ||||||
| 
 | 
 | ||||||
|     :param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT). |     :param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX). | ||||||
| 
 | 
 | ||||||
|                      .. versionadded:: 8.0.0 |                      .. versionadded:: 8.0.0 | ||||||
| 
 | 
 | ||||||
|  | @ -577,7 +577,7 @@ Methods | ||||||
|                      correct substitutions as appropriate, if available. |                      correct substitutions as appropriate, if available. | ||||||
|                      It should be a `BCP 47 language code`_. |                      It should be a `BCP 47 language code`_. | ||||||
|                      Requires libraqm. |                      Requires libraqm. | ||||||
|     :param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT). |     :param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX). | ||||||
| 
 | 
 | ||||||
| .. py:method:: ImageDraw.textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False) | .. py:method:: ImageDraw.textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False) | ||||||
| 
 | 
 | ||||||
|  | @ -626,7 +626,7 @@ Methods | ||||||
|                      It should be a `BCP 47 language code`_. |                      It should be a `BCP 47 language code`_. | ||||||
|                      Requires libraqm. |                      Requires libraqm. | ||||||
|     :param stroke_width: The width of the text stroke. |     :param stroke_width: The width of the text stroke. | ||||||
|     :param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT). |     :param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX). | ||||||
| 
 | 
 | ||||||
| .. py:method:: ImageDraw.multiline_textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False) | .. py:method:: ImageDraw.multiline_textbbox(xy, text, font=None, anchor=None, spacing=4, align="left", direction=None, features=None, language=None, stroke_width=0, embedded_color=False) | ||||||
| 
 | 
 | ||||||
|  | @ -669,7 +669,7 @@ Methods | ||||||
|                      It should be a `BCP 47 language code`_. |                      It should be a `BCP 47 language code`_. | ||||||
|                      Requires libraqm. |                      Requires libraqm. | ||||||
|     :param stroke_width: The width of the text stroke. |     :param stroke_width: The width of the text stroke. | ||||||
|     :param embedded_color: Whether to use font embedded color glyphs (COLR or CBDT). |     :param embedded_color: Whether to use font embedded color glyphs (COLR, CBDT, SBIX). | ||||||
| 
 | 
 | ||||||
| .. py:method:: getdraw(im=None, hints=None) | .. py:method:: getdraw(im=None, hints=None) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -115,8 +115,9 @@ now support fonts with embedded color data. | ||||||
| To render text with embedded color data, use the parameter ``embedded_color=True``. | To render text with embedded color data, use the parameter ``embedded_color=True``. | ||||||
| 
 | 
 | ||||||
| Support for CBDT fonts requires FreeType 2.5 compiled with libpng. | Support for CBDT fonts requires FreeType 2.5 compiled with libpng. | ||||||
|  | Support for SBIX fonts requires FreeType 2.5.1 compiled with libpng. | ||||||
| Support for COLR fonts requires FreeType 2.10. | Support for COLR fonts requires FreeType 2.10. | ||||||
| SBIX and SVG fonts are not yet supported. | SVG fonts are not yet supported. | ||||||
| 
 | 
 | ||||||
| ImageDraw.textlength | ImageDraw.textlength | ||||||
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user