Hello Chris,

On Wednesday 13 January 2010, 18:49, Chris Fleischmann wrote:
> 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.

did you try css.awt.XUnitConversion ? 
http://api.openoffice.org/docs/common/ref/com/sun/star/awt/XUnitConversion.html

see the macros in the doc attached to 
http://www.openoffice.org/issues/show_bug.cgi?id=94067

Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

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

Reply via email to