/usr/src/castle-game-engine-4.1.1/opengl/windows/castleglwindowsfonts.pas is in castle-game-engine-src 4.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | {
Copyright 2004-2013 Michalis Kamburelis.
This file is part of "Castle Game Engine".
"Castle Game Engine" is free software; see the file COPYING.txt,
included in this distribution, for details about the copyright.
"Castle Game Engine" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
}
{ OpenGL fonts from TrueType fonts installed in Windows.
We create Windows font using unit CastleWindowsFonts,
then convert it to TOutlineFont/TBitmapFont using unit CastleWinFontConvert,
then utilize it in OpenGL using unit CastleGLBitmapFonts / CastleGLOutlineFonts.
So this unit is just a simple wrapper for some other units.
}
unit CastleGLWindowsFonts;
interface
uses CastleWindowsFonts, GL, GLU, GLExt, Windows,
CastleBitmapFonts, CastleOutlineFonts, CastleWinFontConvert,
CastleGLBitmapFonts, CastleGLOutlineFonts;
type
{ Outline OpenGL font from an installed Windows font. }
TWindowsOutlineFont = class(TGLOutlineFont)
private
CreatedOutline: TOutlineFont;
public
{ Create outline font from an installed Windows font.
For a description of AFaceName, AHeight, AWeight, AItalic, ACharSet:
see documentation for Windows.CreateFont function.
For a description of Depth and OnlyLines params:
see docs for CastleGLOutlineFonts.TGLOutlineFont.Create. }
constructor Create(const AFaceName: string; AHeight: Integer; AWeight: DWord;
AItalic: boolean; ACharSet: TWinCharSet; Depth: TGLfloat; OnlyLines: boolean);
destructor Destroy; override;
end;
{ Bitmap OpenGL font from an installed Windows font. }
TWindowsBitmapFont = class(TGLBitmapFont)
private
CreatedBitmap: TBitmapFont;
public
{ Create bitmap font from an installed Windows font.
For a description of AFaceName, AHeight, AWeight, AItalic, ACharSet:
see documentation for Windows.CreateFont function. }
constructor Create(const AFaceName: string; AHeight: Integer; AWeight: DWord;
AItalic: boolean; ACharSet: TWinCharSet);
destructor Destroy; override;
end;
implementation
uses SysUtils, CastleUtils;
constructor TWindowsOutlineFont.Create(const AFaceName: string;
AHeight: Integer; AWeight: DWord; AItalic: boolean; ACharSet: TWinCharSet;
Depth: TGLfloat; OnlyLines: boolean);
var
WinFont: TWindowsFont;
WinFontHandle: HFont;
begin
WinFont := TWindowsFont.Create(AHeight);
try
WinFont.OutputPrecision := OUT_TT_ONLY_PRECIS {only TrueType fonts};
WinFont.FaceName := AFaceName;
WinFont.Height := AHeight;
WinFont.Weight := AWeight;
WinFont.Italic := AItalic;
WinFont.CharSet := ACharSet;
WinFontHandle := WinFont.GetHandle;
try
CreatedOutline := Font2OutlineFont(WinFontHandle);
inherited Create(CreatedOutline, Depth, OnlyLines);
finally DeleteObject(WinFontHandle) end;
finally FreeAndNil(WinFont) end;
end;
destructor TWindowsOutlineFont.Destroy;
begin
inherited;
{ free CreatedOutline AFTER calling inherited because TGLOutlineFont
requires that CreatedOutline is valid for it's lifetime }
FreeAndNilFont(CreatedOutline);
end;
{ TWindowsBitmapFont ---------------------------------------- }
constructor TWindowsBitmapFont.Create(const AFaceName: string;
AHeight: Integer; AWeight: DWord; AItalic: boolean; ACharSet: TWinCharSet);
var
WinFont: TWindowsFont;
WinFontHandle: HFont;
begin
WinFont := TWindowsFont.Create(AHeight);
try
WinFont.OutputPrecision := OUT_TT_ONLY_PRECIS {only TrueType fonts};
WinFont.FaceName := AFaceName;
WinFont.Height := AHeight;
WinFont.Weight := AWeight;
WinFont.Italic := AItalic;
WinFont.CharSet := ACharSet;
WinFontHandle := WinFont.GetHandle;
try
CreatedBitmap := Font2BitmapFont(WinFontHandle);
inherited Create(CreatedBitmap);
finally DeleteObject(WinFontHandle) end;
finally FreeAndNil(WinFont) end;
end;
destructor TWindowsBitmapFont.Destroy;
begin
inherited;
{ free CreatedBitmap AFTER calling inherited because TGLBitmapFont
requires that BitmapFont is valid for it's lifetime }
FreeAndNilFont(CreatedBitmap);
end;
end.
|