private void writeCharacterPage(Graphics2D g2d, FontMetrics fm){
        double x = 0;
        double y = 0;
        
        for(char[] range : ranges){
            for(char i = range[0]; i <= range[1]; i++){
                int idx = getIndexOfChar(i);
                double w = charwidths[idx];
                if(x + w > dimx){
                    x = 0;
                    y += charheight+vpad;
                }

                charcoordx[idx] = x;
                charcoordy[idx] = y;

                String str = new String(new char[]{i});
                g2d.drawString(str, (int) x, (int) (fm.getHeight() + y - fm.getDescent()));


                x += w + hpad;
            }
        }
    }