diff --git a/glyphs/symbol-geometric.patel b/glyphs/symbol-geometric.patel index 07e461c..32d852b 100644 --- a/glyphs/symbol-geometric.patel +++ b/glyphs/symbol-geometric.patel @@ -32,6 +32,142 @@ create-glyph 'heavyshade' : glyph-construction { assign-unicode 0x2593 include : Shade [[j k] -> [[k % 2] || [j + k / 2] % 2]] } +let : foreach fill [range 1 8] : begin { + create-glyph ['vfill' + fill] : glyph-construction { + assign-unicode [0x2580 + fill] + start-from 0 [mix font.hhea.descent font.hhea.ascent [fill / 8]] + line-to WIDTH [mix font.hhea.descent font.hhea.ascent [fill / 8]] + line-to WIDTH font.hhea.descent + line-to 0 font.hhea.descent + } + create-glyph ['hfill' + fill] : glyph-construction { + assign-unicode [0x2590 - fill] + start-from 0 font.hhea.ascent + line-to [WIDTH * fill / 8] font.hhea.ascent + line-to [WIDTH * fill / 8] font.hhea.descent + line-to 0 font.hhea.descent + } +} +create-glyph 'upHalfblock' : glyph-construction { + assign-unicode 0x2580 + start-from 0 font.hhea.ascent + line-to WIDTH font.hhea.ascent + line-to WIDTH [mix font.hhea.descent font.hhea.ascent 0.5] + line-to 0 [mix font.hhea.descent font.hhea.ascent 0.5] +} +create-glyph 'rightHalfBlock' : glyph-construction { + assign-unicode 0x2590 + start-from [WIDTH * 0.5] font.hhea.ascent + line-to WIDTH font.hhea.ascent + line-to WIDTH font.hhea.descent + line-to [WIDTH * 0.5] font.hhea.descent +} + +### Box drawing glyphs +let : begin { + local light : adviceBlackness 3.5 + local heavy : light * 2 + define [boxdraw unicode u d l r] : create-glyph ['bd' + [unicode.toString 16]] : glyph-construction { + assign-unicode unicode + local stopH : [Math.max u d] / 2 + local stopV : [Math.max l r] / 2 + local midy : mix font.hhea.descent font.hhea.ascent 0.5 + if l : include : HBar 0 [MIDDLE + stopH] midy l + if r : include : HBar [MIDDLE - stopH] WIDTH midy r + if d : include : VBar MIDDLE font.hhea.descent [midy + stopV] d + if u : include : VBar MIDDLE [midy - stopV] font.hhea.ascent u + } + define [dlboxdraw unicode u d l r] : create-glyph ['bd' + [unicode.toString 16]] : glyph-construction { + assign-unicode unicode + local stopH : [[Math.max u d] - light] / 2 + local stopV : [[Math.max l r] - light] / 2 + local capH : stopH * heavy / [heavy - light] + local capV : stopV * heavy / [heavy - light] + local midy : mix font.hhea.descent font.hhea.ascent 0.5 + if l : begin { + include : HBar 0 [MIDDLE - stopH] [midy + [l - light]] light + if [l > light] : include : HBar 0 [MIDDLE - stopH] [midy - [l - light]] light + } + if r : begin { + include : HBar [MIDDLE + stopH] WIDTH [midy + [r - light]] light + if [r > light] : include : HBar [MIDDLE + stopH] WIDTH [midy - [r - light]] light + } + if d : begin { + include : VBar [MIDDLE + [d - light]] font.hhea.descent [midy - stopV] light + if [d > light] : include : VBar [MIDDLE - [d - light]] font.hhea.descent [midy - stopV] light + } + if u : begin { + include : VBar [MIDDLE + [u - light]] [midy + stopV] font.hhea.ascent light + if [u > light] : include : VBar [MIDDLE - [u - light]] [midy + stopV] font.hhea.ascent light + } + if [stopH > 0 && [not u]] : include : HBar [MIDDLE - stopH - light] [MIDDLE + stopH + light] [midy + capV] light + if [stopH > 0 && [not d]] : include : HBar [MIDDLE - stopH - light] [MIDDLE + stopH + light] [midy - capV] light + if [stopV > 0 && [not l]] : include : VBar [MIDDLE - capH] [midy - stopV - light] [midy + stopV + light] light + if [stopV > 0 && [not r]] : include : VBar [MIDDLE + capH] [midy - stopV - light] [midy + stopV + light] light + } + define [complexBoxDraw unicodeStart U D L R fn dl] : begin { + local order ( + (light light light light) + (light light heavy light) + (light light light heavy) + (light light heavy heavy) + (heavy light light light) + (light heavy light light) + (heavy heavy light light) + (heavy light heavy light) + (heavy light light heavy) + (light heavy heavy light) + (light heavy light heavy) + (heavy light heavy heavy) + (light heavy heavy heavy) + (heavy heavy heavy light) + (heavy heavy light heavy) + (heavy heavy heavy heavy) + ) + local existings () + local n 0 + foreach (u d l r) [items-of order] : begin { + local newcome true + local masked ([U * u] [D * d] [L * l] [R * r]) + foreach existing [items-of existings] : if ['' + existing === '' + masked] : set newcome false + if newcome : begin { + if [[not dl] + || [[not masked.0] || [not masked.1] || [masked.0 === masked.1]] + && [[not masked.2] || [not masked.3] || [masked.2 === masked.3]] + && [masked.0 > light || masked.1 > light || masked.2 > light || masked.3 > light] + ] : begin { + [fallback fn boxdraw].apply null ([unicodeStart + n] :: masked) + inc n + } + existings.push masked + } + } + } + boxdraw 0x2500 0 0 light light + boxdraw 0x2501 0 0 heavy heavy + boxdraw 0x2502 light light 0 0 + boxdraw 0x2503 heavy heavy 0 0 + complexBoxDraw 0x250C 0 1 0 1 + complexBoxDraw 0x2510 0 1 1 0 + complexBoxDraw 0x2514 1 0 0 1 + complexBoxDraw 0x2518 1 0 1 0 + complexBoxDraw 0x251C 1 1 0 1 + complexBoxDraw 0x2524 1 1 1 0 + complexBoxDraw 0x252C 0 1 1 1 + complexBoxDraw 0x2534 1 0 1 1 + complexBoxDraw 0x253C 1 1 1 1 + dlboxdraw 0x2550 0 0 heavy heavy + dlboxdraw 0x2551 heavy heavy 0 0 + complexBoxDraw 0x2552 0 1 0 1 dlboxdraw 1 + complexBoxDraw 0x2555 0 1 1 0 dlboxdraw 1 + complexBoxDraw 0x2558 1 0 0 1 dlboxdraw 1 + complexBoxDraw 0x255B 1 0 1 0 dlboxdraw 1 + complexBoxDraw 0x255E 1 1 0 1 dlboxdraw 1 + complexBoxDraw 0x2561 1 1 1 0 dlboxdraw 1 + complexBoxDraw 0x2564 0 1 1 1 dlboxdraw 1 + complexBoxDraw 0x2567 1 0 1 1 dlboxdraw 1 + complexBoxDraw 0x256A 1 1 1 1 dlboxdraw 1 +} ### POWERLINE glyphs create-glyph 'branch' : glyph-construction {