The Trunk: Collections-mt.886.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-mt.886.mcz

commits-2
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.886.mcz

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

Name: Collections-mt.886
Author: mt
Time: 17 April 2020, 4:56:30.33186 pm
UUID: c7d64e56-0d06-e34f-8a61-8f5a7eb9277d
Ancestors: Collections-eem.885

To our HTML-to-Text converter, add support for <img> tags. Either download an image (or picture) from the Web or evaluate some code to retrieve either a Form or a Morph. As documented in #httpGetImage:, this complements the support of "code://" in TextURL.

=============== Diff against Collections-eem.885 ===============

Item was added:
+ ----- Method: HtmlReadWriter>>httpGetImage: (in category 'private') -----
+ httpGetImage: url
+ "To not add a direct dependency to WebClient, provide this hook for getting am image from an HTTP url. Maybe we can have this via an AppRegistry at some point. Maybe extend WebBrowser."
+
+ (url beginsWith: 'code://') ifTrue: [
+ "Same support for Smalltalk expressions as in TextURL >> #actOnClickFor:."
+ ^ ([Compiler evaluate: (url allButFirst: 7)] ifError: [nil])
+ ifNotNil: [:object | object isForm ifTrue: [object] ifFalse: [nil]]].
+
+ ^ (Smalltalk classNamed: 'WebClient') ifNotNil: [:client |
+ ([client httpGet: url] ifError: [nil]) ifNotNil: [:response |
+ response code = 200 ifFalse: [nil] ifTrue: [
+ [Form fromBinaryStream: response content asByteArray readStream]
+ ifError: [nil]]]]!

Item was added:
+ ----- Method: HtmlReadWriter>>mapImgTag: (in category 'mapping') -----
+ mapImgTag: aTag
+
+ | result startIndex stopIndex attribute src form |
+ result := OrderedCollection new.
+
+ "<img src=""https://squeak.org/img/downloads/image.png"">"
+ attribute := 'src'.
+ startIndex := aTag findString: attribute.
+ startIndex > 0 ifTrue: [
+ startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
+ startIndex > 0
+ ifTrue: [stopIndex := aTag findString: '"' startingAt: startIndex+1]
+ ifFalse: [
+ "URLs without quotes..."
+ startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
+ stopIndex := aTag findString: '>' startingAt: startIndex+1].
+ src := aTag copyFrom: startIndex+1 to: stopIndex-1.
+ form := (self httpGetImage: src) ifNil: [(Form dotOfSize: 12 color: Color veryLightGray)].
+ result
+ add: form asTextAnchor;
+ add: (TextColor color: Color transparent)].
+ ^ result!

Item was changed:
  ----- Method: HtmlReadWriter>>mapTagToAttribute: (in category 'mapping') -----
  mapTagToAttribute: aTag
 
  aTag = '<b>' ifTrue: [^ {TextEmphasis bold}].
  aTag = '<i>' ifTrue: [^ {TextEmphasis italic}].
  aTag = '<u>' ifTrue: [^ {TextEmphasis underlined}].
  aTag = '<s>' ifTrue: [^ {TextEmphasis struckOut}].
  aTag = '<code>' ifTrue: [^ self mapCodeTag].
  aTag = '<pre>' ifTrue: [self breakLines: false. ^ {}].
  (#('<div' '<span' '<center>' ) anySatisfy: [:ea | aTag beginsWith: ea])
  ifTrue: [^(self mapAlignmentTag: aTag) union: (self mapContainerTag: aTag)].
  (aTag beginsWith: '<font') ifTrue: [^ self mapFontTag: aTag].
  (aTag beginsWith: '<a') ifTrue: [^ self mapATag: aTag].
+ (aTag beginsWith: '<img') ifTrue: [^ self mapImgTag: aTag].
 
  "h1, h2, h3, ..."
  (aTag second = $h and: [aTag third isDigit])
  ifTrue: [^ {TextEmphasis bold}].
 
  ^ {}!

Item was changed:
  ----- Method: HtmlReadWriter>>processEmptyTag: (in category 'reading') -----
  processEmptyTag: aTag
 
  (aTag beginsWith: '<br') ifTrue: [
  self addCharacter: Character cr.
  ^ self].
 
+ (aTag beginsWith: '<img') ifTrue:[
+ ^ self processStartTag: aTag].
+
  (self isTagIgnored: aTag)
  ifTrue: [^ self].
 
  "TODO... what?"!

Item was added:
+ ----- Method: HtmlReadWriter>>processEndTagEagerly: (in category 'reading') -----
+ processEndTagEagerly: aTag
+ "Not all tags need an end tag. Simulate that here."
+
+ (aTag beginsWith: '<img')
+ ifTrue: [^ self processEndTag: '</img>'].!

Item was changed:
  ----- Method: HtmlReadWriter>>processStartTag: (in category 'reading') -----
  processStartTag: aTag
 
  | index |
  (self isTagIgnored: aTag) ifTrue: [^ self].
 
  index := count - offset.
 
  aTag = '<br>' ifTrue: [
  self addCharacter: Character cr.
  ^ self].
+
  (aTag beginsWith: '<img') ifTrue: [
+ self addString: Character startOfHeader asString.
+ offset := offset + 1.
+ index := index - 1].
- self addString: '[image]'.
- ^ self].
 
  self processRunStackTop. "To add all attributes before the next tag adds some."
 
  "Copy attr list and add new attr."
  runStack push: ({runStack top first copy addAll: (self mapTagToAttribute: aTag); yourself. index + 1 . index + 1}).
+
+ "For tags such as <img>, we should simulate the closing tag because there won't be any."
+ self processEndTagEagerly: aTag.!
- !


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

Jakob Reschke
Still strange that such things are in Collections.

Am Fr., 17. Apr. 2020 um 16:56 Uhr schrieb <[hidden email]>:

>
> Marcel Taeumel uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-mt.886.mcz
>
> ==================== Summary ====================
>
> Name: Collections-mt.886
> Author: mt
> Time: 17 April 2020, 4:56:30.33186 pm
> UUID: c7d64e56-0d06-e34f-8a61-8f5a7eb9277d
> Ancestors: Collections-eem.885
>
> To our HTML-to-Text converter, add support for <img> tags. Either download an image (or picture) from the Web or evaluate some code to retrieve either a Form or a Morph. As documented in #httpGetImage:, this complements the support of "code://" in TextURL.
>
> =============== Diff against Collections-eem.885 ===============
>
> Item was added:
> + ----- Method: HtmlReadWriter>>httpGetImage: (in category 'private') -----
> + httpGetImage: url
> +       "To not add a direct dependency to WebClient, provide this hook for getting am image from an HTTP url. Maybe we can have this via an AppRegistry at some point. Maybe extend WebBrowser."
> +
> +       (url beginsWith: 'code://') ifTrue: [
> +               "Same support for Smalltalk expressions as in TextURL >> #actOnClickFor:."
> +               ^ ([Compiler evaluate: (url allButFirst: 7)] ifError: [nil])
> +                       ifNotNil: [:object | object isForm ifTrue: [object] ifFalse: [nil]]].
> +
> +       ^ (Smalltalk classNamed: 'WebClient') ifNotNil: [:client |
> +               ([client httpGet: url] ifError: [nil]) ifNotNil: [:response |
> +                       response code = 200 ifFalse: [nil] ifTrue: [
> +                               [Form fromBinaryStream: response content asByteArray readStream]
> +                                       ifError: [nil]]]]!
>
> Item was added:
> + ----- Method: HtmlReadWriter>>mapImgTag: (in category 'mapping') -----
> + mapImgTag: aTag
> +
> +       | result startIndex stopIndex attribute src form |
> +       result := OrderedCollection new.
> +
> +       "<img src=""https://squeak.org/img/downloads/image.png"">"
> +       attribute := 'src'.
> +       startIndex := aTag findString: attribute.
> +       startIndex > 0 ifTrue: [
> +               startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
> +               startIndex > 0
> +                       ifTrue: [stopIndex := aTag findString: '"' startingAt: startIndex+1]
> +                       ifFalse: [
> +                               "URLs without quotes..."
> +                               startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
> +                               stopIndex := aTag findString: '>' startingAt: startIndex+1].
> +               src := aTag copyFrom: startIndex+1 to: stopIndex-1.
> +               form := (self httpGetImage: src) ifNil: [(Form dotOfSize: 12 color: Color veryLightGray)].
> +               result
> +                       add: form asTextAnchor;
> +                       add: (TextColor color: Color transparent)].
> +       ^ result!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>mapTagToAttribute: (in category 'mapping') -----
>   mapTagToAttribute: aTag
>
>         aTag = '<b>' ifTrue: [^ {TextEmphasis bold}].
>         aTag = '<i>' ifTrue: [^ {TextEmphasis italic}].
>         aTag = '<u>' ifTrue: [^ {TextEmphasis underlined}].
>         aTag = '<s>' ifTrue: [^ {TextEmphasis struckOut}].
>         aTag = '<code>' ifTrue: [^ self mapCodeTag].
>         aTag = '<pre>' ifTrue: [self breakLines: false. ^ {}].
>         (#('<div' '<span' '<center>' ) anySatisfy: [:ea | aTag beginsWith: ea])
>                 ifTrue: [^(self mapAlignmentTag: aTag) union: (self mapContainerTag: aTag)].
>         (aTag beginsWith: '<font') ifTrue: [^ self mapFontTag: aTag].
>         (aTag beginsWith: '<a') ifTrue: [^ self mapATag: aTag].
> +       (aTag beginsWith: '<img') ifTrue: [^ self mapImgTag: aTag].
>
>         "h1, h2, h3, ..."
>         (aTag second = $h and: [aTag third isDigit])
>                 ifTrue: [^ {TextEmphasis bold}].
>
>         ^ {}!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>processEmptyTag: (in category 'reading') -----
>   processEmptyTag: aTag
>
>         (aTag beginsWith: '<br') ifTrue: [
>                 self addCharacter: Character cr.
>                 ^ self].
>
> +       (aTag beginsWith: '<img') ifTrue:[
> +               ^ self processStartTag: aTag].
> +
>         (self isTagIgnored: aTag)
>                 ifTrue: [^ self].
>
>         "TODO... what?"!
>
> Item was added:
> + ----- Method: HtmlReadWriter>>processEndTagEagerly: (in category 'reading') -----
> + processEndTagEagerly: aTag
> +       "Not all tags need an end tag. Simulate that here."
> +
> +       (aTag beginsWith: '<img')
> +               ifTrue: [^ self processEndTag: '</img>'].!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>processStartTag: (in category 'reading') -----
>   processStartTag: aTag
>
>         | index |
>         (self isTagIgnored: aTag) ifTrue: [^ self].
>
>         index := count - offset.
>
>         aTag = '<br>' ifTrue: [
>                 self addCharacter: Character cr.
>                 ^ self].
> +
>         (aTag beginsWith: '<img') ifTrue: [
> +               self addString: Character startOfHeader asString.
> +               offset := offset + 1.
> +               index := index - 1].
> -               self addString: '[image]'.
> -               ^ self].
>
>         self processRunStackTop. "To add all attributes before the next tag adds some."
>
>         "Copy attr list and add new attr."
>         runStack push: ({runStack top first copy addAll: (self mapTagToAttribute: aTag); yourself. index + 1 . index + 1}).
> +
> +       "For tags such as <img>, we should simulate the closing tag because there won't be any."
> +       self processEndTagEagerly: aTag.!
> -       !
>
>


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

Christoph Thiede

Great idea!


Still strange that such things are in Collections.


Von: Squeak-dev <[hidden email]> im Auftrag von Jakob Reschke <[hidden email]>
Gesendet: Freitag, 17. April 2020 19:45:38
An: [hidden email]
Betreff: Re: [squeak-dev] The Trunk: Collections-mt.886.mcz
 
Still strange that such things are in Collections.

Am Fr., 17. Apr. 2020 um 16:56 Uhr schrieb <[hidden email]>:
>
> Marcel Taeumel uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-mt.886.mcz
>
> ==================== Summary ====================
>
> Name: Collections-mt.886
> Author: mt
> Time: 17 April 2020, 4:56:30.33186 pm
> UUID: c7d64e56-0d06-e34f-8a61-8f5a7eb9277d
> Ancestors: Collections-eem.885
>
> To our HTML-to-Text converter, add support for <img> tags. Either download an image (or picture) from the Web or evaluate some code to retrieve either a Form or a Morph. As documented in #httpGetImage:, this complements the support of "code://" in TextURL.
>
> =============== Diff against Collections-eem.885 ===============
>
> Item was added:
> + ----- Method: HtmlReadWriter>>httpGetImage: (in category 'private') -----
> + httpGetImage: url
> +       "To not add a direct dependency to WebClient, provide this hook for getting am image from an HTTP url. Maybe we can have this via an AppRegistry at some point. Maybe extend WebBrowser."
> +
> +       (url beginsWith: 'code://') ifTrue: [
> +               "Same support for Smalltalk expressions as in TextURL >> #actOnClickFor:."
> +               ^ ([Compiler evaluate: (url allButFirst: 7)] ifError: [nil])
> +                       ifNotNil: [:object | object isForm ifTrue: [object] ifFalse: [nil]]].
> +
> +       ^ (Smalltalk classNamed: 'WebClient') ifNotNil: [:client |
> +               ([client httpGet: url] ifError: [nil]) ifNotNil: [:response |
> +                       response code = 200 ifFalse: [nil] ifTrue: [
> +                               [Form fromBinaryStream: response content asByteArray readStream]
> +                                       ifError: [nil]]]]!
>
> Item was added:
> + ----- Method: HtmlReadWriter>>mapImgTag: (in category 'mapping') -----
> + mapImgTag: aTag
> +
> +       | result startIndex stopIndex attribute src form |
> +       result := OrderedCollection new.
> +
> +       "<img src=""https://squeak.org/img/downloads/image.png"">"
> +       attribute := 'src'.
> +       startIndex := aTag findString: attribute.
> +       startIndex > 0 ifTrue: [
> +               startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
> +               startIndex > 0
> +                       ifTrue: [stopIndex := aTag findString: '"' startingAt: startIndex+1]
> +                       ifFalse: [
> +                               "URLs without quotes..."
> +                               startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
> +                               stopIndex := aTag findString: '>' startingAt: startIndex+1].
> +               src := aTag copyFrom: startIndex+1 to: stopIndex-1.
> +               form := (self httpGetImage: src) ifNil: [(Form dotOfSize: 12 color: Color veryLightGray)].
> +               result
> +                       add: form asTextAnchor;
> +                       add: (TextColor color: Color transparent)].
> +       ^ result!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>mapTagToAttribute: (in category 'mapping') -----
>   mapTagToAttribute: aTag
>
>         aTag = '<b>' ifTrue: [^ {TextEmphasis bold}].
>         aTag = '<i>' ifTrue: [^ {TextEmphasis italic}].
>         aTag = '<u>' ifTrue: [^ {TextEmphasis underlined}].
>         aTag = '<s>' ifTrue: [^ {TextEmphasis struckOut}].
>         aTag = '<code>' ifTrue: [^ self mapCodeTag].
>         aTag = '<pre>' ifTrue: [self breakLines: false. ^ {}].
>         (#('<div' '<span' '<center>' ) anySatisfy: [:ea | aTag beginsWith: ea])
>                 ifTrue: [^(self mapAlignmentTag: aTag) union: (self mapContainerTag: aTag)].
>         (aTag beginsWith: '<font') ifTrue: [^ self mapFontTag: aTag].
>         (aTag beginsWith: '<a') ifTrue: [^ self mapATag: aTag].
> +       (aTag beginsWith: '<img') ifTrue: [^ self mapImgTag: aTag].
>
>         "h1, h2, h3, ..."
>         (aTag second = $h and: [aTag third isDigit])
>                 ifTrue: [^ {TextEmphasis bold}].
>
>         ^ {}!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>processEmptyTag: (in category 'reading') -----
>   processEmptyTag: aTag
>
>         (aTag beginsWith: '<br') ifTrue: [
>                 self addCharacter: Character cr.
>                 ^ self].
>
> +       (aTag beginsWith: '<img') ifTrue:[
> +               ^ self processStartTag: aTag].
> +
>         (self isTagIgnored: aTag)
>                 ifTrue: [^ self].
>
>         "TODO... what?"!
>
> Item was added:
> + ----- Method: HtmlReadWriter>>processEndTagEagerly: (in category 'reading') -----
> + processEndTagEagerly: aTag
> +       "Not all tags need an end tag. Simulate that here."
> +
> +       (aTag beginsWith: '<img')
> +               ifTrue: [^ self processEndTag: '</img>'].!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>processStartTag: (in category 'reading') -----
>   processStartTag: aTag
>
>         | index |
>         (self isTagIgnored: aTag) ifTrue: [^ self].
>
>         index := count - offset.
>
>         aTag = '<br>' ifTrue: [
>                 self addCharacter: Character cr.
>                 ^ self].
> +
>         (aTag beginsWith: '<img') ifTrue: [
> +               self addString: Character startOfHeader asString.
> +               offset := offset + 1.
> +               index := index - 1].
> -               self addString: '[image]'.
> -               ^ self].
>
>         self processRunStackTop. "To add all attributes before the next tag adds some."
>
>         "Copy attr list and add new attr."
>         runStack push: ({runStack top first copy addAll: (self mapTagToAttribute: aTag); yourself. index + 1 . index + 1}).
> +
> +       "For tags such as <img>, we should simulate the closing tag because there won't be any."
> +       self processEndTagEagerly: aTag.!
> -       !
>
>




Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

marcel.taeumel
Still strange that such things are in Collections.

There has been a discussion on this list about CollectionsExtras. Maybe we should follow up on that.

Best,
Marcel

Am 18.04.2020 15:29:14 schrieb Thiede, Christoph <[hidden email]>:

Great idea!


Still strange that such things are in Collections.


Von: Squeak-dev <[hidden email]> im Auftrag von Jakob Reschke <[hidden email]>
Gesendet: Freitag, 17. April 2020 19:45:38
An: [hidden email]
Betreff: Re: [squeak-dev] The Trunk: Collections-mt.886.mcz
 
Still strange that such things are in Collections.

Am Fr., 17. Apr. 2020 um 16:56 Uhr schrieb <[hidden email]>:
>
> Marcel Taeumel uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-mt.886.mcz
>
> ==================== Summary ====================
>
> Name: Collections-mt.886
> Author: mt
> Time: 17 April 2020, 4:56:30.33186 pm
> UUID: c7d64e56-0d06-e34f-8a61-8f5a7eb9277d
> Ancestors: Collections-eem.885
>
> To our HTML-to-Text converter, add support for <img> tags. Either download an image (or picture) from the Web or evaluate some code to retrieve either a Form or a Morph. As documented in #httpGetImage:, this complements the support of "code://" in TextURL.
>
> =============== Diff against Collections-eem.885 ===============
>
> Item was added:
> + ----- Method: HtmlReadWriter>>httpGetImage: (in category 'private') -----
> + httpGetImage: url
> +       "To not add a direct dependency to WebClient, provide this hook for getting am image from an HTTP url. Maybe we can have this via an AppRegistry at some point. Maybe extend WebBrowser."
> +
> +       (url beginsWith: 'code://') ifTrue: [
> +               "Same support for Smalltalk expressions as in TextURL >> #actOnClickFor:."
> +               ^ ([Compiler evaluate: (url allButFirst: 7)] ifError: [nil])
> +                       ifNotNil: [:object | object isForm ifTrue: [object] ifFalse: [nil]]].
> +
> +       ^ (Smalltalk classNamed: 'WebClient') ifNotNil: [:client |
> +               ([client httpGet: url] ifError: [nil]) ifNotNil: [:response |
> +                       response code = 200 ifFalse: [nil] ifTrue: [
> +                               [Form fromBinaryStream: response content asByteArray readStream]
> +                                       ifError: [nil]]]]!
>
> Item was added:
> + ----- Method: HtmlReadWriter>>mapImgTag: (in category 'mapping') -----
> + mapImgTag: aTag
> +
> +       | result startIndex stopIndex attribute src form |
> +       result := OrderedCollection new.
> +
> +       "<img src=""https://squeak.org/img/downloads/image.png"">"
> +       attribute := 'src'.
> +       startIndex := aTag findString: attribute.
> +       startIndex > 0 ifTrue: [
> +               startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
> +               startIndex > 0
> +                       ifTrue: [stopIndex := aTag findString: '"' startingAt: startIndex+1]
> +                       ifFalse: [
> +                               "URLs without quotes..."
> +                               startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
> +                               stopIndex := aTag findString: '>' startingAt: startIndex+1].
> +               src := aTag copyFrom: startIndex+1 to: stopIndex-1.
> +               form := (self httpGetImage: src) ifNil: [(Form dotOfSize: 12 color: Color veryLightGray)].
> +               result
> +                       add: form asTextAnchor;
> +                       add: (TextColor color: Color transparent)].
> +       ^ result!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>mapTagToAttribute: (in category 'mapping') -----
>   mapTagToAttribute: aTag
>
>         aTag = '<b>' ifTrue: [^ {TextEmphasis bold}].
>         aTag = '<i>' ifTrue: [^ {TextEmphasis italic}].
>         aTag = '<u>' ifTrue: [^ {TextEmphasis underlined}].
>         aTag = '<s>' ifTrue: [^ {TextEmphasis struckOut}].
>         aTag = '<code>' ifTrue: [^ self mapCodeTag].
>         aTag = '<pre>' ifTrue: [self breakLines: false. ^ {}].
>         (#('<div' '<span' '<center>' ) anySatisfy: [:ea | aTag beginsWith: ea])
>                 ifTrue: [^(self mapAlignmentTag: aTag) union: (self mapContainerTag: aTag)].
>         (aTag beginsWith: '<font') ifTrue: [^ self mapFontTag: aTag].
>         (aTag beginsWith: '<a') ifTrue: [^ self mapATag: aTag].
> +       (aTag beginsWith: '<img') ifTrue: [^ self mapImgTag: aTag].
>
>         "h1, h2, h3, ..."
>         (aTag second = $h and: [aTag third isDigit])
>                 ifTrue: [^ {TextEmphasis bold}].
>
>         ^ {}!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>processEmptyTag: (in category 'reading') -----
>   processEmptyTag: aTag
>
>         (aTag beginsWith: '<br') ifTrue: [
>                 self addCharacter: Character cr.
>                 ^ self].
>
> +       (aTag beginsWith: '<img') ifTrue:[
> +               ^ self processStartTag: aTag].
> +
>         (self isTagIgnored: aTag)
>                 ifTrue: [^ self].
>
>         "TODO... what?"!
>
> Item was added:
> + ----- Method: HtmlReadWriter>>processEndTagEagerly: (in category 'reading') -----
> + processEndTagEagerly: aTag
> +       "Not all tags need an end tag. Simulate that here."
> +
> +       (aTag beginsWith: '<img')
> +               ifTrue: [^ self processEndTag: '</img>'].!
>
> Item was changed:
>   ----- Method: HtmlReadWriter>>processStartTag: (in category 'reading') -----
>   processStartTag: aTag
>
>         | index |
>         (self isTagIgnored: aTag) ifTrue: [^ self].
>
>         index := count - offset.
>
>         aTag = '<br>' ifTrue: [
>                 self addCharacter: Character cr.
>                 ^ self].
> +
>         (aTag beginsWith: '<img') ifTrue: [
> +               self addString: Character startOfHeader asString.
> +               offset := offset + 1.
> +               index := index - 1].
> -               self addString: '[image]'.
> -               ^ self].
>
>         self processRunStackTop. "To add all attributes before the next tag adds some."
>
>         "Copy attr list and add new attr."
>         runStack push: ({runStack top first copy addAll: (self mapTagToAttribute: aTag); yourself. index + 1 . index + 1}).
> +
> +       "For tags such as <img>, we should simulate the closing tag because there won't be any."
> +       self processEndTagEagerly: aTag.!
> -       !
>
>




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

Levente Uzonyi
On Mon, 20 Apr 2020, Marcel Taeumel wrote:

> > Still strange that such things are in Collections.
>
> There has been a discussion on this list about CollectionsExtras. Maybe we should follow up on that.

An HTML to text converter wouldn't fit into CollectionsExtras either. It
has nothing to do with collections.


Levente

>
> Best,
> Marcel
>
>       Am 18.04.2020 15:29:14 schrieb Thiede, Christoph <[hidden email]>:
>
>       Great idea!
>
>
> > Still strange that such things are in Collections.
>
> __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> Von: Squeak-dev <[hidden email]> im Auftrag von Jakob Reschke <[hidden email]>
> Gesendet: Freitag, 17. April 2020 19:45:38
> An: [hidden email]
> Betreff: Re: [squeak-dev] The Trunk: Collections-mt.886.mcz  
> Still strange that such things are in Collections.
>
> Am Fr., 17. Apr. 2020 um 16:56 Uhr schrieb <[hidden email]>:
> >
> > Marcel Taeumel uploaded a new version of Collections to project The Trunk:
> > http://source.squeak.org/trunk/Collections-mt.886.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Collections-mt.886
> > Author: mt
> > Time: 17 April 2020, 4:56:30.33186 pm
> > UUID: c7d64e56-0d06-e34f-8a61-8f5a7eb9277d
> > Ancestors: Collections-eem.885
> >
> > To our HTML-to-Text converter, add support for <img> tags. Either download an image (or picture) from the Web or evaluate some code to retrieve either a Form or a Morph. As documented in #httpGetImage:, this complements the support of "code://" in TextURL.
> >
> > =============== Diff against Collections-eem.885 ===============
> >
> > Item was added:
> > + ----- Method: HtmlReadWriter>>httpGetImage: (in category 'private') -----
> > + httpGetImage: url
> > +       "To not add a direct dependency to WebClient, provide this hook for getting am image from an HTTP url. Maybe we can have this via an AppRegistry at some point. Maybe extend WebBrowser."
> > +
> > +       (url beginsWith: 'code://') ifTrue: [
> > +               "Same support for Smalltalk expressions as in TextURL >> #actOnClickFor:."
> > +               ^ ([Compiler evaluate: (url allButFirst: 7)] ifError: [nil])
> > +                       ifNotNil: [:object | object isForm ifTrue: [object] ifFalse: [nil]]].
> > +
> > +       ^ (Smalltalk classNamed: 'WebClient') ifNotNil: [:client |
> > +               ([client httpGet: url] ifError: [nil]) ifNotNil: [:response |
> > +                       response code = 200 ifFalse: [nil] ifTrue: [
> > +                               [Form fromBinaryStream: response content asByteArray readStream]
> > +                                       ifError: [nil]]]]!
> >
> > Item was added:
> > + ----- Method: HtmlReadWriter>>mapImgTag: (in category 'mapping') -----
> > + mapImgTag: aTag
> > +
> > +       | result startIndex stopIndex attribute src form |
> > +       result := OrderedCollection new.
> > +
> > +       "<img src=""https://squeak.org/img/downloads/image.png"">"
> > +       attribute := 'src'.
> > +       startIndex := aTag findString: attribute.
> > +       startIndex > 0 ifTrue: [
> > +               startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
> > +               startIndex > 0
> > +                       ifTrue: [stopIndex := aTag findString: '"' startingAt: startIndex+1]
> > +                       ifFalse: [
> > +                               "URLs without quotes..."
> > +                               startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
> > +                               stopIndex := aTag findString: '>' startingAt: startIndex+1].
> > +               src := aTag copyFrom: startIndex+1 to: stopIndex-1.
> > +               form := (self httpGetImage: src) ifNil: [(Form dotOfSize: 12 color: Color veryLightGray)].
> > +               result
> > +                       add: form asTextAnchor;
> > +                       add: (TextColor color: Color transparent)].
> > +       ^ result!
> >
> > Item was changed:
> >   ----- Method: HtmlReadWriter>>mapTagToAttribute: (in category 'mapping') -----
> >   mapTagToAttribute: aTag
> >
> >         aTag = '<b>' ifTrue: [^ {TextEmphasis bold}].
> >         aTag = '<i>' ifTrue: [^ {TextEmphasis italic}].
> >         aTag = '<u>' ifTrue: [^ {TextEmphasis underlined}].
> >         aTag = '<s>' ifTrue: [^ {TextEmphasis struckOut}].
> >         aTag = '<code>' ifTrue: [^ self mapCodeTag].
> >         aTag = '<pre>' ifTrue: [self breakLines: false. ^ {}].
> >         (#('<div' '<span' '<center>' ) anySatisfy: [:ea | aTag beginsWith: ea])
> >                 ifTrue: [^(self mapAlignmentTag: aTag) union: (self mapContainerTag: aTag)].
> >         (aTag beginsWith: '<font') ifTrue: [^ self mapFontTag: aTag].
> >         (aTag beginsWith: '<a') ifTrue: [^ self mapATag: aTag].
> > +       (aTag beginsWith: '<img') ifTrue: [^ self mapImgTag: aTag].
> >
> >         "h1, h2, h3, ..."
> >         (aTag second = $h and: [aTag third isDigit])
> >                 ifTrue: [^ {TextEmphasis bold}].
> >
> >         ^ {}!
> >
> > Item was changed:
> >   ----- Method: HtmlReadWriter>>processEmptyTag: (in category 'reading') -----
> >   processEmptyTag: aTag
> >
> >         (aTag beginsWith: '<br') ifTrue: [
> >                 self addCharacter: Character cr.
> >                 ^ self].
> >
> > +       (aTag beginsWith: '<img') ifTrue:[
> > +               ^ self processStartTag: aTag].
> > +
> >         (self isTagIgnored: aTag)
> >                 ifTrue: [^ self].
> >
> >         "TODO... what?"!
> >
> > Item was added:
> > + ----- Method: HtmlReadWriter>>processEndTagEagerly: (in category 'reading') -----
> > + processEndTagEagerly: aTag
> > +       "Not all tags need an end tag. Simulate that here."
> > +
> > +       (aTag beginsWith: '<img')
> > +               ifTrue: [^ self processEndTag: '</img>'].!
> >
> > Item was changed:
> >   ----- Method: HtmlReadWriter>>processStartTag: (in category 'reading') -----
> >   processStartTag: aTag
> >
> >         | index |
> >         (self isTagIgnored: aTag) ifTrue: [^ self].
> >
> >         index := count - offset.
> >
> >         aTag = '<br>' ifTrue: [
> >                 self addCharacter: Character cr.
> >                 ^ self].
> > +
> >         (aTag beginsWith: '<img') ifTrue: [
> > +               self addString: Character startOfHeader asString.
> > +               offset := offset + 1.
> > +               index := index - 1].
> > -               self addString: '[image]'.
> > -               ^ self].
> >
> >         self processRunStackTop. "To add all attributes before the next tag adds some."
> >
> >         "Copy attr list and add new attr."
> >         runStack push: ({runStack top first copy addAll: (self mapTagToAttribute: aTag); yourself. index + 1 . index + 1}).
> > +
> > +       "For tags such as <img>, we should simulate the closing tag because there won't be any."
> > +       self processEndTagEagerly: aTag.!
> > -       !
> >
> >
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

marcel.taeumel
It has nothing to do with collections.

Why not? The target format, Text, is a Collection.

Best,
Marcel

Am 20.04.2020 13:52:10 schrieb Levente Uzonyi <[hidden email]>:

On Mon, 20 Apr 2020, Marcel Taeumel wrote:

> > Still strange that such things are in Collections.
>
> There has been a discussion on this list about CollectionsExtras. Maybe we should follow up on that.

An HTML to text converter wouldn't fit into CollectionsExtras either. It
has nothing to do with collections.


Levente

>
> Best,
> Marcel
>
> Am 18.04.2020 15:29:14 schrieb Thiede, Christoph :
>
> Great idea!
>
>
> > Still strange that such things are in Collections.
>
> __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> Von: Squeak-dev im Auftrag von Jakob Reschke
> Gesendet: Freitag, 17. April 2020 19:45:38
> An: [hidden email]
> Betreff: Re: [squeak-dev] The Trunk: Collections-mt.886.mcz  
> Still strange that such things are in Collections.
>
> Am Fr., 17. Apr. 2020 um 16:56 Uhr schrieb :
> >
> > Marcel Taeumel uploaded a new version of Collections to project The Trunk:
> > http://source.squeak.org/trunk/Collections-mt.886.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Collections-mt.886
> > Author: mt
> > Time: 17 April 2020, 4:56:30.33186 pm
> > UUID: c7d64e56-0d06-e34f-8a61-8f5a7eb9277d
> > Ancestors: Collections-eem.885
> >
> > To our HTML-to-Text converter, add support for tags. Either download an image (or picture) from the Web or evaluate some code to retrieve either a Form or a Morph. As documented in #httpGetImage:, this complements the support of "code://" in TextURL.
> >
> > =============== Diff against Collections-eem.885 ===============
> >
> > Item was added:
> > + ----- Method: HtmlReadWriter>>httpGetImage: (in category 'private') -----
> > + httpGetImage: url
> > +       "To not add a direct dependency to WebClient, provide this hook for getting am image from an HTTP url. Maybe we can have this via an AppRegistry at some point. Maybe extend WebBrowser."
> > +
> > +       (url beginsWith: 'code://') ifTrue: [
> > +               "Same support for Smalltalk expressions as in TextURL >> #actOnClickFor:."
> > +               ^ ([Compiler evaluate: (url allButFirst: 7)] ifError: [nil])
> > +                       ifNotNil: [:object | object isForm ifTrue: [object] ifFalse: [nil]]].
> > +
> > +       ^ (Smalltalk classNamed: 'WebClient') ifNotNil: [:client |
> > +               ([client httpGet: url] ifError: [nil]) ifNotNil: [:response |
> > +                       response code = 200 ifFalse: [nil] ifTrue: [
> > +                               [Form fromBinaryStream: response content asByteArray readStream]
> > +                                       ifError: [nil]]]]!
> >
> > Item was added:
> > + ----- Method: HtmlReadWriter>>mapImgTag: (in category 'mapping') -----
> > + mapImgTag: aTag
> > +
> > +       | result startIndex stopIndex attribute src form |
> > +       result := OrderedCollection new.
> > +
> > +       ""
> > +       attribute := 'src'.
> > +       startIndex := aTag findString: attribute.
> > +       startIndex > 0 ifTrue: [
> > +               startIndex := aTag findString: '"' startingAt: startIndex+attribute size.
> > +               startIndex > 0
> > +                       ifTrue: [stopIndex := aTag findString: '"' startingAt: startIndex+1]
> > +                       ifFalse: [
> > +                               "URLs without quotes..."
> > +                               startIndex := aTag findString: '=' startingAt: startIndex+attribute size.
> > +                               stopIndex := aTag findString: '>' startingAt: startIndex+1].
> > +               src := aTag copyFrom: startIndex+1 to: stopIndex-1.
> > +               form := (self httpGetImage: src) ifNil: [(Form dotOfSize: 12 color: Color veryLightGray)].
> > +               result
> > +                       add: form asTextAnchor;
> > +                       add: (TextColor color: Color transparent)].
> > +       ^ result!
> >
> > Item was changed:
> >   ----- Method: HtmlReadWriter>>mapTagToAttribute: (in category 'mapping') -----
> >   mapTagToAttribute: aTag
> >
> >         aTag = '' ifTrue: [^ {TextEmphasis bold}].
> >         aTag = '' ifTrue: [^ {TextEmphasis italic}].
> >         aTag = '' ifTrue: [^ {TextEmphasis underlined}].
> >         aTag = '' ifTrue: [^ {TextEmphasis struckOut}].
> >         aTag = '' ifTrue: [^ self mapCodeTag].
> >         aTag = '
' ifTrue: [self breakLines: false. ^ {}].

> >         (#('
' ) anySatisfy: [:ea | aTag beginsWith: ea])
> >                 ifTrue: [^(self mapAlignmentTag: aTag) union: (self mapContainerTag: aTag)].
> >         (aTag beginsWith: '
> >         (aTag beginsWith: '
> > +       (aTag beginsWith: '
> >
> >         "h1, h2, h3, ..."
> >         (aTag second = $h and: [aTag third isDigit])
> >                 ifTrue: [^ {TextEmphasis bold}].
> >
> >         ^ {}!
> >
> > Item was changed:
> >   ----- Method: HtmlReadWriter>>processEmptyTag: (in category 'reading') -----
> >   processEmptyTag: aTag
> >
> >         (aTag beginsWith: '
> >                 self addCharacter: Character cr.
> >                 ^ self].
> >
> > +       (aTag beginsWith: '
> > +               ^ self processStartTag: aTag].
> > +
> >         (self isTagIgnored: aTag)
> >                 ifTrue: [^ self].
> >
> >         "TODO... what?"!
> >
> > Item was added:
> > + ----- Method: HtmlReadWriter>>processEndTagEagerly: (in category 'reading') -----
> > + processEndTagEagerly: aTag
> > +       "Not all tags need an end tag. Simulate that here."
> > +
> > +       (aTag beginsWith: '
> > +               ifTrue: [^ self processEndTag: ''].!
> >
> > Item was changed:
> >   ----- Method: HtmlReadWriter>>processStartTag: (in category 'reading') -----
> >   processStartTag: aTag
> >
> >         | index |
> >         (self isTagIgnored: aTag) ifTrue: [^ self].
> >
> >         index := count - offset.
> >
> >         aTag = '
' ifTrue: [
> >                 self addCharacter: Character cr.
> >                 ^ self].
> > +
> >         (aTag beginsWith: '
> > +               self addString: Character startOfHeader asString.
> > +               offset := offset + 1.
> > +               index := index - 1].
> > -               self addString: '[image]'.
> > -               ^ self].
> >
> >         self processRunStackTop. "To add all attributes before the next tag adds some."
> >
> >         "Copy attr list and add new attr."
> >         runStack push: ({runStack top first copy addAll: (self mapTagToAttribute: aTag); yourself. index + 1 . index + 1}).
> > +
> > +       "For tags such as , we should simulate the closing tag because there won't be any."
> > +       self processEndTagEagerly: aTag.!
> > -       !
> >
> >
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

timrowledge


> On 2020-04-20, at 5:03 AM, Marcel Taeumel <[hidden email]> wrote:
>
> > It has nothing to do with collections.
>
> Why not? The target format, Text, is a Collection.

But the source format is HTML which I imagine is in some web nominative category. I think I'd probably see it as part of a web-thing for most purposes, though it's clearly an extra to the basics of fetching etc.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Fractured Idiom:- QUIP PRO QUO - A fast retort



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

Jakob Reschke
In reply to this post by marcel.taeumel
Am Mo., 20. Apr. 2020 um 14:04 Uhr schrieb Marcel Taeumel <[hidden email]>:
It has nothing to do with collections.

Why not? The target format, Text, is a Collection.


By today's nomenclature, yes. But I'd even say that a Text is more than a general-purpose Collection and could well belong in its own package. That can also contain HTML or Markdown stuff if desired.


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

marcel.taeumel
Hmm... Text might as well be moved to the Graphics package....

Am 20.04.2020 20:03:52 schrieb Jakob Reschke <[hidden email]>:

Am Mo., 20. Apr. 2020 um 14:04 Uhr schrieb Marcel Taeumel <[hidden email]>:
It has nothing to do with collections.

Why not? The target format, Text, is a Collection.


By today's nomenclature, yes. But I'd even say that a Text is more than a general-purpose Collection and could well belong in its own package. That can also contain HTML or Markdown stuff if desired.


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

Tobias Pape

> On 21.04.2020, at 16:59, Marcel Taeumel <[hidden email]> wrote:
>
> Hmm... Text might as well be moved to the Graphics package....


.. why? o_O

>> Am 20.04.2020 20:03:52 schrieb Jakob Reschke <[hidden email]>:
>>
>> Am Mo., 20. Apr. 2020 um 14:04 Uhr schrieb Marcel Taeumel <[hidden email]>:
>> > It has nothing to do with collections.
>>
>> Why not? The target format, Text, is a Collection.
>>
>>
>> By today's nomenclature, yes. But I'd even say that a Text is more than a general-purpose Collection and could well belong in its own package. That can also contain HTML or Markdown stuff if desired.
>



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

marcel.taeumel
> .. why? o_O

Because Text is the visual companion for String. With Text, you can add various attributes to shape the visual appearance of String such as through emphasis, color, and other font-related things. Fonts are already in the Graphics package. TextStyle, too. A version of NewParagraph that would be independent from Morphic would fit into the Graphics package, too.

So many reasons. :-)

Best,
Marcel

Am 21.04.2020 20:39:38 schrieb Tobias Pape <[hidden email]>:


> On 21.04.2020, at 16:59, Marcel Taeumel wrote:
>
> Hmm... Text might as well be moved to the Graphics package....


.. why? o_O

>> Am 20.04.2020 20:03:52 schrieb Jakob Reschke :
>>
>> Am Mo., 20. Apr. 2020 um 14:04 Uhr schrieb Marcel Taeumel :
>> > It has nothing to do with collections.
>>
>> Why not? The target format, Text, is a Collection.
>>
>>
>> By today's nomenclature, yes. But I'd even say that a Text is more than a general-purpose Collection and could well belong in its own package. That can also contain HTML or Markdown stuff if desired.
>





Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

Tobias Pape

> On 22.04.2020, at 09:19, Marcel Taeumel <[hidden email]> wrote:
>
> > .. why? o_O
>
> Because Text is the visual companion for String. With Text, you can add various attributes to shape the visual appearance of String such as through emphasis, color, and other font-related things. Fonts are already in the Graphics package. TextStyle, too. A version of NewParagraph that would be independent from Morphic would fit into the Graphics package, too.
>
> So many reasons. :-)

I'd rather have its own package. I don't think about most of text in the domain of graphics ;D

-t

>
> Best,
> Marcel
>> Am 21.04.2020 20:39:38 schrieb Tobias Pape <[hidden email]>:
>>
>>
>> > On 21.04.2020, at 16:59, Marcel Taeumel wrote:
>> >
>> > Hmm... Text might as well be moved to the Graphics package....
>>
>>
>> .. why? o_O
>> >> Am 20.04.2020 20:03:52 schrieb Jakob Reschke :
>> >>
>> >> Am Mo., 20. Apr. 2020 um 14:04 Uhr schrieb Marcel Taeumel :
>> >> > It has nothing to do with collections.
>> >>
>> >> Why not? The target format, Text, is a Collection.
>> >>
>> >>
>> >> By today's nomenclature, yes. But I'd even say that a Text is more than a general-purpose Collection and could well belong in its own package. That can also contain HTML or Markdown stuff if desired.
>> >
>>
>>
>>
>



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

marcel.taeumel
I'd rather have its own package. I don't think about most of text in the domain of graphics ;D

In such a package, Fonts, TextStyle, Paragraph, etc. would be, too. ;-)

Best,
Marcel

Am 22.04.2020 09:41:25 schrieb Tobias Pape <[hidden email]>:


> On 22.04.2020, at 09:19, Marcel Taeumel wrote:
>
> > .. why? o_O
>
> Because Text is the visual companion for String. With Text, you can add various attributes to shape the visual appearance of String such as through emphasis, color, and other font-related things. Fonts are already in the Graphics package. TextStyle, too. A version of NewParagraph that would be independent from Morphic would fit into the Graphics package, too.
>
> So many reasons. :-)

I'd rather have its own package. I don't think about most of text in the domain of graphics ;D

-t

>
> Best,
> Marcel
>> Am 21.04.2020 20:39:38 schrieb Tobias Pape :
>>
>>
>> > On 21.04.2020, at 16:59, Marcel Taeumel wrote:
>> >
>> > Hmm... Text might as well be moved to the Graphics package....
>>
>>
>> .. why? o_O
>> >> Am 20.04.2020 20:03:52 schrieb Jakob Reschke :
>> >>
>> >> Am Mo., 20. Apr. 2020 um 14:04 Uhr schrieb Marcel Taeumel :
>> >> > It has nothing to do with collections.
>> >>
>> >> Why not? The target format, Text, is a Collection.
>> >>
>> >>
>> >> By today's nomenclature, yes. But I'd even say that a Text is more than a general-purpose Collection and could well belong in its own package. That can also contain HTML or Markdown stuff if desired.
>> >
>>
>>
>>
>





Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

K K Subbu
On 22/04/20 1:17 PM, Marcel Taeumel wrote:
>  > I'd rather have its own package. I don't think about most of text in
> the domain of graphics ;D
>
> In such a package, Fonts, TextStyle, Paragraph, etc. would be, too. ;-)

In theory, Text (string decorations) comes under graphics. In practice,
there is difference between fine text used in spans like paragraphs and
gross text used in shapes like Text Art.

Fine text needs careful handling beyond simple graphic transformations.
Word wrapping are not just graphical ops. They need to account for
language-dependent direction, hyphenation and ligatures. Fonts are not
just an array of vector shapes but have rendering hints and tweaks for
various resolutions. So fine text needs its own package.

Larger text (like Text Art) does come under graphics and can behave like
any other graphic shapes. Text Art could be part of graphics.

Regards .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

Nicolas Cellier
Text is an abstract layer, independent of rendering.
It's not the graphic object per se, just some specification (= string + tags).
We can render the same Text with different style options (line wrap or not, default font, tab spacing, paragraph indentation, interline, etc...).
Text rendering requires composition which currently occur in the Graphics package (CharacterScanner & al).

CompositionScanner and DIsplayScanner are higher level than what we generally expect in graphics.
They use what we might consider much lower level graphics primitives like measuring and rendering individual characters or short strings with a specific font...

Le mer. 22 avr. 2020 à 17:51, K K Subbu <[hidden email]> a écrit :
On 22/04/20 1:17 PM, Marcel Taeumel wrote:
>  > I'd rather have its own package. I don't think about most of text in
> the domain of graphics ;D
>
> In such a package, Fonts, TextStyle, Paragraph, etc. would be, too. ;-)

In theory, Text (string decorations) comes under graphics. In practice,
there is difference between fine text used in spans like paragraphs and
gross text used in shapes like Text Art.

Fine text needs careful handling beyond simple graphic transformations.
Word wrapping are not just graphical ops. They need to account for
language-dependent direction, hyphenation and ligatures. Fonts are not
just an array of vector shapes but have rendering hints and tweaks for
various resolutions. So fine text needs its own package.

Larger text (like Text Art) does come under graphics and can behave like
any other graphic shapes. Text Art could be part of graphics.

Regards .. Subbu



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

marcel.taeumel
This is exciting. :-) I agree with the both of you, Subbu and Nicolas. Even if not in Graphics, Text does not belong in the Collections package.

Best,
Marcel

Am 22.04.2020 19:09:56 schrieb Nicolas Cellier <[hidden email]>:

Text is an abstract layer, independent of rendering.
It's not the graphic object per se, just some specification (= string + tags).
We can render the same Text with different style options (line wrap or not, default font, tab spacing, paragraph indentation, interline, etc...).
Text rendering requires composition which currently occur in the Graphics package (CharacterScanner & al).

CompositionScanner and DIsplayScanner are higher level than what we generally expect in graphics.
They use what we might consider much lower level graphics primitives like measuring and rendering individual characters or short strings with a specific font...

Le mer. 22 avr. 2020 à 17:51, K K Subbu <[hidden email]> a écrit :
On 22/04/20 1:17 PM, Marcel Taeumel wrote:
>  > I'd rather have its own package. I don't think about most of text in
> the domain of graphics ;D
>
> In such a package, Fonts, TextStyle, Paragraph, etc. would be, too. ;-)

In theory, Text (string decorations) comes under graphics. In practice,
there is difference between fine text used in spans like paragraphs and
gross text used in shapes like Text Art.

Fine text needs careful handling beyond simple graphic transformations.
Word wrapping are not just graphical ops. They need to account for
language-dependent direction, hyphenation and ligatures. Fonts are not
just an array of vector shapes but have rendering hints and tweaks for
various resolutions. So fine text needs its own package.

Larger text (like Text Art) does come under graphics and can behave like
any other graphic shapes. Text Art could be part of graphics.

Regards .. Subbu



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-mt.886.mcz

Tobias Pape
In reply to this post by Nicolas Cellier

> On 22.04.2020, at 19:08, Nicolas Cellier <[hidden email]> wrote:
>
> Text is an abstract layer, independent of rendering.
> It's not the graphic object per se, just some specification (= string + tags).
> We can render the same Text with different style options (line wrap or not, default font, tab spacing, paragraph indentation, interline, etc...).
> Text rendering requires composition which currently occur in the Graphics package (CharacterScanner & al).
>
> CompositionScanner and DIsplayScanner are higher level than what we generally expect in graphics.
> They use what we might consider much lower level graphics primitives like measuring and rendering individual characters or short strings with a specific font...

+1

-t

>
> Le mer. 22 avr. 2020 à 17:51, K K Subbu <[hidden email]> a écrit :
> On 22/04/20 1:17 PM, Marcel Taeumel wrote:
> >  > I'd rather have its own package. I don't think about most of text in
> > the domain of graphics ;D
> >
> > In such a package, Fonts, TextStyle, Paragraph, etc. would be, too. ;-)
>
> In theory, Text (string decorations) comes under graphics. In practice,
> there is difference between fine text used in spans like paragraphs and
> gross text used in shapes like Text Art.
>
> Fine text needs careful handling beyond simple graphic transformations.
> Word wrapping are not just graphical ops. They need to account for
> language-dependent direction, hyphenation and ligatures. Fonts are not
> just an array of vector shapes but have rendering hints and tweaks for
> various resolutions. So fine text needs its own package.
>
> Larger text (like Text Art) does come under graphics and can behave like
> any other graphic shapes. Text Art could be part of graphics.
>
> Regards .. Subbu
>
>