###### Brailles symbols
$$include '../meta/macros.ptl'

import [mix linreg clamp fallback] from '../support/utils'
import [designParameters] from '../meta/aesthetics'

export : define [apply] : begin
	glyph-module-entry commonShapes overmarks

	if recursive : return nothing
	local leftMiddle : MIDDLE - (0.25 * WIDTH)
	local rightMiddle : MIDDLE + (0.25 * WIDTH)
	local offsetY : 0.25 * (parenMid - parenTop)
	local brailleStress : 0.5 * [adviceBlackness 3.375]
	local brailleDotsRadius : PERIODRADIUS * [Math.min 1 (brailleStress / HALFSTROKE)]
	
	### Basics / Templates
	sketch # brailleBlank
		set-width WIDTH
		save 'brailleBlank' 0x2800
	sketch # braille1
		include : DotAt (leftMiddle) (parenMid - 3 * offsetY) brailleDotsRadius
		set currentGlyph.cmpPriority (-101)
		save 'braille1' 0x2801
	sketch # braille2
		include : DotAt (leftMiddle) (parenMid - 1 * offsetY) brailleDotsRadius
		set currentGlyph.cmpPriority (-101)
		save 'braille2' 0x2802
	sketch # braille3
		include : DotAt (leftMiddle) (parenMid + 1 * offsetY) brailleDotsRadius
		set currentGlyph.cmpPriority (-101)
		save 'braille3' 0x2804
	sketch # braille4
		include : DotAt (rightMiddle) (parenMid - 3 * offsetY) brailleDotsRadius
		set currentGlyph.cmpPriority (-101)
		save 'braille4' 0x2808
	sketch # braille5
		include : DotAt (rightMiddle) (parenMid - 1 * offsetY) brailleDotsRadius
		set currentGlyph.cmpPriority (-101)
		save 'braille5' 0x2810
	sketch # braille6
		include : DotAt (rightMiddle) (parenMid + 1 * offsetY) brailleDotsRadius
		set currentGlyph.cmpPriority (-101)
		save 'braille6' 0x2820
	sketch # braille7
		include : DotAt (leftMiddle) (parenMid + 3 * offsetY) brailleDotsRadius
		set currentGlyph.cmpPriority (-101)
		save 'braille7' 0x2840
	sketch # braille8
		include : DotAt (rightMiddle) (parenMid + 3 * offsetY) brailleDotsRadius
		set currentGlyph.cmpPriority (-101)
		save 'braille8' 0x2880
	
	### Template
	define [build-braille-patterns archive] : if [not recursive] : begin
		foreach [{assignments unicode} : items-of archive] : sketch
			foreach [b : items-of assignments] : include glyphs.("braille" + b)
			set currentGlyph.cmpPriority (-101)
			save ("braille" + [assignments.join '']) unicode
	
	### Inheriting characters
	build-braille-patterns : list
		list {1 2} 0x2803
		list {1 3} 0x2805
		list {2 3} 0x2806
		list {1 2 3} 0x2807
		list {1 4} 0x2809
		list {2 4} 0x280A
		list {1 2 4} 0x280B
		list {3 4} 0x280C
		list {1 3 4} 0x280D
		list {2 3 4} 0x280E
		list {1 2 3 4} 0x280F
		list {1 5} 0x2811
		list {2 5} 0x2812
		list {1 2 5} 0x2813
		list {3 5} 0x2814
		list {1 3 5} 0x2815
		list {2 3 5} 0x2816
		list {1 2 3 5} 0x2817
		list {4 5} 0x2818
		list {1 4 5} 0x2819
		list {2 4 5} 0x281A
		list {1 2 4 5} 0x281B
		list {3 4 5} 0x281C
		list {1 3 4 5} 0x281D
		list {2 3 4 5} 0x281E
		list {1 2 3 4 5} 0x281F
		list {1 6} 0x2821
		list {2 6} 0x2822
		list {1 2 6} 0x2823
		list {3 6} 0x2824
		list {1 3 6} 0x2825
		list {2 3 6} 0x2826
		list {1 2 3 6} 0x2827
		list {4 6} 0x2828
		list {1 4 6} 0x2829
		list {2 4 6} 0x282A
		list {1 2 4 6} 0x282B
		list {3 4 6} 0x282C
		list {1 3 4 6} 0x282D
		list {2 3 4 6} 0x282E
		list {1 2 3 4 6} 0x282F
		list {5 6} 0x2830
		list {1 5 6} 0x2831
		list {2 5 6} 0x2832
		list {1 2 5 6} 0x2833
		list {3 5 6} 0x2834
		list {1 3 5 6} 0x2835
		list {2 3 5 6} 0x2836
		list {1 2 3 5 6} 0x2837
		list {4 5 6} 0x2838
		list {1 4 5 6} 0x2839
		list {2 4 5 6} 0x283A
		list {1 2 4 5 6} 0x283B
		list {3 4 5 6} 0x283C
		list {1 3 4 5 6} 0x283D
		list {2 3 4 5 6} 0x283E
		list {1 2 3 4 5 6} 0x283F
		list {1 7} 0x2841
		list {2 7} 0x2842
		list {1 2 7} 0x2843
		list {3 7} 0x2844
		list {1 3 7} 0x2845
		list {2 3 7} 0x2846
		list {1 2 3 7} 0x2847
		list {4 7} 0x2848
		list {1 4 7} 0x2849
		list {2 4 7} 0x284A
		list {1 2 4 7} 0x284B
		list {3 4 7} 0x284C
		list {1 3 4 7} 0x284D
		list {2 3 4 7} 0x284E
		list {1 2 3 4 7} 0x284F
		list {5 7} 0x2850
		list {1 5 7} 0x2851
		list {2 5 7} 0x2852
		list {1 2 5 7} 0x2853
		list {3 5 7} 0x2854
		list {1 3 5 7} 0x2855
		list {2 3 5 7} 0x2856
		list {1 2 3 5 7} 0x2857
		list {4 5 7} 0x2858
		list {1 4 5 7} 0x2859
		list {2 4 5 7} 0x285A
		list {1 2 4 5 7} 0x285B
		list {3 4 5 7} 0x285C
		list {1 3 4 5 7} 0x285D
		list {2 3 4 5 7} 0x285E
		list {1 2 3 4 5 7} 0x285F
		list {6 7} 0x2860
		list {1 6 7} 0x2861
		list {2 6 7} 0x2862
		list {1 2 6 7} 0x2863
		list {3 6 7} 0x2864
		list {1 3 6 7} 0x2865
		list {2 3 6 7} 0x2866
		list {1 2 3 6 7} 0x2867
		list {4 6 7} 0x2868
		list {1 4 6 7} 0x2869
		list {2 4 6 7} 0x286A
		list {1 2 4 6 7} 0x286B
		list {3 4 6 7} 0x286C
		list {1 3 4 6 7} 0x286D
		list {2 3 4 6 7} 0x286E
		list {1 2 3 4 6 7} 0x286F
		list {5 6 7} 0x2870
		list {1 5 6 7} 0x2871
		list {2 5 6 7} 0x2872
		list {1 2 5 6 7} 0x2873
		list {3 5 6 7} 0x2874
		list {1 3 5 6 7} 0x2875
		list {2 3 5 6 7} 0x2876
		list {1 2 3 5 6 7} 0x2877
		list {4 5 6 7} 0x2878
		list {1 4 5 6 7} 0x2879
		list {2 4 5 6 7} 0x287A
		list {1 2 4 5 6 7} 0x287B
		list {3 4 5 6 7} 0x287C
		list {1 3 4 5 6 7} 0x287D
		list {2 3 4 5 6 7} 0x287E
		list {1 2 3 4 5 6 7} 0x287F
		list {1 8} 0x2881
		list {2 8} 0x2882
		list {1 2 8} 0x2883
		list {3 8} 0x2884
		list {1 3 8} 0x2885
		list {2 3 8} 0x2886
		list {1 2 3 8} 0x2887
		list {4 8} 0x2888
		list {1 4 8} 0x2889
		list {2 4 8} 0x288A
		list {1 2 4 8} 0x288B
		list {3 4 8} 0x288C
		list {1 3 4 8} 0x288D
		list {2 3 4 8} 0x288E
		list {1 2 3 4 8} 0x288F
		list {5 8} 0x2890
		list {1 5 8} 0x2891
		list {2 5 8} 0x2892
		list {1 2 5 8} 0x2893
		list {3 5 8} 0x2894
		list {1 3 5 8} 0x2895
		list {2 3 5 8} 0x2896
		list {1 2 3 5 8} 0x2897
		list {4 5 8} 0x2898
		list {1 4 5 8} 0x2899
		list {2 4 5 8} 0x289A
		list {1 2 4 5 8} 0x289B
		list {3 4 5 8} 0x289C
		list {1 3 4 5 8} 0x289D
		list {2 3 4 5 8} 0x289E
		list {1 2 3 4 5 8} 0x289F
		list {6 8} 0x28A0
		list {1 6 8} 0x28A1
		list {2 6 8} 0x28A2
		list {1 2 6 8} 0x28A3
		list {3 6 8} 0x28A4
		list {1 3 6 8} 0x28A5
		list {2 3 6 8} 0x28A6
		list {1 2 3 6 8} 0x28A7
		list {4 6 8} 0x28A8
		list {1 4 6 8} 0x28A9
		list {2 4 6 8} 0x28AA
		list {1 2 4 6 8} 0x28AB
		list {3 4 6 8} 0x28AC
		list {1 3 4 6 8} 0x28AD
		list {2 3 4 6 8} 0x28AE
		list {1 2 3 4 6 8} 0x28AF
		list {5 6 8} 0x28B0
		list {1 5 6 8} 0x28B1
		list {2 5 6 8} 0x28B2
		list {1 2 5 6 8} 0x28B3
		list {3 5 6 8} 0x28B4
		list {1 3 5 6 8} 0x28B5
		list {2 3 5 6 8} 0x28B6
		list {1 2 3 5 6 8} 0x28B7
		list {4 5 6 8} 0x28B8
		list {1 4 5 6 8} 0x28B9
		list {2 4 5 6 8} 0x28BA
		list {1 2 4 5 6 8} 0x28BB
		list {3 4 5 6 8} 0x28BC
		list {1 3 4 5 6 8} 0x28BD
		list {2 3 4 5 6 8} 0x28BE
		list {1 2 3 4 5 6 8} 0x28BF
		list {7 8} 0x28C0
		list {1 7 8} 0x28C1
		list {2 7 8} 0x28C2
		list {1 2 7 8} 0x28C3
		list {3 7 8} 0x28C4
		list {1 3 7 8} 0x28C5
		list {2 3 7 8} 0x28C6
		list {1 2 3 7 8} 0x28C7
		list {4 7 8} 0x28C8
		list {1 4 7 8} 0x28C9
		list {2 4 7 8} 0x28CA
		list {1 2 4 7 8} 0x28CB
		list {3 4 7 8} 0x28CC
		list {1 3 4 7 8} 0x28CD
		list {2 3 4 7 8} 0x28CE
		list {1 2 3 4 7 8} 0x28CF
		list {5 7 8} 0x28D0
		list {1 5 7 8} 0x28D1
		list {2 5 7 8} 0x28D2
		list {1 2 5 7 8} 0x28D3
		list {3 5 7 8} 0x28D4
		list {1 3 5 7 8} 0x28D5
		list {2 3 5 7 8} 0x28D6
		list {1 2 3 5 7 8} 0x28D7
		list {4 5 7 8} 0x28D8
		list {1 4 5 7 8} 0x28D9
		list {2 4 5 7 8} 0x28DA
		list {1 2 4 5 7 8} 0x28DB
		list {3 4 5 7 8} 0x28DC
		list {1 3 4 5 7 8} 0x28DD
		list {2 3 4 5 7 8} 0x28DE
		list {1 2 3 4 5 7 8} 0x28DF
		list {6 7 8} 0x28E0
		list {1 6 7 8} 0x28E1
		list {2 6 7 8} 0x28E2
		list {1 2 6 7 8} 0x28E3
		list {3 6 7 8} 0x28E4
		list {1 3 6 7 8} 0x28E5
		list {2 3 6 7 8} 0x28E6
		list {1 2 3 6 7 8} 0x28E7
		list {4 6 7 8} 0x28E8
		list {1 4 6 7 8} 0x28E9
		list {2 4 6 7 8} 0x28EA
		list {1 2 4 6 7 8} 0x28EB
		list {3 4 6 7 8} 0x28EC
		list {1 3 4 6 7 8} 0x28ED
		list {2 3 4 6 7 8} 0x28EE
		list {1 2 3 4 6 7 8} 0x28EF
		list {5 6 7 8} 0x28F0
		list {1 5 6 7 8} 0x28F1
		list {2 5 6 7 8} 0x28F2
		list {1 2 5 6 7 8} 0x28F3
		list {3 5 6 7 8} 0x28F4
		list {1 3 5 6 7 8} 0x28F5
		list {2 3 5 6 7 8} 0x28F6
		list {1 2 3 5 6 7 8} 0x28F7
		list {4 5 6 7 8} 0x28F8
		list {1 4 5 6 7 8} 0x28F9
		list {2 4 5 6 7 8} 0x28FA
		list {1 2 4 5 6 7 8} 0x28FB
		list {3 4 5 6 7 8} 0x28FC
		list {1 3 4 5 6 7 8} 0x28FD
		list {2 3 4 5 6 7 8} 0x28FE
		list {1 2 3 4 5 6 7 8} 0x28FF
	
	set glyphs.braille1237.cmpPriority 104
	set glyphs.braille123.cmpPriority 103
	set glyphs.braille127.cmpPriority 103
	set glyphs.braille137.cmpPriority 103
	set glyphs.braille13.cmpPriority 102
	set glyphs.braille12.cmpPriority 102
	set glyphs.braille17.cmpPriority 102
	set glyphs.braille1.cmpPriority 103