More work on user linking to existing defined system

This commit is contained in:
Deon George
2022-12-04 13:30:38 +11:00
parent 14f28c5263
commit 05528f1c33
6 changed files with 133 additions and 17 deletions

View File

@@ -47,23 +47,23 @@ class Font
*/
private function chars(): Collection
{
static $chars = NULL;
static $chars = [];
if (is_null($chars) && $this->text) {
if ($this->text && empty($chars[$this->text])) {
// Trim any leading/trailing spaces
$text = trim(strtolower($this->text));
$chars = collect();
$chars[$this->text] = collect();
// Work out the characters we need
foreach (array_unique(str_split($text)) as $c) {
if (! $x=Arr::get(static::FONT,$c))
continue;
$chars->put($c,$x);
$chars[$this->text]->put($c,$x);
}
}
return $chars ?: collect();
return $chars[$this->text] ?: collect();
}
/**
@@ -94,7 +94,7 @@ class Font
// If the last character is a space, we'll reduce the width
$space = TRUE;
foreach ($chars->get($c) as $line => $x)
foreach ($chars->get($c) as $x)
if (array_pop($x) != 32) {
$space = FALSE;
break;