.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/validation/validate_text_outline.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__gallery_validation_validate_text_outline.py: Text outline always behind text itself ====================================== Example demonstrating the capabilities of text outline to stay behind the text itself, even for very thick value of the outline thickness where the outline of one character may overlap with the neighboring one. .. GENERATED FROM PYTHON SOURCE LINES 9-43 .. image-sg:: /_gallery/validation/images/sphx_glr_validate_text_outline_001.webp :alt: validate text outline :srcset: /_gallery/validation/images/sphx_glr_validate_text_outline_001.webp :class: sphx-glr-single-img .. code-block:: Python from rendercanvas.auto import RenderCanvas, loop import pygfx as gfx scene = gfx.Scene() scene.add(gfx.Background.from_color("#fff", "#000")) text = gfx.Text( text="Hello world", font_size=100, screen_space=True, text_align="right", anchor="middle-center", material=gfx.TextMaterial( color="#DA9DFF", outline_color="#000", # Choose a very thick outline to ensure the effect is noticeable outline_thickness=0.45, aa=False, ), ) scene.add(text) camera = gfx.OrthographicCamera(4, 3) renderer = gfx.renderers.WgpuRenderer(RenderCanvas(size=(800, 600))) renderer.request_draw(lambda: renderer.render(scene, camera)) if __name__ == "__main__": loop.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.245 seconds) .. _sphx_glr_download__gallery_validation_validate_text_outline.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: validate_text_outline.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: validate_text_outline.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: validate_text_outline.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_ .. only:: html Interactive example ------------------- Try this example in your browser using Pyodide. Might not work with all examples and all devices. Check the output and your browser's console for details. .. raw:: html