Skip to content

Commit 971ca82

Browse files
committed
Custom Font (Vollkorn)
1 parent e3ece90 commit 971ca82

File tree

5 files changed

+155
-18
lines changed

5 files changed

+155
-18
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- @rexim
1111

1212
- @rexim - Increased Path Finding Limit. Now Bosses give up on chasing the Player if the distance is over 10 turns instead of just 4. - https://github.com/tsoding/eepers/issues/16
13+
- @rexim - Custom font for "You Died!" sign (Vollkorn)
1314
- ...
1415

1516
# Eepers v1.2

assets/fonts/Vollkorn/OFL.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Copyright 2017 The Vollkorn Project Authors (https://github.com/FAlthausen/Vollkorn-Typeface)
2+
3+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
4+
This license is copied below, and is also available with a FAQ at:
5+
https://openfontlicense.org
6+
7+
8+
-----------------------------------------------------------
9+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10+
-----------------------------------------------------------
11+
12+
PREAMBLE
13+
The goals of the Open Font License (OFL) are to stimulate worldwide
14+
development of collaborative font projects, to support the font creation
15+
efforts of academic and linguistic communities, and to provide a free and
16+
open framework in which fonts may be shared and improved in partnership
17+
with others.
18+
19+
The OFL allows the licensed fonts to be used, studied, modified and
20+
redistributed freely as long as they are not sold by themselves. The
21+
fonts, including any derivative works, can be bundled, embedded,
22+
redistributed and/or sold with any software provided that any reserved
23+
names are not used by derivative works. The fonts and derivatives,
24+
however, cannot be released under any other type of license. The
25+
requirement for fonts to remain under this license does not apply
26+
to any document created using the fonts or their derivatives.
27+
28+
DEFINITIONS
29+
"Font Software" refers to the set of files released by the Copyright
30+
Holder(s) under this license and clearly marked as such. This may
31+
include source files, build scripts and documentation.
32+
33+
"Reserved Font Name" refers to any names specified as such after the
34+
copyright statement(s).
35+
36+
"Original Version" refers to the collection of Font Software components as
37+
distributed by the Copyright Holder(s).
38+
39+
"Modified Version" refers to any derivative made by adding to, deleting,
40+
or substituting -- in part or in whole -- any of the components of the
41+
Original Version, by changing formats or by porting the Font Software to a
42+
new environment.
43+
44+
"Author" refers to any designer, engineer, programmer, technical
45+
writer or other person who contributed to the Font Software.
46+
47+
PERMISSION & CONDITIONS
48+
Permission is hereby granted, free of charge, to any person obtaining
49+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
50+
redistribute, and sell modified and unmodified copies of the Font
51+
Software, subject to the following conditions:
52+
53+
1) Neither the Font Software nor any of its individual components,
54+
in Original or Modified Versions, may be sold by itself.
55+
56+
2) Original or Modified Versions of the Font Software may be bundled,
57+
redistributed and/or sold with any software, provided that each copy
58+
contains the above copyright notice and this license. These can be
59+
included either as stand-alone text files, human-readable headers or
60+
in the appropriate machine-readable metadata fields within text or
61+
binary files as long as those fields can be easily viewed by the user.
62+
63+
3) No Modified Version of the Font Software may use the Reserved Font
64+
Name(s) unless explicit written permission is granted by the corresponding
65+
Copyright Holder. This restriction only applies to the primary font name as
66+
presented to the users.
67+
68+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69+
Software shall not be used to promote, endorse or advertise any
70+
Modified Version, except to acknowledge the contribution(s) of the
71+
Copyright Holder(s) and the Author(s) or with their explicit written
72+
permission.
73+
74+
5) The Font Software, modified or unmodified, in part or in whole,
75+
must be distributed entirely under this license, and must not be
76+
distributed under any other license. The requirement for fonts to
77+
remain under this license does not apply to any document created
78+
using the Font Software.
79+
80+
TERMINATION
81+
This license becomes null and void if any of the above conditions are
82+
not met.
83+
84+
DISCLAIMER
85+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93+
OTHER DEALINGS IN THE FONT SOFTWARE.
337 KB
Binary file not shown.

eepers.adb

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ procedure Eepers is
3636
Guard_Step_Sound: Sound;
3737
Popup_Show_Sound: Sound;
3838
Ambient_Music: Music;
39+
Tutorial_Font: Font;
40+
Death_Font: Font;
41+
42+
Tutorial_Font_Size: constant Int := 42;
43+
Death_Font_Size: constant Int := 68;
3944

4045
DEVELOPMENT : constant Boolean := False;
4146

@@ -358,19 +363,13 @@ procedure Eepers is
358363

359364
if Popup.Animation > 0.0 then
360365
declare
361-
Label_Max_Height : constant C_Float := 28.0;
362-
Label_Height: constant Integer := Integer(Label_Max_Height*Popup.Animation);
363-
Label_Padding: constant C_Float := C_Float(Label_Height)*0.6;
364-
Popup_Bottom_Margin: constant C_Float := C_Float(Label_Height);
365-
366-
Label_Width: constant Integer := Integer(Measure_Text(Popup.Label, Int(Label_Height)));
367-
Label_Size: constant IVector2 := (Label_Width, Label_Height);
368-
Popup_Size: constant Vector2 := To_Vector2(Label_Size) + (Label_Padding*2.0, Label_Padding*2.0);
369-
Popup_Position: constant Vector2 := Start + Size*(0.5, 0.0) - Popup_Size*(0.5, 1.0) - (0.0, Popup_Bottom_Margin);
370-
Label_Position: constant Vector2 := Popup_Position + Popup_Size*(0.5, 0.5) - To_Vector2(Label_Size)*(0.5, 0.5);
366+
Font_Size: constant C_Float := C_Float(Tutorial_Font_Size)*Popup.Animation;
367+
Popup_Bottom_Margin: constant C_Float := Font_Size*0.05;
368+
Label_Size: constant Vector2 := Measure_Text_Ex(Tutorial_Font, Popup.Label, Font_Size, 0.0);
369+
Label_Position: constant Vector2 := Start + Size*(0.5, 0.0) - Label_Size*(0.5, 1.0) - (0.0, Popup_Bottom_Margin);
371370
begin
372-
Draw_Rectangle_V(Popup_Position, Popup_Size, Palette_RGB(COLOR_WALL));
373-
Draw_Text(Popup.Label, Int(Label_Position.X), Int(Label_Position.Y), Int(Label_Height), Palette_RGB(COLOR_PLAYER));
371+
Draw_Text_Ex(Tutorial_Font, Popup.Label, Label_Position + (-2.0, 2.0), Font_Size, 0.0, Palette_RGB(COLOR_WALL));
372+
Draw_Text_Ex(Tutorial_Font, Popup.Label, Label_Position, Font_Size, 0.0, Palette_RGB(COLOR_PLAYER));
374373
end;
375374
end if;
376375
end;
@@ -1475,12 +1474,11 @@ procedure Eepers is
14751474
if Game.Player.Dead then
14761475
declare
14771476
Label: constant Char_Array := To_C("You Died!");
1478-
Label_Height: constant Integer := 48;
1479-
Label_Width: constant Integer := Integer(Measure_Text(Label, Int(Label_Height)));
1480-
Text_Size: constant Vector2 := To_Vector2((Label_Width, Label_Height));
1477+
Text_Size: constant Vector2 := Measure_Text_Ex(Death_Font, Label, C_Float(Death_Font_Size), 0.0);
14811478
Position: constant Vector2 := Screen_Size*0.5 - Text_Size*0.5;
14821479
begin
1483-
Draw_Text(Label, Int(Position.X), Int(Position.Y), Int(Label_Height), Palette_RGB(COLOR_LABEL));
1480+
Draw_Text_Ex(Death_Font, Label, Position + (-2.0, 2.0), C_Float(Death_Font_Size), 0.0, Palette_RGB(COLOR_WALL));
1481+
Draw_Text_Ex(Death_Font, Label, Position, C_Float(Death_Font_Size), 0.0, Palette_RGB(COLOR_PLAYER));
14841482
end;
14851483
end if;
14861484
end;
@@ -1585,6 +1583,10 @@ begin
15851583
Guard_Step_Sound := Load_Sound(To_C("assets/sounds/guard-step.ogg")); -- https://opengameart.org/content/fire-whip-hit-yo-frankie
15861584
Plant_Bomb_Sound := Load_Sound(To_C("assets/sounds/plant-bomb.wav")); -- https://opengameart.org/content/ui-soundpack-by-m1chiboi-bleeps-and-clicks
15871585
Popup_Show_Sound := Load_Sound(To_C("assets/sounds/popup-show.wav")); -- https://opengameart.org/content/ui-soundpack-by-m1chiboi-bleeps-and-clicks
1586+
Tutorial_Font := Load_Font_Ex(To_C("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf"), Tutorial_Font_Size, 0, 0);
1587+
Gen_Texture_Mipmaps(Tutorial_Font.Texture'Access);
1588+
Death_Font := Load_Font_Ex(To_C("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf"), Death_Font_Size, 0, 0);
1589+
Gen_Texture_Mipmaps(Death_Font.Texture'Access);
15881590

15891591
Random_Integer.Reset(Gen);
15901592
Load_Colors("assets/colors.txt");
@@ -1789,6 +1791,7 @@ end;
17891791

17901792
-- TODO: Increase Bomb Slots item.
17911793
-- TODO: Items in HUD may sometimes blend with the background
1794+
-- TODO: Restart is annoying. It's easy to accidentally hit restart after death.
17921795
-- TODO: The gnome blocking trick was never properly explained.
17931796
-- We should introduce an extra room that entirely relies on that mechanic,
17941797
-- so it does not feel out of place, when you discover it on Mother.
@@ -1799,7 +1802,6 @@ end;
17991802
-- Or maybe we should just save Path Maps too?
18001803
-- TODO: If you are standing on the refilled bomb gen and place a bomb you should refill your bomb in that turn.
18011804
-- TODO: Checkpoints should be circles (like all the items)
1802-
-- TODO: Custom font
18031805
-- TODO: Mother should require several attacks before being "split"
18041806
-- TODO: Enemies should attack on zero just like a bomb.
18051807
-- TODO: Properly disablable DEV features

raylib.ads

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package Raylib is
77
type Bool is new Boolean;
88
pragma Convention (C, Bool);
99

10+
type Addr is mod 2 ** Standard'Address_Size;
11+
1012
procedure Init_Window(Width, Height: int; Title: in char_array)
1113
with
1214
Import => True,
@@ -164,6 +166,30 @@ package Raylib is
164166
Import => True,
165167
Convention => C,
166168
External_Name => "DrawText";
169+
type Texture2D is record
170+
Id: unsigned;
171+
Width: int;
172+
Height: int;
173+
Mipmaps: int;
174+
Format: int;
175+
end record
176+
with Convention => C_Pass_By_Copy;
177+
178+
type Font is record
179+
Base_Size: int;
180+
Glyph_Count: int;
181+
Glyph_Padding: int;
182+
Texture: aliased Texture2D;
183+
Rects: Addr;
184+
Glyph_Info: Addr;
185+
end record
186+
with Convention => C_Pass_By_Copy;
187+
188+
procedure Draw_Text_Ex(F: Font; Text: Char_Array; Position: Vector2; Font_Size: C_Float; Spacing: C_Float; Tint: Color)
189+
with
190+
Import => True,
191+
Convention => C,
192+
External_Name => "DrawTextEx";
167193
procedure Set_Target_FPS(Fps: int)
168194
with
169195
Import => True,
@@ -199,7 +225,6 @@ package Raylib is
199225
Import => True,
200226
Convention => C,
201227
External_Name => "GetTime";
202-
type Addr is mod 2 ** Standard'Address_Size;
203228
type Image is record
204229
Data: Addr;
205230
Width: int;
@@ -333,4 +358,20 @@ package Raylib is
333358
Import => True,
334359
Convention => C,
335360
External_Name => "SetWindowIcon";
361+
362+
function Load_Font_Ex(File_Name: char_array; Font_Size: int; Codepoints: Addr; Codepoint_Count: Integer) return Font
363+
with
364+
Import => True,
365+
Convention => C,
366+
External_Name => "LoadFontEx";
367+
function Measure_Text_Ex(F: Font; Text: Char_Array; Font_Size: C_Float; Spacing: C_Float) return Vector2
368+
with
369+
Import => True,
370+
Convention => C,
371+
External_Name => "MeasureTextEx";
372+
procedure Gen_Texture_Mipmaps(T: access Texture2D)
373+
with
374+
Import => True,
375+
Convention => C,
376+
External_Name => "GenTextureMipmaps";
336377
end Raylib;

0 commit comments

Comments
 (0)