forked from Sandstorm-Station/Sandstorm-Station-13
-
-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,236 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Font metrics bitfield | ||
/// Include leading A width and trailing C width in GetWidth() or in DrawText() | ||
#define INCLUDE_AC (1<<0) | ||
|
||
DEFINE_BITFIELD(font_flags, list( | ||
"INCLUDE_AC" = INCLUDE_AC, | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/// A font datum, it exists to define a custom font to use in a span style later. | ||
/datum/font | ||
/// Font name, just so people know what to put in their span style. | ||
var/name | ||
/// The font file we link to. | ||
var/font_family | ||
|
||
/// Font features and metrics | ||
/// Generated by Lummox's dmifontsplus (https://www.byond.com/developer/LummoxJR/DmiFontsPlus) | ||
/// Note: these variable names have been changed, so you can't straight copy/paste from dmifontsplus.exe | ||
|
||
/// list of font size/spacing metrics | ||
var/list/metrics | ||
/// total height of a line | ||
var/height | ||
/// distance above baseline (including whitespace) | ||
var/ascent | ||
/// distance below baseline | ||
var/descent | ||
/// average character width | ||
var/average_width | ||
/// maximum character width | ||
var/max_width | ||
/// extra width, such as from italics, for a line | ||
var/overhang | ||
/// internal leading vertical space, for accent marks | ||
var/in_leading | ||
/// external leading vertical space, just plain blank | ||
var/ex_leading | ||
/// default character (for undefined chars) | ||
var/default_character | ||
/// first character in metrics | ||
var/start | ||
/// last character in metrics | ||
var/end | ||
|
||
/// Get font metrics | ||
/// From Lummox's dmifontsplus (https://www.byond.com/developer/LummoxJR/DmiFontsPlus) | ||
/datum/font/proc/get_metrics(text, flags, first_line) | ||
. = 0 | ||
var/longest = 0 | ||
if(!length(text)) | ||
return | ||
|
||
var/i = 1 | ||
var/idx | ||
while(i <= length(text)) | ||
var/character = text2ascii(text, i++) | ||
if(character <= 10) | ||
if(character <= 7) | ||
. += character // spacers for justification | ||
|
||
if(character <= 9) | ||
continue // soft-break chars | ||
|
||
if(. && idx && !(flags & INCLUDE_AC)) | ||
. -= max(metrics[idx + 3], 0) | ||
|
||
longest = max(longest, . + first_line) | ||
. = 0 | ||
first_line = 0 | ||
idx = 0 | ||
continue | ||
|
||
idx = (character - start) * 3 | ||
if(idx <= 0 || idx >= metrics.len) | ||
idx = (default_character - start) * 3 | ||
|
||
if(!. && !(flags & INCLUDE_AC)) | ||
. -= metrics[idx + 1] | ||
. += metrics[idx + 1] + metrics[idx + 2] + metrics[idx +3] | ||
|
||
if(. && idx && !(flags & INCLUDE_AC)) | ||
. -= max(metrics[idx + 3], 0) | ||
|
||
. = max(. + first_line, longest) | ||
if(. > 0) | ||
. += overhang |
Oops, something went wrong.