223 lines
19 KiB
Text
223 lines
19 KiB
Text
'''Fonts''' are used for rendering text in ''Minecraft''. Several fonts are used in the game; the primary font used is known as [[Mojangles|either Mojangles or Minecraft Seven]].
|
||
|
||
Multiple fonts can be defined and referenced with [[resource pack]]s.
|
||
|
||
== Fonts available ==
|
||
=== ''Java Edition'' ===
|
||
By default, ''[[Java Edition]]'' includes 4 fonts.
|
||
|
||
; {{mono|default}}
|
||
{{main|Mojangles}}
|
||
|
||
; {{mono|alt}}
|
||
{{main|Standard Galactic Alphabet}}
|
||
|
||
; {{mono|uniform}}
|
||
{{main|GNU Unifont}}
|
||
|
||
; {{mono|illageralt}}
|
||
{{main|illageralt}}
|
||
|
||
=== ''Bedrock Edition'' ===
|
||
In ''[[Bedrock Edition]]'', there are 2 default fonts. Many other font resources are used regardless of the font setting. Unlike in ''Java Edition'', the font can be swapped out with a built-in setting.
|
||
The font can be changed in [[File:Chat button.png|25px]] for touchscreens, or {{Xbutton|onedpad-right}} for controllers, and then the gear icon.
|
||
|
||
; Mojangles
|
||
{{main|Mojangles}}
|
||
|
||
; Noto Sans
|
||
{{main|Noto Sans}}
|
||
|
||
== Display modifications ==
|
||
|
||
=== Bold text ===
|
||
{{section needed}}
|
||
|
||
=== Experience bar text ===
|
||
{{section needed}}
|
||
|
||
=== Shadow ===
|
||
In most places text is rendered, a shadow appears beneath every character.
|
||
This shadow is a copy of the character's glyph, with the red, green, and blue values divided by 4 and positioned 12.5% south-east of the character, relative to its spacing.
|
||
Regardless of the resolution of the character's texture, the shadow is always moved by 12.5%.
|
||
In the default font ({{code|assets/minecraft/textures/font/ascii.png}}), the shadow position is moved 1 pixel down and to the right.
|
||
|
||
For pixels where the glyph overlaps with the shadow, the above glyph's channels have 1 subtracted from them. For example, in areas where a white ({{mono|#FFFFFF}}) glyph's pixel overlaps a shadow's, the white pixel becomes {{mono|#FEFEFE}}.
|
||
|
||
=== Glowing text ===
|
||
[[File:Glow text.gif|right|thumb|Comparison of all the dyed glowing texts.]]
|
||
|
||
[[Glow Ink Sac]] applied on a sign causes a character to create eight copies of itself in all eight directions. This results in the font appearing to have a thick outline. Glowing text always renders with an emissive texture, so it appears bright in darkness. The text takes priority over the outline; outlines appear below a character's pixels if they conflict. However, it is a rendering effect that does not actually emit any [[light]]. The player can {{Control|use}} a black ink sac on the sign to remove the glow.
|
||
|
||
In a sign's block data, {{nbt|compound|front_text}} or {{nbt|compound|back_text}}'s {{nbt|bool|has_glowing_text}} controls whether the text glows.
|
||
|
||
== Providers ==
|
||
{{exclusive|java|section=1}}
|
||
|
||
A font is constructed from a list of '''providers''', sources that provide characters to use. Different providers use different formats and methods of constructing characters. The default font uses all except for 1, {{cd|ttf}}.
|
||
|
||
=== Bitmap provider ===
|
||
The {{cd|bitmap}} provider defines simple bitmap glyphs – glyphs from textures. It references a single PNG file, a list of the characters it applies to, an optional height, and an ascent.
|
||
|
||
Textures may be any size, and glyphs may be any color. White glyphs can be colored any other color in-game. Other colors retain that tint when re-colored. Black glyphs always appear black. The glyphs' widths are automatically determined based on the last right-most column of pixels containing any alpha value above 0. Glyphs themselves must not be larger than 512×512 pixels. The '''chars''' field is a list of strings. The characters inside each string entry inside this list are mapped to the corresponding positions in the referenced file. The texture is divided evenly according to the number of strings in the list, and the length of the longest string in that list.
|
||
|
||
Since [[Java Edition 1.16 Pre-release 7]], UTF-16 codepoints encoded in UTF-8 sequences can be used by use of surrogate pairs. To convert a character into a surrogate pair, one can use the following equations, where ''C'' is the codepoint in '''decimal''':
|
||
|
||
* High Surrogate (first codepoint): {{math|((C - 65536) - (C % 1024)) ÷ 1024 + 55296}}
|
||
* Low Surrogate (second codepoint): {{math|(C % 1024) + 56320}}
|
||
|
||
When the length of either the list or the strings is ''not'' a divisor of the resource's dimensions, it can result in an unexpected division of glyphs. The Unicode escape {{mono|\u0000}} can be used to add padding in the list. Padding acts as a "dummy character", so that the glyph data at that corresponding position in the file is not assigned a character.
|
||
|
||
The '''height''' field is the scale of the resulting glyph. This scale should generally match the glyph's individual height, or be a power of it. While heights outside of this recommended range are allowed and are valid, the resulting glyphs declared inside the provider appears warped when rendered in-game. The height field is optional. When not defined, it defaults to 8, regardless of the underlying texture resolution.
|
||
|
||
The '''ascent''' field is the amount of vertical shifting is applied to the glyph. In typography, the ascent is the distance above the baseline to the cap height (top of glyph). The baseline in a glyph is the line where the descender begins. For example, in the lowercase letter {{mono|y}}, the bottom end of the {{mono|y}} extends past the baseline. In Vanilla, when the height is 8, the ascent is most often 7, as the descender is 1.
|
||
|
||
=== Space provider ===
|
||
The {{cd|space}} provider defines the width of a character's glyph. It is the most simple provider: it contains only the character widths.
|
||
|
||
The keys of the '''advances''' are the characters, and the values are the widths. The keys must be only 1 grapheme long (multi-byte character still count as one character, like {{mono|U+1F525 🔥 FIRE}}, which is encoded as {{cd|0xF0 0x9F 0x94 0xA5}}). Values must be an integer whose absolute value is less than or equal to 256. Negative values are forced to 0 when typed in [[chat]]. Although it is intended to be used for whitespace characters (characters that have "WSpace=Y" in Unicode), it can be used for any character, as long as there is no prior definition of that character's glyph.
|
||
|
||
By default, the game has two widths defined:
|
||
|
||
* U+0020 <SPACE> SPACE is 4
|
||
* U+200C <ZWNJ> ZERO WIDTH NON-JOINER is 0
|
||
|
||
=== TTF provider ===
|
||
The {{cd|ttf}} provider embeds already-compiled TrueType and OpenType fonts.{{fn|Despite its name, the TTF provider accepts OpenType ("otf") fonts.}} It contains 5 fields.
|
||
|
||
The '''file''' field is a [[resource location]] to a file ending in {{cd|.ttf}}. Path is relative from {{mono|/assets/minecraft/font/}}.
|
||
|
||
The '''shift''' field is an array of two integers. It defines how much each glyph contained in this TrueType font is to be moved horizontally and vertically, respectively. The first element controls the horizontal shifting (positive is ''leftward'', negative is ''rightward''). The second element controls the vertical shifting (positive is ''downward'', negative is ''upward'').
|
||
|
||
The '''size''' field is similar to a bitmap provider's height field. This is a divisor by which the em-size of the font's glyphs are to be divided and then fitted into the bitmap grid. This value can vary greatly across different fonts.
|
||
|
||
The '''oversample''' field is the resolution to render at. Values that don't match the glyph's native em sizing division or DPI cause it to be anti-aliased.
|
||
|
||
The '''skip''' field is either a list of strings, or a string of the characters to which this font has no assignment. If it is a list of strings, the strings are concatenated together and then act as if it were originally a string. This allows the same input as a bitmap provider's '''chars'''.
|
||
|
||
=== Legacy Unicode provider ===
|
||
{{Outdated feature|section=1}}
|
||
|
||
The {{cd|legacy_unicode}} provider is similar to the bitmap provider in that it loads glyphs from only textures. This format is deprecated, and is prioritized only when the "Force Unicode Font" option is turned on. It acts as a "fallback" for glyphs that no other provider has defined a texture for.
|
||
|
||
It uses a system of templates to create and add high amounts of characters. Templates are name-based, and are all PNG files. Each template file must have equal width and height. The template numbering scheme works based off of the Unicode [[wikipedia:Plane_(Unicode)#Basic_Multilingual_Plane|BMP]]. The number used is equal to a BMP codepoint's high byte.{{fn|"High byte" refers to the first byte in a multi-byte sequence. For example, the high byte of {{cd|0xABCD}} is {{cd|0xAB}}.}}{{fn|For codepoints with digits less than 4, they are padded with 0. For example, {{cd|0xF3}} would be padded to {{cd|0x00F3}}: page 00. Likewise, {{cd|0xFAE}} is {{cd|0x0FAE}}: page 0F.}} These template textures are called "pages". Template page "22" must cover characters {{mono|U+2200}} to {{mono|U+22FF}}. Page numbers go from {{cd|00}} to {{cd|FF}}. Characters beyond {{mono|U+FFFF}} cannot be changed through this provider. By default, each glyph is 16×16 pixels wide, so each individual template page is 256×256 pixels (16 glyphs on each line, 16 lines). Its default textures are an outdated version of [https://unifoundry.com/unifont/index.html GNU Unifont].<ref>{{bug|MC-197772||Missing textures in minecraft:uniform font|Fixed}}</ref><!-- The degree of how outdated it is, is unknown. -->
|
||
|
||
The '''template''' field is a string that references a set of files. The string {{cd|%s}} must be included in this field. {{cd|%s}} is replaced with every valid page number, in hexadecimal.
|
||
|
||
The '''sizes''' field references a binary resource that contains the widths of each glyph. Most often, this file is called {{cd|glyph_sizes.bin}}; this is its default name.
|
||
Each character width is one byte large. The high nibble{{fn|A nibble is "half" of a byte. For example, in the byte {{mono|0xAB}}, {{mono|A}} is the high nibble and {{mono|B}} is the low nibble.}} records the starting position, while the lower nibble records the ending position in the 16×16 glyph grid. For this reason, the file must be 0xFFFF bytes long (65535 in decimal).
|
||
A specific character's width is determined by finding its codepoints byte. The character 'A' has a codepoint of {{mono|U+0041}}, so byte offset {{mono|0x41}} (65 in decimal) would be addressed. A square character occupying the entire grid (pixel width #1 [0, 0x0] through #16 [15, 0xF]) would have a value of 0x0F (15 in decimal).
|
||
Widths cannot extend past 16 pixels, and characters whose codepoints are greater than {{mono|U+FFFF}} are not handled.
|
||
|
||
Some codepoints are invalid on their own. These are the [[wikipedia:UTF-16#U+D800_to_U+DFFF_(surrogates)|surrogate pairs]]; they are used to encode codepoints higher than {{mono|U+FFFF}} in UTF-16.
|
||
This means that the template pages {{code|D8|D9|DA|DB|DC|DD|DE|DF}} are invalid and cannot be used.
|
||
|
||
It was removed in [[23w17a]].
|
||
|
||
=== Unihex provider ===
|
||
The {{cd|unihex}} provider is a replacement for the Legacy Unicode provider, introduced in [[23w17a]]. It uses the [[wikipedia:GNU_Unifont#.hex_format|GNU Unifont .hex format]]. It references a ZIP archive that contains a number of {{cd|.hex}} files.
|
||
|
||
The '''hex_file''' field is a [[resource location]] to a .ZIP archive file. It must be openable by Java's [https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/zip/ZipFile.html ZipFile]. Inside, there must be at least 1 {{cd|.hex}} file at the root of the archive. Subdirectories are not walked through and filenames with an extension different from ".hex" are ignored. Filenames must follow normal file resource name rules.
|
||
In each .hex file is 1 or more glyph definitions. A glyph definitions is 1 line only, and follows the format {{code|codepoint:data}}. The ''codepoint'' is the Unicode codepoint, without the U+ or 0x. It must have 4, 5, or 6 digits. The ''data'' is a hexadecimal number that encodes the glyph data. Glyphs are always 16 pixels high. Glyphs can be 8, 16, 24, or 32 pixels wide.{{fn|Because the height is always 16, the width can be calculated. It is always equal to {{cd|len(data) // 4}}.}}
|
||
|
||
The '''size_overrides''' field is a list of compounds that define custom widths for a range of characters. Each element in this list must be a compound. Inside of each compound are 4 fields. '''from''' is the starting character for the range at which this size override applies to. '''to''' is the ending character for this range. Both '''from''' and '''to''' must be 1 character. '''left''' is the position of the left-most column of glyphs in range. '''right''' is the position of the right-most column of glyphs in range. Both '''left''' and '''right''' cannot be less than 0 or greater than 32.
|
||
|
||
=== Reference provider ===
|
||
The {{cd|reference}} provider serves one purpose: to include another provider only once. It can be used to include providers from other fonts in other resource packs.
|
||
|
||
Referenced providers are guaranteed to be loaded only once, no matter how many times they are included.
|
||
|
||
The '''id''' field is a [[resource location]] to another font file.
|
||
|
||
=== Filters ===
|
||
All font providers can be selectively included depending upon toggle-able buttons in-game.
|
||
|
||
Right now, these buttons are hardcoded, preventing the extension of these font filtering capabilities beyond the preset options provided.
|
||
Two buttons exist, located in Language -> Font Settings.
|
||
They are "Force Uniform" and "Japanese Glyph Variants".
|
||
|
||
== Emoji support ==
|
||
''Minecraft'' has included textures for a number of emojis. The earliest emoji textures were for {{mono|☺☻}}.
|
||
Since [[Java Edition 1.15|1.15]], this support has expanded. Emojis are monochromatic and behave just as any other character. The game does not support modifiers, such as skin tone, joining, or [[wikipedia:Emoji#Emoji_versus_text_presentation|emoji presentation]]. The skin tone modifiers {{mono|U+1F3FB..U+1F3FF 🏻 🏼 🏽 🏾 🏿}}<!-- Be careful when changing these, as your text input likely treats the skin tone modifiers as 'unselectable' or innately part of the prior space. --> do not apply colored skin tones to their applicable emojis, and instead show tones as their Unifont glyphs. Joining multiple emojis via {{mono|U+200D ‍ ZERO WIDTH JOINER}} to create 1 single emoji is not supported; multi-sequence emoji such as {{mono|👨👩👧}} instead show as {{mono|👨‌👩‌👧}} with dotted boxes showing {{mono|ZWJ}} between them. Variation selectors, which control presentation, are displayed as dotted boxes with {{mono|VS''number''}}.
|
||
|
||
For characters supported in the default font, as opposed to the fallback fonts, see [[Mojangles#Emoji]].
|
||
|
||
''Bedrock Edition'' does not support any character above {{mono|U+FFFF}}, which includes many modern emoji. It does not include any textures for emojis below that either; only those provided by GNU Unifont below {{mono|U+FFFF}} are included and visible.
|
||
|
||
== Special characters ==
|
||
{{IN|java}}, there are 2 characters that are accessible only through technical means:
|
||
* The first is {{mono|U+FFFD <20> REPLACEMENT CHARACTER}}, which appears when either the U+FFFD character is typed, or there is an invalid UTF-8 multi-byte sequence.
|
||
* The second is the "notdef" character,{{fn|Is not an actual Unicode character. "notdef" refers to the name given to it in font formats.}} seen when a character that has no texture in the currently-used font is typed. It is hardcoded and cannot be modified through resource packs. It is sometimes called "tofu" in the typographical community because of it resembles a block of {{w|tofu}}. More information on this character can be found at [[Missing textures and models#Missing font character]].
|
||
|
||
{{IN|bedrock}}, a character with no texture data appears as a blank space. The {{mono|U+FFFD <20> REPLACEMENT CHARACTER}} shown belongs to GNU Unifont.
|
||
|
||
== History ==
|
||
{{info needed section|Console Edition font info}}
|
||
{{HistoryTable
|
||
|{{HistoryLine|Java classic}}
|
||
|{{HistoryLine||0.0.2a|Added text to the game, and the default font as a result.}}
|
||
|{{HistoryLine|Java}}
|
||
|{{HistoryLine||1.1|dev=11w49a|Added GNU Unifont to fully support multi-[[language]]s.}}
|
||
|{{HistoryLine||1.5|dev=13w09a|The font texture is now able to be changed in a resource pack.
|
||
|Added support for glyph resolutions above 16×16.}}
|
||
|{{HistoryLine||1.6.2|dev=reupload|slink=Java Edition 1.6.2#Reuploads|Fixed distorted font when HD font is used.<ref>{{bug|MC-17673||Distorted fonts when using a converted texturepack on startup|Fixed}}</ref>}}
|
||
|{{HistoryLine||1.13|dev=pre6|Fonts are now saved as TrueType font files.}}
|
||
|{{HistoryLine|||dev=pre7|Reverted TrueType font.
|
||
|Retroactively removed TrueType font file from pre-6.}}
|
||
|{{HistoryLine||1.16|dev=20w17a|[[Raw JSON text format]] now has a {{cd|font}} key, which defines the font to use for that component. Default is {{cd|minecraft:default}}.
|
||
|Added the {{cd|unihex}} provider.{{verify|this seems misplaced}}
|
||
|The full range of Unicode is now supported in font definitions.{{verify|may also be misplaced}}}}
|
||
|{{HistoryLine||1.19|dev=22w11a|Added the {{cd|space}} provider.
|
||
|Rendering of the space glyph is no longer hardcoded; it needs to be declared manually in the font.}}
|
||
|{{HistoryLine||1.20|dev=23w17a|Removed the {{cd|legacy_unicode}} provider.
|
||
|Added the {{cd|unihex}} provider.
|
||
|Added the {{cd|reference}} provider.}}
|
||
|{{HistoryLine||1.20.5|dev=24w06a|Added font variant filters to font providers.}}
|
||
|{{HistoryLine||1.21.4|dev=Pre-Release 1|[[GNU Unifont]] updated to version 16.0.01.}}
|
||
|
||
|{{HistoryLine|Pocket alpha}}
|
||
|{{HistoryLine||v0.1.0|Added the default ASCII font called {{cd|default.png}}.}}
|
||
|{{HistoryLine||v0.11.0|dev=build 1|Added GNU Unifont to fully support multi-languages.}}
|
||
}}
|
||
|
||
== Issues ==
|
||
{{issue list}}
|
||
|
||
== Trivia ==
|
||
* Although not in the changelog or specification, the default copy of the {{cd|unihex}} provider also includes a {{nbt|list|__ranges}} field in the {{nbt|compound}} entries of {{nbt|list|size_overrides}}. It is a list of strings, being the Unicode block names of the applying range.
|
||
* The [[New Nintendo 3DS Edition]]'s font is a combination of the pre-1.12 JE font and some select characters from GNU Unifont. In addition, the {{mono|®}} sign was changed.
|
||
|
||
== Gallery ==
|
||
<gallery>
|
||
Lit vs unlit signs.png|Side-by-side comparison of glowing text versus normal text on a sign.
|
||
Minecraft Formatting.gif|Formatted text in a book.
|
||
Textformatting.png|Formatted text in chat.
|
||
Font emojis JE1.png|The collection of the emojis in Java Edition.
|
||
Font typography diagram JE1.png|A diagram of typography terms and their relation to the font.
|
||
Font ZWJ example JE1.png|Example of how multi-sequence emojis do not render correctly. This is the emoji {{mono|👨👩👧}}. The [ZWJ] are {{mono|U+200D ‍ ZERO WIDTH JOINER}}
|
||
Font U+FFFD and notdef JE1.png|Side-by-side comparison of <20> and the notdef character.
|
||
Emojis.png|The 43 supported emojis as they appear in-game.
|
||
</gallery>
|
||
|
||
== See also ==
|
||
* [[Language]]
|
||
* [[Resource packs#Fonts]]
|
||
* [[Sign]]
|
||
|
||
== Notes ==
|
||
{{fnlist}}
|
||
|
||
== References ==
|
||
{{reflist}}
|
||
|
||
== External links ==
|
||
* [https://unifoundry.com/unifont/index.html GNU Unifont]
|
||
|
||
== Navigation ==
|
||
{{Navbox gameplay}}
|
||
|
||
[[Category:Font| ]]
|
||
|
||
[[de:Schriftdaten]]
|
||
[[ja:フォント]]
|
||
[[zh:字体]]
|