RandomGuy32

determineGlyphWidths()

Jun 11th, 2016
142
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×