class_resourceimporterdynamicfont.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/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:`bool<class_bool>` | :ref:`disable_embedded_bitmaps<class_ResourceImporterDynamicFont_property_disable_embedded_bitmaps>` | ``true`` |
  34. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  35. | :ref:`Array<class_Array>` | :ref:`fallbacks<class_ResourceImporterDynamicFont_property_fallbacks>` | ``[]`` |
  36. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  37. | :ref:`bool<class_bool>` | :ref:`force_autohinter<class_ResourceImporterDynamicFont_property_force_autohinter>` | ``false`` |
  38. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  39. | :ref:`bool<class_bool>` | :ref:`generate_mipmaps<class_ResourceImporterDynamicFont_property_generate_mipmaps>` | ``false`` |
  40. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  41. | :ref:`int<class_int>` | :ref:`hinting<class_ResourceImporterDynamicFont_property_hinting>` | ``1`` |
  42. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  43. | :ref:`Dictionary<class_Dictionary>` | :ref:`language_support<class_ResourceImporterDynamicFont_property_language_support>` | ``{}`` |
  44. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  45. | :ref:`int<class_int>` | :ref:`msdf_pixel_range<class_ResourceImporterDynamicFont_property_msdf_pixel_range>` | ``8`` |
  46. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  47. | :ref:`int<class_int>` | :ref:`msdf_size<class_ResourceImporterDynamicFont_property_msdf_size>` | ``48`` |
  48. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  49. | :ref:`bool<class_bool>` | :ref:`multichannel_signed_distance_field<class_ResourceImporterDynamicFont_property_multichannel_signed_distance_field>` | ``false`` |
  50. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  51. | :ref:`Dictionary<class_Dictionary>` | :ref:`opentype_features<class_ResourceImporterDynamicFont_property_opentype_features>` | ``{}`` |
  52. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  53. | :ref:`float<class_float>` | :ref:`oversampling<class_ResourceImporterDynamicFont_property_oversampling>` | ``0.0`` |
  54. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  55. | :ref:`Array<class_Array>` | :ref:`preload<class_ResourceImporterDynamicFont_property_preload>` | ``[]`` |
  56. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  57. | :ref:`Dictionary<class_Dictionary>` | :ref:`script_support<class_ResourceImporterDynamicFont_property_script_support>` | ``{}`` |
  58. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  59. | :ref:`int<class_int>` | :ref:`subpixel_positioning<class_ResourceImporterDynamicFont_property_subpixel_positioning>` | ``4`` |
  60. +-------------------------------------+--------------------------------------------------------------------------------------------------------------------------+-----------+
  61. .. rst-class:: classref-section-separator
  62. ----
  63. .. rst-class:: classref-descriptions-group
  64. Property Descriptions
  65. ---------------------
  66. .. _class_ResourceImporterDynamicFont_property_allow_system_fallback:
  67. .. rst-class:: classref-property
  68. :ref:`bool<class_bool>` **allow_system_fallback** = ``true`` :ref:`🔗<class_ResourceImporterDynamicFont_property_allow_system_fallback>`
  69. 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>`.
  70. \ **Note:** The appearance of system fonts varies across platforms. Loading system fonts is only supported on Windows, macOS, Linux, Android and iOS.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_ResourceImporterDynamicFont_property_antialiasing:
  74. .. rst-class:: classref-property
  75. :ref:`int<class_int>` **antialiasing** = ``1`` :ref:`🔗<class_ResourceImporterDynamicFont_property_antialiasing>`
  76. The font antialiasing method to use.
  77. \ **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.
  78. \ **Grayscale:** Use grayscale antialiasing. This is the approach used by the operating system on macOS, Android and iOS.
  79. \ **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.
  80. .. rst-class:: classref-item-separator
  81. ----
  82. .. _class_ResourceImporterDynamicFont_property_compress:
  83. .. rst-class:: classref-property
  84. :ref:`bool<class_bool>` **compress** = ``true`` :ref:`🔗<class_ResourceImporterDynamicFont_property_compress>`
  85. If ``true``, uses lossless compression for the resulting font.
  86. .. rst-class:: classref-item-separator
  87. ----
  88. .. _class_ResourceImporterDynamicFont_property_disable_embedded_bitmaps:
  89. .. rst-class:: classref-property
  90. :ref:`bool<class_bool>` **disable_embedded_bitmaps** = ``true`` :ref:`🔗<class_ResourceImporterDynamicFont_property_disable_embedded_bitmaps>`
  91. If set to ``true``, embedded font bitmap loading is disabled (bitmap-only and color fonts ignore this property).
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_ResourceImporterDynamicFont_property_fallbacks:
  95. .. rst-class:: classref-property
  96. :ref:`Array<class_Array>` **fallbacks** = ``[]`` :ref:`🔗<class_ResourceImporterDynamicFont_property_fallbacks>`
  97. 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>`.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_ResourceImporterDynamicFont_property_force_autohinter:
  101. .. rst-class:: classref-property
  102. :ref:`bool<class_bool>` **force_autohinter** = ``false`` :ref:`🔗<class_ResourceImporterDynamicFont_property_force_autohinter>`
  103. 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.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_ResourceImporterDynamicFont_property_generate_mipmaps:
  107. .. rst-class:: classref-property
  108. :ref:`bool<class_bool>` **generate_mipmaps** = ``false`` :ref:`🔗<class_ResourceImporterDynamicFont_property_generate_mipmaps>`
  109. 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).
  110. 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.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_ResourceImporterDynamicFont_property_hinting:
  114. .. rst-class:: classref-property
  115. :ref:`int<class_int>` **hinting** = ``1`` :ref:`🔗<class_ResourceImporterDynamicFont_property_hinting>`
  116. 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>`).
  117. \ **None:** Smoothest appearance, which can make the font look blurry at small sizes.
  118. \ **Light:** Sharp result by snapping glyph edges to pixels on the Y axis only.
  119. \ **Full:** Sharpest by snapping glyph edges to pixels on both X and Y axes.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_ResourceImporterDynamicFont_property_language_support:
  123. .. rst-class:: classref-property
  124. :ref:`Dictionary<class_Dictionary>` **language_support** = ``{}`` :ref:`🔗<class_ResourceImporterDynamicFont_property_language_support>`
  125. 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>`.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_ResourceImporterDynamicFont_property_msdf_pixel_range:
  129. .. rst-class:: classref-property
  130. :ref:`int<class_int>` **msdf_pixel_range** = ``8`` :ref:`🔗<class_ResourceImporterDynamicFont_property_msdf_pixel_range>`
  131. 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.
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. _class_ResourceImporterDynamicFont_property_msdf_size:
  135. .. rst-class:: classref-property
  136. :ref:`int<class_int>` **msdf_size** = ``48`` :ref:`🔗<class_ResourceImporterDynamicFont_property_msdf_size>`
  137. 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``.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_ResourceImporterDynamicFont_property_multichannel_signed_distance_field:
  141. .. rst-class:: classref-property
  142. :ref:`bool<class_bool>` **multichannel_signed_distance_field** = ``false`` :ref:`🔗<class_ResourceImporterDynamicFont_property_multichannel_signed_distance_field>`
  143. If set to ``true``, the 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).
  144. MSDF font rendering can be combined with :ref:`generate_mipmaps<class_ResourceImporterDynamicFont_property_generate_mipmaps>` to further improve font rendering quality when scaled down.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_ResourceImporterDynamicFont_property_opentype_features:
  148. .. rst-class:: classref-property
  149. :ref:`Dictionary<class_Dictionary>` **opentype_features** = ``{}`` :ref:`🔗<class_ResourceImporterDynamicFont_property_opentype_features>`
  150. 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.
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _class_ResourceImporterDynamicFont_property_oversampling:
  154. .. rst-class:: classref-property
  155. :ref:`float<class_float>` **oversampling** = ``0.0`` :ref:`🔗<class_ResourceImporterDynamicFont_property_oversampling>`
  156. 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``.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_ResourceImporterDynamicFont_property_preload:
  160. .. rst-class:: classref-property
  161. :ref:`Array<class_Array>` **preload** = ``[]`` :ref:`🔗<class_ResourceImporterDynamicFont_property_preload>`
  162. 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.
  163. .. rst-class:: classref-item-separator
  164. ----
  165. .. _class_ResourceImporterDynamicFont_property_script_support:
  166. .. rst-class:: classref-property
  167. :ref:`Dictionary<class_Dictionary>` **script_support** = ``{}`` :ref:`🔗<class_ResourceImporterDynamicFont_property_script_support>`
  168. 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>`.
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _class_ResourceImporterDynamicFont_property_subpixel_positioning:
  172. .. rst-class:: classref-property
  173. :ref:`int<class_int>` **subpixel_positioning** = ``4`` :ref:`🔗<class_ResourceImporterDynamicFont_property_subpixel_positioning>`
  174. 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.
  175. \ **Disabled:** No subpixel positioning. Lowest quality, fastest rendering.
  176. \ **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.
  177. \ **One Half of a Pixel:** Always perform intermediate subpixel positioning regardless of font size. High quality, slow rendering.
  178. \ **One Quarter of a Pixel:** Always perform precise subpixel positioning regardless of font size. Highest quality, slowest rendering.
  179. \ **Auto (Except Pixel Fonts):** **Disabled** for the pixel style fonts (each glyph contours contain only straight horizontal and vertical lines), **Auto** for the other fonts.
  180. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  181. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  182. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  183. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  184. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  185. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  186. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  187. .. |void| replace:: :abbr:`void (No return value.)`