[squeak-dev] The Trunk: Tools-mt.1139.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Mar 3 13:49:45 UTC 2022
Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1139.mcz
==================== Summary ====================
Name: Tools-mt.1139
Author: mt
Time: 3 March 2022, 2:49:41.991142 pm
UUID: b7db1f19-33ca-d44f-8b77-c1ca9f523f88
Ancestors: Tools-mt.1138
Glyph browsing:
- use non-breaking space(s) to make zero-width glyphs visible
- do not skip empty glyphs anymore
- replace #asUnicode with #charCode to just drop the #leadingChar if any; it is not about decoding here
=============== Diff against Tools-mt.1138 ===============
Item was changed:
----- Method: AbstractFont>>browseAllGlyphsByCategory (in category '*Tools-Browsing') -----
browseAllGlyphsByCategory
"Browse glyphs for all printable characters/code-points in the receiver."
^ self
browseGlyphsByCategoryOf: ((self minCodePoint max: 32 "space"+1) to: self maxCodePoint)
+ select: [:char | self hasGlyphOf: char]!
- select: [:char | (self hasGlyphOf: char) and: [(self widthOf: char) > 0]]!
Item was changed:
----- Method: AbstractFont>>browseGlyphsByCategoryOf:select:label: (in category '*Tools-Browsing') -----
browseGlyphsByCategoryOf: someCodePointsOrCharacters select: aBlock label: aLabelOrNil
"Like #browseGlyphsOf:... but group the code points by Unicode category."
| sortedCodePoints contents isRange tmp separatorBlock |
isRange := isRange := someCodePointsOrCharacters isInterval and: [someCodePointsOrCharacters increment = 1].
separatorBlock := [:codePoints :category |
(('\{1}\\' withCRs asText
format: { Unicode generalCategoryLabels at: category+1 ifAbsent: ['n/a'] })
addAttribute: (TextFontReference toFont: TextStyle defaultFixedFont);
addAttribute: (PluggableTextAttribute evalBlock: [self browseGlyphsByCategoryOf: codePoints select: aBlock label: aLabelOrNil]);
yourself) ].
sortedCodePoints := (someCodePointsOrCharacters
+ collect: [:ea | ea isCharacter ifTrue: [ea charCode] ifFalse: [ea] ]
- collect: [:ea | ea isCharacter ifTrue: [ea asUnicode] ifFalse: [ea] ]
thenSelect: [:ea | aBlock value: (Character value: ea)])
sorted: [:a :b | | ca cb | (ca := (Unicode generalCategoryOf: a) ifNil: [0]) < (cb := (Unicode generalCategoryOf: b) ifNil: [0])
or: [ca = cb and: [a < b]]].
"Header"
contents := (('Family name: {1}{6}\ Emphasis: {2}\ Point size: {3} ({4}ppi {5}px{7})\' withCRs asText format: { self familyName asText addAttribute: (PluggableTextAttribute evalBlock: [self explore]); yourself. [self emphasisString] on: Error do: [self subfamilyName]. self pointSize. self pixelsPerInch. self height. isRange ifTrue: [''] ifFalse: [' (selected code points)']. (self isTTCFont and: [(tmp := self extraGlyphScale) ~= 1]) ifFalse: [''] ifTrue: [' ', (tmp * 100) rounded asString, '%'] }) addAttribute: (TextFontReference toFont: TextStyle defaultFixedFont); yourself).
String streamContents: [:s | | priorCategory currentCodePoints |
currentCodePoints := OrderedCollection new.
sortedCodePoints withIndexDo: [:codePoint :index |
| char category |
char := Character value: codePoint.
category := Unicode generalCategoryOf: codePoint.
priorCategory ifNil: [priorCategory := category].
category = priorCategory ifTrue: [
currentCodePoints add: codePoint.
s nextPut: char].
(category ~= priorCategory or: [index = sortedCodePoints size])
ifTrue: [
contents := contents, (separatorBlock value: currentCodePoints value: priorCategory).
contents := contents, ((s cr; contents) asText addAttribute: (TextFontReference toFont: self); yourself).
currentCodePoints := OrderedCollection new.
s reset.
currentCodePoints add: codePoint.
s nextPut: char].
+ (self widthOf: char) = 0 ifTrue: [s nextPut: Character nbsp; nextPut: Character nbsp].
priorCategory := category]].
contents editWithLabel: (aLabelOrNil ifNil: [self printString]).!
Item was changed:
----- Method: AbstractFont>>browseGlyphsFrom:to: (in category '*Tools-Browsing') -----
browseGlyphsFrom: firstCodePoint to: lastCodePoint
"Split range in sub-ranges whenever the receiver has no glyph for a certain code point or when that glyph is not visible. Start with at least a printable character after #space to avoid line breaks in the editor. Note that non-breaking space an similar are skipped as well."
^ self
browseGlyphsOf:
((firstCodePoint max: (self minCodePoint max: 32 "space" +1))
to: (lastCodePoint min: self maxCodePoint))
+ select: [:char | self hasGlyphOf: char]!
- select: [:char | (self hasGlyphOf: char) and: [(self widthOf: char) > 0]
- and: [(self characterFormAt: char) bits anySatisfy: [:ea |
- ea ~= 0 "transparent" and: [ea ~= 4294967295 "white"]]]
- ]!
Item was changed:
----- Method: AbstractFont>>browseGlyphsOf:select:label: (in category '*Tools-Browsing') -----
browseGlyphsOf: someCodePointsOrCharacters select: aBlock label: aLabelOrNil
"Browse all glyphs in the given collection of code points or characters. Split range in sub-ranges whenever the receiver has no glyph for a certain code point. DO NOT translate user-facing text because this is a debugging tool so that text should only use ASCII."
| contents isRange tmp separatorBlock |
isRange := someCodePointsOrCharacters isInterval and: [someCodePointsOrCharacters increment = 1].
separatorBlock := [:currentRange |
(('\16r{1} to: 16r{2}\\' withCRs asText
format: { currentRange first printStringBase: 16 length: 6 padded: true. currentRange last printStringBase: 16 length: 6 padded: true })
addAttribute: (TextFontReference toFont: TextStyle defaultFixedFont);
addAttribute: (PluggableTextAttribute evalBlock: [self browseGlyphsFrom: currentRange first to: currentRange last select: aBlock]);
yourself)].
"Header"
contents := (('Family name: {1}{6}\ Emphasis: {2}\ Point size: {3} ({4}ppi {5}px{7})\' withCRs asText format: { self familyName asText addAttribute: (PluggableTextAttribute evalBlock: [self explore]); yourself. [self emphasisString] on: Error do: [self subfamilyName]. self pointSize. self pixelsPerInch. self height. isRange ifTrue: [''] ifFalse: [' (selected code points)']. (self isTTCFont and: [(tmp := self extraGlyphScale) ~= 1]) ifFalse: [''] ifTrue: [' ', (tmp * 100) rounded asString, '%'] }) addAttribute: (TextFontReference toFont: TextStyle defaultFixedFont); yourself).
String streamContents: [:s | | first last |
last := someCodePointsOrCharacters last.
someCodePointsOrCharacters withIndexDo: [:codePointOrChar :index |
| current char valid |
+ current := codePointOrChar isCharacter ifTrue: [codePointOrChar charCode] ifFalse: [codePointOrChar].
- current := codePointOrChar isCharacter ifTrue: [codePointOrChar asUnicode] ifFalse: [codePointOrChar].
char := Character value: current.
(valid := (aBlock value: char))
+ ifTrue: [
+ s position = 0 ifTrue: [first := current].
+ s nextPut: char.
+ (self widthOf: char) = 0 ifTrue: [s nextPut: Character nbsp; nextPut: Character nbsp] ].
- ifTrue: [s position = 0 ifTrue: [first := current]. s nextPut: char].
(valid not or: [index = someCodePointsOrCharacters size])
ifTrue: [s position = 0 ifFalse: [
isRange ifFalse: [contents := contents, String cr] ifTrue: [ | currentRange |
currentRange := first to: (index = someCodePointsOrCharacters size ifTrue: [last] ifFalse: [current-1]).
contents := contents, (separatorBlock value: currentRange)].
contents := contents, ((s cr; contents) asText addAttribute: (TextFontReference toFont: self); yourself).
s reset]] ]].
contents editWithLabel: (aLabelOrNil ifNil: [self printString]).!
More information about the Squeak-dev
mailing list
|