- 355
- 2
- 17
Добро! Я использую библиотеку Slick2D для отрисовки шрифтов по типу .ttf, на версиях ниже 1.10 все работает нормально, а вот на MCP 1.10 вот такой вот косяк, ломает все другие шрифты (обычные майна), по всей области данного GUI (чат не трогает).
Насколько я понял, это уже где-то в UnicodeFont самой библиотеки, пробовал оборачивать рендер шрифта в GL11.glPushMatrix и GL11.glPopMatrix - Не помогло. Что это может быть?
Возможно что-то подрубается или отрубается в методе рендера, так что приложу его:
Насколько я понял, это уже где-то в UnicodeFont самой библиотеки, пробовал оборачивать рендер шрифта в GL11.glPushMatrix и GL11.glPopMatrix - Не помогло. Что это может быть?
Возможно что-то подрубается или отрубается в методе рендера, так что приложу его:
Java:
public UnicodeFont.DisplayList drawDisplayList(float x, float y, String text, Color color, int startIndex, int endIndex) {
if (text == null) {
throw new IllegalArgumentException("text cannot be null.");
} else if (text.length() == 0) {
return EMPTY_DISPLAY_LIST;
} else if (color == null) {
throw new IllegalArgumentException("color cannot be null.");
} else {
x -= (float)this.paddingLeft;
y -= (float)this.paddingTop;
String displayListKey = text.substring(startIndex, endIndex);
color.bind();
TextureImpl.bindNone();
UnicodeFont.DisplayList displayList = null;
if (this.displayListCaching && this.queuedGlyphs.isEmpty()) {
if (this.baseDisplayListID == -1) {
this.baseDisplayListID = GL.glGenLists(200);
if (this.baseDisplayListID == 0) {
this.baseDisplayListID = -1;
this.displayListCaching = false;
return new UnicodeFont.DisplayList();
}
}
displayList = (UnicodeFont.DisplayList)this.displayLists.get(displayListKey);
if (displayList != null) {
if (!displayList.invalid) {
GL.glTranslatef(x, y, 0.0F);
GL.glCallList(displayList.id);
GL.glTranslatef(-x, -y, 0.0F);
return displayList;
}
displayList.invalid = false;
} else if (displayList == null) {
displayList = new UnicodeFont.DisplayList();
int displayListCount = this.displayLists.size();
this.displayLists.put(displayListKey, displayList);
if (displayListCount < 200) {
displayList.id = this.baseDisplayListID + displayListCount;
} else {
displayList.id = this.eldestDisplayListID;
}
}
this.displayLists.put(displayListKey, displayList);
}
GL.glTranslatef(x, y, 0.0F);
if (displayList != null) {
GL.glNewList(displayList.id, 4865);
}
char[] chars = text.substring(0, endIndex).toCharArray();
GlyphVector vector = this.font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length, 0);
int maxWidth = 0;
int totalHeight = 0;
int lines = 0;
int extraX = 0;
int extraY = this.ascent;
boolean startNewLine = false;
Texture lastBind = null;
int glyphIndex = 0;
for(int n = vector.getNumGlyphs(); glyphIndex < n; ++glyphIndex) {
int charIndex = vector.getGlyphCharIndex(glyphIndex);
if (charIndex >= startIndex) {
if (charIndex > endIndex) {
break;
}
int codePoint = text.codePointAt(charIndex);
Rectangle bounds = this.getGlyphBounds(vector, glyphIndex, codePoint);
Glyph glyph = this.getGlyph(vector.getGlyphCode(glyphIndex), codePoint, bounds, vector, glyphIndex);
if (startNewLine && codePoint != 10) {
extraX = -bounds.x;
startNewLine = false;
}
Image image = glyph.getImage();
if (image == null && this.missingGlyph != null && glyph.isMissing()) {
image = this.missingGlyph.getImage();
}
if (image != null) {
Texture texture = image.getTexture();
if (lastBind != null && lastBind != texture) {
GL.glEnd();
lastBind = null;
}
if (lastBind == null) {
texture.bind();
GL.glBegin(7);
lastBind = texture;
}
image.drawEmbedded((float)(bounds.x + extraX), (float)(bounds.y + extraY), (float)image.getWidth(), (float)image.getHeight());
}
if (glyphIndex >= 0) {
extraX += this.paddingRight + this.paddingLeft + this.paddingAdvanceX;
}
maxWidth = Math.max(maxWidth, bounds.x + extraX + bounds.width);
totalHeight = Math.max(totalHeight, this.ascent + bounds.y + bounds.height);
if (codePoint == 10) {
startNewLine = true;
extraY += this.getLineHeight();
++lines;
totalHeight = 0;
}
}
}
if (lastBind != null) {
GL.glEnd();
}
if (displayList != null) {
GL.glEndList();
if (!this.queuedGlyphs.isEmpty()) {
displayList.invalid = true;
}
}
GL.glTranslatef(-x, -y, 0.0F);
if (displayList == null) {
displayList = new UnicodeFont.DisplayList();
}
displayList.width = (short)maxWidth;
displayList.height = (short)(lines * this.getLineHeight() + totalHeight);
return displayList;
}
}