[squeak-dev] The Trunk: Tools-mt.1134.mcz
commits at source.squeak.org
commits at source.squeak.org
Mon Feb 14 16:34:19 UTC 2022
Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1134.mcz
==================== Summary ====================
Name: Tools-mt.1134
Author: mt
Time: 14 February 2022, 5:34:16.071304 pm
UUID: de92e53a-c700-7549-990e-ee5cb3f9600b
Ancestors: Tools-mt.1133
Extends glyph browsing with a mode for browse-by-(Unicode)-category.
=============== Diff against Tools-mt.1133 ===============
Item was added:
+ ----- 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) and: [(self widthOf: char) > 0]]!
Item was added:
+ ----- Method: AbstractFont>>browseAllGlyphsScaledToDisplay (in category '*Tools-Browsing') -----
+ browseAllGlyphsScaledToDisplay
+ "Browse all glyphs from the receiver's fontFamily in the system's default #pointSize."
+
+ (self asPointSize: TextStyle defaultFont pointSize) browseAllGlyphs.
+
+ "(self textStyle fontOfPointSize: TextStyle defaultFont pointSize) browseAllGlyphs."!
Item was added:
+ ----- Method: AbstractFont>>browseAllSymbols (in category '*Tools-Browsing') -----
+ browseAllSymbols
+ "This is a variation of #browseAllGlyphs that is optimized to show all available glyphs in a single run, even though their code points may be scattered all over the Unicode range. See #browseAllSymbolsByCategory."
+
+ self isSymbolFont ifFalse: [self notify: 'This is not a symbol font: ', self familyName].
+
+ ^ self
+ browseGlyphsOf: ((self minCodePoint to: self maxCodePoint) select: [:ea | self hasGlyphForCode: ea])
+ label: 'All symbols in ', self familyName!
Item was added:
+ ----- Method: AbstractFont>>browseAllSymbolsByCategory (in category '*Tools-Browsing') -----
+ browseAllSymbolsByCategory
+
+ self isSymbolFont ifFalse: [self notify: 'This is not a symbol font: ', self familyName].
+ ^ self browseAllGlyphsByCategory!
Item was added:
+ ----- Method: AbstractFont>>browseGlyphsByCategoryOf: (in category '*Tools-Browsing') -----
+ browseGlyphsByCategoryOf: someCodePointsOrCharacters
+
+ self browseGlyphsByCategoryOf: someCodePointsOrCharacters label: nil.!
Item was added:
+ ----- Method: AbstractFont>>browseGlyphsByCategoryOf:label: (in category '*Tools-Browsing') -----
+ browseGlyphsByCategoryOf: someCodePointsOrCharacters label: label
+
+ self
+ browseGlyphsByCategoryOf: someCodePointsOrCharacters
+ select: [:char | true]
+ label: label!
Item was added:
+ ----- Method: AbstractFont>>browseGlyphsByCategoryOf:select: (in category '*Tools-Browsing') -----
+ browseGlyphsByCategoryOf: someCodePointsOrCharacters select: aBlock
+
+ self browseGlyphsByCategoryOf: someCodePointsOrCharacters select: aBlock label: nil.!
Item was added:
+ ----- 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 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 ttcDescription extraScale) ~= 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].
+ priorCategory := category]].
+
+ contents editWithLabel: (aLabelOrNil ifNil: [self printString]).!
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 |
- | contents isRange tmp |
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 ttcDescription extraScale) ~= 1]) ifFalse: [''] ifTrue: [' ', (tmp * 100) rounded asString, '%'] }) addAttribute: (TextFontReference toFont: TextStyle defaultFixedFont); yourself).
- 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. self pointSize. self pixelsPerInch. self height. isRange ifTrue: [''] ifFalse: [' (selected code points)']. (self isTTCFont and: [(tmp := self ttcDescription extraScale) > 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 asUnicode] ifFalse: [codePointOrChar].
char := Character value: current.
(valid := (aBlock value: char))
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, (('\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)].
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
|