What would be the proper (i.e. respecting the design) way to make text bold? The current attributes seem to be special cases which are hard-coded e.g. font and foreground color are accessed explicitly during drawing... ----- Cheers, Sean -- View this message in context: http://forum.world.st/Tx-Bold-Text-tp4822964.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Am 29.04.2015 5:30 nachm. schrieb "Sean P. DeNigris" <sean@clipperadams.com
:
What would be the proper (i.e. respecting the design) way to make text bold?
Assign the proper Attribute?
The current attributes seem to be special cases which are hard-coded e.g. font and foreground color are accessed explicitly during drawing...
Arent these attributes applied to the spans during scanning?
----- Cheers, Sean -- View this message in context:
http://forum.world.st/Tx-Bold-Text-tp4822964.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Nicolai Hess wrote
Assign the proper Attribute?
Well AFAICT there is no bold attribute, but I tried setting the font to bold via "(LogicalFont familyName: 'Tahoma' pointSize: 9 + i) emphasis: 1; yourself." but it was rendered the same as before... ----- Cheers, Sean -- View this message in context: http://forum.world.st/Tx-Bold-Text-tp4822964p4822987.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2015-04-29 18:04 GMT+02:00 Sean P. DeNigris <sean@clipperadams.com>:
Nicolai Hess wrote
Assign the proper Attribute?
Well AFAICT there is no bold attribute,
Ah yes, I mix up this with TextMorph and addAttribute:TextEmphasis....
but I tried setting the font to bold via "(LogicalFont familyName: 'Tahoma' pointSize: 9 + i) emphasis: 1; yourself." but it was rendered the same as before...
If the font is in the system, this should work. | text font1 font2 font3 string1 | font1 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis normal emphasisCode. font2 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis bold emphasisCode. font3 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis italic emphasisCode. string1 := 'Normal Bold Italic '. text := TxModel new. text at: text startPosition insert: string1. (text startPosition selectTo: text startPosition + 7) applyAttribute: (TxForeColorAttribute with: Color red); applyAttribute: (TxFontAttribute with: font1). (text startPosition + 7 selectTo: text startPosition + 12) applyAttribute: (TxForeColorAttribute with: Color green); applyAttribute: (TxFontAttribute with: font2). (text startPosition + 12 selectTo: text startPosition + 18) applyAttribute: (TxForeColorAttribute with: Color blue); applyAttribute: (TxFontAttribute with: font3). TxTextEditorMorph openInWindowWithText: text
----- Cheers, Sean -- View this message in context: http://forum.world.st/Tx-Bold-Text-tp4822964p4822987.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2015-04-29 21:32 GMT+02:00 Nicolai Hess <nicolaihess@web.de>:
2015-04-29 18:04 GMT+02:00 Sean P. DeNigris <sean@clipperadams.com>:
Nicolai Hess wrote
Assign the proper Attribute?
Well AFAICT there is no bold attribute,
Ah yes, I mix up this with TextMorph and addAttribute:TextEmphasis....
but I tried setting the font to bold via "(LogicalFont familyName: 'Tahoma' pointSize: 9 + i) emphasis: 1; yourself." but it was rendered the same as before...
If the font is in the system, this should work.
| text font1 font2 font3 string1 | font1 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis normal emphasisCode. font2 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis bold emphasisCode. font3 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis italic emphasisCode.
If an emphasisCode is used at low level, that's fine, but shouldn't the API be more straight like: emphasis: aTextEmphasis or: emphasisCode: anIntegerOrSymbolOrLetterOrAnyOtherWayToCodeAnEmphasis Nicolas string1 := 'Normal Bold Italic '.
text := TxModel new. text at: text startPosition insert: string1.
(text startPosition selectTo: text startPosition + 7) applyAttribute: (TxForeColorAttribute with: Color red); applyAttribute: (TxFontAttribute with: font1).
(text startPosition + 7 selectTo: text startPosition + 12) applyAttribute: (TxForeColorAttribute with: Color green); applyAttribute: (TxFontAttribute with: font2).
(text startPosition + 12 selectTo: text startPosition + 18) applyAttribute: (TxForeColorAttribute with: Color blue); applyAttribute: (TxFontAttribute with: font3).
TxTextEditorMorph openInWindowWithText: text
----- Cheers, Sean -- View this message in context: http://forum.world.st/Tx-Bold-Text-tp4822964p4822987.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Nicolas Cellier wrote
If the font is in the system
Eureka! This is the key: if the font is *not* in the system, the requested emphasis does not get carried over to the fallback font. Changing from 'Tahoma' to 'Source Sans Pro' did the trick. ----- Cheers, Sean -- View this message in context: http://forum.world.st/Tx-Bold-Text-tp4822964p4823055.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2015-04-29 21:40 GMT+02:00 Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com>:
2015-04-29 21:32 GMT+02:00 Nicolai Hess <nicolaihess@web.de>:
2015-04-29 18:04 GMT+02:00 Sean P. DeNigris <sean@clipperadams.com>:
Nicolai Hess wrote
Assign the proper Attribute?
Well AFAICT there is no bold attribute,
Ah yes, I mix up this with TextMorph and addAttribute:TextEmphasis....
but I tried setting the font to bold via "(LogicalFont familyName: 'Tahoma' pointSize: 9 + i) emphasis: 1; yourself." but it was rendered the same as before...
If the font is in the system, this should work.
| text font1 font2 font3 string1 | font1 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis normal emphasisCode. font2 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis bold emphasisCode. font3 := (LogicalFont familyName: 'Tahoma' pointSize: 25) emphasis: TextEmphasis italic emphasisCode.
If an emphasisCode is used at low level, that's fine, but shouldn't the API be more straight like:
emphasis: aTextEmphasis or: emphasisCode: anIntegerOrSymbolOrLetterOrAnyOtherWayToCodeAnEmphasis
Nicolas
+1 Sadly, we have quite some places in pharo where just the code is used, for example: .. aWindow isActive ifTrue: [ lab emphasis: 1 "1 -> bold" ]. ..
Nicolas Cellier wrote
shouldn't the API be more straight like: emphasis: aTextEmphasis
+1. We have nice emphasis objects, and then undermine them by spreading their state around! ----- Cheers, Sean -- View this message in context: http://forum.world.st/Tx-Bold-Text-tp4822964p4823146.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
participants (3)
-
Nicolai Hess -
Nicolas Cellier -
Sean P. DeNigris