public class FontRenderer extends java.lang.Object implements IResourceManagerReloadListener
Modifier and Type | Field and Description |
---|---|
private float |
alpha
Used to speify new alpha value for the current color.
|
private boolean |
bidiFlag
If true, the Unicode Bidirectional Algorithm should be run before rendering any string.
|
private float |
blue
Used to specify new blue value for the current color.
|
private boolean |
boldStyle
Set if the "l" style (bold) is active in currently rendering string
|
private int[] |
charWidth
Array of width of all the characters in default.png
|
private int[] |
colorCode
Array of RGB triplets defining the 16 standard chat colors followed by 16 darker version of the same colors for
drop shadows.
|
int |
FONT_HEIGHT
the height in pixels of default text
|
java.util.Random |
fontRandom |
private byte[] |
glyphWidth
Array of the start/end column (in upper/lower nibble) for every glyph in the /font directory.
|
private float |
green
Used to specify new green value for the current color.
|
private boolean |
italicStyle
Set if the "o" style (italic) is active in currently rendering string
|
private ResourceLocation |
locationFontTexture |
private float |
posX
Current X coordinate at which to draw the next character.
|
private float |
posY
Current Y coordinate at which to draw the next character.
|
private boolean |
randomStyle
Set if the "k" style (random) is active in currently rendering string
|
private float |
red
Used to specify new red value for the current color.
|
private TextureManager |
renderEngine
The RenderEngine used to load and setup glyph textures.
|
private boolean |
strikethroughStyle
Set if the "m" style (strikethrough) is active in currently rendering string
|
private int |
textColor
Text color of the currently rendering string.
|
private boolean |
underlineStyle
Set if the "n" style (underlined) is active in currently rendering string
|
private boolean |
unicodeFlag
If true, strings should be rendered with Unicode fonts instead of the default.png font
|
private static ResourceLocation[] |
unicodePageLocations |
Constructor and Description |
---|
FontRenderer(GameSettings gameSettingsIn,
ResourceLocation location,
TextureManager textureManagerIn,
boolean unicode) |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
bidiReorder(java.lang.String p_147647_1_)
Apply Unicode Bidirectional Algorithm to string and return a new possibly reordered string for visual rendering.
|
void |
drawSplitString(java.lang.String str,
int x,
int y,
int wrapWidth,
int textColor)
Splits and draws a String with wordwrap (maximum length is parameter k)
|
int |
drawString(java.lang.String text,
float x,
float y,
int color,
boolean dropShadow)
Draws the specified string.
|
int |
drawString(java.lang.String text,
int x,
int y,
int color)
Draws the specified string.
|
int |
drawStringWithShadow(java.lang.String text,
float x,
float y,
int color)
Draws the specified string with a shadow.
|
private float |
func_181559_a(char p_181559_1_,
boolean p_181559_2_) |
boolean |
getBidiFlag()
Get bidiFlag that controls if the Unicode Bidirectional Algorithm should be run before rendering any string
|
int |
getCharWidth(char character)
Returns the width of this character as rendered.
|
int |
getColorCode(char character) |
static java.lang.String |
getFormatFromString(java.lang.String text)
Digests a string for nonprinting formatting characters then returns a string containing only that formatting.
|
int |
getStringWidth(java.lang.String text)
Returns the width of this string.
|
boolean |
getUnicodeFlag()
Get unicodeFlag controlling whether strings should be rendered with Unicode fonts instead of the default.png
font.
|
private ResourceLocation |
getUnicodePageLocation(int p_111271_1_) |
private static boolean |
isFormatColor(char colorChar)
Checks if the char code is a hexadecimal character, used to set colour.
|
private static boolean |
isFormatSpecial(char formatChar)
Checks if the char code is O-K...lLrRk-o...
|
java.util.List<java.lang.String> |
listFormattedStringToWidth(java.lang.String str,
int wrapWidth) |
private void |
loadGlyphTexture(int p_78257_1_)
Load one of the /font/glyph_XX.png into a new GL texture and store the texture ID in glyphTextureName array.
|
void |
onResourceManagerReload(IResourceManager resourceManager) |
private void |
readFontTexture() |
private void |
readGlyphSizes() |
private float |
renderDefaultChar(int p_78266_1_,
boolean p_78266_2_)
Render a single character with the default.png font at current (posX,posY) location...
|
private void |
renderSplitString(java.lang.String str,
int x,
int y,
int wrapWidth,
boolean addShadow)
Perform actual work of rendering a multi-line string with wordwrap and with darker drop shadow color if flag is
set
|
private int |
renderString(java.lang.String text,
float x,
float y,
int color,
boolean dropShadow)
Render single line string by setting GL color, current (posX,posY), and calling renderStringAtPos()
|
private int |
renderStringAligned(java.lang.String text,
int x,
int y,
int p_78274_4_,
int color,
boolean dropShadow)
Render string either left or right aligned depending on bidiFlag
|
private void |
renderStringAtPos(java.lang.String p_78255_1_,
boolean p_78255_2_)
Render a single line string at the current (posX,posY) and update posX
|
private float |
renderUnicodeChar(char p_78277_1_,
boolean p_78277_2_)
Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files...
|
private void |
resetStyles()
Reset all style flag fields in the class to false; called at the start of string rendering
|
void |
setBidiFlag(boolean bidiFlagIn)
Set bidiFlag to control if the Unicode Bidirectional Algorithm should be run before rendering any string.
|
void |
setUnicodeFlag(boolean unicodeFlagIn)
Set unicodeFlag controlling whether strings should be rendered with Unicode fonts instead of the default.png
font.
|
private int |
sizeStringToWidth(java.lang.String str,
int wrapWidth)
Determines how many characters from the string will fit into the specified width.
|
int |
splitStringWidth(java.lang.String p_78267_1_,
int p_78267_2_)
Returns the width of the wordwrapped String (maximum length is parameter k)
|
private java.lang.String |
trimStringNewline(java.lang.String text)
Remove all newline characters from the end of the string
|
java.lang.String |
trimStringToWidth(java.lang.String text,
int width)
Trims a string to fit a specified Width.
|
java.lang.String |
trimStringToWidth(java.lang.String text,
int width,
boolean reverse)
Trims a string to a specified width, and will reverse it if par3 is set.
|
(package private) java.lang.String |
wrapFormattedStringToWidth(java.lang.String str,
int wrapWidth)
Inserts newline and formatting into a string to wrap it within the specified width.
|
private static final ResourceLocation[] unicodePageLocations
private int[] charWidth
public int FONT_HEIGHT
public java.util.Random fontRandom
private byte[] glyphWidth
private int[] colorCode
private final ResourceLocation locationFontTexture
private final TextureManager renderEngine
private float posX
private float posY
private boolean unicodeFlag
private boolean bidiFlag
private float red
private float blue
private float green
private float alpha
private int textColor
private boolean randomStyle
private boolean boldStyle
private boolean italicStyle
private boolean underlineStyle
private boolean strikethroughStyle
public FontRenderer(GameSettings gameSettingsIn, ResourceLocation location, TextureManager textureManagerIn, boolean unicode)
public void onResourceManagerReload(IResourceManager resourceManager)
onResourceManagerReload
in interface IResourceManagerReloadListener
private void readFontTexture()
private void readGlyphSizes()
private float func_181559_a(char p_181559_1_, boolean p_181559_2_)
private float renderDefaultChar(int p_78266_1_, boolean p_78266_2_)
private ResourceLocation getUnicodePageLocation(int p_111271_1_)
private void loadGlyphTexture(int p_78257_1_)
private float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_)
public int drawStringWithShadow(java.lang.String text, float x, float y, int color)
public int drawString(java.lang.String text, int x, int y, int color)
public int drawString(java.lang.String text, float x, float y, int color, boolean dropShadow)
private java.lang.String bidiReorder(java.lang.String p_147647_1_)
private void resetStyles()
private void renderStringAtPos(java.lang.String p_78255_1_, boolean p_78255_2_)
private int renderStringAligned(java.lang.String text, int x, int y, int p_78274_4_, int color, boolean dropShadow)
private int renderString(java.lang.String text, float x, float y, int color, boolean dropShadow)
public int getStringWidth(java.lang.String text)
public int getCharWidth(char character)
public java.lang.String trimStringToWidth(java.lang.String text, int width)
public java.lang.String trimStringToWidth(java.lang.String text, int width, boolean reverse)
private java.lang.String trimStringNewline(java.lang.String text)
public void drawSplitString(java.lang.String str, int x, int y, int wrapWidth, int textColor)
private void renderSplitString(java.lang.String str, int x, int y, int wrapWidth, boolean addShadow)
public int splitStringWidth(java.lang.String p_78267_1_, int p_78267_2_)
public void setUnicodeFlag(boolean unicodeFlagIn)
public boolean getUnicodeFlag()
public void setBidiFlag(boolean bidiFlagIn)
public java.util.List<java.lang.String> listFormattedStringToWidth(java.lang.String str, int wrapWidth)
java.lang.String wrapFormattedStringToWidth(java.lang.String str, int wrapWidth)
private int sizeStringToWidth(java.lang.String str, int wrapWidth)
private static boolean isFormatColor(char colorChar)
private static boolean isFormatSpecial(char formatChar)
public static java.lang.String getFormatFromString(java.lang.String text)
public boolean getBidiFlag()
public int getColorCode(char character)