This repository was archived by the owner on Mar 9, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +41
-15
lines changed Expand file tree Collapse file tree 3 files changed +41
-15
lines changed Original file line number Diff line number Diff line change 35
35
return ;
36
36
}
37
37
}
38
-
39
38
if ( opts . onlyVisible && ! ( node . offsetWidth || node . offsetHeight || node . getClientRects ( ) . length ) ) {
40
39
return ;
41
40
}
132
131
}
133
132
134
133
if ( node . parentNode ) {
135
- var textTransform = this . win . getComputedStyle ( node . parentNode ) . getPropertyValue ( "text-transform" ) ;
136
- // console.log( "textTransform:", textTransform );
137
- switch ( textTransform ) {
138
- case "uppercase" :
139
- return value . toUpperCase ( ) ;
140
- case "lowercase" :
141
- return value . toLowerCase ( ) ;
142
- case "capitalize" :
143
- // workaround language specific rules with text-transform
144
- // "ß".toUpperCase() => "SS" in german, for example
145
- return value . toUpperCase ( ) + value . toLowerCase ( ) ;
134
+ var style = this . win . getComputedStyle ( node . parentNode ) ;
135
+ var textTransform = style . getPropertyValue ( "text-transform" ) ;
136
+ // More information on small-caps at issue #51
137
+ var fontVariant = style . getPropertyValue ( "font-variant" ) ;
138
+
139
+ if ( fontVariant === "small-caps" || textTransform === "capitalize" ) {
140
+ // workaround language specific rules with text-transform
141
+ // "ß".toUpperCase() => "SS" in german, for example
142
+ return value . toUpperCase ( ) + value . toLowerCase ( ) ;
143
+ } else if ( textTransform === "uppercase" ) {
144
+ return value . toUpperCase ( ) ;
145
+ } else if ( textTransform === "lowercase" ) {
146
+ return value . toLowerCase ( ) ;
146
147
}
147
148
}
148
149
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ describe( "Integration test", function() {
14
14
} ) ;
15
15
} ) ;
16
16
17
- it ( "should have work with text-transform: uppercase" , function ( done ) {
17
+ it ( "should work with text-transform: uppercase" , function ( done ) {
18
18
this . timeout ( 10000 ) ;
19
19
20
20
var gh = new GlyphHanger ( ) ;
@@ -26,7 +26,7 @@ describe( "Integration test", function() {
26
26
} ) ;
27
27
} ) ;
28
28
29
- it ( "should have work with text-transform: capitalize" , function ( done ) {
29
+ it ( "should work with text-transform: capitalize" , function ( done ) {
30
30
this . timeout ( 10000 ) ;
31
31
32
32
var gh = new GlyphHanger ( ) ;
@@ -38,7 +38,19 @@ describe( "Integration test", function() {
38
38
} ) ;
39
39
} ) ;
40
40
41
- it ( "should have work with onload and DOMContentLoaded content" , function ( done ) {
41
+ it ( "should work with font-variant: small-caps" , function ( done ) {
42
+ this . timeout ( 10000 ) ;
43
+
44
+ var gh = new GlyphHanger ( ) ;
45
+ gh . fetchUrls ( [ "test/small-caps.html" ] ) . then ( function ( result ) {
46
+ // abc ^d e => abcDe => Dabcde
47
+ assert . equal ( gh . getUniversalSet ( ) . toString ( ) , "Dabcde" ) ;
48
+
49
+ done ( ) ;
50
+ } ) ;
51
+ } ) ;
52
+
53
+ it ( "should work with onload and DOMContentLoaded content" , function ( done ) {
42
54
this . timeout ( 10000 ) ;
43
55
44
56
var gh = new GlyphHanger ( ) ;
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < title > </ title >
7
+ </ head >
8
+ < body >
9
+ abc
10
+ < span style ="font-variant: small-caps; "> d</ span >
11
+ < span style ="font-feature-settings: 'smcp' on "> e</ span >
12
+ </ body >
13
+ </ html >
You can’t perform that action at this time.
0 commit comments