diff options
author | rexim <reximkut@gmail.com> | 2024-03-30 07:25:23 +0700 |
---|---|---|
committer | rexim <reximkut@gmail.com> | 2024-03-30 07:25:23 +0700 |
commit | 971ca82ac5445caa62b130ec034e6e63a70ce7fe (patch) | |
tree | 06abdc6bdf6588f974f5d77342df07e997afa121 | |
parent | e3ece90b9877d3b0145f7a359b91e0192567464b (diff) |
Custom Font (Vollkorn)
-rw-r--r-- | CHANGELOG.txt | 1 | ||||
-rw-r--r-- | assets/fonts/Vollkorn/OFL.txt | 93 | ||||
-rw-r--r-- | assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf | bin | 0 -> 345232 bytes | |||
-rw-r--r-- | eepers.adb | 36 | ||||
-rw-r--r-- | raylib.ads | 43 |
5 files changed, 155 insertions, 18 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7c0ddcb..7d8ec63 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -10,6 +10,7 @@ - @rexim
- @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
+- @rexim - Custom font for "You Died!" sign (Vollkorn)
- ...
# Eepers v1.2
diff --git a/assets/fonts/Vollkorn/OFL.txt b/assets/fonts/Vollkorn/OFL.txt new file mode 100644 index 0000000..f72bad1 --- /dev/null +++ b/assets/fonts/Vollkorn/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2017 The Vollkorn Project Authors (https://github.com/FAlthausen/Vollkorn-Typeface)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf b/assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf Binary files differnew file mode 100644 index 0000000..88b0657 --- /dev/null +++ b/assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf @@ -36,6 +36,11 @@ procedure Eepers is Guard_Step_Sound: Sound; Popup_Show_Sound: Sound; Ambient_Music: Music; + Tutorial_Font: Font; + Death_Font: Font; + + Tutorial_Font_Size: constant Int := 42; + Death_Font_Size: constant Int := 68; DEVELOPMENT : constant Boolean := False; @@ -358,19 +363,13 @@ procedure Eepers is if Popup.Animation > 0.0 then declare - Label_Max_Height : constant C_Float := 28.0; - Label_Height: constant Integer := Integer(Label_Max_Height*Popup.Animation); - Label_Padding: constant C_Float := C_Float(Label_Height)*0.6; - Popup_Bottom_Margin: constant C_Float := C_Float(Label_Height); - - Label_Width: constant Integer := Integer(Measure_Text(Popup.Label, Int(Label_Height))); - Label_Size: constant IVector2 := (Label_Width, Label_Height); - Popup_Size: constant Vector2 := To_Vector2(Label_Size) + (Label_Padding*2.0, Label_Padding*2.0); - Popup_Position: constant Vector2 := Start + Size*(0.5, 0.0) - Popup_Size*(0.5, 1.0) - (0.0, Popup_Bottom_Margin); - Label_Position: constant Vector2 := Popup_Position + Popup_Size*(0.5, 0.5) - To_Vector2(Label_Size)*(0.5, 0.5); + Font_Size: constant C_Float := C_Float(Tutorial_Font_Size)*Popup.Animation; + Popup_Bottom_Margin: constant C_Float := Font_Size*0.05; + Label_Size: constant Vector2 := Measure_Text_Ex(Tutorial_Font, Popup.Label, Font_Size, 0.0); + Label_Position: constant Vector2 := Start + Size*(0.5, 0.0) - Label_Size*(0.5, 1.0) - (0.0, Popup_Bottom_Margin); begin - Draw_Rectangle_V(Popup_Position, Popup_Size, Palette_RGB(COLOR_WALL)); - Draw_Text(Popup.Label, Int(Label_Position.X), Int(Label_Position.Y), Int(Label_Height), Palette_RGB(COLOR_PLAYER)); + Draw_Text_Ex(Tutorial_Font, Popup.Label, Label_Position + (-2.0, 2.0), Font_Size, 0.0, Palette_RGB(COLOR_WALL)); + Draw_Text_Ex(Tutorial_Font, Popup.Label, Label_Position, Font_Size, 0.0, Palette_RGB(COLOR_PLAYER)); end; end if; end; @@ -1475,12 +1474,11 @@ procedure Eepers is if Game.Player.Dead then declare Label: constant Char_Array := To_C("You Died!"); - Label_Height: constant Integer := 48; - Label_Width: constant Integer := Integer(Measure_Text(Label, Int(Label_Height))); - Text_Size: constant Vector2 := To_Vector2((Label_Width, Label_Height)); + Text_Size: constant Vector2 := Measure_Text_Ex(Death_Font, Label, C_Float(Death_Font_Size), 0.0); Position: constant Vector2 := Screen_Size*0.5 - Text_Size*0.5; begin - Draw_Text(Label, Int(Position.X), Int(Position.Y), Int(Label_Height), Palette_RGB(COLOR_LABEL)); + Draw_Text_Ex(Death_Font, Label, Position + (-2.0, 2.0), C_Float(Death_Font_Size), 0.0, Palette_RGB(COLOR_WALL)); + Draw_Text_Ex(Death_Font, Label, Position, C_Float(Death_Font_Size), 0.0, Palette_RGB(COLOR_PLAYER)); end; end if; end; @@ -1585,6 +1583,10 @@ begin Guard_Step_Sound := Load_Sound(To_C("assets/sounds/guard-step.ogg")); -- https://opengameart.org/content/fire-whip-hit-yo-frankie Plant_Bomb_Sound := Load_Sound(To_C("assets/sounds/plant-bomb.wav")); -- https://opengameart.org/content/ui-soundpack-by-m1chiboi-bleeps-and-clicks Popup_Show_Sound := Load_Sound(To_C("assets/sounds/popup-show.wav")); -- https://opengameart.org/content/ui-soundpack-by-m1chiboi-bleeps-and-clicks + Tutorial_Font := Load_Font_Ex(To_C("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf"), Tutorial_Font_Size, 0, 0); + Gen_Texture_Mipmaps(Tutorial_Font.Texture'Access); + Death_Font := Load_Font_Ex(To_C("assets/fonts/Vollkorn/static/Vollkorn-Regular.ttf"), Death_Font_Size, 0, 0); + Gen_Texture_Mipmaps(Death_Font.Texture'Access); Random_Integer.Reset(Gen); Load_Colors("assets/colors.txt"); @@ -1789,6 +1791,7 @@ end; -- TODO: Increase Bomb Slots item. -- TODO: Items in HUD may sometimes blend with the background +-- TODO: Restart is annoying. It's easy to accidentally hit restart after death. -- TODO: The gnome blocking trick was never properly explained. -- We should introduce an extra room that entirely relies on that mechanic, -- so it does not feel out of place, when you discover it on Mother. @@ -1799,7 +1802,6 @@ end; -- Or maybe we should just save Path Maps too? -- TODO: If you are standing on the refilled bomb gen and place a bomb you should refill your bomb in that turn. -- TODO: Checkpoints should be circles (like all the items) --- TODO: Custom font -- TODO: Mother should require several attacks before being "split" -- TODO: Enemies should attack on zero just like a bomb. -- TODO: Properly disablable DEV features @@ -7,6 +7,8 @@ package Raylib is type Bool is new Boolean; pragma Convention (C, Bool); + type Addr is mod 2 ** Standard'Address_Size; + procedure Init_Window(Width, Height: int; Title: in char_array) with Import => True, @@ -164,6 +166,30 @@ package Raylib is Import => True, Convention => C, External_Name => "DrawText"; + type Texture2D is record + Id: unsigned; + Width: int; + Height: int; + Mipmaps: int; + Format: int; + end record + with Convention => C_Pass_By_Copy; + + type Font is record + Base_Size: int; + Glyph_Count: int; + Glyph_Padding: int; + Texture: aliased Texture2D; + Rects: Addr; + Glyph_Info: Addr; + end record + with Convention => C_Pass_By_Copy; + + procedure Draw_Text_Ex(F: Font; Text: Char_Array; Position: Vector2; Font_Size: C_Float; Spacing: C_Float; Tint: Color) + with + Import => True, + Convention => C, + External_Name => "DrawTextEx"; procedure Set_Target_FPS(Fps: int) with Import => True, @@ -199,7 +225,6 @@ package Raylib is Import => True, Convention => C, External_Name => "GetTime"; - type Addr is mod 2 ** Standard'Address_Size; type Image is record Data: Addr; Width: int; @@ -333,4 +358,20 @@ package Raylib is Import => True, Convention => C, External_Name => "SetWindowIcon"; + + function Load_Font_Ex(File_Name: char_array; Font_Size: int; Codepoints: Addr; Codepoint_Count: Integer) return Font + with + Import => True, + Convention => C, + External_Name => "LoadFontEx"; + function Measure_Text_Ex(F: Font; Text: Char_Array; Font_Size: C_Float; Spacing: C_Float) return Vector2 + with + Import => True, + Convention => C, + External_Name => "MeasureTextEx"; + procedure Gen_Texture_Mipmaps(T: access Texture2D) + with + Import => True, + Convention => C, + External_Name => "GenTextureMipmaps"; end Raylib; |