class_fontfile.rst 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  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.1/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.1/doc/classes/FontFile.xml.
  6. .. _class_FontFile:
  7. FontFile
  8. ========
  9. **Inherits:** :ref:`Font<class_Font>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Holds font source data and prerendered glyph cache, imported from a dynamic or a bitmap font.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **FontFile** contains a set of glyphs to represent Unicode characters imported from a font file, as well as a cache of rasterized glyphs, and a set of fallback :ref:`Font<class_Font>`\ s to use.
  15. Use :ref:`FontVariation<class_FontVariation>` to access specific OpenType variation of the font, create simulated bold / slanted version, and draw lines of text.
  16. For more complex text processing, use :ref:`FontVariation<class_FontVariation>` in conjunction with :ref:`TextLine<class_TextLine>` or :ref:`TextParagraph<class_TextParagraph>`.
  17. Supported font formats:
  18. - Dynamic font importer: TrueType (.ttf), TrueType collection (.ttc), OpenType (.otf), OpenType collection (.otc), WOFF (.woff), WOFF2 (.woff2), Type 1 (.pfb, .pfm).
  19. - Bitmap font importer: AngelCode BMFont (.fnt, .font), text and binary (version 3) format variants.
  20. - Monospace image font importer: All supported image formats.
  21. \ **Note:** A character is a symbol that represents an item (letter, digit etc.) in an abstract way.
  22. \ **Note:** A glyph is a bitmap or a shape used to draw one or more characters in a context-dependent manner. Glyph indices are bound to the specific font data source.
  23. \ **Note:** If none of the font data sources contain glyphs for a character used in a string, the character in question will be replaced with a box displaying its hexadecimal code.
  24. .. tabs::
  25. .. code-tab:: gdscript
  26. var f = load("res://BarlowCondensed-Bold.ttf")
  27. $Label.add_theme_font_override("font", f)
  28. $Label.add_theme_font_size_override("font_size", 64)
  29. .. code-tab:: csharp
  30. var f = ResourceLoader.Load<FontFile>("res://BarlowCondensed-Bold.ttf");
  31. GetNode("Label").AddThemeFontOverride("font", f);
  32. GetNode("Label").AddThemeFontSizeOverride("font_size", 64);
  33. .. rst-class:: classref-reftable-group
  34. Properties
  35. ----------
  36. .. table::
  37. :widths: auto
  38. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  39. | :ref:`bool<class_bool>` | :ref:`allow_system_fallback<class_FontFile_property_allow_system_fallback>` | ``true`` |
  40. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  41. | :ref:`FontAntialiasing<enum_TextServer_FontAntialiasing>` | :ref:`antialiasing<class_FontFile_property_antialiasing>` | ``1`` |
  42. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  43. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`data<class_FontFile_property_data>` | ``PackedByteArray()`` |
  44. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  45. | :ref:`Font[]<class_Font>` | :ref:`fallbacks<class_FontFile_property_fallbacks>` | ``[]`` |
  46. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  47. | :ref:`int<class_int>` | :ref:`fixed_size<class_FontFile_property_fixed_size>` | ``0`` |
  48. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  49. | :ref:`String<class_String>` | :ref:`font_name<class_FontFile_property_font_name>` | ``""`` |
  50. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  51. | :ref:`int<class_int>` | :ref:`font_stretch<class_FontFile_property_font_stretch>` | ``100`` |
  52. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  53. | |bitfield|\<:ref:`FontStyle<enum_TextServer_FontStyle>`\> | :ref:`font_style<class_FontFile_property_font_style>` | ``0`` |
  54. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  55. | :ref:`int<class_int>` | :ref:`font_weight<class_FontFile_property_font_weight>` | ``400`` |
  56. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  57. | :ref:`bool<class_bool>` | :ref:`force_autohinter<class_FontFile_property_force_autohinter>` | ``false`` |
  58. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  59. | :ref:`bool<class_bool>` | :ref:`generate_mipmaps<class_FontFile_property_generate_mipmaps>` | ``false`` |
  60. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  61. | :ref:`Hinting<enum_TextServer_Hinting>` | :ref:`hinting<class_FontFile_property_hinting>` | ``1`` |
  62. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  63. | :ref:`int<class_int>` | :ref:`msdf_pixel_range<class_FontFile_property_msdf_pixel_range>` | ``16`` |
  64. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  65. | :ref:`int<class_int>` | :ref:`msdf_size<class_FontFile_property_msdf_size>` | ``48`` |
  66. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  67. | :ref:`bool<class_bool>` | :ref:`multichannel_signed_distance_field<class_FontFile_property_multichannel_signed_distance_field>` | ``false`` |
  68. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  69. | :ref:`Dictionary<class_Dictionary>` | :ref:`opentype_feature_overrides<class_FontFile_property_opentype_feature_overrides>` | ``{}`` |
  70. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  71. | :ref:`float<class_float>` | :ref:`oversampling<class_FontFile_property_oversampling>` | ``0.0`` |
  72. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  73. | :ref:`String<class_String>` | :ref:`style_name<class_FontFile_property_style_name>` | ``""`` |
  74. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  75. | :ref:`SubpixelPositioning<enum_TextServer_SubpixelPositioning>` | :ref:`subpixel_positioning<class_FontFile_property_subpixel_positioning>` | ``1`` |
  76. +-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-----------------------+
  77. .. rst-class:: classref-reftable-group
  78. Methods
  79. -------
  80. .. table::
  81. :widths: auto
  82. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`clear_cache<class_FontFile_method_clear_cache>` **(** **)** |
  84. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`clear_glyphs<class_FontFile_method_clear_glyphs>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)** |
  86. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`clear_kerning_map<class_FontFile_method_clear_kerning_map>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |
  88. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`clear_size_cache<class_FontFile_method_clear_size_cache>` **(** :ref:`int<class_int>` cache_index **)** |
  90. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`clear_textures<class_FontFile_method_clear_textures>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)** |
  92. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`float<class_float>` | :ref:`get_cache_ascent<class_FontFile_method_get_cache_ascent>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const| |
  94. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`int<class_int>` | :ref:`get_cache_count<class_FontFile_method_get_cache_count>` **(** **)** |const| |
  96. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`float<class_float>` | :ref:`get_cache_descent<class_FontFile_method_get_cache_descent>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const| |
  98. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`float<class_float>` | :ref:`get_cache_scale<class_FontFile_method_get_cache_scale>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const| |
  100. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`float<class_float>` | :ref:`get_cache_underline_position<class_FontFile_method_get_cache_underline_position>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const| |
  102. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`float<class_float>` | :ref:`get_cache_underline_thickness<class_FontFile_method_get_cache_underline_thickness>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const| |
  104. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`int<class_int>` | :ref:`get_char_from_glyph_index<class_FontFile_method_get_char_from_glyph_index>` **(** :ref:`int<class_int>` size, :ref:`int<class_int>` glyph_index **)** |const| |
  106. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`float<class_float>` | :ref:`get_embolden<class_FontFile_method_get_embolden>` **(** :ref:`int<class_int>` cache_index **)** |const| |
  108. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`int<class_int>` | :ref:`get_face_index<class_FontFile_method_get_face_index>` **(** :ref:`int<class_int>` cache_index **)** |const| |
  110. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`Vector2<class_Vector2>` | :ref:`get_glyph_advance<class_FontFile_method_get_glyph_advance>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`int<class_int>` glyph **)** |const| |
  112. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`int<class_int>` | :ref:`get_glyph_index<class_FontFile_method_get_glyph_index>` **(** :ref:`int<class_int>` size, :ref:`int<class_int>` char, :ref:`int<class_int>` variation_selector **)** |const| |
  114. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`get_glyph_list<class_FontFile_method_get_glyph_list>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)** |const| |
  116. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`Vector2<class_Vector2>` | :ref:`get_glyph_offset<class_FontFile_method_get_glyph_offset>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |const| |
  118. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`Vector2<class_Vector2>` | :ref:`get_glyph_size<class_FontFile_method_get_glyph_size>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |const| |
  120. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`int<class_int>` | :ref:`get_glyph_texture_idx<class_FontFile_method_get_glyph_texture_idx>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |const| |
  122. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`Rect2<class_Rect2>` | :ref:`get_glyph_uv_rect<class_FontFile_method_get_glyph_uv_rect>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |const| |
  124. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | :ref:`Vector2<class_Vector2>` | :ref:`get_kerning<class_FontFile_method_get_kerning>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`Vector2i<class_Vector2i>` glyph_pair **)** |const| |
  126. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_kerning_list<class_FontFile_method_get_kerning_list>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const| |
  128. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | :ref:`bool<class_bool>` | :ref:`get_language_support_override<class_FontFile_method_get_language_support_override>` **(** :ref:`String<class_String>` language **)** |const| |
  130. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_language_support_overrides<class_FontFile_method_get_language_support_overrides>` **(** **)** |const| |
  132. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`bool<class_bool>` | :ref:`get_script_support_override<class_FontFile_method_get_script_support_override>` **(** :ref:`String<class_String>` script **)** |const| |
  134. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_script_support_overrides<class_FontFile_method_get_script_support_overrides>` **(** **)** |const| |
  136. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :ref:`Vector2i[]<class_Vector2i>` | :ref:`get_size_cache_list<class_FontFile_method_get_size_cache_list>` **(** :ref:`int<class_int>` cache_index **)** |const| |
  138. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`int<class_int>` | :ref:`get_texture_count<class_FontFile_method_get_texture_count>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)** |const| |
  140. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | :ref:`Image<class_Image>` | :ref:`get_texture_image<class_FontFile_method_get_texture_image>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index **)** |const| |
  142. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`get_texture_offsets<class_FontFile_method_get_texture_offsets>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index **)** |const| |
  144. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_transform<class_FontFile_method_get_transform>` **(** :ref:`int<class_int>` cache_index **)** |const| |
  146. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_variation_coordinates<class_FontFile_method_get_variation_coordinates>` **(** :ref:`int<class_int>` cache_index **)** |const| |
  148. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_bitmap_font<class_FontFile_method_load_bitmap_font>` **(** :ref:`String<class_String>` path **)** |
  150. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_dynamic_font<class_FontFile_method_load_dynamic_font>` **(** :ref:`String<class_String>` path **)** |
  152. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  153. | void | :ref:`remove_cache<class_FontFile_method_remove_cache>` **(** :ref:`int<class_int>` cache_index **)** |
  154. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  155. | void | :ref:`remove_glyph<class_FontFile_method_remove_glyph>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |
  156. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  157. | void | :ref:`remove_kerning<class_FontFile_method_remove_kerning>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`Vector2i<class_Vector2i>` glyph_pair **)** |
  158. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  159. | void | :ref:`remove_language_support_override<class_FontFile_method_remove_language_support_override>` **(** :ref:`String<class_String>` language **)** |
  160. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  161. | void | :ref:`remove_script_support_override<class_FontFile_method_remove_script_support_override>` **(** :ref:`String<class_String>` script **)** |
  162. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  163. | void | :ref:`remove_size_cache<class_FontFile_method_remove_size_cache>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)** |
  164. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  165. | void | :ref:`remove_texture<class_FontFile_method_remove_texture>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index **)** |
  166. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  167. | void | :ref:`render_glyph<class_FontFile_method_render_glyph>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` index **)** |
  168. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  169. | void | :ref:`render_range<class_FontFile_method_render_range>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` start, :ref:`int<class_int>` end **)** |
  170. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  171. | void | :ref:`set_cache_ascent<class_FontFile_method_set_cache_ascent>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` ascent **)** |
  172. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  173. | void | :ref:`set_cache_descent<class_FontFile_method_set_cache_descent>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` descent **)** |
  174. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  175. | void | :ref:`set_cache_scale<class_FontFile_method_set_cache_scale>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` scale **)** |
  176. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  177. | void | :ref:`set_cache_underline_position<class_FontFile_method_set_cache_underline_position>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` underline_position **)** |
  178. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  179. | void | :ref:`set_cache_underline_thickness<class_FontFile_method_set_cache_underline_thickness>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` underline_thickness **)** |
  180. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  181. | void | :ref:`set_embolden<class_FontFile_method_set_embolden>` **(** :ref:`int<class_int>` cache_index, :ref:`float<class_float>` strength **)** |
  182. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  183. | void | :ref:`set_face_index<class_FontFile_method_set_face_index>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` face_index **)** |
  184. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  185. | void | :ref:`set_glyph_advance<class_FontFile_method_set_glyph_advance>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`int<class_int>` glyph, :ref:`Vector2<class_Vector2>` advance **)** |
  186. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  187. | void | :ref:`set_glyph_offset<class_FontFile_method_set_glyph_offset>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph, :ref:`Vector2<class_Vector2>` offset **)** |
  188. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  189. | void | :ref:`set_glyph_size<class_FontFile_method_set_glyph_size>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph, :ref:`Vector2<class_Vector2>` gl_size **)** |
  190. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  191. | void | :ref:`set_glyph_texture_idx<class_FontFile_method_set_glyph_texture_idx>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph, :ref:`int<class_int>` texture_idx **)** |
  192. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  193. | void | :ref:`set_glyph_uv_rect<class_FontFile_method_set_glyph_uv_rect>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph, :ref:`Rect2<class_Rect2>` uv_rect **)** |
  194. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  195. | void | :ref:`set_kerning<class_FontFile_method_set_kerning>` **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`Vector2i<class_Vector2i>` glyph_pair, :ref:`Vector2<class_Vector2>` kerning **)** |
  196. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  197. | void | :ref:`set_language_support_override<class_FontFile_method_set_language_support_override>` **(** :ref:`String<class_String>` language, :ref:`bool<class_bool>` supported **)** |
  198. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  199. | void | :ref:`set_script_support_override<class_FontFile_method_set_script_support_override>` **(** :ref:`String<class_String>` script, :ref:`bool<class_bool>` supported **)** |
  200. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  201. | void | :ref:`set_texture_image<class_FontFile_method_set_texture_image>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index, :ref:`Image<class_Image>` image **)** |
  202. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  203. | void | :ref:`set_texture_offsets<class_FontFile_method_set_texture_offsets>` **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index, :ref:`PackedInt32Array<class_PackedInt32Array>` offset **)** |
  204. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  205. | void | :ref:`set_transform<class_FontFile_method_set_transform>` **(** :ref:`int<class_int>` cache_index, :ref:`Transform2D<class_Transform2D>` transform **)** |
  206. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  207. | void | :ref:`set_variation_coordinates<class_FontFile_method_set_variation_coordinates>` **(** :ref:`int<class_int>` cache_index, :ref:`Dictionary<class_Dictionary>` variation_coordinates **)** |
  208. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  209. .. rst-class:: classref-section-separator
  210. ----
  211. .. rst-class:: classref-descriptions-group
  212. Property Descriptions
  213. ---------------------
  214. .. _class_FontFile_property_allow_system_fallback:
  215. .. rst-class:: classref-property
  216. :ref:`bool<class_bool>` **allow_system_fallback** = ``true``
  217. .. rst-class:: classref-property-setget
  218. - void **set_allow_system_fallback** **(** :ref:`bool<class_bool>` value **)**
  219. - :ref:`bool<class_bool>` **is_allow_system_fallback** **(** **)**
  220. If set to ``true``, system fonts can be automatically used as fallbacks.
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_FontFile_property_antialiasing:
  224. .. rst-class:: classref-property
  225. :ref:`FontAntialiasing<enum_TextServer_FontAntialiasing>` **antialiasing** = ``1``
  226. .. rst-class:: classref-property-setget
  227. - void **set_antialiasing** **(** :ref:`FontAntialiasing<enum_TextServer_FontAntialiasing>` value **)**
  228. - :ref:`FontAntialiasing<enum_TextServer_FontAntialiasing>` **get_antialiasing** **(** **)**
  229. Font anti-aliasing mode.
  230. .. rst-class:: classref-item-separator
  231. ----
  232. .. _class_FontFile_property_data:
  233. .. rst-class:: classref-property
  234. :ref:`PackedByteArray<class_PackedByteArray>` **data** = ``PackedByteArray()``
  235. .. rst-class:: classref-property-setget
  236. - void **set_data** **(** :ref:`PackedByteArray<class_PackedByteArray>` value **)**
  237. - :ref:`PackedByteArray<class_PackedByteArray>` **get_data** **(** **)**
  238. Contents of the dynamic font source file.
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_FontFile_property_fallbacks:
  242. .. rst-class:: classref-property
  243. :ref:`Font[]<class_Font>` **fallbacks** = ``[]``
  244. .. rst-class:: classref-property-setget
  245. - void **set_fallbacks** **(** :ref:`Font[]<class_Font>` value **)**
  246. - :ref:`Font[]<class_Font>` **get_fallbacks** **(** **)**
  247. Array of fallback :ref:`Font<class_Font>`\ s.
  248. .. rst-class:: classref-item-separator
  249. ----
  250. .. _class_FontFile_property_fixed_size:
  251. .. rst-class:: classref-property
  252. :ref:`int<class_int>` **fixed_size** = ``0``
  253. .. rst-class:: classref-property-setget
  254. - void **set_fixed_size** **(** :ref:`int<class_int>` value **)**
  255. - :ref:`int<class_int>` **get_fixed_size** **(** **)**
  256. Font size, used only for the bitmap fonts.
  257. .. rst-class:: classref-item-separator
  258. ----
  259. .. _class_FontFile_property_font_name:
  260. .. rst-class:: classref-property
  261. :ref:`String<class_String>` **font_name** = ``""``
  262. .. rst-class:: classref-property-setget
  263. - void **set_font_name** **(** :ref:`String<class_String>` value **)**
  264. - :ref:`String<class_String>` **get_font_name** **(** **)**
  265. Font family name.
  266. .. rst-class:: classref-item-separator
  267. ----
  268. .. _class_FontFile_property_font_stretch:
  269. .. rst-class:: classref-property
  270. :ref:`int<class_int>` **font_stretch** = ``100``
  271. .. rst-class:: classref-property-setget
  272. - void **set_font_stretch** **(** :ref:`int<class_int>` value **)**
  273. - :ref:`int<class_int>` **get_font_stretch** **(** **)**
  274. Font stretch amount, compared to a normal width. A percentage value between ``50%`` and ``200%``.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_FontFile_property_font_style:
  278. .. rst-class:: classref-property
  279. |bitfield|\<:ref:`FontStyle<enum_TextServer_FontStyle>`\> **font_style** = ``0``
  280. .. rst-class:: classref-property-setget
  281. - void **set_font_style** **(** |bitfield|\<:ref:`FontStyle<enum_TextServer_FontStyle>`\> value **)**
  282. - |bitfield|\<:ref:`FontStyle<enum_TextServer_FontStyle>`\> **get_font_style** **(** **)**
  283. Font style flags, see :ref:`FontStyle<enum_TextServer_FontStyle>`.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_FontFile_property_font_weight:
  287. .. rst-class:: classref-property
  288. :ref:`int<class_int>` **font_weight** = ``400``
  289. .. rst-class:: classref-property-setget
  290. - void **set_font_weight** **(** :ref:`int<class_int>` value **)**
  291. - :ref:`int<class_int>` **get_font_weight** **(** **)**
  292. Weight (boldness) of the font. A value in the ``100...999`` range, normal font weight is ``400``, bold font weight is ``700``.
  293. .. rst-class:: classref-item-separator
  294. ----
  295. .. _class_FontFile_property_force_autohinter:
  296. .. rst-class:: classref-property
  297. :ref:`bool<class_bool>` **force_autohinter** = ``false``
  298. .. rst-class:: classref-property-setget
  299. - void **set_force_autohinter** **(** :ref:`bool<class_bool>` value **)**
  300. - :ref:`bool<class_bool>` **is_force_autohinter** **(** **)**
  301. If set to ``true``, auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only (MSDF fonts don't support hinting).
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_FontFile_property_generate_mipmaps:
  305. .. rst-class:: classref-property
  306. :ref:`bool<class_bool>` **generate_mipmaps** = ``false``
  307. .. rst-class:: classref-property-setget
  308. - void **set_generate_mipmaps** **(** :ref:`bool<class_bool>` value **)**
  309. - :ref:`bool<class_bool>` **get_generate_mipmaps** **(** **)**
  310. If set to ``true``, generate mipmaps for the font textures.
  311. .. rst-class:: classref-item-separator
  312. ----
  313. .. _class_FontFile_property_hinting:
  314. .. rst-class:: classref-property
  315. :ref:`Hinting<enum_TextServer_Hinting>` **hinting** = ``1``
  316. .. rst-class:: classref-property-setget
  317. - void **set_hinting** **(** :ref:`Hinting<enum_TextServer_Hinting>` value **)**
  318. - :ref:`Hinting<enum_TextServer_Hinting>` **get_hinting** **(** **)**
  319. Font hinting mode. Used by dynamic fonts only.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_FontFile_property_msdf_pixel_range:
  323. .. rst-class:: classref-property
  324. :ref:`int<class_int>` **msdf_pixel_range** = ``16``
  325. .. rst-class:: classref-property-setget
  326. - void **set_msdf_pixel_range** **(** :ref:`int<class_int>` value **)**
  327. - :ref:`int<class_int>` **get_msdf_pixel_range** **(** **)**
  328. 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_FontFile_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_FontFile_property_msdf_pixel_range>` value of ``16`` allows outline sizes up to ``8`` to look correct.
  329. .. rst-class:: classref-item-separator
  330. ----
  331. .. _class_FontFile_property_msdf_size:
  332. .. rst-class:: classref-property
  333. :ref:`int<class_int>` **msdf_size** = ``48``
  334. .. rst-class:: classref-property-setget
  335. - void **set_msdf_size** **(** :ref:`int<class_int>` value **)**
  336. - :ref:`int<class_int>` **get_msdf_size** **(** **)**
  337. 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.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_FontFile_property_multichannel_signed_distance_field:
  341. .. rst-class:: classref-property
  342. :ref:`bool<class_bool>` **multichannel_signed_distance_field** = ``false``
  343. .. rst-class:: classref-property-setget
  344. - void **set_multichannel_signed_distance_field** **(** :ref:`bool<class_bool>` value **)**
  345. - :ref:`bool<class_bool>` **is_multichannel_signed_distance_field** **(** **)**
  346. If set to ``true``, glyphs of all sizes are rendered using single multichannel signed distance field (MSDF) generated from the dynamic font vector data. 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). As a downside, font hinting is not available with MSDF. The lack of font hinting may result in less crisp and less readable fonts at small sizes.
  347. \ **Note:** If using font outlines, :ref:`msdf_pixel_range<class_FontFile_property_msdf_pixel_range>` must be set to at least *twice* the size of the largest font outline.
  348. \ **Note:** MSDF font rendering does not render glyphs with overlapping shapes correctly. Overlapping shapes are not valid per the OpenType standard, but are still commonly found in many font files, especially those converted by Google Fonts. To avoid issues with overlapping glyphs, consider downloading the font file directly from the type foundry instead of relying on Google Fonts.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_FontFile_property_opentype_feature_overrides:
  352. .. rst-class:: classref-property
  353. :ref:`Dictionary<class_Dictionary>` **opentype_feature_overrides** = ``{}``
  354. .. rst-class:: classref-property-setget
  355. - void **set_opentype_feature_overrides** **(** :ref:`Dictionary<class_Dictionary>` value **)**
  356. - :ref:`Dictionary<class_Dictionary>` **get_opentype_feature_overrides** **(** **)**
  357. Font OpenType feature set override.
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_FontFile_property_oversampling:
  361. .. rst-class:: classref-property
  362. :ref:`float<class_float>` **oversampling** = ``0.0``
  363. .. rst-class:: classref-property-setget
  364. - void **set_oversampling** **(** :ref:`float<class_float>` value **)**
  365. - :ref:`float<class_float>` **get_oversampling** **(** **)**
  366. Font oversampling factor. If set to ``0.0``, the global oversampling factor is used instead. Used by dynamic fonts only (MSDF fonts ignore oversampling).
  367. .. rst-class:: classref-item-separator
  368. ----
  369. .. _class_FontFile_property_style_name:
  370. .. rst-class:: classref-property
  371. :ref:`String<class_String>` **style_name** = ``""``
  372. .. rst-class:: classref-property-setget
  373. - void **set_font_style_name** **(** :ref:`String<class_String>` value **)**
  374. - :ref:`String<class_String>` **get_font_style_name** **(** **)**
  375. Font style name.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_FontFile_property_subpixel_positioning:
  379. .. rst-class:: classref-property
  380. :ref:`SubpixelPositioning<enum_TextServer_SubpixelPositioning>` **subpixel_positioning** = ``1``
  381. .. rst-class:: classref-property-setget
  382. - void **set_subpixel_positioning** **(** :ref:`SubpixelPositioning<enum_TextServer_SubpixelPositioning>` value **)**
  383. - :ref:`SubpixelPositioning<enum_TextServer_SubpixelPositioning>` **get_subpixel_positioning** **(** **)**
  384. Font glyph subpixel positioning mode. Subpixel positioning provides shaper text and better kerning for smaller font sizes, at the cost of higher memory usage and lower font rasterization speed. Use :ref:`TextServer.SUBPIXEL_POSITIONING_AUTO<class_TextServer_constant_SUBPIXEL_POSITIONING_AUTO>` to automatically enable it based on the font size.
  385. .. rst-class:: classref-section-separator
  386. ----
  387. .. rst-class:: classref-descriptions-group
  388. Method Descriptions
  389. -------------------
  390. .. _class_FontFile_method_clear_cache:
  391. .. rst-class:: classref-method
  392. void **clear_cache** **(** **)**
  393. Removes all font cache entries.
  394. .. rst-class:: classref-item-separator
  395. ----
  396. .. _class_FontFile_method_clear_glyphs:
  397. .. rst-class:: classref-method
  398. void **clear_glyphs** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)**
  399. Removes all rendered glyphs information from the cache entry.
  400. \ **Note:** This function will not remove textures associated with the glyphs, use :ref:`remove_texture<class_FontFile_method_remove_texture>` to remove them manually.
  401. .. rst-class:: classref-item-separator
  402. ----
  403. .. _class_FontFile_method_clear_kerning_map:
  404. .. rst-class:: classref-method
  405. void **clear_kerning_map** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)**
  406. Removes all kerning overrides.
  407. .. rst-class:: classref-item-separator
  408. ----
  409. .. _class_FontFile_method_clear_size_cache:
  410. .. rst-class:: classref-method
  411. void **clear_size_cache** **(** :ref:`int<class_int>` cache_index **)**
  412. Removes all font sizes from the cache entry
  413. .. rst-class:: classref-item-separator
  414. ----
  415. .. _class_FontFile_method_clear_textures:
  416. .. rst-class:: classref-method
  417. void **clear_textures** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)**
  418. Removes all textures from font cache entry.
  419. \ **Note:** This function will not remove glyphs associated with the texture, use :ref:`remove_glyph<class_FontFile_method_remove_glyph>` to remove them manually.
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_FontFile_method_get_cache_ascent:
  423. .. rst-class:: classref-method
  424. :ref:`float<class_float>` **get_cache_ascent** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const|
  425. Returns the font ascent (number of pixels above the baseline).
  426. .. rst-class:: classref-item-separator
  427. ----
  428. .. _class_FontFile_method_get_cache_count:
  429. .. rst-class:: classref-method
  430. :ref:`int<class_int>` **get_cache_count** **(** **)** |const|
  431. Returns number of the font cache entries.
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _class_FontFile_method_get_cache_descent:
  435. .. rst-class:: classref-method
  436. :ref:`float<class_float>` **get_cache_descent** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const|
  437. Returns the font descent (number of pixels below the baseline).
  438. .. rst-class:: classref-item-separator
  439. ----
  440. .. _class_FontFile_method_get_cache_scale:
  441. .. rst-class:: classref-method
  442. :ref:`float<class_float>` **get_cache_scale** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const|
  443. Returns scaling factor of the color bitmap font.
  444. .. rst-class:: classref-item-separator
  445. ----
  446. .. _class_FontFile_method_get_cache_underline_position:
  447. .. rst-class:: classref-method
  448. :ref:`float<class_float>` **get_cache_underline_position** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const|
  449. Returns pixel offset of the underline below the baseline.
  450. .. rst-class:: classref-item-separator
  451. ----
  452. .. _class_FontFile_method_get_cache_underline_thickness:
  453. .. rst-class:: classref-method
  454. :ref:`float<class_float>` **get_cache_underline_thickness** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const|
  455. Returns thickness of the underline in pixels.
  456. .. rst-class:: classref-item-separator
  457. ----
  458. .. _class_FontFile_method_get_char_from_glyph_index:
  459. .. rst-class:: classref-method
  460. :ref:`int<class_int>` **get_char_from_glyph_index** **(** :ref:`int<class_int>` size, :ref:`int<class_int>` glyph_index **)** |const|
  461. Returns character code associated with ``glyph_index``, or ``0`` if ``glyph_index`` is invalid. See :ref:`get_glyph_index<class_FontFile_method_get_glyph_index>`.
  462. .. rst-class:: classref-item-separator
  463. ----
  464. .. _class_FontFile_method_get_embolden:
  465. .. rst-class:: classref-method
  466. :ref:`float<class_float>` **get_embolden** **(** :ref:`int<class_int>` cache_index **)** |const|
  467. Returns embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
  468. .. rst-class:: classref-item-separator
  469. ----
  470. .. _class_FontFile_method_get_face_index:
  471. .. rst-class:: classref-method
  472. :ref:`int<class_int>` **get_face_index** **(** :ref:`int<class_int>` cache_index **)** |const|
  473. Recturns an active face index in the TrueType / OpenType collection.
  474. .. rst-class:: classref-item-separator
  475. ----
  476. .. _class_FontFile_method_get_glyph_advance:
  477. .. rst-class:: classref-method
  478. :ref:`Vector2<class_Vector2>` **get_glyph_advance** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`int<class_int>` glyph **)** |const|
  479. Returns glyph advance (offset of the next glyph).
  480. \ **Note:** Advance for glyphs outlines is the same as the base glyph advance and is not saved.
  481. .. rst-class:: classref-item-separator
  482. ----
  483. .. _class_FontFile_method_get_glyph_index:
  484. .. rst-class:: classref-method
  485. :ref:`int<class_int>` **get_glyph_index** **(** :ref:`int<class_int>` size, :ref:`int<class_int>` char, :ref:`int<class_int>` variation_selector **)** |const|
  486. Returns the glyph index of a ``char``, optionally modified by the ``variation_selector``.
  487. .. rst-class:: classref-item-separator
  488. ----
  489. .. _class_FontFile_method_get_glyph_list:
  490. .. rst-class:: classref-method
  491. :ref:`PackedInt32Array<class_PackedInt32Array>` **get_glyph_list** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)** |const|
  492. Returns list of rendered glyphs in the cache entry.
  493. .. rst-class:: classref-item-separator
  494. ----
  495. .. _class_FontFile_method_get_glyph_offset:
  496. .. rst-class:: classref-method
  497. :ref:`Vector2<class_Vector2>` **get_glyph_offset** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |const|
  498. Returns glyph offset from the baseline.
  499. .. rst-class:: classref-item-separator
  500. ----
  501. .. _class_FontFile_method_get_glyph_size:
  502. .. rst-class:: classref-method
  503. :ref:`Vector2<class_Vector2>` **get_glyph_size** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |const|
  504. Returns glyph size.
  505. .. rst-class:: classref-item-separator
  506. ----
  507. .. _class_FontFile_method_get_glyph_texture_idx:
  508. .. rst-class:: classref-method
  509. :ref:`int<class_int>` **get_glyph_texture_idx** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |const|
  510. Returns index of the cache texture containing the glyph.
  511. .. rst-class:: classref-item-separator
  512. ----
  513. .. _class_FontFile_method_get_glyph_uv_rect:
  514. .. rst-class:: classref-method
  515. :ref:`Rect2<class_Rect2>` **get_glyph_uv_rect** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)** |const|
  516. Returns rectangle in the cache texture containing the glyph.
  517. .. rst-class:: classref-item-separator
  518. ----
  519. .. _class_FontFile_method_get_kerning:
  520. .. rst-class:: classref-method
  521. :ref:`Vector2<class_Vector2>` **get_kerning** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`Vector2i<class_Vector2i>` glyph_pair **)** |const|
  522. Returns kerning for the pair of glyphs.
  523. .. rst-class:: classref-item-separator
  524. ----
  525. .. _class_FontFile_method_get_kerning_list:
  526. .. rst-class:: classref-method
  527. :ref:`Vector2i[]<class_Vector2i>` **get_kerning_list** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size **)** |const|
  528. Returns list of the kerning overrides.
  529. .. rst-class:: classref-item-separator
  530. ----
  531. .. _class_FontFile_method_get_language_support_override:
  532. .. rst-class:: classref-method
  533. :ref:`bool<class_bool>` **get_language_support_override** **(** :ref:`String<class_String>` language **)** |const|
  534. Returns ``true`` if support override is enabled for the ``language``.
  535. .. rst-class:: classref-item-separator
  536. ----
  537. .. _class_FontFile_method_get_language_support_overrides:
  538. .. rst-class:: classref-method
  539. :ref:`PackedStringArray<class_PackedStringArray>` **get_language_support_overrides** **(** **)** |const|
  540. Returns list of language support overrides.
  541. .. rst-class:: classref-item-separator
  542. ----
  543. .. _class_FontFile_method_get_script_support_override:
  544. .. rst-class:: classref-method
  545. :ref:`bool<class_bool>` **get_script_support_override** **(** :ref:`String<class_String>` script **)** |const|
  546. Returns ``true`` if support override is enabled for the ``script``.
  547. .. rst-class:: classref-item-separator
  548. ----
  549. .. _class_FontFile_method_get_script_support_overrides:
  550. .. rst-class:: classref-method
  551. :ref:`PackedStringArray<class_PackedStringArray>` **get_script_support_overrides** **(** **)** |const|
  552. Returns list of script support overrides.
  553. .. rst-class:: classref-item-separator
  554. ----
  555. .. _class_FontFile_method_get_size_cache_list:
  556. .. rst-class:: classref-method
  557. :ref:`Vector2i[]<class_Vector2i>` **get_size_cache_list** **(** :ref:`int<class_int>` cache_index **)** |const|
  558. Returns list of the font sizes in the cache. Each size is ``Vector2i`` with font size and outline size.
  559. .. rst-class:: classref-item-separator
  560. ----
  561. .. _class_FontFile_method_get_texture_count:
  562. .. rst-class:: classref-method
  563. :ref:`int<class_int>` **get_texture_count** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)** |const|
  564. Returns number of textures used by font cache entry.
  565. .. rst-class:: classref-item-separator
  566. ----
  567. .. _class_FontFile_method_get_texture_image:
  568. .. rst-class:: classref-method
  569. :ref:`Image<class_Image>` **get_texture_image** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index **)** |const|
  570. Returns a copy of the font cache texture image.
  571. .. rst-class:: classref-item-separator
  572. ----
  573. .. _class_FontFile_method_get_texture_offsets:
  574. .. rst-class:: classref-method
  575. :ref:`PackedInt32Array<class_PackedInt32Array>` **get_texture_offsets** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index **)** |const|
  576. Returns a copy of the array containing glyph packing data.
  577. .. rst-class:: classref-item-separator
  578. ----
  579. .. _class_FontFile_method_get_transform:
  580. .. rst-class:: classref-method
  581. :ref:`Transform2D<class_Transform2D>` **get_transform** **(** :ref:`int<class_int>` cache_index **)** |const|
  582. Returns 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
  583. .. rst-class:: classref-item-separator
  584. ----
  585. .. _class_FontFile_method_get_variation_coordinates:
  586. .. rst-class:: classref-method
  587. :ref:`Dictionary<class_Dictionary>` **get_variation_coordinates** **(** :ref:`int<class_int>` cache_index **)** |const|
  588. Returns variation coordinates for the specified font cache entry. See :ref:`Font.get_supported_variation_list<class_Font_method_get_supported_variation_list>` for more info.
  589. .. rst-class:: classref-item-separator
  590. ----
  591. .. _class_FontFile_method_load_bitmap_font:
  592. .. rst-class:: classref-method
  593. :ref:`Error<enum_@GlobalScope_Error>` **load_bitmap_font** **(** :ref:`String<class_String>` path **)**
  594. Loads an AngelCode BMFont (.fnt, .font) bitmap font from file ``path``.
  595. \ **Warning:** This method should only be used in the editor or in cases when you need to load external fonts at run-time, such as fonts located at the ``user://`` directory.
  596. .. rst-class:: classref-item-separator
  597. ----
  598. .. _class_FontFile_method_load_dynamic_font:
  599. .. rst-class:: classref-method
  600. :ref:`Error<enum_@GlobalScope_Error>` **load_dynamic_font** **(** :ref:`String<class_String>` path **)**
  601. Loads a TrueType (.ttf), OpenType (.otf), WOFF (.woff), WOFF2 (.woff2) or Type 1 (.pfb, .pfm) dynamic font from file ``path``.
  602. \ **Warning:** This method should only be used in the editor or in cases when you need to load external fonts at run-time, such as fonts located at the ``user://`` directory.
  603. .. rst-class:: classref-item-separator
  604. ----
  605. .. _class_FontFile_method_remove_cache:
  606. .. rst-class:: classref-method
  607. void **remove_cache** **(** :ref:`int<class_int>` cache_index **)**
  608. Removes specified font cache entry.
  609. .. rst-class:: classref-item-separator
  610. ----
  611. .. _class_FontFile_method_remove_glyph:
  612. .. rst-class:: classref-method
  613. void **remove_glyph** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph **)**
  614. Removes specified rendered glyph information from the cache entry.
  615. \ **Note:** This function will not remove textures associated with the glyphs, use :ref:`remove_texture<class_FontFile_method_remove_texture>` to remove them manually.
  616. .. rst-class:: classref-item-separator
  617. ----
  618. .. _class_FontFile_method_remove_kerning:
  619. .. rst-class:: classref-method
  620. void **remove_kerning** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`Vector2i<class_Vector2i>` glyph_pair **)**
  621. Removes kerning override for the pair of glyphs.
  622. .. rst-class:: classref-item-separator
  623. ----
  624. .. _class_FontFile_method_remove_language_support_override:
  625. .. rst-class:: classref-method
  626. void **remove_language_support_override** **(** :ref:`String<class_String>` language **)**
  627. Remove language support override.
  628. .. rst-class:: classref-item-separator
  629. ----
  630. .. _class_FontFile_method_remove_script_support_override:
  631. .. rst-class:: classref-method
  632. void **remove_script_support_override** **(** :ref:`String<class_String>` script **)**
  633. Removes script support override.
  634. .. rst-class:: classref-item-separator
  635. ----
  636. .. _class_FontFile_method_remove_size_cache:
  637. .. rst-class:: classref-method
  638. void **remove_size_cache** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size **)**
  639. Removes specified font size from the cache entry.
  640. .. rst-class:: classref-item-separator
  641. ----
  642. .. _class_FontFile_method_remove_texture:
  643. .. rst-class:: classref-method
  644. void **remove_texture** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index **)**
  645. Removes specified texture from the cache entry.
  646. \ **Note:** This function will not remove glyphs associated with the texture. Remove them manually using :ref:`remove_glyph<class_FontFile_method_remove_glyph>`.
  647. .. rst-class:: classref-item-separator
  648. ----
  649. .. _class_FontFile_method_render_glyph:
  650. .. rst-class:: classref-method
  651. void **render_glyph** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` index **)**
  652. Renders specified glyph to the font cache texture.
  653. .. rst-class:: classref-item-separator
  654. ----
  655. .. _class_FontFile_method_render_range:
  656. .. rst-class:: classref-method
  657. void **render_range** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` start, :ref:`int<class_int>` end **)**
  658. Renders the range of characters to the font cache texture.
  659. .. rst-class:: classref-item-separator
  660. ----
  661. .. _class_FontFile_method_set_cache_ascent:
  662. .. rst-class:: classref-method
  663. void **set_cache_ascent** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` ascent **)**
  664. Sets the font ascent (number of pixels above the baseline).
  665. .. rst-class:: classref-item-separator
  666. ----
  667. .. _class_FontFile_method_set_cache_descent:
  668. .. rst-class:: classref-method
  669. void **set_cache_descent** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` descent **)**
  670. Sets the font descent (number of pixels below the baseline).
  671. .. rst-class:: classref-item-separator
  672. ----
  673. .. _class_FontFile_method_set_cache_scale:
  674. .. rst-class:: classref-method
  675. void **set_cache_scale** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` scale **)**
  676. Sets scaling factor of the color bitmap font.
  677. .. rst-class:: classref-item-separator
  678. ----
  679. .. _class_FontFile_method_set_cache_underline_position:
  680. .. rst-class:: classref-method
  681. void **set_cache_underline_position** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` underline_position **)**
  682. Sets pixel offset of the underline below the baseline.
  683. .. rst-class:: classref-item-separator
  684. ----
  685. .. _class_FontFile_method_set_cache_underline_thickness:
  686. .. rst-class:: classref-method
  687. void **set_cache_underline_thickness** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`float<class_float>` underline_thickness **)**
  688. Sets thickness of the underline in pixels.
  689. .. rst-class:: classref-item-separator
  690. ----
  691. .. _class_FontFile_method_set_embolden:
  692. .. rst-class:: classref-method
  693. void **set_embolden** **(** :ref:`int<class_int>` cache_index, :ref:`float<class_float>` strength **)**
  694. Sets embolden strength, if is not equal to zero, emboldens the font outlines. Negative values reduce the outline thickness.
  695. .. rst-class:: classref-item-separator
  696. ----
  697. .. _class_FontFile_method_set_face_index:
  698. .. rst-class:: classref-method
  699. void **set_face_index** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` face_index **)**
  700. Sets an active face index in the TrueType / OpenType collection.
  701. .. rst-class:: classref-item-separator
  702. ----
  703. .. _class_FontFile_method_set_glyph_advance:
  704. .. rst-class:: classref-method
  705. void **set_glyph_advance** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`int<class_int>` glyph, :ref:`Vector2<class_Vector2>` advance **)**
  706. Sets glyph advance (offset of the next glyph).
  707. \ **Note:** Advance for glyphs outlines is the same as the base glyph advance and is not saved.
  708. .. rst-class:: classref-item-separator
  709. ----
  710. .. _class_FontFile_method_set_glyph_offset:
  711. .. rst-class:: classref-method
  712. void **set_glyph_offset** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph, :ref:`Vector2<class_Vector2>` offset **)**
  713. Sets glyph offset from the baseline.
  714. .. rst-class:: classref-item-separator
  715. ----
  716. .. _class_FontFile_method_set_glyph_size:
  717. .. rst-class:: classref-method
  718. void **set_glyph_size** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph, :ref:`Vector2<class_Vector2>` gl_size **)**
  719. Sets glyph size.
  720. .. rst-class:: classref-item-separator
  721. ----
  722. .. _class_FontFile_method_set_glyph_texture_idx:
  723. .. rst-class:: classref-method
  724. void **set_glyph_texture_idx** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph, :ref:`int<class_int>` texture_idx **)**
  725. Sets index of the cache texture containing the glyph.
  726. .. rst-class:: classref-item-separator
  727. ----
  728. .. _class_FontFile_method_set_glyph_uv_rect:
  729. .. rst-class:: classref-method
  730. void **set_glyph_uv_rect** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` glyph, :ref:`Rect2<class_Rect2>` uv_rect **)**
  731. Sets rectangle in the cache texture containing the glyph.
  732. .. rst-class:: classref-item-separator
  733. ----
  734. .. _class_FontFile_method_set_kerning:
  735. .. rst-class:: classref-method
  736. void **set_kerning** **(** :ref:`int<class_int>` cache_index, :ref:`int<class_int>` size, :ref:`Vector2i<class_Vector2i>` glyph_pair, :ref:`Vector2<class_Vector2>` kerning **)**
  737. Sets kerning for the pair of glyphs.
  738. .. rst-class:: classref-item-separator
  739. ----
  740. .. _class_FontFile_method_set_language_support_override:
  741. .. rst-class:: classref-method
  742. void **set_language_support_override** **(** :ref:`String<class_String>` language, :ref:`bool<class_bool>` supported **)**
  743. Adds override for :ref:`Font.is_language_supported<class_Font_method_is_language_supported>`.
  744. .. rst-class:: classref-item-separator
  745. ----
  746. .. _class_FontFile_method_set_script_support_override:
  747. .. rst-class:: classref-method
  748. void **set_script_support_override** **(** :ref:`String<class_String>` script, :ref:`bool<class_bool>` supported **)**
  749. Adds override for :ref:`Font.is_script_supported<class_Font_method_is_script_supported>`.
  750. .. rst-class:: classref-item-separator
  751. ----
  752. .. _class_FontFile_method_set_texture_image:
  753. .. rst-class:: classref-method
  754. void **set_texture_image** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index, :ref:`Image<class_Image>` image **)**
  755. Sets font cache texture image.
  756. .. rst-class:: classref-item-separator
  757. ----
  758. .. _class_FontFile_method_set_texture_offsets:
  759. .. rst-class:: classref-method
  760. void **set_texture_offsets** **(** :ref:`int<class_int>` cache_index, :ref:`Vector2i<class_Vector2i>` size, :ref:`int<class_int>` texture_index, :ref:`PackedInt32Array<class_PackedInt32Array>` offset **)**
  761. Sets array containing glyph packing data.
  762. .. rst-class:: classref-item-separator
  763. ----
  764. .. _class_FontFile_method_set_transform:
  765. .. rst-class:: classref-method
  766. void **set_transform** **(** :ref:`int<class_int>` cache_index, :ref:`Transform2D<class_Transform2D>` transform **)**
  767. Sets 2D transform, applied to the font outlines, can be used for slanting, flipping and rotating glyphs.
  768. .. rst-class:: classref-item-separator
  769. ----
  770. .. _class_FontFile_method_set_variation_coordinates:
  771. .. rst-class:: classref-method
  772. void **set_variation_coordinates** **(** :ref:`int<class_int>` cache_index, :ref:`Dictionary<class_Dictionary>` variation_coordinates **)**
  773. Sets variation coordinates for the specified font cache entry. See :ref:`Font.get_supported_variation_list<class_Font_method_get_supported_variation_list>` for more info.
  774. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  775. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  776. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  777. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  778. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  779. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  780. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`