44 ucd "github.com/go-text/typesetting/internal/unicodedata"
55)
66
7- // uni exposes some lookup functions for Unicode properties.
8- var uni = unicodeFuncs {}
9-
107// generalCategory is an enum value to allow compact storage (see generalCategories)
118type generalCategory = ucd.GeneralCategory
129
@@ -205,9 +202,7 @@ var modifiedCombiningClass = [256]uint8{
205202 255 , /* HB_UNICODE_COMBINING_CLASS_INVALID */
206203}
207204
208- type unicodeFuncs struct {}
209-
210- func (unicodeFuncs ) modifiedCombiningClass (u rune ) uint8 {
205+ func uniModifiedCombiningClass (u rune ) uint8 {
211206 // Reorder SAKOT to ensure it comes after any tone marks.
212207 if u == 0x1A60 {
213208 return 254
@@ -272,20 +267,6 @@ func IsDefaultIgnorable(ch rune) bool {
272267 }
273268}
274269
275- func (unicodeFuncs ) isDefaultIgnorable (ch rune ) bool {
276- return IsDefaultIgnorable (ch )
277- }
278-
279- // retrieves the General Category property for
280- // a specified Unicode code point, expressed as enumeration value.
281- func (unicodeFuncs ) generalCategory (ch rune ) generalCategory { return ucd .LookupGeneralCategory (ch ) }
282-
283- func (unicodeFuncs ) isExtendedPictographic (ch rune ) bool { return ucd .IsExtendedPictographic (ch ) }
284-
285- // returns the mirroring Glyph code point (for bi-directional
286- // replacement) of a code point, or itself
287- func (unicodeFuncs ) mirroring (ch rune ) rune { return ucd .LookupMirrorChar (ch ) }
288-
289270/* Space estimates based on:
290271 * https://unicode.org/charts/PDF/U2000.pdf
291272 * https://docs.microsoft.com/en-us/typography/develop/character-design-standards/whitespace
@@ -306,7 +287,7 @@ const (
306287 spaceEM6 = 6
307288)
308289
309- func ( unicodeFuncs ) spaceFallbackType (u rune ) uint8 {
290+ func uniSpaceFallbackType (u rune ) uint8 {
310291 switch u {
311292 // all GC=Zs chars that can use a fallback.
312293 case 0x0020 :
@@ -346,17 +327,14 @@ func (unicodeFuncs) spaceFallbackType(u rune) uint8 {
346327 }
347328}
348329
349- func ( unicodeFuncs ) isVariationSelector (r rune ) bool {
330+ func uniIsVariationSelector (r rune ) bool {
350331 /* U+180B..180D, U+180F MONGOLIAN FREE VARIATION SELECTORs are handled in the
351332 * Arabic shaper. No need to match them here. */
352333 /* VARIATION SELECTOR-1..16 */
353334 /* VARIATION SELECTOR-17..256 */
354335 return (0xFE00 <= r && r <= 0xFE0F ) || (0xE0100 <= r && r <= 0xE01EF )
355336}
356337
357- func (unicodeFuncs ) decompose (ab rune ) (a , b rune , ok bool ) { return ucd .Decompose (ab ) }
358- func (unicodeFuncs ) compose (a , b rune ) (rune , bool ) { return ucd .Compose (a , b ) }
359-
360338/* Prepare */
361339
362340func isRegionalIndicator (r rune ) bool { return 0x1F1E6 <= r && r <= 0x1F1FF }
@@ -399,7 +377,7 @@ func (b *Buffer) setUnicodeProps() {
399377 }
400378 } else if info [i ].isZwj () {
401379 info [i ].setContinuation (b )
402- if i + 1 < len (b .Info ) && uni . isExtendedPictographic (info [i + 1 ].codepoint ) {
380+ if i + 1 < len (b .Info ) && ucd . IsExtendedPictographic (info [i + 1 ].codepoint ) {
403381 i ++
404382 info [i ].setUnicodeProps (b )
405383 info [i ].setContinuation (b )
@@ -520,11 +498,11 @@ func (b *Buffer) ensureNativeDirection() {
520498
521499// the returned flag must be ORed with the current
522500func computeUnicodeProps (u rune ) (unicodeProp , bufferScratchFlags ) {
523- genCat := uni . generalCategory (u )
501+ genCat := ucd . LookupGeneralCategory (u )
524502 props := unicodeProp (genCat )
525503 var flags bufferScratchFlags
526504 if u >= 0x80 {
527- if uni . isDefaultIgnorable (u ) {
505+ if IsDefaultIgnorable (u ) {
528506 flags |= bsfHasDefaultIgnorables
529507 props |= upropsMaskIgnorable
530508 if u == 0x200C {
@@ -555,7 +533,7 @@ func computeUnicodeProps(u rune) (unicodeProp, bufferScratchFlags) {
555533 if genCat .IsMark () {
556534 flags |= bsfHasContinuations
557535 props |= upropsMaskContinuation
558- props |= unicodeProp (uni . modifiedCombiningClass (u )) << 8
536+ props |= unicodeProp (uniModifiedCombiningClass (u )) << 8
559537 }
560538 }
561539
0 commit comments