From f50851705ed6522a322beab1584d25d5ca062cbe Mon Sep 17 00:00:00 2001 From: Clay Smalley Date: Sat, 8 Apr 2023 14:08:11 -0400 Subject: [PATCH 1/5] add Saudi Arabia shields --- icons/shield_sa_national.svg | 56 ++++++++++++++++++++++++++++++++++++ src/js/screen_gfx.js | 4 ++- src/js/shield.js | 28 ++++++++++++++++-- src/js/shield_defs.js | 14 +++++++++ src/shieldtest.js | 4 +++ 5 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 icons/shield_sa_national.svg diff --git a/icons/shield_sa_national.svg b/icons/shield_sa_national.svg new file mode 100644 index 000000000..896d6ec95 --- /dev/null +++ b/icons/shield_sa_national.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/js/screen_gfx.js b/src/js/screen_gfx.js index 144a45027..e060c68f0 100644 --- a/src/js/screen_gfx.js +++ b/src/js/screen_gfx.js @@ -2,7 +2,9 @@ import rgba from "color-rgba"; -const fontFamily = '"sans-serif-condensed", "Arial Narrow", sans-serif'; +const naskhFonts = + '"Noto Naskh Arabic", KacstNaskh, "Sakkal Majalla", "DecoType Naskh Regular"'; +const fontFamily = `"sans-serif-condensed", "Arial Narrow", ${naskhFonts}, sans-serif`; export const shieldFont = (size) => `bold ${size}px ${fontFamily}`; export const fontSizeThreshold = 12; diff --git a/src/js/shield.js b/src/js/shield.js index f967a78c3..4f9f387c2 100644 --- a/src/js/shield.js +++ b/src/js/shield.js @@ -303,6 +303,23 @@ export function getRouteDef(id) { }; } +/** + * Reformats an alphanumeric ref as Eastern Arabic numerals, preserving any + * alphabetic suffix. + */ +export const latinToArabicDigits = (ref) => + `${ref}` + .replaceAll("0", "\u0660") + .replaceAll("1", "\u0661") + .replaceAll("2", "\u0662") + .replaceAll("3", "\u0663") + .replaceAll("4", "\u0664") + .replaceAll("5", "\u0665") + .replaceAll("6", "\u0666") + .replaceAll("7", "\u0667") + .replaceAll("8", "\u0668") + .replaceAll("9", "\u0669"); + /** * Reformats an alphanumeric ref as Roman numerals, preserving any alphabetic * suffix. @@ -382,8 +399,15 @@ export function generateShieldCtx(map, id) { // Convert numbering systems. Normally alternative numbering systems should be // tagged directly in ref=*, but some shields use different numbering systems // for aesthetic reasons only. - if (routeDef.ref && shieldDef.numberingSystem === "roman") { - routeDef.ref = romanizeRef(routeDef.ref); + if (routeDef.ref) { + switch (shieldDef.numberingSystem) { + case "arab": + routeDef.ref = latinToArabicDigits(routeDef.ref); + break; + case "roman": + routeDef.ref = romanizeRef(routeDef.ref); + break; + } } // Add the halo around modifier plaque text diff --git a/src/js/shield_defs.js b/src/js/shield_defs.js index 5cbefebe0..11f95ea63 100644 --- a/src/js/shield_defs.js +++ b/src/js/shield_defs.js @@ -3687,6 +3687,20 @@ export function loadShields() { }, }; + // Saudi Arabia + shields["SA:national"] = { + spriteBlank: "shield_sa_national", + textLayout: textConstraint("diamond"), + textColor: Color.shields.black, + numberingSystem: "arab", + padding: { + left: 3, + right: 2, + top: 4, + bottom: 3, + }, + }; + // Turkey shields["TR:motorway"] = hexagonVerticalShield( 2, diff --git a/src/shieldtest.js b/src/shieldtest.js index 3e1cc33bb..7fb5c202d 100644 --- a/src/shieldtest.js +++ b/src/shieldtest.js @@ -232,6 +232,10 @@ let networks = [ "AU:QLD:ALT", "AU:QLD:ALT_S", "AU:VIC:ALT_NR", + + // With other numeral systems + "IN:NE", + "SA:national", ]; // Uncomment for a list of all supported networks. This makes for a very long page. From a65d52f747e8ec9393e2bcc427474045fd30a505 Mon Sep 17 00:00:00 2001 From: Clay Smalley Date: Sat, 8 Apr 2023 16:09:02 -0400 Subject: [PATCH 2/5] add Saudi Arabia to status map --- doc-img/shield_map_world.svg | 1 + 1 file changed, 1 insertion(+) diff --git a/doc-img/shield_map_world.svg b/doc-img/shield_map_world.svg index 65b6116aa..40ced38ed 100644 --- a/doc-img/shield_map_world.svg +++ b/doc-img/shield_map_world.svg @@ -138,6 +138,7 @@ See the end of this file for a list of available jurisdictions and their codes. .np, .ph, .pk, +.sa, .tr, .tw, .vn, From 56ff0cf57012e1eb543d366e857a3f616df77d53 Mon Sep 17 00:00:00 2001 From: Clay Smalley Date: Sat, 8 Apr 2023 20:20:25 -0400 Subject: [PATCH 3/5] more succinct digit conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Minh Nguyễn --- src/js/shield.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/js/shield.js b/src/js/shield.js index 4f9f387c2..b6f2b2023 100644 --- a/src/js/shield.js +++ b/src/js/shield.js @@ -308,17 +308,7 @@ export function getRouteDef(id) { * alphabetic suffix. */ export const latinToArabicDigits = (ref) => - `${ref}` - .replaceAll("0", "\u0660") - .replaceAll("1", "\u0661") - .replaceAll("2", "\u0662") - .replaceAll("3", "\u0663") - .replaceAll("4", "\u0664") - .replaceAll("5", "\u0665") - .replaceAll("6", "\u0666") - .replaceAll("7", "\u0667") - .replaceAll("8", "\u0668") - .replaceAll("9", "\u0669"); + ref.replaceAll(/[0-9]/g, m => String.fromCharCode(0x0660 + parseInt(m))); /** * Reformats an alphanumeric ref as Roman numerals, preserving any alphabetic From fd71cb49bec15b88f7896d8a40ca0b75416222f6 Mon Sep 17 00:00:00 2001 From: Clay Smalley Date: Sat, 8 Apr 2023 20:23:56 -0400 Subject: [PATCH 4/5] rename digit conversion function --- src/js/shield.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/shield.js b/src/js/shield.js index b6f2b2023..ebc364715 100644 --- a/src/js/shield.js +++ b/src/js/shield.js @@ -307,8 +307,8 @@ export function getRouteDef(id) { * Reformats an alphanumeric ref as Eastern Arabic numerals, preserving any * alphabetic suffix. */ -export const latinToArabicDigits = (ref) => - ref.replaceAll(/[0-9]/g, m => String.fromCharCode(0x0660 + parseInt(m))); +export const arabizeRef = (ref) => + ref.replaceAll(/[0-9]/g, (m) => String.fromCharCode(0x0660 + parseInt(m))); /** * Reformats an alphanumeric ref as Roman numerals, preserving any alphabetic @@ -392,7 +392,7 @@ export function generateShieldCtx(map, id) { if (routeDef.ref) { switch (shieldDef.numberingSystem) { case "arab": - routeDef.ref = latinToArabicDigits(routeDef.ref); + routeDef.ref = arabizeRef(routeDef.ref); break; case "roman": routeDef.ref = romanizeRef(routeDef.ref); From 5b7c2d3a1c623628011c3512ead1092bf9d19cc2 Mon Sep 17 00:00:00 2001 From: Clay Smalley Date: Mon, 10 Apr 2023 17:08:44 -0400 Subject: [PATCH 5/5] add web fonts for Arabic, Armenian, Georgian --- src/index.html | 32 ++++++++++++++++++++++++++++++++ src/js/screen_gfx.js | 6 +++--- src/shieldtest.html | 29 ++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/index.html b/src/index.html index 3a828f824..ef2a27aaa 100644 --- a/src/index.html +++ b/src/index.html @@ -3,6 +3,8 @@ OpenStreetMap Americana + + + @@ -157,5 +163,31 @@

Legend

+

+ Invisible text so the font will load early +

+

+ Invisible text so the font will load early +

+

+ Invisible text so the font will load early +

+

+ Invisible text so the font will load early +

diff --git a/src/js/screen_gfx.js b/src/js/screen_gfx.js index e060c68f0..58e38157a 100644 --- a/src/js/screen_gfx.js +++ b/src/js/screen_gfx.js @@ -2,9 +2,9 @@ import rgba from "color-rgba"; -const naskhFonts = - '"Noto Naskh Arabic", KacstNaskh, "Sakkal Majalla", "DecoType Naskh Regular"'; -const fontFamily = `"sans-serif-condensed", "Arial Narrow", ${naskhFonts}, sans-serif`; +const nonLatinFonts = + '"Noto Naskh Arabic", "Noto Sans Armenian", "Noto Sans Georgian"'; +const fontFamily = `"sans-serif-condensed", "Arial Narrow", ${nonLatinFonts}, sans-serif`; export const shieldFont = (size) => `bold ${size}px ${fontFamily}`; export const fontSizeThreshold = 12; diff --git a/src/shieldtest.html b/src/shieldtest.html index 77b703211..911c5d118 100644 --- a/src/shieldtest.html +++ b/src/shieldtest.html @@ -9,6 +9,10 @@ href="https://fonts.googleapis.com/css2?family=Overpass:wght@500&display=block" rel="stylesheet" /> +