Advertisement
RandomGuy32

determineGlyphWidths()

Jun 11th, 2016
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. byte[] widths = new byte[this.end - this.start + 1];
  2.  
  3.  
  4.         for (int i: widths) {
  5.             BufferedImage sheet = this.sheets.get(i / 128);
  6.  
  7.             for (int j = 0; j < 128; j++) {
  8.                 // for each individual glyph...
  9.                 int width = 0;
  10.                 boolean[] isWhite = new boolean[128];
  11.  
  12.                 for (int k = 0; k < 128; k++) {
  13.                     // for each individual pixel...
  14.                     int x = (j % 128) / 8 + (k / 8);
  15.                     int y = (j / 128) * 8 + (k % 8);
  16.  
  17.                     isWhite[k] = sheet.getRGB(x, y) == (new Color(0xff, 0xff, 0xff)).getRGB();   // I don't trust any of this
  18.                 }
  19.  
  20.                 for (int h = 127; h >= 0; h--) {
  21.                     // for each individual pixel in reverse
  22.                     if (isWhite[h]) {
  23.                         int index = 127 - h;
  24.  
  25.                         width = index % 8;
  26.                     }
  27.                 }
  28.  
  29.                 widths[i] = (byte) width;
  30.             }
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement