Hello folks, just wondering if there is a more accurate way of converting
pixels to 1/00mm in OpenOffice... Other than the 72 DPI type of calculation
people use?

Currently I do the following: 

                if (fontDescriptor[i].Name.equalsIgnoreCase("Arial")) {
                    fontDescriptor[i].Height = (short)12; // just an
arbitrary height number.
                    
                    XFont xFont = xDevice.getFont(fontDescriptor[i]);
                    
                    width = xFont.getStringWidth(message);

                    SimpleFontMetric simpleFontMetric =
xFont.getFontMetric();

                    height = simpleFontMetric.Ascent +
                        simpleFontMetric.Descent +
                        simpleFontMetric.Leading;

                    break;
                }
            }
            Object shape = xWriterFactory_tmp.createInstance(
                "com.sun.star.drawing.RectangleShape");

            XShape xShape = (XShape) UnoRuntime.queryInterface(
                XShape.class, shape);

            xShape.setPosition(new Point(pageBorderLeft, pageBorderTop));

            int nwidth = (int)(((float)width / (float)72) * (float)2540) +
50; // This is what I use to convert, which works on the MAC.
            int nheight = (int)(((float)height / (float)72) * (float)2540) +
50; // This is what I use to convert, which works on the MAC.
            
            System.out.println("New Height: " + nheight);
            System.out.println("New Width: " + nwidth);

            xShape.setSize(new Size(nwidth, nheight));

Now the above code works hapilly on my Apple Laptop, but when I move the
same code over to OpenSolaris and the width calculation is way off.... the
font is either larger or smaller depending on the height size of the font.

Any advice or help, much appreciated.

Thanks,

Chris

-- 
View this message in context: 
http://old.nabble.com/Please-Help%3A-Getting-the-width---height-sizes-to-create-a-RectangleShape-to-create-a-boundary-box-tp27152636p27152636.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org

Reply via email to