1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CanvasFont.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 import com
.sun
.star
.rendering
.*;
34 public class CanvasFont
35 extends com
.sun
.star
.lib
.uno
.helper
.ComponentBase
36 implements com
.sun
.star
.lang
.XServiceInfo
,
37 com
.sun
.star
.rendering
.XCanvasFont
39 private CanvasBase associatedCanvas
;
40 private com
.sun
.star
.rendering
.FontRequest fontRequest
;
41 private java
.awt
.Font font
;
43 //----------------------------------------------------------------------------------
45 public CanvasFont( com
.sun
.star
.rendering
.FontRequest _fontRequest
,
48 associatedCanvas
= _canvas
;
49 fontRequest
= _fontRequest
;
51 // TODO: Use proper attributes here, first of all, use fractional point font size
52 font
= new java
.awt
.Font( fontRequest
.FontDescription
.FamilyName
, java
.awt
.Font
.PLAIN
, (int)(fontRequest
.CellSize
+ .5) );
55 public java
.awt
.Font
getFont()
60 //----------------------------------------------------------------------------------
63 // XCanvasFont implementation
64 // ===========================
67 public XTextLayout
createTextLayout( StringContext aText
, byte nDirection
, long nRandomSeed
)
69 return new TextLayout( aText
, nDirection
, nRandomSeed
, this, associatedCanvas
);
72 public FontRequest
getFontRequest( )
77 public FontMetrics
getFontMetrics( )
83 public double[] getAvailableSizes( )
89 public com
.sun
.star
.beans
.PropertyValue
[] getExtraFontProperties( )
95 //----------------------------------------------------------------------------------
102 private static final String s_implName
= "CanvasFont.java.impl";
103 private static final String s_serviceName
= "com.sun.star.rendering.XCanvasFont";
105 public String
getImplementationName()
110 public String
[] getSupportedServiceNames()
112 return new String
[] { s_serviceName
};
115 public boolean supportsService( String serviceName
)
117 return serviceName
.equals( s_serviceName
);