312 The returned font is not associated to a specific device" |
314 The returned font is not associated to a specific device" |
313 |
315 |
314 |proto| |
316 |proto| |
315 |
317 |
316 RecentlyUsedFonts notNil ifTrue:[ |
318 RecentlyUsedFonts notNil ifTrue:[ |
317 proto := RecentlyUsedFonts |
319 proto := RecentlyUsedFonts |
318 detect:[:fn | |
320 detect:[:fn | |
319 fn family = familyString |
321 fn family = familyString |
320 and:[ fn size = size and:[fn sizeUnit = sizeUnit |
322 and:[ fn size = size and:[fn sizeUnit = sizeUnit |
321 and:[ fn face = faceString |
323 and:[ fn face = faceString |
322 and:[ (fn style = styleString |
324 and:[ (fn style = styleString |
323 or:[ (fn style = 'oblique' and:[styleString = 'italic']) |
325 or:[ (fn style = 'oblique' and:[styleString = 'italic']) |
324 or:[ (fn style = 'italic' and:[styleString = 'oblique']) ]]) ]]]]] |
326 or:[ (fn style = 'italic' and:[styleString = 'oblique']) ]]) ]]]]] |
325 ifNone:nil. |
327 ifNone:nil. |
326 proto notNil ifTrue:[ |
328 proto notNil ifTrue:[ |
327 ^ proto |
329 ^ proto |
328 ]. |
330 ]. |
329 ]. |
331 ]. |
330 |
332 |
331 CachedFontList notNil ifTrue:[ |
333 CachedFontList notNil ifTrue:[ |
332 proto := CachedFontList |
334 proto := CachedFontList |
333 detect:[:fn | |
335 detect:[:fn | |
334 fn family = familyString |
336 fn family = familyString |
335 and:[ fn face = faceString |
337 and:[ fn face = faceString |
336 and:[ (fn style = styleString |
338 and:[ (fn style = styleString |
337 or:[ (fn style = 'oblique' and:[styleString = 'italic']) |
339 or:[ (fn style = 'oblique' and:[styleString = 'italic']) |
338 or:[ (fn style = 'italic' and:[styleString = 'oblique']) ]]) ]]] |
340 or:[ (fn style = 'italic' and:[styleString = 'oblique']) ]]) ]]] |
339 ifNone:nil. |
341 ifNone:nil. |
340 proto notNil ifTrue:[ |
342 proto notNil ifTrue:[ |
341 ^ (proto shallowCopy) |
343 ^ (proto shallowCopy) |
342 setDevice: nil patternId: nil fontId: nil; |
344 setDevice: nil patternId: nil fontId: nil; |
343 family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
345 family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
344 ]. |
346 ]. |
345 ]. |
347 ]. |
346 ^ super |
348 ^ super |
347 family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
349 family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
348 ! |
350 ! |
349 |
351 |
350 new |
352 new |
351 "/ self halt. |
353 "/ self halt. |
352 ^ super new. |
354 ^ super new. |
|
355 ! ! |
|
356 |
|
357 !XftFontDescription class methodsFor:'change & update'! |
|
358 |
|
359 aboutToDestroyViewWithDevice:aDevice id:aWindowId |
|
360 "a view is going to be destroyed. |
|
361 Have to disassociate the XftDrawId from the drawableId aWindowId" |
|
362 |
|
363 Lobby do:[:eachXftFont| |
|
364 eachXftFont graphicsDevice == aDevice ifTrue:[ |
|
365 eachXftFont disassociateXftDrawableFrom:aWindowId. |
|
366 ]. |
|
367 ]. |
353 ! ! |
368 ! ! |
354 |
369 |
355 !XftFontDescription class methodsFor:'examples'! |
370 !XftFontDescription class methodsFor:'examples'! |
356 |
371 |
357 example1 |
372 example1 |
813 #endif |
824 #endif |
814 %}. |
825 %}. |
815 error notNil ifTrue:[ |
826 error notNil ifTrue:[ |
816 self primitiveFailed: error. |
827 self primitiveFailed: error. |
817 ]. |
828 ]. |
818 newDrawableAssociation notNil ifTrue:[ |
829 newXftDrawId notNil ifTrue:[ |
819 newXftDrawId notNil ifTrue:[ |
830 Lobby register:self. |
820 Lobby register:self. |
|
821 ]. |
|
822 aGC addDependent:self. "I need to be informed, when the GC is destroyed" |
|
823 ]. |
831 ]. |
824 "Created: / 21-12-2013 / 21:11:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
832 "Created: / 21-12-2013 / 21:11:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
825 "Modified: / 10-01-2014 / 11:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
833 "Modified: / 10-01-2014 / 11:13:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
826 ! ! |
834 ! ! |
827 |
835 |
987 |
995 |
988 setDevice: deviceArg patternId: patternIdArg fontId: fontIdArg |
996 setDevice: deviceArg patternId: patternIdArg fontId: fontIdArg |
989 device := deviceArg. |
997 device := deviceArg. |
990 fontId := fontIdArg. |
998 fontId := fontIdArg. |
991 patternIdArg notNil ifTrue:[ |
999 patternIdArg notNil ifTrue:[ |
992 family := self xftPatternGet: patternIdArg attribute: FC_FAMILY index: 0. |
1000 family := self xftPatternGet: patternIdArg attribute: FC_FAMILY index: 0. |
993 size := self xftPatternGet: patternIdArg attribute: FC_SIZE index: 0. |
1001 size := self xftPatternGet: patternIdArg attribute: FC_SIZE index: 0. |
994 face := self xftPatternGet: patternIdArg attribute: FC_WEIGHT index: 0. |
1002 face := self xftPatternGet: patternIdArg attribute: FC_WEIGHT index: 0. |
995 face := StXFace2FCWeightMap keyAtValue: face. |
1003 face := StXFace2FCWeightMap keyAtValue: face. |
996 style := self xftPatternGet: patternIdArg attribute: FC_SLANT index: 0. |
1004 style := self xftPatternGet: patternIdArg attribute: FC_SLANT index: 0. |
997 style := StXStyle2FCSlantMap keyAtValue: style. |
1005 style := StXStyle2FCSlantMap keyAtValue: style. |
998 |
1006 |
999 name:= self xftPatternGet: patternIdArg attribute: 'fullname' index: 0. |
1007 name:= self xftPatternGet: patternIdArg attribute: 'fullname' index: 0. |
1000 |
1008 |
1001 encoding:= self xftPatternGet: patternIdArg attribute: 'encoding' index: 0. |
1009 encoding:= self xftPatternGet: patternIdArg attribute: 'encoding' index: 0. |
|
1010 ]. |
|
1011 size isNil ifTrue:[ |
|
1012 size := 0. |
1002 ]. |
1013 ]. |
1003 |
1014 |
1004 "Created: / 21-12-2013 / 00:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1015 "Created: / 21-12-2013 / 00:46:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1005 "Modified: / 30-12-2013 / 12:49:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1016 "Modified: / 30-12-2013 / 12:49:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1006 ! ! |
1017 ! ! |
1915 |readEntry list l fcListProg| |
1920 |readEntry list l fcListProg| |
1916 |
1921 |
1917 list := OrderedCollection new. |
1922 list := OrderedCollection new. |
1918 |
1923 |
1919 readEntry := |
1924 readEntry := |
1920 [ |
1925 [ |
1921 |key| |
1926 |key| |
1922 |
1927 |
1923 [l startsWith:'Pattern has'] whileFalse:[ |
1928 [l startsWith:'Pattern has'] whileFalse:[ |
1924 l := pipeStream nextLine. Transcript showCR:l. |
1929 l := pipeStream nextLine. Transcript showCR:l. |
1925 ]. |
1930 ]. |
1926 |
1931 |
1927 currentDescription := XftFontDescription new. |
1932 currentDescription := XftFontDescription new. |
1928 [ l := pipeStream nextLine. l notEmptyOrNil ] whileTrue:[ |
1933 [ l := pipeStream nextLine. l notEmptyOrNil ] whileTrue:[ |
1929 "/ Transcript showCR:l. |
1934 "/ Transcript showCR:l. |
1930 lineStream := l readStream. lineStream skipSeparators. |
1935 lineStream := l readStream. lineStream skipSeparators. |
1931 key := lineStream upToSeparator. |
1936 key := lineStream upToSeparator. |
1932 ( |
1937 ( |
1933 #('family:' 'style:' 'slant:' 'weight:' 'width:' |
1938 #('family:' 'style:' 'slant:' 'weight:' 'width:' |
1934 'pixelsize:' 'spacing:' 'foundry:' 'antialias:' |
1939 'pixelsize:' 'spacing:' 'foundry:' 'antialias:' |
1935 'file:' 'outline' 'scalable:' 'charset:' 'lang:' |
1940 'file:' 'outline' 'scalable:' 'charset:' 'lang:' |
1936 'fontversion:' 'fontformat:' 'decorative:' 'index:' |
1941 'fontversion:' 'fontformat:' 'decorative:' 'index:' |
1937 'outline:' 'familylang:' 'stylelang:' 'fullname:' |
1942 'outline:' 'familylang:' 'stylelang:' 'fullname:' |
1938 'fullnamelang:' 'capability:' 'hash:' 'postscriptname:' |
1943 'fullnamelang:' 'capability:' 'hash:' 'postscriptname:' |
1939 ) includes:key |
1944 ) includes:key |
1940 ) ifTrue:[ |
1945 ) ifTrue:[ |
1941 self perform:('fc_',(key allButLast)) asSymbol |
1946 self perform:('fc_', (key allButLast)) asSymbol |
1942 ] ifFalse:[ |
1947 ] ifFalse:[ |
1943 Transcript show:'Xft ignored line: '; showCR:l. |
1948 Transcript show:'Xft ignored line: '; showCR:l. |
1944 self breakPoint:#cg. |
1949 self breakPoint:#cg. |
1945 ]. |
1950 ]. |
1946 ]. |
1951 ]. |
1947 list add:currentDescription |
1952 list add:currentDescription |
1948 ]. |
1953 ]. |
1949 |
1954 |
1950 fcListProg := #('/usr/bin/fc-list' '/usr/X11/bin/fc-list') detect:[:eachProg| |
1955 fcListProg := #('/usr/bin/fc-list' '/usr/X11/bin/fc-list') detect:[:eachProg| |
1951 eachProg asFilename isExecutableProgram |
1956 eachProg asFilename isExecutableProgram |
1952 ] ifNone:[ |
1957 ] ifNone:[ |
1953 'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR. |
1958 'XftFontDescription [warning]: fc-list program not found - no XFT fonts' errorPrintCR. |
1954 ^ list. |
1959 ^ list. |
1955 ]. |
1960 ]. |
1956 |
1961 |
1957 pipeStream := PipeStream readingFrom:fcListProg, ' -v'. |
1962 pipeStream := PipeStream readingFrom:fcListProg, ' -v'. |
1958 [ |
1963 [ |
1959 [pipeStream atEnd] whileFalse:[ |
1964 [pipeStream atEnd] whileFalse:[ |
1960 l := pipeStream nextLine. |
1965 l := pipeStream nextLine. |
1961 readEntry value. |
1966 readEntry value. |
1962 ] |
1967 ] |
1963 ] ensure:[ |
1968 ] ensure:[ |
1964 pipeStream close |
1969 pipeStream close |
1965 ]. |
1970 ]. |
1966 ^ list |
1971 ^ list |
1967 |
1972 |
1968 " |
1973 " |
1969 FCFontListParser new listOfAvailableFonts |
1974 FCFontListParser new listOfAvailableFonts |