Skip to content

Commit 816f190

Browse files
ADD: Support truetype and ASCII font ;)
1 parent df458eb commit 816f190

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

OpenGL/uopengl_truetype_font.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
Procedure Exit2d(); //< Aus Kompatibilitätsgründen werden nicht oder nur Teilweise unterstützt
6969
public
7070

71-
Constructor Create();
71+
Constructor Create(); override;
7272
Destructor Destroy; override;
7373

7474
Procedure Init_Create_Font_by_Bitmaps();

OpenGL/uopengl_widgetset.pas

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(******************************************************************************)
22
(* uOpenGL_WidgetSet.pas ??.??.???? *)
33
(* *)
4-
(* Version : 0.07 *)
4+
(* Version : 0.08 *)
55
(* *)
66
(* Author : Uwe Schächterle (Corpsman) *)
77
(* *)
@@ -33,6 +33,7 @@
3333
(* 0.05 = Erlauben OnClick für TOpenGl_Image *)
3434
(* 0.06 = Umbau auf ueventer.pas *)
3535
(* 0.07 = Umstellen auf smClamp => deutlich bessere Graphiken *)
36+
(* 0.08 = Support für OpenGLASCIIFont *)
3637
(* *)
3738
(******************************************************************************)
3839

@@ -57,6 +58,7 @@
5758
LCLType,
5859
lclintf,
5960
uopengl_graphikengine,
61+
uopengl_font_common,
6062
ueventer;
6163

6264
Type
@@ -84,7 +86,7 @@
8486
Function FGetFontSize: single;
8587
Procedure FSetFontSize(value: Single);
8688
protected
87-
FFont: TOpenGL_TrueType_Font; // Das Kontrollelement bekommt noch zusätzlich eine OpenGLFont
89+
FFont: TOpenGL_Font; // Das Kontrollelement bekommt noch zusätzlich eine OpenGLFont
8890
Property FontColor: TVector3 read fGetFontColor write fSetFontColor;
8991
Property FontSize: Single read FGetFontSize write FSetFontSize;
9092
public
@@ -849,7 +851,7 @@
849851
glvertex2f(left + 2, 4 + top + round(ffont.TextHeight('8') * (i + 0)));
850852
glend;
851853
End;
852-
ffont.Color3v := FLineColors[fTopIndex + i];
854+
ffont.Colorv3 := FLineColors[fTopIndex + i];
853855
s := FItems[i + fTopIndex];
854856
While (ffont.TextWidth(s) > width - 4 - ScrollbarWidth) And (s <> '') Do Begin
855857
delete(s, length(s), 1);
@@ -1173,7 +1175,7 @@
11731175
While (FFont.TextWidth(tex) > Width - 6) And (tex <> '') Do Begin
11741176
delete(tex, 1, 1);
11751177
End;
1176-
FFont.Color3v := FontColor;
1178+
FFont.Colorv3 := FontColor;
11771179
FFont.Textout(left + 2, top + 2, tex);
11781180
// Dann den Cursor
11791181
If FFocus Then Begin
@@ -1234,12 +1236,12 @@
12341236

12351237
Function TOpenGL_BaseFontClass.fGetFontColor: TVector3;
12361238
Begin
1237-
result := FFont.Color3v;
1239+
result := FFont.ColorV3;
12381240
End;
12391241

12401242
Procedure TOpenGL_BaseFontClass.fSetFontColor(Value: TVector3);
12411243
Begin
1242-
FFont.Color3v := value;
1244+
FFont.Colorv3 := value;
12431245
End;
12441246

12451247
Function TOpenGL_BaseFontClass.FGetFontSize: single;
@@ -1255,14 +1257,24 @@
12551257
Constructor TOpenGL_BaseFontClass.create(Owner: TOpenGLControl; FontFile: String
12561258
);
12571259
Begin
1258-
FFont := TOpenGL_TrueType_Font.Create();
1259-
ffont.LoadfromFile(FontFile);
1260+
If (FontFile <> '') And FileExists(FontFile) Then Begin
1261+
FFont := TOpenGL_TrueType_Font.Create();
1262+
TOpenGL_TrueType_Font(ffont).LoadfromFile(FontFile);
1263+
End
1264+
Else Begin
1265+
If Not assigned(OpenGL_ASCII_Font) Then Begin
1266+
Create_ASCII_Font;
1267+
End;
1268+
FFont := OpenGL_ASCII_Font;
1269+
End;
12601270
Inherited create(Owner);
12611271
End;
12621272

12631273
Destructor TOpenGL_BaseFontClass.destroy;
12641274
Begin
1265-
ffont.free;
1275+
If OpenGL_ASCII_Font <> FFont Then Begin
1276+
ffont.free;
1277+
End;
12661278
Inherited destroy;
12671279
End;
12681280

0 commit comments

Comments
 (0)