 | OO-Snippets: Display the available fontsCommons| Keywords | getFontDescriptors, Font, FontDescriptor, getContainerWindow |
|---|
| Language | OOBasic |
|---|
| Application | Office |
|---|
| Authors | Andrew Pitonyak (initial)
|
|---|
| Supported Versions | |
|---|
| Supported OS | |
|---|
| Question |
How can I list the fonts available to a document?
|
|---|
| Answer |
The available fonts are known by the container window. The
getFontDescriptors() method returns an array of awt FontDescriptor
structures that contain a lot of information about the font. The font
descriptor can be passed to the getFont() method, which returns an
object that supports the awt XFont interface. The XFont interface
provides methods to determine font metrics, and the width of an
individual character or an entire string of characters.
Taken from Andrew's Macro Document at
http://www.pitonyak.org |
|---|
Sub ListFonts
Dim oWindow
Dim oDescript
Dim s$
Dim i%
oWindow = ThisComponent.getCurrentController().getFrame().getContainerWindow()
oDescript = oWindow.getFontDescriptors()
s = ""
For i = LBound(oDescript) to UBound(oDescript)
s = s & oDescript(i).Name & ", "
Next
MsgBox s
End Sub
|
Changelog| Date | User | Modification |
|---|
| 2004-06-28 | pitonyak | Initial version |
|