From f61b625a015a1ea167050935dfff53cf29d872ed Mon Sep 17 00:00:00 2001 From: ochafik Date: Sat, 13 Jul 2024 05:09:24 +0100 Subject: [PATCH] Add Noto Fonts --- LICENSE.md | 7 ++ Makefile | 63 +++++++++++++- examples/fonts.scad | 204 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 270 insertions(+), 4 deletions(-) create mode 100644 examples/fonts.scad diff --git a/LICENSE.md b/LICENSE.md index 429fcd9..572cb19 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -33,6 +33,7 @@ The WASM build was made possible by https://github.com/DSchroer/openscad-wasm. * [Flex](#flex) * [double-conversion](#double-conversion) * [Liberation Fonts](#liberation-fonts) +* [Noto Fonts](#noto-fonts) * [SCAD Libraries](#scad-libraries) + [BOSL2](#bosl2) + [NopSCADlib](#nopscadlib) @@ -150,6 +151,12 @@ https://github.com/shantigilbert/liberation-fonts-ttf.git Licensed under the [SIL Open Font License, Version 1.1](#sil-11) +## Noto Fonts + +https://fonts.google.com/noto + +Licensed under the [SIL Open Font License, Version 1.1](#sil-11) + ## SCAD Libraries Zip archives of the following libraries are loaded lazily by the demo. diff --git a/Makefile b/Makefile index 390c2e1..c08c5b2 100644 --- a/Makefile +++ b/Makefile @@ -64,11 +64,66 @@ public/openscad.js: libs/openscad-wasm libs/openscad-wasm/openscad.js public/openscad.wasm: libs/openscad-wasm libs/openscad-wasm/openscad.wasm ln -sf libs/openscad-wasm/openscad.wasm public/openscad.wasm -public/libraries/fonts.zip: libs/liberation - mkdir -p public/libraries - cp fonts.conf libs/liberation - ( cd libs/liberation && zip -r ../../public/libraries/fonts.zip fonts.conf *.ttf LICENSE AUTHORS ) +# Var w/ noto fonts +NOTO_FONTS=\ + libs/noto/NotoNaskhArabic-Bold.ttf \ + libs/noto/NotoNaskhArabic-Regular.ttf \ + libs/noto/NotoSans-Bold.ttf \ + libs/noto/NotoSans-Italic.ttf \ + libs/noto/NotoSans-Regular.ttf \ + libs/noto/NotoSansArmenian-Bold.ttf \ + libs/noto/NotoSansArmenian-Regular.ttf \ + libs/noto/NotoSansBalinese-Regular.ttf \ + libs/noto/NotoSansBengali-Bold.ttf \ + libs/noto/NotoSansBengali-Regular.ttf \ + libs/noto/NotoSansCJKtc-Bold.otf \ + libs/noto/NotoSansCJKtc-Regular.otf \ + libs/noto/NotoSansDevanagari-Bold.ttf \ + libs/noto/NotoSansDevanagari-Regular.ttf \ + libs/noto/NotoSansEthiopic-Bold.ttf \ + libs/noto/NotoSansEthiopic-Regular.ttf \ + libs/noto/NotoSansGeorgian-Bold.ttf \ + libs/noto/NotoSansGeorgian-Regular.ttf \ + libs/noto/NotoSansGujarati-Bold.ttf \ + libs/noto/NotoSansGujarati-Regular.ttf \ + libs/noto/NotoSansGurmukhi-Bold.ttf \ + libs/noto/NotoSansGurmukhi-Regular.ttf \ + libs/noto/NotoSansHebrew-Bold.ttf \ + libs/noto/NotoSansHebrew-Regular.ttf \ + libs/noto/NotoSansJavanese-Regular.ttf \ + libs/noto/NotoSansKannada-Bold.ttf \ + libs/noto/NotoSansKannada-Regular.ttf \ + libs/noto/NotoSansKhmer-Bold.ttf \ + libs/noto/NotoSansKhmer-Regular.ttf \ + libs/noto/NotoSansLao-Bold.ttf \ + libs/noto/NotoSansLao-Regular.ttf \ + libs/noto/NotoSansMongolian-Regular.ttf \ + libs/noto/NotoSansMyanmar-Bold.ttf \ + libs/noto/NotoSansMyanmar-Regular.ttf \ + libs/noto/NotoSansOriya-Bold.ttf \ + libs/noto/NotoSansOriya-Regular.ttf \ + libs/noto/NotoSansSinhala-Bold.ttf \ + libs/noto/NotoSansSinhala-Regular.ttf \ + libs/noto/NotoSansTamil-Bold.ttf \ + libs/noto/NotoSansTamil-Regular.ttf \ + libs/noto/NotoSansThai-Bold.ttf \ + libs/noto/NotoSansThai-Regular.ttf \ + libs/noto/NotoSansTibetan-Bold.ttf \ + libs/noto/NotoSansTibetan-Regular.ttf \ + libs/noto/NotoSansTifinagh-Regular.ttf \ + +public/libraries/fonts.zip: $(NOTO_FONTS) libs/liberation + zip -r $@ -j fonts.conf libs/noto/{*.ttf,*.otf} libs/liberation/{*.ttf,LICENSE,AUTHORS} + +libs/noto/%.ttf: + mkdir -p libs/noto + wget https://github.com/openmaptiles/fonts/raw/master/noto-sans/$(notdir $@) -O $@ + +libs/noto/%.otf: + mkdir -p libs/noto + wget https://github.com/openmaptiles/fonts/raw/master/noto-sans/$(notdir $@) -O $@ + libs/liberation: git clone --recurse https://github.com/shantigilbert/liberation-fonts-ttf.git ${SHALLOW} ${SINGLE_BRANCH} $@ diff --git a/examples/fonts.scad b/examples/fonts.scad new file mode 100644 index 0000000..44ace58 --- /dev/null +++ b/examples/fonts.scad @@ -0,0 +1,204 @@ +include +include + +script="Arabic"; // [Arabic,Armenian,Balinese,Bengali,CJK TC,Devanagari,English,Ethiopic,Georgian,Gujarati,Gurmukhi,Hebrew,Javanese,Kannada,Khmer,Lao,Mongolian,Myanmar,Oriya,Sinhala,Tamil,Thai,Tibetan,Tifinagh] + +style="Regular"; // [Regular,Bold,Italic] + +fonts=[ + "Noto Naskh Arabic", + // "Noto Naskh Arabic:style=Bold", + "Noto Sans", + // "Noto Sans:style=Bold", + // "Noto Sans:style=Italic", + "Noto SansArmenian", + // "Noto SansArmenian:style=Bold", + "Noto SansBalinese", + "Noto SansBengali", + // "Noto SansBengali:style=Bold", + "Noto Sans CJK TC", + "Noto SansDevanagari", + // "Noto SansDevanagari:style=Bold", + "Noto SansEthiopic", + // "Noto SansEthiopic:style=Bold", + "Noto SansGeorgian", + // "Noto SansGeorgian:style=Bold", + "Noto SansGujarati", + // "Noto SansGujarati:style=Bold", + "Noto SansGurmukhi", + // "Noto SansGurmukhi:style=Bold", + "Noto SansHebrew", + // "Noto SansHebrew:style=Bold", + "Noto SansJavanese", + "Noto SansKannada", + // "Noto SansKannada:style=Bold", + "Noto SansKhmer", + // "Noto SansKhmer:style=Bold", + "Noto SansLao", + // "Noto SansLao:style=Bold", + "Noto SansMongolian", + "Noto SansMyanmar", + // "Noto SansMyanmar:style=Bold", + "Noto SansOriya", + // "Noto SansOriya:style=Bold", + "Noto SansSinhala", + // "Noto SansSinhala:style=Bold", + "Noto SansTamil", + // "Noto SansTamil:style=Bold", + "Noto SansThai", + // "Noto SansThai:style=Bold", + "Noto SansTibetan", + // "Noto SansTibetan:style=Bold", + "Noto SansTifinagh", +]; + +function pick_font(language, i=0) = + i < 0 || i > len(fonts) + ? "Noto Sans" + str(i) + : is_undef(str_find(fonts[i], language)) + ? pick_font(language, i=i+1) + : fonts[i]; + +font = pick_font(script); + +greeting = struct_val([ + ["Arabic", "سلام"], + ["Armenian", "Բարև"], + ["Balinese", "ᬒᬁᬓᬭ"], + ["Bengali", "নমস্কার"], + ["CJK TC": "你好"], + ["Devanagari", "नमस्ते"], + ["English", "Hello"], + ["Ethiopic", "ሰላም"], + ["Georgian", "გამარჯობა"], + ["Gujarati", "નમસ્તે"], + ["Gurmukhi", "ਸਤ ਸ੍ਰੀ ਅਕਾਲ"], + ["Hebrew", "שלום"], + ["Javanese", "ꦱꦸꦒꦼꦁꦫꦮꦸꦃ"], + ["Kannada", "ನಮಸ್ಕಾರ"], + ["Khmer", "សួស្តី"], + ["Lao", "ສະບາຍດີ"], + ["Mongolian", "ᠰᠠᠶᠢᠨ ᠪᠠᠶᠢᠨᠠ ᠣᠣ"], + ["Myanmar", "မင်္ဂလာပါ"], + ["Oriya", "ନମସ୍କାର"], + ["Sinhala", "ආයුබෝවන්"], + ["Tamil", "வணக்கம்"], + ["Thai", "สวัสดี"], + ["Tibetan", "བཀྲ་ཤིས་བདེ་ལེགས།"], + ["Tifinagh", "ⴰⵣⵓⵍ"], +], language, "Hello"); + +echo(script=script, + greeting=greeting, + font=font, + style=style); + +color("gray") + translate([0, debug ? -60 : -20, 0]) + linear_extrude(1) + text( + greeting, + font=str(font, ":style=", style), + script=script, + halign="center", + valign="center"); + +// You can find the original for the following example in the file explorer above, +// under openscad / examples / Basic / CSG-modules.scad + +// CSG-modules.scad - Basic usage of modules, if, color, $fs/$fa + +// Change this to false to remove the helper geometry +debug = true; + +// Global resolution +$fs=$preview ? 1 : 0.1; // Don't generate smaller facets than 0.1 mm +$fa=$preview ? 15 : 5; // Don't generate larger angles than 5 degrees + +rotate([-90, 0, 0]) { + // Main geometry + difference() { + intersection() { + body(); + intersector(); + } + holes(); + } + + // Helpers + if (debug) helpers(); +} + +// Core geometric primitives. +// These can be modified to create variations of the final object + +module body() { + color("Blue") sphere(10); +} + +module intersector() { + color("Red") cube(15, center=true); +} + +module holeObject() { + color("Lime") cylinder(h=20, r=5, center=true); +} + +// Various modules for visualizing intermediate components + +module intersected() { + intersection() { + body(); + intersector(); + } +} + +module holeA() rotate([0,90,0]) holeObject(); +module holeB() rotate([90,0,0]) holeObject(); +module holeC() holeObject(); + +module holes() { + union() { + holeA(); + holeB(); + holeC(); + } +} + +module helpers() { + // Inner module since it's only needed inside helpers + module line() color("Black") cylinder(r=1, h=10, center=true); + + scale(0.5) { + translate([-30,0,-40]) { + intersected(); + translate([-15,0,-35]) body(); + translate([15,0,-35]) intersector(); + translate([-7.5,0,-17.5]) rotate([0,30,0]) line(); + translate([7.5,0,-17.5]) rotate([0,-30,0]) line(); + } + translate([30,0,-40]) { + holes(); + translate([-10,0,-35]) holeA(); + translate([10,0,-35]) holeB(); + translate([30,0,-35]) holeC(); + translate([5,0,-17.5]) rotate([0,-20,0]) line(); + translate([-5,0,-17.5]) rotate([0,30,0]) line(); + translate([15,0,-17.5]) rotate([0,-45,0]) line(); + } + translate([-20,0,-22.5]) rotate([0,45,0]) line(); + translate([20,0,-22.5]) rotate([0,-45,0]) line(); + } +} + +echo(version=version()); +// Written by Marius Kintel +// +// To the extent possible under law, the author(s) have dedicated all +// copyright and related and neighboring rights to this software to the +// public domain worldwide. This software is distributed without any +// warranty. +// +// You should have received a copy of the CC0 Public Domain +// Dedication along with this software. +// If not, see .