@@ -125,34 +125,52 @@ glyph-block AutoBuild-Enclosure : begin
125125 glyph-block-import Common-Derivatives
126126 glyph-block-import Recursive-Build : Fork Miniature MiniatureParaT
127127 glyph-block-import Autobuild-Enclosure-Shared : CircNameNoCheck CircName CollectJobs EnsureComponentGlyphT CreateDerivedFontFromJobs applyRelations getGlyphDefaultShift
128+ glyph-block-import CommonShapes-Polygon : Polygon
128129
129130 define circleWidthClasses {{'NWID' Width 0.12} {'WWID' WideWidth0 0.08}}
130131 define [AdjustDigitCount digits width] : Math.max 1 (digits * Width / width)
131132 define [EnclosureStrokeScale dscale digits width] : dscale / ([AdjustDigitCount digits width] ** 0.66)
132133
133134 define enclosureInnerPartActualWidth : new Map
134135
135- define [GlyphNameInnerOf gniPrefix subGlyph mp actualWidth accumulatedTfm] : begin
136- define nameParts : list mp actualWidth accumulatedTfm
136+ define [GlyphNameInnerOf gniPrefix subGlyph isMultiPart actualWidth accumulatedTfm] : begin
137+ define nameParts : list isMultiPart actualWidth accumulatedTfm
137138 hashGeometry subGlyph.geometry
138139 hashCv subGlyph
139140 return : '.ci.' + gniPrefix + '/' + [nameParts.join '/']
140141
141- define [EnsureInnerSubGlyphImpl inners markClass miniatureFont mp actualWidth accumulatedTfm] : function [gidPart] : begin
142- define subGlyph : miniatureFont.queryByNameEnsured gidPart
143- define gniPart : GlyphNameInnerOf inners.gniPrefix subGlyph mp actualWidth accumulatedTfm
144- if [query-glyph gniPart] : return gniPart
145-
146- enclosureInnerPartActualWidth.set gniPart (actualWidth)
147- create-glyph gniPart : glyph-proc
148- set-width 0
149- set-mark-anchor 'compositeInner' 0 0
150- include : inners.buildInnerShape subGlyph
151- include accumulatedTfm
152- include : inners.addAnchors mp markClass actualWidth
153- return gniPart
142+ define flex-params [EnsureInnerSubGlyphImpl] : begin
143+ local-parameter inners
144+ local-parameter markClass
145+ local-parameter miniatureFont
146+ local-parameter isMultiPart
147+ local-parameter actualWidth
148+ local-parameter accumulatedTfm
149+
150+ return : function [gidPart] : begin
151+ define subGlyph : miniatureFont.queryByNameEnsured gidPart
152+ define gniPart : GlyphNameInnerOf inners.gniPrefix subGlyph isMultiPart actualWidth accumulatedTfm
153+ if [query-glyph gniPart] : return gniPart
154+
155+ enclosureInnerPartActualWidth.set gniPart (actualWidth)
156+ create-glyph gniPart : glyph-proc
157+ set-width 0
158+ set-mark-anchor 'compositeInner' 0 0
159+ include : inners.buildInnerShape subGlyph
160+ include accumulatedTfm
161+ include : inners.addAnchors isMultiPart markClass actualWidth
162+ return gniPart
163+
164+ define flex-params [EnsureInnerSubGlyphSeq] : begin
165+ local-parameter inners
166+ local-parameter markClass
167+ local-parameter miniatureFont
168+ local-parameter job
169+ local-parameter dimens
170+ local-parameter xCompress
171+ local-parameter yCompress
172+ local-parameter kExtraYShift
154173
155- define [EnsureInnerSubGlyphSeq inners markClass miniatureFont job dimens yCompress kExtraYShift] : begin
156174 define { gn unicode parts w bal baly } job
157175 define [object width mockInnerWidth dscale] dimens
158176
@@ -162,22 +180,27 @@ glyph-block AutoBuild-Enclosure : begin
162180 local derivedGlyph : miniatureFont.queryByNameEnsured gidPart
163181 if [not firstDerivedGyph] : set firstDerivedGyph derivedGlyph
164182 set totalWidth : totalWidth + derivedGlyph.advanceWidth
165- local xCompress : inners.getXScalar parts.length markClass mockInnerWidth totalWidth
183+ local xCompressInternal : inners.getXScalar parts.length markClass mockInnerWidth totalWidth
166184 set totalWidth : Math.min mockInnerWidth totalWidth
167185
168186 local shift : inners.getShift bal baly firstDerivedGyph
169187 local accumulatedTfm : Transform.Combine
170188 firstDerivedGyph.gizmo.inverse
171- Scale (dscale * xCompress) (dscale * yCompress)
189+ Scale (dscale * xCompressInternal * xCompress) (dscale * yCompress)
172190 Translate 0 (dscale * shift + SymbolMid + (kExtraYShift - 0.5) * CAP * dscale)
173191 begin firstDerivedGyph.gizmo
174192
175193 local finalParts {}
176194 foreach partIndex [range 0 parts.length] : do
177195 local gidPart parts.(partIndex)
178- local actualWidth : [miniatureFont.queryByNameEnsured gidPart].advanceWidth * dscale * xCompress
179- finalParts.push : EnsureComponentGlyphT gidPart
180- EnsureInnerSubGlyphImpl inners markClass miniatureFont (parts.length > 1) actualWidth accumulatedTfm
196+ local actualWidth : [miniatureFont.queryByNameEnsured gidPart].advanceWidth * dscale * xCompress * xCompressInternal
197+ finalParts.push : EnsureComponentGlyphT gidPart : EnsureInnerSubGlyphImpl
198+ markClass -- markClass
199+ inners -- inners
200+ miniatureFont -- miniatureFont
201+ isMultiPart -- (parts.length > 1)
202+ actualWidth -- actualWidth
203+ accumulatedTfm -- accumulatedTfm
181204
182205 return finalParts
183206
@@ -192,22 +215,49 @@ glyph-block AutoBuild-Enclosure : begin
192215 include : with-transform [Translate x 0] : refer-glyph gniPart
193216 set x : x + ([enclosureInnerPartActualWidth.get gniPart] || 0)
194217
195- define [EnclosureInner dimens inners miniatureFont job] : glyph-proc
196- define { gn unicode parts w bal baly } job
218+ define [EnclosureInnerWithScale dimens inners miniatureFont xs ys job] : glyph-proc
219+ define { gn unicode parts w bal baly } job
197220 define [object width] dimens
198221
199- local finalParts : EnsureInnerSubGlyphSeq inners 'enclosureInner' miniatureFont job dimens 1 0
222+ local finalParts : EnsureInnerSubGlyphSeq
223+ markClass -- 'enclosureInner'
224+ inners -- inners
225+ miniatureFont -- miniatureFont
226+ job -- job
227+ dimens -- dimens
228+ xCompress -- xs
229+ yCompress -- ys
230+ kExtraYShift -- (0.5 * (1 - ys))
200231
201232 include : new-glyph : EnclosureInnerImpl dimens finalParts
202233 return finalParts
203234
235+ define [EnclosureInner dimens inners miniatureFont job] : begin
236+ return : EnclosureInnerWithScale dimens inners miniatureFont 1.0 1.0 job
237+
204238 define [TwoRowEnclosureInner dimens inners miniatureFont job] : glyph-proc
205239 define { gn unicode parts w bal baly } job
206240 define [object width] dimens
207241 local jobFirstHalf { gn unicode [parts.slice 0 (parts.length / 2)] w bal baly }
208242 local jobSecondHalf { gn unicode [parts.slice (parts.length / 2)] w bal baly }
209- local finalPartsFirstHalf : EnsureInnerSubGlyphSeq inners "enclosureInnerFirstHalf" miniatureFont jobFirstHalf dimens 0.55 (+0.55)
210- local finalPartsSecondHalf : EnsureInnerSubGlyphSeq inners "enclosureInnerSecondHalf" miniatureFont jobSecondHalf dimens 0.55 (-0.10)
243+ local finalPartsFirstHalf : EnsureInnerSubGlyphSeq
244+ markClass -- 'enclosureInnerFirstHalf'
245+ inners -- inners
246+ miniatureFont -- miniatureFont
247+ job -- jobFirstHalf
248+ dimens -- dimens
249+ xCompress -- 1.00
250+ yCompress -- 0.55
251+ kExtraYShift -- (+0.55)
252+ local finalPartsSecondHalf : EnsureInnerSubGlyphSeq
253+ markClass -- 'enclosureInnerSecondHalf'
254+ inners -- inners
255+ miniatureFont -- miniatureFont
256+ job -- jobSecondHalf
257+ dimens -- dimens
258+ xCompress -- 1.00
259+ yCompress -- 0.55
260+ kExtraYShift -- (-0.10)
211261
212262 return : {}.concat finalPartsFirstHalf finalPartsSecondHalf
213263
@@ -217,8 +267,24 @@ glyph-block AutoBuild-Enclosure : begin
217267 local jobFirstHalf { gn unicode [parts.slice 0 (parts.length / 2)] w bal baly }
218268 local jobSecondHalf { gn unicode [parts.slice (parts.length / 2)] w bal baly }
219269
220- local finalPartsFirstHalf : EnsureInnerSubGlyphSeq inners "enclosureInnerFirstHalf" miniatureFont jobFirstHalf dimens 0.6 (+0.55)
221- local finalPartsSecondHalf : EnsureInnerSubGlyphSeq inners "enclosureInnerSecondHalf" miniatureFont jobSecondHalf dimens 0.6 (-0.15)
270+ local finalPartsFirstHalf : EnsureInnerSubGlyphSeq
271+ markClass -- 'enclosureInnerFirstHalf'
272+ inners -- inners
273+ miniatureFont -- miniatureFont
274+ job -- jobFirstHalf
275+ dimens -- dimens
276+ xCompress -- 1.0
277+ yCompress -- 0.6
278+ kExtraYShift -- (+0.55)
279+ local finalPartsSecondHalf : EnsureInnerSubGlyphSeq
280+ markClass -- 'enclosureInnerSecondHalf'
281+ inners -- inners
282+ miniatureFont -- miniatureFont
283+ job -- jobSecondHalf
284+ dimens -- dimens
285+ xCompress -- 1.0
286+ yCompress -- 0.6
287+ kExtraYShift -- (-0.15)
222288
223289 return : {}.concat finalPartsFirstHalf finalPartsSecondHalf
224290
@@ -348,6 +414,14 @@ glyph-block AutoBuild-Enclosure : begin
348414 local parts : include : EnclosureInner dimens inners miniatureFont job
349415 if decomp : CvDecompose.set currentGlyph [{gnEnclosure}.concat parts]
350416
417+ define DiamondBuilder : object
418+ decomposable true
419+ buildGlyph : function [dimens inners miniatureFont decomp job gnEnclosure] : glyph-proc
420+ include : refer-glyph gnEnclosure
421+ local s : Math.min 1.0 (0.75 * (dimens.width / Width))
422+ local parts : include : EnclosureInnerWithScale dimens inners miniatureFont s s job
423+ if decomp : CvDecompose.set currentGlyph [{gnEnclosure}.concat parts]
424+
351425 define DecomposableInsetBuilder : object
352426 decomposable true
353427 buildGlyph : function [dimens inners miniatureFont decomp job gnEnclosure] : glyph-proc
@@ -430,17 +504,6 @@ glyph-block AutoBuild-Enclosure : begin
430504 VBar.r right bot top sw
431505 include : AddEnclosureMark digits : CircleDimens digits ww
432506
433- define [createAribSpeedSignGlyphs digits demands]
434- EnclosureT 'aribSpeedSign' CircledBuilder StandardInners digits 1 demands AribSpeedSignEnclosureShape
435- define [AribSpeedSignEnclosureShape digits ww gap] : glyph-proc
436- define [object width sw top bot left right] : CircleDimens digits ww
437- set-width width
438- local f : AdviceStroke 8
439- include : difference
440- Rect top bot left right
441- Ring (top - f) (bot + f) (left + f) (right - f)
442- include : AddEnclosureMark digits : CircleDimens digits ww
443-
444507 define [createTwoRowBoxedGlyphs digits demands]
445508 EnclosureT 'twoRowBoxed' TwoRowBoxedBuilder StandardInners digits 2 demands TwoRowBoxEnclosureShape
446509 define [TwoRowBoxEnclosureShape digits ww gap] : glyph-proc
@@ -457,6 +520,30 @@ glyph-block AutoBuild-Enclosure : begin
457520 set-base-anchor 'enclosureInnerFirstHalf' (0.5 * width - 0.5 * dscale * [Math.min (Width * digits) mockInnerWidth]) 0
458521 set-base-anchor 'enclosureInnerSecondHalf' (0.5 * width - 0.5 * dscale * [Math.min (Width * digits) mockInnerWidth]) 0
459522
523+ define [createAribSpeedSignGlyphs digits demands]
524+ EnclosureT 'aribSpeedSign' CircledBuilder StandardInners digits 1 demands AribSpeedSignEnclosureShape
525+ define [AribSpeedSignEnclosureShape digits ww gap] : glyph-proc
526+ define [object width sw top bot left right] : CircleDimens digits ww
527+ set-width width
528+ local f : AdviceStroke 8
529+ include : difference
530+ Rect top bot left right
531+ Ring (top - f) (bot + f) (left + f) (right - f)
532+ include : AddEnclosureMark digits : CircleDimens digits ww
533+
534+ define [createDiamondGlyphs digits demands]
535+ EnclosureT 'diamond' DiamondBuilder StandardInners digits 1 demands DiamondEnclosureShape
536+ define [DiamondEnclosureShape digits ww gap] : glyph-proc
537+ define [object width sw top bot left right] : CircleDimens digits ww
538+ local swAdj : sw * [AdviceStroke 3] / Stroke
539+ set-width width
540+ include : Polygon.inset-bordered swAdj : list
541+ corner (left + O) [mix bot top 0.5]
542+ corner [mix left right 0.5] (bot + O)
543+ corner (right - O) [mix bot top 0.5]
544+ corner [mix left right 0.5] (top - O)
545+ include : AddEnclosureMark digits : CircleDimens digits ww
546+
460547 define [createPlayingCardGlyphs digits demands]
461548 EnclosureT 'playingCard' PlayingCardBuilder PlayingCardInners digits 2 demands PlayingCardEnclosure.Shape
462549 define [createTrumpCardGlyphs digits demands]
@@ -926,17 +1013,6 @@ glyph-block AutoBuild-Enclosure : begin
9261013 list 0x1F19F {'eight.lnum' 'K'} WideWidth1
9271014 list 0x1F1A6 {'H' 'C'} WideWidth1
9281015
929- do "ARIB STD B24 speed signs"
930- createAribSpeedSignGlyphs 2 : list
931- list 0x3248 {'one.lnum' 'zero.lnum'} WideWidth1
932- list 0x3249 {'two.lnum' 'zero.lnum'} WideWidth1
933- list 0x324A {'three.lnum' 'zero.lnum'} WideWidth1
934- list 0x324B {'four.lnum' 'zero.lnum'} WideWidth1
935- list 0x324C {'five.lnum' 'zero.lnum'} WideWidth1
936- list 0x324D {'six.lnum' 'zero.lnum'} WideWidth1
937- list 0x324E {'seven.lnum' 'zero.lnum'} WideWidth1
938- list 0x324F {'eight.lnum' 'zero.lnum'} WideWidth1
939-
9401016 do "Triple-digit boxed"
9411017 createBoxedGlyphs 3 : list
9421018 list 0x1F14E {'P' 'P' 'V'} WideWidth1
@@ -967,6 +1043,21 @@ glyph-block AutoBuild-Enclosure : begin
9671043 createTwoRowBoxedGlyphs 4 : list
9681044 list 0x1F1A9 { 'L' 'O' 'S' 'S' 'L' 'E' 'S' 'S' } WideWidth1
9691045
1046+ do "ARIB STD B24 speed signs"
1047+ createAribSpeedSignGlyphs 2 : list
1048+ list 0x3248 {'one.lnum' 'zero.lnum'} WideWidth1
1049+ list 0x3249 {'two.lnum' 'zero.lnum'} WideWidth1
1050+ list 0x324A {'three.lnum' 'zero.lnum'} WideWidth1
1051+ list 0x324B {'four.lnum' 'zero.lnum'} WideWidth1
1052+ list 0x324C {'five.lnum' 'zero.lnum'} WideWidth1
1053+ list 0x324D {'six.lnum' 'zero.lnum'} WideWidth1
1054+ list 0x324E {'seven.lnum' 'zero.lnum'} WideWidth1
1055+ list 0x324F {'eight.lnum' 'zero.lnum'} WideWidth1
1056+
1057+ do "Diamond"
1058+ createDiamondGlyphs 1 : list
1059+ list 0x2BD1 {'question'} WideWidth2
1060+
9701061 do "Playing cards"
9711062 # Here we always construct the two-digit cards to ensure that all digit and suit glyphs
9721063 # are aligned across all cards.
0 commit comments