1 "{ Package: 'stx:libview' }" |
1 "{ Package: 'stx:libview' }" |
2 |
2 |
3 FontDescription subclass:#XftFontDescription |
3 FontDescription subclass:#XftFontDescription |
4 instanceVariableNames:'device fontId drawId closestFont minCode maxCode' |
4 instanceVariableNames:'device fontId sharedDrawId closestFont minCode maxCode' |
5 classVariableNames:'FC_FAMILY FC_STYLE FC_SLANT FC_WEIGHT FC_SIZE FC_ASPECT |
5 classVariableNames:'FC_FAMILY FC_STYLE FC_SLANT FC_WEIGHT FC_SIZE FC_ASPECT |
6 FC_PIXEL_SIZE FC_SPACING FC_FOUNDRY FC_ANTIALIAS FC_HINTING |
6 FC_PIXEL_SIZE FC_SPACING FC_FOUNDRY FC_ANTIALIAS FC_HINTING |
7 FC_HINT_STYLE FC_VERTICAL_LAYOUT FC_AUTOHINT FC_WIDTH FC_FILE |
7 FC_HINT_STYLE FC_VERTICAL_LAYOUT FC_AUTOHINT FC_WIDTH FC_FILE |
8 FC_INDEX FC_FT_FACE FC_RASTERIZER FC_OUTLINE FC_SCALABLE FC_SCALE |
8 FC_INDEX FC_FT_FACE FC_RASTERIZER FC_OUTLINE FC_SCALABLE FC_SCALE |
9 FC_DPI FC_RGBA FC_MINSPACE FC_SOURCE FC_CHARSET FC_LANG |
9 FC_DPI FC_RGBA FC_MINSPACE FC_SOURCE FC_CHARSET FC_LANG |
287 ! ! |
287 ! ! |
288 |
288 |
289 !XftFontDescription class methodsFor:'instance creation'! |
289 !XftFontDescription class methodsFor:'instance creation'! |
290 |
290 |
291 family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
291 family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
292 "returns a font for given family, face, style, size and the specified encoding. |
292 "returns a font for given family, face, style, size and the specified encoding. |
293 The returned font is not associated to a specific device" |
293 The returned font is not associated to a specific device" |
294 |
294 |
295 |proto| |
295 |proto| |
296 |
296 |
297 CachedFontList notNil ifTrue:[ |
297 CachedFontList notNil ifTrue:[ |
298 proto := CachedFontList |
298 proto := CachedFontList |
299 detect:[:fn | |
299 detect:[:fn | |
300 fn family = familyString |
300 fn family = familyString |
301 and:[ fn face = faceString |
301 and:[ fn face = faceString |
302 and:[ (fn style = styleString |
302 and:[ (fn style = styleString |
303 or:[ (fn style = 'oblique' and:[styleString = 'italic']) |
303 or:[ (fn style = 'oblique' and:[styleString = 'italic']) |
304 or:[ (fn style = 'italic' and:[styleString = 'oblique']) ]]) ]]] |
304 or:[ (fn style = 'italic' and:[styleString = 'oblique']) ]]) ]]] |
305 ifNone:nil. |
305 ifNone:nil. |
306 proto notNil ifTrue:[ |
306 proto notNil ifTrue:[ |
307 ^ (proto shallowCopy) |
307 ^ (proto shallowCopy) |
308 setDevice: nil patternId: nil fontId: nil; |
308 setDevice: nil patternId: nil fontId: nil; |
309 family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
309 family:familyString face:faceString style:styleString size:size sizeUnit:sizeUnit encoding:encoding |
310 ]. |
310 ]. |
535 goto err; |
535 goto err; |
536 } |
536 } |
537 |
537 |
538 __bytesPerCharacter = __intVal(bytesPerCharacter); |
538 __bytesPerCharacter = __intVal(bytesPerCharacter); |
539 |
539 |
540 if ( __INST(drawId) == nil ) { |
540 if ( __INST(sharedDrawId) == nil ) { |
541 __INST(drawId) = XFT_DRAW_HANDLE_NEW ( XftDrawCreate ( DISPLAY( displayId ) , |
541 __INST(sharedDrawId) = XFT_DRAW_HANDLE_NEW ( XftDrawCreate ( DISPLAY( displayId ) , |
542 DRAWABLE( drawableId ) , |
542 DRAWABLE( drawableId ) , |
543 DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) , |
543 DefaultVisual( DISPLAY( displayId), SCREEN (screen) ) , |
544 DefaultColormap( DISPLAY( displayId), SCREEN (screen) ) ) ); |
544 DefaultColormap( DISPLAY( displayId), SCREEN (screen) ) ) ); |
545 __STORE(self, __INST(drawId)); |
545 __STORE(self, __INST(sharedDrawId)); |
546 } |
546 } |
547 |
547 |
548 if ( XftDrawDrawable ( XFT_DRAW ( __INST(drawId) ) ) != DRAWABLE( drawableId ) ) { |
548 if ( XftDrawDrawable ( XFT_DRAW ( __INST(sharedDrawId) ) ) != DRAWABLE( drawableId ) ) { |
549 XftDrawChange( XFT_DRAW( __INST(drawId) ) , DRAWABLE( drawableId ) ); |
549 XftDrawChange( XFT_DRAW( __INST(sharedDrawId) ) , DRAWABLE( drawableId ) ); |
550 } |
550 } |
551 |
551 |
552 string = __stringVal( aString ) + (( __intVal(index1) - 1 ) * __bytesPerCharacter); |
552 string = __stringVal( aString ) + (( __intVal(index1) - 1 ) * __bytesPerCharacter); |
553 len = __intVal(index2) - __intVal(index1) + 1; |
553 len = __intVal(index2) - __intVal(index1) + 1; |
554 |
554 |
555 if (clipR != nil) { |
555 if (clipR != nil) { |
556 clipRX.x = __intVal(clipX); |
556 clipRX.x = __intVal(clipX); |
557 clipRX.y = __intVal(clipY); |
557 clipRX.y = __intVal(clipY); |
558 clipRX.width = __intVal(clipW); |
558 clipRX.width = __intVal(clipW); |
559 clipRX.height = __intVal(clipH); |
559 clipRX.height = __intVal(clipH); |
560 XftDrawSetClipRectangles( XFT_DRAW( __INST( drawId ) ) , 0, 0, &clipRX, 1); |
560 XftDrawSetClipRectangles( XFT_DRAW( __INST( sharedDrawId ) ) , 0, 0, &clipRX, 1); |
561 } else { |
561 } else { |
562 XftDrawSetClip( XFT_DRAW( __INST( drawId ) ) , 0); |
562 XftDrawSetClip( XFT_DRAW( __INST( sharedDrawId ) ) , 0); |
563 } |
563 } |
564 |
564 |
565 if (opaque == true) { |
565 if (opaque == true) { |
566 if (bgPixel != nil) { |
566 if (bgPixel != nil) { |
567 color.pixel = (unsigned long)__intVal(bgPixel); |
567 color.pixel = (unsigned long)__intVal(bgPixel); |
581 break; |
581 break; |
582 case 4: |
582 case 4: |
583 XftTextExtents32( DISPLAY( displayId ), XFT_FONT( __INST( fontId ) ), (FcChar32*)string, len, &extents); |
583 XftTextExtents32( DISPLAY( displayId ), XFT_FONT( __INST( fontId ) ), (FcChar32*)string, len, &extents); |
584 break; |
584 break; |
585 } |
585 } |
586 XftDrawRect( XFT_DRAW ( __INST( drawId ) ), &color, __intVal(drawX) - extents.x, __intVal(drawY) - XFT_FONT( __INST( fontId ) )->ascent, extents.width, XFT_FONT(__INST (fontId ) )->height); |
586 XftDrawRect( XFT_DRAW ( __INST( sharedDrawId ) ), &color, __intVal(drawX) - extents.x, __intVal(drawY) - XFT_FONT( __INST( fontId ) )->ascent, extents.width, XFT_FONT(__INST (fontId ) )->height); |
587 } |
587 } |
588 if (fgPixel != nil) { |
588 if (fgPixel != nil) { |
589 color.pixel = (unsigned long)__intVal(fgPixel); |
589 color.pixel = (unsigned long)__intVal(fgPixel); |
590 } |
590 } |
591 // else { |
591 // else { |
594 color.color.blue = __intVal(fgB); |
594 color.color.blue = __intVal(fgB); |
595 color.color.alpha = __intVal(fgA); |
595 color.color.alpha = __intVal(fgA); |
596 // } |
596 // } |
597 switch (__bytesPerCharacter) { |
597 switch (__bytesPerCharacter) { |
598 case 1: |
598 case 1: |
599 XftDrawString8( XFT_DRAW ( __INST( drawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
599 XftDrawString8( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
600 __intVal(drawX), |
600 __intVal(drawX), |
601 __intVal(drawY), |
601 __intVal(drawY), |
602 (FcChar8*)string, |
602 (FcChar8*)string, |
603 len); |
603 len); |
604 RETURN ( self ); |
604 RETURN ( self ); |
605 break; |
605 break; |
606 case 2: |
606 case 2: |
607 XftDrawString16( XFT_DRAW ( __INST( drawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
607 XftDrawString16( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
608 __intVal(drawX), |
608 __intVal(drawX), |
609 __intVal(drawY), |
609 __intVal(drawY), |
610 (FcChar16*)string, |
610 (FcChar16*)string, |
611 len); |
611 len); |
612 RETURN ( self ); |
612 RETURN ( self ); |
613 break; |
613 break; |
614 case 4: |
614 case 4: |
615 XftDrawString32( XFT_DRAW ( __INST( drawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
615 XftDrawString32( XFT_DRAW ( __INST( sharedDrawId ) ), &color, XFT_FONT( __INST( fontId ) ), |
616 __intVal(drawX), |
616 __intVal(drawX), |
617 __intVal(drawY), |
617 __intVal(drawY), |
618 (FcChar32*)string, |
618 (FcChar32*)string, |
619 len); |
619 len); |
620 RETURN ( self ); |
620 RETURN ( self ); |
1569 view isNil ifTrue:[ ^ self ]. |
1569 view isNil ifTrue:[ ^ self ]. |
1570 drawableId := view id. |
1570 drawableId := view id. |
1571 drawableId isNil ifTrue: [ ^ self ]. |
1571 drawableId isNil ifTrue: [ ^ self ]. |
1572 %{ |
1572 %{ |
1573 #ifdef XFT |
1573 #ifdef XFT |
1574 if ( __INST(drawId) != nil ) { |
1574 if ( __INST(sharedDrawId) != nil ) { |
1575 if (XftDrawDrawable(XFT_DRAW(__INST(drawId))) == DRAWABLE(drawableId)) { |
1575 if (XftDrawDrawable(XFT_DRAW(__INST(sharedDrawId))) == DRAWABLE(drawableId)) { |
1576 __INST(drawId) = nil; |
1576 __INST(sharedDrawId) = nil; |
1577 XftDrawDestroy(DRAWABLE(drawableId)); |
1577 XftDrawDestroy(DRAWABLE(drawableId)); |
1578 } |
1578 } |
1579 } |
1579 } |
1580 RETURN (self); |
1580 RETURN (self); |
1581 #endif |
1581 #endif |
1702 "helper for font listing" |
1702 "helper for font listing" |
1703 |
1703 |
1704 |page bits l min max minCode maxCode| |
1704 |page bits l min max minCode maxCode| |
1705 |
1705 |
1706 [ l := pipeStream nextLine. l notEmpty ] whileTrue:[ |
1706 [ l := pipeStream nextLine. l notEmpty ] whileTrue:[ |
1707 "/ Transcript show:'->'; showCR:l. |
1707 "/ Transcript show:'->'; showCR:l. |
1708 (l startsWith:Character tab) ifFalse:[ |
1708 (l startsWith:Character tab) ifFalse:[ |
1709 (l startsWith:'(') ifFalse:[self halt]. |
1709 (l startsWith:'(') ifFalse:[self halt]. |
1710 currentDescription minCode:minCode. |
1710 currentDescription minCode:minCode. |
1711 currentDescription maxCode:maxCode. |
1711 currentDescription maxCode:maxCode. |
1712 ^ self. |
1712 ^ self. |
1713 ]. |
1713 ]. |
1714 |
1714 |
1715 lineStream := l readStream. |
1715 lineStream := l readStream. |
1716 lineStream skipSeparators. |
1716 lineStream skipSeparators. |
1717 page := Integer readFrom:(lineStream upTo:$:) radix:16. |
1717 page := Integer readFrom:(lineStream upTo:$:) radix:16. |
1718 lineStream next. |
1718 lineStream next. |
1719 bits := 0 to:7 collect:[:i| |
1719 bits := 0 to:7 collect:[:i| |
1720 lineStream skipSeparators. |
1720 lineStream skipSeparators. |
1721 Integer readFrom:(lineStream upToSeparator) radix:16. |
1721 Integer readFrom:(lineStream upToSeparator) radix:16. |
1722 ]. |
1722 ]. |
1723 min := (page * 256 + 0). |
1723 min := (page * 256 + 0). |
1724 max := (page * 256 + 255). |
1724 max := (page * 256 + 255). |
1725 minCode isNil ifTrue:[ |
1725 minCode isNil ifTrue:[ |
1726 minCode := min. |
1726 minCode := min. |
1727 maxCode := max. |
1727 maxCode := max. |
1728 ] ifFalse:[ |
1728 ] ifFalse:[ |
1729 minCode := minCode min:min. |
1729 minCode := minCode min:min. |
1730 maxCode := maxCode max:max. |
1730 maxCode := maxCode max:max. |
1731 ]. |
1731 ]. |
1732 ]. |
1732 ]. |
1733 "/ currentDescription characterSet:(self getString). |
1733 "/ currentDescription characterSet:(self getString). |
1734 currentDescription minCode:minCode. |
1734 currentDescription minCode:minCode. |
1735 currentDescription maxCode:maxCode. |
1735 currentDescription maxCode:maxCode. |
1736 ! |
1736 ! |
1737 |
1737 |
1738 fc_decorative |
1738 fc_decorative |
1851 |
1851 |
1852 |xftStyle| |
1852 |xftStyle| |
1853 |
1853 |
1854 xftStyle := self getString. |
1854 xftStyle := self getString. |
1855 (xftStyle includesString:'Bold') ifTrue:[ |
1855 (xftStyle includesString:'Bold') ifTrue:[ |
1856 currentDescription face:'bold'. |
1856 currentDescription face:'bold'. |
1857 currentDescription style:'roman'. |
1857 currentDescription style:'roman'. |
1858 ^ self. |
1858 ^ self. |
1859 ]. |
1859 ]. |
1860 (xftStyle includesString:'Italic') ifTrue:[ |
1860 (xftStyle includesString:'Italic') ifTrue:[ |
1861 currentDescription face:'medium'. |
1861 currentDescription face:'medium'. |
1862 currentDescription style:'italic'. |
1862 currentDescription style:'italic'. |
1863 ^ self. |
1863 ^ self. |
1864 ]. |
1864 ]. |
1865 (xftStyle includesString:'Oblique') ifTrue:[ |
1865 (xftStyle includesString:'Oblique') ifTrue:[ |
1866 currentDescription face:'medium'. |
1866 currentDescription face:'medium'. |
1867 currentDescription style:'italic'. |
1867 currentDescription style:'italic'. |
1868 ^ self. |
1868 ^ self. |
1869 ]. |
1869 ]. |
1870 "/ self halt. |
1870 "/ self halt. |
1871 currentDescription face:'medium'. |
1871 currentDescription face:'medium'. |
1872 currentDescription style:'roman'. |
1872 currentDescription style:'roman'. |
1873 ! |
1873 ! |
1874 |
1874 |
1875 fc_stylelang |
1875 fc_stylelang |
1876 "helper for font listing" |
1876 "helper for font listing" |