Package org.jnode.font.bdf

Examples of org.jnode.font.bdf.BDFGlyph


    @Override
    public boolean canDisplay(Font font, char c) {       
        BDFFont bdfFont = getCompatibleFont(font);
       
        //TODO this is a temporary workaround : we should add a method to BDFFont
        BDFGlyph spaceGlyph = bdfFont.getContainer().getGlyph(MISSING_GLYPH_CODE);
        BDFGlyph characterGlyph = bdfFont.getContainer().getGlyph(c);
       
        return (c == MISSING_GLYPH_CODE) || ((c != MISSING_GLYPH_CODE) && (characterGlyph != spaceGlyph));
    }
View Full Code Here


        double height = 0;
        for (char c = ci.setIndex(begin); ci.getIndex() <= limit; c = ci.next()) {
            if (c == CharacterIterator.DONE)
                break;
           
            BDFGlyph g = container.getGlyph(c);
            if (g != null) {
                width += g.getDWidth().width;
                height = Math.max(g.getDWidth().height, height);
            }               
        }
        final Rectangle2D bounds = new Rectangle2D.Double(0, 0, width, height);
               
        transform(bounds, frc);
View Full Code Here

            int y_min = Integer.MAX_VALUE;
            int x_max = Integer.MIN_VALUE;
            int y_max = Integer.MIN_VALUE;

            for (int i = 0; i < charsCount; i++) {
                BDFGlyph glyph = bdfFont.getGlyph(str.charAt(i));
                if (glyph == null) {
                    continue;
                }

                glyph_box = glyph.getBbx(glyph_box);

                final int fHeight = glyph_box.height;
                final int[] fData = glyph.getData();
                final int scan = fData.length / fHeight;

                int fg_r = color.getRed();
                int fg_g = color.getGreen();
                int fg_b = color.getBlue();

                //box location
                final int bx = x + offset + glyph_box.x;
                final int by = y - fHeight - glyph_box.y;

                for (int k = 0; k < fHeight; k++) {
                    final int offsetLine = k * scan;
                    for (int j = 0; j < scan; j++) {
                        int fPixel = fData[offsetLine + j];
                        if (fPixel != 0) {

                            //pixel location
                            int px = bx + j;
                            int py = by + k;

                            if (tx != null) {
                                src.setLocation(px, py);
                                tx.transform(src, dst);
                                px = (int) dst.getX();
                                py = (int) dst.getY();
                            }

                            //clip
                            if (clip == null || clip.contains(px, py)) {
                                //compute color
                                int bg_color = surface.getRGBPixel(px, py);

                                int bg_r = (bg_color & 0x00FF0000) >> 16;
                                int bg_g = (bg_color & 0x0000FF00) >> 8;
                                int bg_b = (bg_color & 0x000000FF);

                                //todo improve this pixel composition

                                float alpha = fPixel / f_max;

                                int r = bg_r + ((int) ((fg_r - bg_r) * alpha)) & 0xFF;
                                int g = bg_g + ((int) ((fg_g - bg_g) * alpha)) & 0xFF;
                                int b = bg_b + ((int) ((fg_b - bg_b) * alpha)) & 0xFF;

                                fPixel = (((r << 16) + (g << 8) + b) | 0xFF000000);

                                surface.setRGBPixel(px, py, fPixel);

                                if (x_min > px) x_min = px;
                                if (y_min > py) y_min = py;
                                if (x_max < px) x_max = px;
                                if (y_max < py) y_max = py;
                            }
                        }
                    }
                }
                offset += glyph.getDWidth().width;
            }
            if (x_min < Integer.MAX_VALUE && y_min < Integer.MAX_VALUE &&
                x_max > Integer.MIN_VALUE && y_max > Integer.MIN_VALUE)
                surface.update(x_min, y_min, x_max - x_min + 1, y_max - y_min + 1);
        }
View Full Code Here

TOP

Related Classes of org.jnode.font.bdf.BDFGlyph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.