[squeak-dev] The Trunk: Tools-mt.1141.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Mar 10 15:27:11 UTC 2022


Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1141.mcz

==================== Summary ====================

Name: Tools-mt.1141
Author: mt
Time: 10 March 2022, 4:27:09.051767 pm
UUID: e3ff94ed-ef02-2e48-a3c0-90884068593e
Ancestors: Tools-mt.1140

Revises glyph-browsing methods.

Adds new ones on ByteTextConverter and EncodedCharSet. The user can manually check whether the tables are correct.

Once you have installed a useful system font or fallback font, you can try this:

JISX0208 browseAllCodePoints.
MacRomanTextConverter browseAllCodePoints.
KOI8RTextConverter browseAllCodePoints.

I used MSGothic for my experiments:

TTCFont installFromFileNames: #('C:\Windows\Fonts\msgothic.ttc').
TextStyle setDefaultFallback: (TextStyle named: #MSGothic).
TextStyle installDefaultFallbackTextStyle.

=============== Diff against Tools-mt.1140 ===============

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] ]
+ 		thenSelect: [:ea | aBlock value: (Unicode value: 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 := Unicode value: codePoint.
- 			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>>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].
+ 			char := Unicode value: current.
- 			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] ].
  			(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]).!

Item was added:
+ ----- Method: ByteTextConverter class>>browseAllCodePoints (in category '*Tools-Browsing') -----
+ browseAllCodePoints
+ 	"
+ 	MacRomanTextConverter browseAllCodePoints.
+ 	Latin1TextConverter browseAllCodePoints.
+ 	CP1252TextConverter browseAllCodePoints.
+ 
+ 	MacLatin2TextConverter browseAllCodePoints.	
+ 	Latin2TextConverter browseAllCodePoints.
+ 
+ 	MacCyrillicTextConverter browseAllCodePoints.
+ 	
+ 	
+ 	"
+ 	self browseAllCodePointsUsing: TextStyle defaultFont.!

Item was added:
+ ----- Method: ByteTextConverter class>>browseAllCodePointsUsing: (in category '*Tools-Browsing') -----
+ browseAllCodePointsUsing: aFont
+ 	"Apply the receivers encoding (code points 0 to 255) to browse the result using glyphs of aFont (and its #fallbackFont)."
+ 
+ 	aFont
+ 		browseGlyphsOf: (Array streamContents: [:s | | |
+ 			self decodeTable withIndexDo: [:ea :i | | codePoint |
+ 				codePoint := ea = -1
+ 					ifTrue: [ea]
+ 					ifFalse: [ea bitAnd: 16r1FFFFF "Drop language info / leadingChar"].
+ 				codePoint := codePoint caseOf: { [-1] -> [32]. [9 "tab"] -> [32]. [10 "line break"] -> [32]. [13 "line break"] -> [32]. } otherwise: [codePoint].
+ 				(i-1 \\ 16 = 0 and: [s position > 0]) ifTrue: [s cr].
+ 				s tab; nextPut: codePoint]])
+ 		label: self name, ' decoding table'.!

Item was added:
+ ----- Method: EncodedCharSet class>>browseAllCodePoints (in category '*Tools-Browsing') -----
+ browseAllCodePoints
+ 	"
+ 	JISX0208 browseAllCodePoints.
+ 	GB2312 browseAllCodePoints.
+ 	KSX1001 browseAllCodePoints.
+ 	"
+ 		
+ 	self browseAllCodePointsUsing: TextStyle defaultFont.!

Item was added:
+ ----- Method: EncodedCharSet class>>browseAllCodePointsUsing: (in category '*Tools-Browsing') -----
+ browseAllCodePointsUsing: aFont
+ 	"Apply the receivers encoding to browse the result using glyphs of aFont (and its #fallbackFont).
+ 	
+ 	(Locale isoLanguage: 'ja') languageEnvironment installFont. --- Fetch StrikeFont from metatoys.org; see #fontDownloadUrls
+ 	JISX0208 browseAllCodePointsUsing: (TextConstants at: #FontJapaneseEnvironment) last. --- Largest point size
+ 	...
+ 	JISX0208 browseAllCodePointsUsing: (TTFontFileHandle fromFontFileName: 'C:\Windows\Fonts\msgothic.ttc') first font.
+ 	GB2312 browseAllCodePointsUsing: (TTFontFileHandle fromFontFileName: 'C:\Windows\Fonts\msyh.ttc') first font.
+ 	KSX1001 browseAllCodePointsUsing: (TTFontFileHandle fromFontFileName: 'C:\Windows\Fonts\batang.ttc') first font.
+ 	"
+ 
+ 	aFont
+ 		browseGlyphsOf: (Array streamContents: [:s | | last |
+ 			self ucsTable do: [:ea |
+ 				(ea = -1 and: [last ~= -1] and: [s position > 0])
+ 					ifTrue: [s cr; cr] ifFalse: [ea ~= -1 ifTrue: [s nextPut: ea]].
+ 				last := ea]])
+ 		label: self name, ' encoding'.!



More information about the Squeak-dev mailing list