0024386: Provide high-level API to specify font by user-defined path for AIS (Prs3d...
[occt.git] / src / Font / Font_FontMgr.cdl
CommitLineData
b311480e 1-- Created on: 2008-01-20
2-- Created by: Alexander A. BORODIN
3-- Copyright (c) 2008-2012 OPEN CASCADE SAS
4--
5-- The content of this file is subject to the Open CASCADE Technology Public
6-- License Version 6.5 (the "License"). You may not use the content of this file
7-- except in compliance with the License. Please obtain a copy of the License
8-- at http://www.opencascade.org and read it completely before using this file.
9--
10-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12--
13-- The Original Code and all software distributed under the License is
14-- distributed on an "AS IS" basis, without warranty of any kind, and the
15-- Initial Developer hereby disclaims all such warranties, including without
16-- limitation, any warranties of merchantability, fitness for a particular
17-- purpose or non-infringement. Please see the License for the specific terms
18-- and conditions governing the rights and limitations under the License.
19
eeaaaefb 20class FontMgr from Font inherits TShared from MMgt
aff395a3 21---Purpose: Collects and provides information about available fonts in system.
22---On Windows it gets information about available fonts from registry value
23---"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts". If the description
24---of the font does not contain the full path to it, FontMgr looks for it in the
25---default fonts directory. (WinAPI function GetSystemWindowsDirectory is used
26---to get the path of the shared Windows directory on a multi-user system.)
27---On Linux and Mac OS X platforms for getting the directories with fonts, at first
28---it checks X11 configuration files, which can be located at "/etc/X11/fs/config",
29---"/usr/X11R6/lib/X11/fs/config" or "/usr/X11/lib/X11/fs/config". Then it adds
30---default directories(for Linux: "/usr/share/fonts" and "/usr/local/share/fonts",
31---for Mac OS X: "/System/Library/Fonts" and "/Library/Fonts"). After that FontMgr
32---looks for the "fonts.dir" file in each stored directory. This file contain
33---fonts description in XLFD (X Logical Font Description) format.
34---On all platforms (Windows, Linux, Mac OS X) we use FreeType library for getting
35---font name and aspect.
36---On Linux and Mac OS X in cases when the font description obtained from FreeType
37---does not match the description in XLFD, FontMgr stores such fonts as two different
38---fonts (font management feature on Unix systems).
7fd59977 39
aff395a3 40uses FontAspect,
41 SystemFont,
7fd59977 42 NListOfSystemFont,
eeaaaefb 43 Path from OSD,
aff395a3 44 AsciiString from TCollection,
45 HAsciiString from TCollection,
46 SequenceOfHAsciiString from TColStd
7fd59977 47is
eeaaaefb 48 GetInstance(myclass) returns FontMgr;
49 ---Level: Public
7fd59977 50
aff395a3 51 GetAvailableFonts(me) returns NListOfSystemFont;
52 ---C++: return const &
53
54 GetAvailableFontsNames(me;
55 theFontsNames: out SequenceOfHAsciiString);
56 ---Purpose: Returns sequence of available fonts names
57 ---Level: Public
58
59 GetFont (me;
60 theFontName : HAsciiString;
61 theFontAspect : FontAspect;
62 theFontSize : Integer) returns SystemFont;
63 ---Purpose: Returns font that match given parameters.
64 --- If theFontName is empty string returned font can have any FontName.
65 --- If theFontAspect is Font_FA_Undefined returned font can have any FontAspect.
66 --- If theFontSize is "-1" returned font can have any FontSize.
67 ---Level: Public
68
69 FindFont (me;
70 theFontName : HAsciiString;
71 theFontAspect : FontAspect;
72 theFontSize : Integer) returns SystemFont;
73 ---Purpose: Tries to find font by given parameters.
74 --- If the specified font is not found tries to use font names mapping.
75 --- If the requested family name not found -> search for any font family
76 --- with given aspect and height. If the font is still not found, returns
77 --- any font available in the system. Returns NULL in case when the fonts
78 --- are not found in the system.
79 ---Level: Public
7fd59977 80
725ef85e 81 CheckFont (me; theFontPath : CString from Standard) returns SystemFont;
82 ---Purpose: Read font file and retrieve information from it.
83 ---Level: Public
84
85 RegisterFont (me : mutable;
86 theFont : SystemFont;
87 theToOverride : Boolean from Standard) returns Boolean from Standard;
88 ---Purpose: Register new font.
89 --- If there is existing entity with the same name and properties but different path
90 --- then font will will be overridden or ignored depending on theToOverride flag.
91 ---Level: Public
92
aff395a3 93 --- Private methods
7fd59977 94
eeaaaefb 95 Create returns FontMgr is private;
96 ---Purpose: Creates empty font object
97 ---Level: Private
7fd59977 98
aff395a3 99 InitFontDataBase(me:mutable) is private;
100 ---Purpose: Collects available fonts paths.
101 ---Level: Private
7fd59977 102
103fields
aff395a3 104
105 myListOfFonts : NListOfSystemFont;
7fd59977 106
eeaaaefb 107end FontMgr;