-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from SWTI2014/rendering/font-family
Fix #54: Rendering/font family
- Loading branch information
Showing
95 changed files
with
227 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mkdir -p -v ${BUILD_PATH}/travisCI/Scamper/fonts | ||
cp -R -v $PROJECT_HOME/build-support/fonts ${BUILD_PATH}/travisCI/Scamper/ | ||
chmod -R 777 ${BUILD_PATH}/travisCI/Scamper/fonts/* |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
# | ||
# Generic test driver script for builderCI | ||
# | ||
# -verbose flag causes unconditional transcript display | ||
# | ||
# Copyright (c) 2012-2013 VMware, Inc. All Rights Reserved <dhenrich@vmware.com>. | ||
# Copyright (C) 2014 GemTalk Systems LLC <dale.henrichs@gemtalksystems.com> | ||
# | ||
$BUILDER_CI_HOME/build.sh -d -i $ST -m -f "$PROJECT_HOME/tests/travisCI.st" -o travisCI | ||
if [[ $? != 0 ]] ; then | ||
echo "ERROR: $(basename $0)" | ||
cd "${BUILD_PATH}/travisCI/" | ||
$BUILDER_CI_HOME/buildImageErrorCheck.sh # dump Transcript on error and exit | ||
if [[ $? != 0 ]] ; then exit 1; fi | ||
$BUILDER_CI_HOME/dumpTranscript.sh | ||
exit 1 | ||
fi | ||
cd "${BUILD_PATH}/travisCI/" | ||
$BUILDER_CI_HOME/buildImageErrorCheck.sh # dump Transcript on error and exit | ||
if [[ $? != 0 ]] ; then exit 1; fi | ||
$BUILDER_CI_HOME/buildTravisStatusCheck.sh "$@" # dump Transcript on failed tests and exit | ||
if [[ $? != 0 ]] ; then exit 1; fi |
4 changes: 4 additions & 0 deletions
4
packages/HTML.package/CSSFontFormatter.class/class/initialize.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class initialization | ||
initialize | ||
super initialize. | ||
self installFontsIfNecessary. |
7 changes: 7 additions & 0 deletions
7
packages/HTML.package/CSSFontFormatter.class/class/installFonts.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class initialization | ||
installFonts | ||
((FileDirectory uri: 'Scamper' , FileDirectory slash , 'fonts') fileNamesMatching: '*.ttf') | ||
do: [:fontfile | | ||
TTCFont newTextStyleFromTTFile: | ||
(FileDirectory uri: 'Scamper' , FileDirectory slash , 'fonts') fullName , FileDirectory slash , fontfile]. | ||
fontsInstalled := true. |
4 changes: 4 additions & 0 deletions
4
packages/HTML.package/CSSFontFormatter.class/class/installFontsIfNecessary.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class initialization | ||
installFontsIfNecessary | ||
fontsInstalled ifNil: [self installFonts]. | ||
fontsInstalled ifFalse: [self installFonts]. |
5 changes: 5 additions & 0 deletions
5
packages/HTML.package/CSSFontFormatter.class/class/uninstallFonts.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class initialization | ||
uninstallFonts | ||
{'NimbusMonoL' . 'TrebuchetMS' . 'Webdings' . 'Georgia' . 'Verdana' . 'AndaleMono' . 'NimbusRomanNo9L' . 'NimbusSansL' . 'ComicSansMS' . 'URWChanceryL'} | ||
do: [:font | TTCFont removeStyleName: font]. | ||
fontsInstalled := false. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/HTML.package/CSSFontFormatter.class/instance/fontMap.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
accessing | ||
fontMap | ||
"I replace some fonts with licence issues by free alternatives and set a mapping for generic font families such as serif or monospace." | ||
^ fontMap ifNil: | ||
[ Dictionary newFrom: { | ||
'serif' -> 'NimbusRomanNo9L'. | ||
'Times' -> 'NimbusRomanNo9L'. | ||
'Times New Roman' -> 'NimbusRomanNo9L'. | ||
'Nimbus Roman No9 L' -> 'NimbusRomanNo9L'. | ||
'sans-serif' -> 'NimbusSansL'. | ||
'Arial' -> 'NimbusSansL'. | ||
'Helvetica' -> 'NimbusSansL'. | ||
'Nimbus Sans L' -> 'NimbusSansL'. | ||
'fantasy' -> 'ComicSansMS'. | ||
'Comic Sans MS' -> 'ComicSansMS'. | ||
'cursive' -> 'URWChanceryL'. | ||
'URW Chancery L' -> 'URWChanceryL'. | ||
'monospace' -> 'NimbusMonoL'. | ||
'Courier New' -> 'NimubsMonoL'. | ||
'Nimbus Mono L' -> 'NimbusMonoL'. | ||
'Trebuchet MS' -> 'TrebuchetMS'. | ||
'Andale Mono' -> 'AndaleMono'. | ||
}] |
2 changes: 1 addition & 1 deletion
2
packages/HTML.package/CSSFontFormatter.class/instance/parseTextAttributesFrom.into..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
parsing | ||
parseTextAttributesFrom: aCSSProperty into: aContext | ||
|
||
self class installFontsIfNecessary. | ||
(self attributeMap at: aCSSProperty propertyName ifAbsent: [nil]) | ||
ifNotNilDo: [ :process | process value: aCSSProperty value: aContext ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/HTML.package/CSSFontFormatter.class/instance/readFontFamilyAttribute.to..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
parsing | ||
readFontFamilyAttribute: aString to: aContext | ||
| style | | ||
style := ((TextStyle named: 'Verdana') ifNil: [TextStyle default]). | ||
aString splitBy: ',' reversed do: [:family | (self styleForFamily: family) ifNotNilDo: [:s | style := s]]. | ||
aContext at: #family put: style. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/HTML.package/CSSFontFormatter.class/instance/styleForFamily..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
parsing | ||
styleForFamily: aString | ||
| family | | ||
family := aString trimBoth: [:char | char isSeparator or: [char = $"] or: [char = $']]. | ||
(TextStyle named: family) ifNotNilDo: [:style | ^style]. | ||
self fontMap at: family ifPresent: [:replacement | ^TextStyle named: replacement]. | ||
^nil. |
20 changes: 13 additions & 7 deletions
20
packages/HTML.package/CSSFontFormatter.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
{ | ||
"class" : { | ||
}, | ||
"initialize" : "SN 6/15/2014 11:47", | ||
"installFonts" : "SN 6/15/2014 14:19", | ||
"installFontsIfNecessary" : "SN 6/12/2014 22:16", | ||
"uninstallFonts" : "SN 6/12/2014 22:13" }, | ||
"instance" : { | ||
"attributeMap" : "rs 5/21/2014 12:46:49.11", | ||
"attributeMap" : "SN 6/11/2014 22:54", | ||
"fontMap" : "SN 6/12/2014 14:31", | ||
"isValidStyleValue:" : "rs 5/21/2014 15:44:29.914", | ||
"isValidWeightValue:" : "rs 5/21/2014 15:43:47.846", | ||
"parseTextAttributesFrom:into:" : "rs 6/7/2014 13:29:31.21", | ||
"readFontAttribute:to:" : "rs 5/21/2014 16:06:04.462", | ||
"readFontSizeAttribute:to:" : "rs 6/7/2014 13:32:04.925", | ||
"readFontStyleAttribute:to:" : "rs 5/21/2014 11:48:15.832", | ||
"readFontWeightAttribute:to:" : "rs 5/21/2014 11:48:27.886" } } | ||
"parseTextAttributesFrom:into:" : "SN 6/12/2014 22:14", | ||
"readFontAttribute:to:" : "SN 6/12/2014 14:26", | ||
"readFontFamilyAttribute:to:" : "SN 6/15/2014 13:06", | ||
"readFontSizeAttribute:to:" : "SN 6/12/2014 12:11", | ||
"readFontStyleAttribute:to:" : "SN 6/12/2014 14:20", | ||
"readFontWeightAttribute:to:" : "rs 5/21/2014 11:48:27.886", | ||
"styleForFamily:" : "SN 6/12/2014 10:07" } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/HTML.package/CSSFontFormatterTest.class/instance/setUp.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
running | ||
setUp | ||
self timeout: 300. | ||
self fontFormatter: CSSFontFormatter new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ML.package/CSSFontFormatterTest.class/instance/test05FontFamilyShouldBeParsedCorrectly.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
testing | ||
test05FontFamilyShouldBeParsedCorrectly | ||
| prop result | | ||
result := Dictionary new. | ||
prop := CSSProperty new | ||
propertyName: 'font-family'; | ||
propertyString: 'serif'; | ||
yourself. | ||
self fontFormatter parseTextAttributesFrom: prop into: result. | ||
self assert: (TextStyle named: 'NimbusRomanNo9L') equals: (result at: #family). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/HTML.package/DHtmlFormatter.class/instance/parseTextStyleAttributesFor.in..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
formatting commands | ||
parseTextStyleAttributesFor: aStyleResolver in: anOrderedCollection | ||
|
||
| family size | | ||
|
||
size := aStyleResolver ifStyleNotNil: #size do: [:s | s] ifNil: [12]. | ||
family := aStyleResolver ifStyleNotNil: #family do: [:f | f] ifNil: [TextStyle default]. | ||
|
||
((aStyleResolver getStyle: #family) notNil or: [(aStyleResolver getStyle: #size) notNil]) | ||
ifTrue: [anOrderedCollection add: (TextFontReference toFont: (family fontOfPointSize: size))]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/HTML.package/DHtmlFormatterTest.class/instance/setUp.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
running | ||
setUp | ||
self timeout: 300. | ||
self htmlFormatter: DHtmlFormatter new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/HTML.package/StyleResolver.class/instance/ifStyleNotNil.do..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
resolution | ||
ifStyleNotNil: attributeKey do: aBlock | ||
|
||
(self getStyle: attributeKey) ifNotNilDo: [ :attribValue | aBlock value: attribValue ] | ||
(self getStyle: attributeKey) ifNotNilDo: [ :attribValue | ^aBlock value: attribValue ] |
4 changes: 4 additions & 0 deletions
4
packages/HTML.package/StyleResolver.class/instance/ifStyleNotNil.do.ifNil..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resolution | ||
ifStyleNotNil: attributeKey do: aBlock ifNil: anotherBlock | ||
|
||
(self getStyle: attributeKey) ifNil: [^anotherBlock value] ifNotNilDo: [ :attribValue | ^aBlock value: attribValue ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/HTML.package/TTFontReader.extension/instance/readFrom..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
*html | ||
readFrom: aStream | ||
|
||
| fontData headerEntry maxProfileEntry nameEntry indexLocEntry charMapEntry glyphEntry horzHeaderEntry horzMetricsEntry kerningEntry glyphOffset cmap numHMetrics indexToLocFormat | | ||
|
||
"Read the raw font byte data" | ||
aStream binary. | ||
fontData := aStream contents asByteArray. | ||
fontDescription := TTFontDescription new. | ||
|
||
"Search the tables required to build the font" | ||
(headerEntry := self getTableDirEntry: 'head' from: fontData) == nil ifTrue:[ | ||
^self error:'This font does not have a header table']. | ||
(maxProfileEntry := self getTableDirEntry: 'maxp' from: fontData) == nil ifTrue:[ | ||
^self error:'This font does not have a maximum profile table']. | ||
(nameEntry := self getTableDirEntry: 'name' from: fontData) == nil ifTrue:[ | ||
^self error:'This font does not have a name table']. | ||
(indexLocEntry := self getTableDirEntry: 'loca' from: fontData) == nil ifTrue:[ | ||
^self error:'This font does not have a relocation table']. | ||
(charMapEntry := self getTableDirEntry: 'cmap' from: fontData) == nil ifTrue:[ | ||
^self error:'This font does not have a character map table']. | ||
(glyphEntry := self getTableDirEntry: 'glyf' from: fontData) == nil ifTrue:[ | ||
^self error:'This font does not have a glyph table']. | ||
(horzHeaderEntry := self getTableDirEntry: 'hhea' from: fontData) == nil ifTrue:[ | ||
^self error:'This font does not have a horizontal header table']. | ||
(horzMetricsEntry := self getTableDirEntry: 'hmtx' from: fontData) == nil ifTrue:[ | ||
^self error:'This font does not have a horizontal metrics table']. | ||
(kerningEntry := self getTableDirEntry: 'kern' from: fontData) == nil ifTrue:[ | ||
Transcript cr; show:'This font does not have a kerning table']. | ||
|
||
|
||
"Process the data" | ||
indexToLocFormat := self processFontHeaderTable: headerEntry. | ||
self processMaximumProfileTable: maxProfileEntry. | ||
self processNamingTable: nameEntry. | ||
glyphOffset := self processIndexToLocationTable: indexLocEntry format: indexToLocFormat. | ||
cmap := self processCharacterMappingTable: charMapEntry. | ||
(cmap == nil or:[cmap value == nil]) | ||
ifTrue:[^self error:'This font has no suitable character mappings']. | ||
self processGlyphDataTable: glyphEntry offsets: glyphOffset. | ||
numHMetrics := self processHorizontalHeaderTable: horzHeaderEntry. | ||
self processHorizontalMetricsTable: horzMetricsEntry length: numHMetrics. | ||
kerningEntry isNil | ||
ifTrue:[kernPairs := #()] | ||
ifFalse:[self processKerningTable: kerningEntry]. | ||
charMap := self processCharMap: cmap. | ||
fontDescription setGlyphs: glyphs mapping: charMap. | ||
fontDescription setKernPairs: kernPairs. | ||
^fontDescription |
Oops, something went wrong.