class_resourceimporterdynamicfont.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/ResourceImporterDynamicFont.xml.
  6. .. _class_ResourceImporterDynamicFont:
  7. ResourceImporterDynamicFont
  8. ===========================
  9. **Inherits:** :ref:`ResourceImporter<class_ResourceImporter>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Imports a TTF, TTC, OTF, OTC, WOFF or WOFF2 font file for font rendering that adapts to any size.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Unlike bitmap fonts, dynamic fonts can be resized to any size and still look crisp. Dynamic fonts also optionally support MSDF font rendering, which allows for run-time scale changes with no re-rasterization cost.
  15. While WOFF and especially WOFF2 tend to result in smaller file sizes, there is no universally "better" font format. In most situations, it's recommended to use the font format that was shipped on the font developer's website.
  16. See also :ref:`ResourceImporterBMFont<class_ResourceImporterBMFont>` and :ref:`ResourceImporterImageFont<class_ResourceImporterImageFont>`.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - `Dynamic fonts - Using fonts <../tutorials/ui/gui_using_fonts.html#dynamic-fonts>`__
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  27. | :ref:`bool<class_bool>` | :ref:`allow_system_fallback<class_ResourceImporterDynamicFont_property_allow_system_fallback>` | ``true`` |
  28. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  29. | :ref:`int<class_int>` | :ref:`antialiasing<class_ResourceImporterDynamicFont_property_antialiasing>` | ``1`` |
  30. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`compress<class_ResourceImporterDynamicFont_property_compress>` | ``true`` |
  32. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  33. | :ref:`Array<class_Array>` | :ref:`fallbacks<class_ResourceImporterDynamicFont_property_fallbacks>` | ``[]`` |
  34. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  35. | :ref:`bool<class_bool>` | :ref:`force_autohinter<class_ResourceImporterDynamicFont_property_force_autohinter>` | ``false`` |
  36. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  37. | :ref:`bool<class_bool>` | :ref:`generate_mipmaps<class_ResourceImporterDynamicFont_property_generate_mipmaps>` | ``false`` |
  38. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  39. | :ref:`int<class_int>` | :ref:`hinting<class_ResourceImporterDynamicFont_property_hinting>` | ``1`` |
  40. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  41. | :ref:`Dictionary<class_Dictionary>` | :ref:`language_support<class_ResourceImporterDynamicFont_property_language_support>` | ``{}`` |
  42. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  43. | :ref:`int<class_int>` | :ref:`msdf_pixel_range<class_ResourceImporterDynamicFont_property_msdf_pixel_range>` | ``8`` |
  44. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  45. | :ref:`int<class_int>` | :ref:`msdf_size<class_ResourceImporterDynamicFont_property_msdf_size>` | ``48`` |
  46. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  47. | :ref:`bool<class_bool>` | :ref:`multichannel_signed_distance_field<class_ResourceImporterDynamicFont_property_multichannel_signed_distance_field>` | ``false`` |
  48. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  49. | :ref:`Dictionary<class_Dictionary>` | :ref:`opentype_features<class_ResourceImporterDynamicFont_property_opentype_features>` | ``{}`` |
  50. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  51. | :ref:`float<class_float>` | :ref:`oversampling<class_ResourceImporterDynamicFont_property_oversampling>` | ``0.0`` |
  52. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  53. | :ref:`Array<class_Array>` | :ref:`preload<class_ResourceImporterDynamicFont_property_preload>` | ``[]`` |
  54. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  55. | :ref:`Dictionary<class_Dictionary>` | :ref:`script_support<class_ResourceImporterDynamicFont_property_script_support>` | ``{}`` |
  56. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  57. | :ref:`int<class_int>` | :ref:`subpixel_positioning<class_ResourceImporterDynamicFont_property_subpixel_positioning>` | ``1`` |
  58. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  59. .. rst-class:: classref-section-separator
  60. ----
  61. .. rst-class:: classref-descriptions-group
  62. Property Descriptions
  63. ---------------------
  64. .. _class_ResourceImporterDynamicFont_property_allow_system_fallback:
  65. .. rst-class:: classref-property
  66. :ref:`bool<class_bool>` **allow_system_fallback** = ``true``
  67. If ``true``, automatically use system fonts as a fallback if a glyph isn't found in this dynamic font. This makes supporting CJK characters or emoji more straightforward, as you don't need to include a CJK/emoji font in your project. See also :ref:`fallbacks<class_ResourceImporterDynamicFont_property_fallbacks>`.
  68. \ **Note:** The appearance of system fonts varies across platforms. Loading system fonts is only supported on Windows, macOS, Linux, Android and iOS.
  69. .. rst-class:: classref-item-separator
  70. ----
  71. .. _class_ResourceImporterDynamicFont_property_antialiasing:
  72. .. rst-class:: classref-property
  73. :ref:`int<class_int>` **antialiasing** = ``1``
  74. The font antialiasing method to use.
  75. \ **Disabled:** Most suited for pixel art fonts, although you do not *have* to change the antialiasing from the default **Grayscale** if the font file was well-created and the font is used at an integer multiple of its intended size. If pixel art fonts have a bad appearance at their intended size, try setting :ref:`subpixel_positioning<class_ResourceImporterDynamicFont_property_subpixel_positioning>` to **Disabled** instead.
  76. \ **Grayscale:** Use grayscale antialiasing. This is the approach used by the operating system on macOS, Android and iOS.
  77. \ **LCD Subpixel:** Use antialiasing with subpixel patterns to make fonts sharper on LCD displays. This is the approach used by the operating system on Windows and most Linux distributions. The downside is that this can introduce "fringing" on edges, especially on display technologies that don't use standard RGB subpixels (such as OLED displays). The LCD subpixel layout is globally controlled by :ref:`ProjectSettings.gui/theme/lcd_subpixel_layout<class_ProjectSettings_property_gui/theme/lcd_subpixel_layout>`, which also allows falling back to grayscale antialiasing.
  78. .. rst-class:: classref-item-separator
  79. ----
  80. .. _class_ResourceImporterDynamicFont_property_compress:
  81. .. rst-class:: classref-property
  82. :ref:`bool<class_bool>` **compress** = ``true``
  83. If ``true``, uses lossless compression for the resulting font.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_ResourceImporterDynamicFont_property_fallbacks:
  87. .. rst-class:: classref-property
  88. :ref:`Array<class_Array>` **fallbacks** = ``[]``
  89. List of font fallbacks to use if a glyph isn't found in this dynamic font. Fonts at the beginning of the array are attempted first, but fallback fonts that don't support the glyph's language and script are attempted last (see :ref:`language_support<class_ResourceImporterDynamicFont_property_language_support>` and :ref:`script_support<class_ResourceImporterDynamicFont_property_script_support>`). See also :ref:`allow_system_fallback<class_ResourceImporterDynamicFont_property_allow_system_fallback>`.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_ResourceImporterDynamicFont_property_force_autohinter:
  93. .. rst-class:: classref-property
  94. :ref:`bool<class_bool>` **force_autohinter** = ``false``
  95. If ``true``, forces generation of hinting data for the font using `FreeType <https://freetype.org/>`__'s autohinter. This will make :ref:`hinting<class_ResourceImporterDynamicFont_property_hinting>` effective with fonts that don't include hinting data.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_ResourceImporterDynamicFont_property_generate_mipmaps:
  99. .. rst-class:: classref-property
  100. :ref:`bool<class_bool>` **generate_mipmaps** = ``false``
  101. If ``true``, this font will have mipmaps generated. This prevents text from looking grainy when a :ref:`Control<class_Control>` is scaled down, or when a :ref:`Label3D<class_Label3D>` is viewed from a long distance (if :ref:`Label3D.texture_filter<class_Label3D_property_texture_filter>` is set to a mode that displays mipmaps).
  102. Enabling :ref:`generate_mipmaps<class_ResourceImporterDynamicFont_property_generate_mipmaps>` increases font generation time and memory usage. Only enable this setting if you actually need it.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_ResourceImporterDynamicFont_property_hinting:
  106. .. rst-class:: classref-property
  107. :ref:`int<class_int>` **hinting** = ``1``
  108. The hinting mode to use. This controls how aggressively glyph edges should be snapped to pixels when rasterizing the font. Depending on personal preference, you may prefer using one hinting mode over the other. Hinting modes other than **None** are only effective if the font contains hinting data (see :ref:`force_autohinter<class_ResourceImporterDynamicFont_property_force_autohinter>`).
  109. \ **None:** Smoothest appearance, which can make the font look blurry at small sizes.
  110. \ **Light:** Sharp result by snapping glyph edges to pixels on the Y axis only.
  111. \ **Full:** Sharpest by snapping glyph edges to pixels on both X and Y axes.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_ResourceImporterDynamicFont_property_language_support:
  115. .. rst-class:: classref-property
  116. :ref:`Dictionary<class_Dictionary>` **language_support** = ``{}``
  117. Override the list of languages supported by this font. If left empty, this is supplied by the font metadata. There is usually no need to change this. See also :ref:`script_support<class_ResourceImporterDynamicFont_property_script_support>`.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_ResourceImporterDynamicFont_property_msdf_pixel_range:
  121. .. rst-class:: classref-property
  122. :ref:`int<class_int>` **msdf_pixel_range** = ``8``
  123. The width of the range around the shape between the minimum and maximum representable signed distance. If using font outlines, :ref:`msdf_pixel_range<class_ResourceImporterDynamicFont_property_msdf_pixel_range>` must be set to at least *twice* the size of the largest font outline. The default :ref:`msdf_pixel_range<class_ResourceImporterDynamicFont_property_msdf_pixel_range>` value of ``8`` allows outline sizes up to ``4`` to look correct.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_ResourceImporterDynamicFont_property_msdf_size:
  127. .. rst-class:: classref-property
  128. :ref:`int<class_int>` **msdf_size** = ``48``
  129. Source font size used to generate MSDF textures. Higher values allow for more precision, but are slower to render and require more memory. Only increase this value if you notice a visible lack of precision in glyph rendering. Only effective if :ref:`multichannel_signed_distance_field<class_ResourceImporterDynamicFont_property_multichannel_signed_distance_field>` is ``true``.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_ResourceImporterDynamicFont_property_multichannel_signed_distance_field:
  133. .. rst-class:: classref-property
  134. :ref:`bool<class_bool>` **multichannel_signed_distance_field** = ``false``
  135. If set to ``true``, the default font will use multichannel signed distance field (MSDF) for crisp rendering at any size. Since this approach does not rely on rasterizing the font every time its size changes, this allows for resizing the font in real-time without any performance penalty. Text will also not look grainy for :ref:`Control<class_Control>`\ s that are scaled down (or for :ref:`Label3D<class_Label3D>`\ s viewed from a long distance).
  136. MSDF font rendering can be combined with :ref:`generate_mipmaps<class_ResourceImporterDynamicFont_property_generate_mipmaps>` to further improve font rendering quality when scaled down.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_ResourceImporterDynamicFont_property_opentype_features:
  140. .. rst-class:: classref-property
  141. :ref:`Dictionary<class_Dictionary>` **opentype_features** = ``{}``
  142. The OpenType features to enable, disable or set a value for this font. This can be used to enable optional features provided by the font, such as ligatures or alternative glyphs. The list of supported OpenType features varies on a per-font basis.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_ResourceImporterDynamicFont_property_oversampling:
  146. .. rst-class:: classref-property
  147. :ref:`float<class_float>` **oversampling** = ``0.0``
  148. If set to a value greater than ``0.0``, overrides the oversampling factor for the font. This can be used to render the font at a higher or lower resolution than intended without affecting its physical size. In most cases, this should be left at ``0.0``.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_ResourceImporterDynamicFont_property_preload:
  152. .. rst-class:: classref-property
  153. :ref:`Array<class_Array>` **preload** = ``[]``
  154. The glyph ranges to prerender. This can avoid stuttering during gameplay when new characters need to be rendered, especially if :ref:`subpixel_positioning<class_ResourceImporterDynamicFont_property_subpixel_positioning>` is enabled. The downside of using preloading is that initial project load times will increase, as well as memory usage.
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_ResourceImporterDynamicFont_property_script_support:
  158. .. rst-class:: classref-property
  159. :ref:`Dictionary<class_Dictionary>` **script_support** = ``{}``
  160. Override the list of language scripts supported by this font. If left empty, this is supplied by the font metadata. There is usually no need to change this. See also :ref:`language_support<class_ResourceImporterDynamicFont_property_language_support>`.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_ResourceImporterDynamicFont_property_subpixel_positioning:
  164. .. rst-class:: classref-property
  165. :ref:`int<class_int>` **subpixel_positioning** = ``1``
  166. Subpixel positioning improves font rendering appearance, especially at smaller font sizes. The downside is that it takes more time to initially render the font, which can cause stuttering during gameplay, especially if used with large font sizes. This should be set to **Disabled** for fonts with a pixel art appearance.
  167. \ **Disabled:** No subpixel positioning. Lowest quality, fastest rendering.
  168. \ **Auto:** Use subpixel positioning at small font sizes (the chosen quality varies depending on font size). Large fonts will not use subpixel positioning. This is a good tradeoff between performance and quality.
  169. \ **One Half of a Pixel:** Always perform intermediate subpixel positioning regardless of font size. High quality, slow rendering.
  170. \ **One Quarter of a Pixel:** Always perform precise subpixel positioning regardless of font size. Highest quality, slowest rendering.
  171. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  172. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  173. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  174. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  175. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  176. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  177. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`