예제 #1
0
 private void completeStructure(
     List<Line> lines, Line currentLine, Word currentWord, GUIText text) {
   boolean added = currentLine.attemptToAddWord(currentWord);
   if (!added) {
     lines.add(currentLine);
     currentLine = new Line(metaData.getSpaceWidth(), text.getFontSize(), text.getMaxLineSize());
     currentLine.attemptToAddWord(currentWord);
   }
   lines.add(currentLine);
 }
예제 #2
0
 private List<Line> createStructure(GUIText text) {
   char[] chars = text.getTextString().toCharArray();
   List<Line> lines = new ArrayList<Line>();
   Line currentLine =
       new Line(metaData.getSpaceWidth(), text.getFontSize(), text.getMaxLineSize());
   Word currentWord = new Word(text.getFontSize());
   for (char c : chars) {
     int ascii = (int) c;
     if (ascii == SPACE_ASCII) {
       boolean added = currentLine.attemptToAddWord(currentWord);
       if (!added) {
         lines.add(currentLine);
         currentLine =
             new Line(metaData.getSpaceWidth(), text.getFontSize(), text.getMaxLineSize());
         currentLine.attemptToAddWord(currentWord);
       }
       currentWord = new Word(text.getFontSize());
       continue;
     }
     Character character = metaData.getCharacter(ascii);
     currentWord.addCharacter(character);
   }
   completeStructure(lines, currentLine, currentWord, text);
   return lines;
 }
예제 #3
0
 private TextMeshData createQuadVertices(GUIText text, List<Line> lines) {
   text.setNumberOfLines(lines.size());
   double curserX = 0f;
   double curserY = 0f;
   List<Float> vertices = new ArrayList<Float>();
   List<Float> textureCoords = new ArrayList<Float>();
   for (Line line : lines) {
     if (text.isCentered()) {
       curserX = (line.getMaxLength() - line.getLineLength()) / 2;
     }
     for (Word word : line.getWords()) {
       for (Character letter : word.getCharacters()) {
         addVerticesForCharacter(curserX, curserY, letter, text.getFontSize(), vertices);
         addTexCoords(
             textureCoords,
             letter.getxTextureCoord(),
             letter.getyTextureCoord(),
             letter.getXMaxTextureCoord(),
             letter.getYMaxTextureCoord());
         curserX += letter.getxAdvance() * text.getFontSize();
       }
       curserX += metaData.getSpaceWidth() * text.getFontSize();
     }
     curserX = 0;
     curserY += LINE_HEIGHT * text.getFontSize();
   }
   return new TextMeshData(listToArray(vertices), listToArray(textureCoords));
 }