7656 Screen current getDefaultFontWithEncoding:#'iso10646-1' |
7656 Screen current getDefaultFontWithEncoding:#'iso10646-1' |
7657 " |
7657 " |
7658 ! |
7658 ! |
7659 |
7659 |
7660 getFontWithFamily:familyString face:faceString |
7660 getFontWithFamily:familyString face:faceString |
7661 style:styleArgString size:sizeArgOrNil sizeUnit:sizeUnit encoding:encoding |
7661 style:styleArgString size:sizeArgOrNil sizeUnit:sizeUnit encoding:encoding |
7662 |
7662 |
7663 "try to get the specified font, if not available, try next smaller |
7663 "try to get the specified font, if not available, try next smaller |
7664 font. Access to X-fonts by name is possible, by passing the X font name |
7664 font. Access to X-fonts by name is possible, by passing the X font name |
7665 as family and the other parameters as nil. For example, the cursor font |
7665 as family and the other parameters as nil. For example, the cursor font |
7666 can be aquired that way." |
7666 can be acquired that way." |
7667 |
7667 |
7668 |styleString theName theId xlatedStyle |
7668 |styleString theName theId xlatedStyle |
7669 id spacing encodingMatch idx roundedSize pixelSize pointSize| |
7669 id spacing encodingMatch idx roundedSize pixelSize pointSize| |
7670 |
7670 |
7671 styleString := styleArgString. |
7671 styleString := styleArgString. |
7672 |
7672 |
7673 sizeArgOrNil notNil ifTrue:[ |
7673 sizeArgOrNil notNil ifTrue:[ |
7674 roundedSize := sizeArgOrNil rounded asInteger. |
7674 roundedSize := sizeArgOrNil rounded asInteger. |
7675 sizeUnit == #px ifTrue:[ |
7675 sizeUnit == #px ifTrue:[ |
7676 pixelSize := roundedSize. |
7676 pixelSize := roundedSize. |
7677 ] ifFalse:[ |
7677 ] ifFalse:[ |
7678 pointSize := roundedSize. |
7678 pointSize := roundedSize. |
7679 ]. |
7679 ]. |
7680 ]. |
7680 ]. |
7681 |
7681 |
7682 "special: if face is nil, allow access to X-fonts" |
7682 "special: if face is nil, allow access to X-fonts" |
7683 faceString isNil ifTrue:[ |
7683 faceString isNil ifTrue:[ |
7684 roundedSize notNil ifTrue:[ |
7684 roundedSize notNil ifTrue:[ |
7685 theName := familyString , '-' , roundedSize printString |
7685 theName := familyString , '-' , roundedSize printString |
7686 ] ifFalse:[ |
7686 ] ifFalse:[ |
7687 theName := familyString |
7687 theName := familyString |
7688 ]. |
7688 ]. |
7689 theName notNil ifTrue:[ |
7689 theName notNil ifTrue:[ |
7690 theId := self createFontFor:theName. |
7690 theId := self createFontFor:theName. |
7691 ]. |
7691 ]. |
7692 theId isNil ifTrue:[ |
7692 theId isNil ifTrue:[ |
7693 theId := self getDefaultFontWithEncoding:encoding |
7693 theId := self getDefaultFontWithEncoding:encoding |
7694 ]. |
7694 ]. |
7695 ^ theId |
7695 ^ theId |
7696 ]. |
7696 ]. |
7697 |
7697 |
7698 "/ spacing other than 'normal' is contained as last component |
7698 "/ spacing other than 'normal' is contained as last component |
7699 "/ in style |
7699 "/ in style |
7700 |
7700 |
7701 (styleString notNil |
7701 (styleString notNil |
7702 and:[(styleString endsWith:'-narrow') |
7702 and:[(styleString endsWith:'-narrow') |
7703 or:[styleString endsWith:'-semicondensed']]) ifTrue:[ |
7703 or:[styleString endsWith:'-semicondensed']]) ifTrue:[ |
7704 |i| |
7704 |i| |
7705 i := styleString lastIndexOf:$-. |
7705 i := styleString lastIndexOf:$-. |
7706 spacing := styleString copyFrom:(i+1). |
7706 spacing := styleString copyFrom:(i+1). |
7707 styleString := styleString copyTo:(i-1). |
7707 styleString := styleString copyTo:(i-1). |
7708 ] ifFalse:[ |
7708 ] ifFalse:[ |
7709 spacing := 'normal'. |
7709 spacing := 'normal'. |
7710 ]. |
7710 ]. |
7711 |
7711 |
7712 xlatedStyle := styleString. |
7712 xlatedStyle := styleString. |
7713 xlatedStyle notNil ifTrue:[ |
7713 xlatedStyle notNil ifTrue:[ |
7714 xlatedStyle := xlatedStyle first asString |
7714 xlatedStyle := xlatedStyle first asString |
7715 ]. |
7715 ]. |
7716 |
7716 |
7717 encoding isNil ifTrue:[ |
7717 encoding isNil ifTrue:[ |
7718 encodingMatch := '*-*'. |
7718 encodingMatch := '*-*'. |
7719 ] ifFalse:[ |
7719 ] ifFalse:[ |
7720 idx := encoding indexOf:$-. |
7720 idx := encoding indexOf:$-. |
7721 idx ~~ 0 ifTrue:[ |
7721 idx ~~ 0 ifTrue:[ |
7722 encodingMatch := encoding |
7722 encodingMatch := encoding |
7723 ] ifFalse:[ |
7723 ] ifFalse:[ |
7724 encodingMatch := encoding , '-*'. |
7724 encodingMatch := encoding , '-*'. |
7725 ]. |
7725 ]. |
7726 ]. |
7726 ]. |
7727 |
7727 |
7728 id := self |
7728 id := self |
7729 getFontWithFoundry:'*' |
7729 getFontWithFoundry:'*' |
7730 family:familyString asLowercase |
7730 family:familyString asLowercase |
7731 weight:faceString |
7731 weight:faceString |
7732 slant:xlatedStyle |
7732 slant:xlatedStyle |
7733 spacing:spacing |
7733 spacing:spacing |
7734 pixelSize:pixelSize |
7734 pixelSize:pixelSize |
7735 size:pointSize |
7735 size:pointSize |
7736 encoding:encodingMatch. |
7736 encoding:encodingMatch. |
7737 |
7737 |
7738 id isNil ifTrue:[ |
7738 id isNil ifTrue:[ |
7739 (encodingMatch notNil and:[encodingMatch ~= '*']) ifTrue:[ |
7739 (encodingMatch notNil and:[encodingMatch ~= '*']) ifTrue:[ |
7740 "/ too stupid: registries come in both cases |
7740 "/ too stupid: registries come in both cases |
7741 "/ and X does not ignore case |
7741 "/ and X does not ignore case |
7742 "/ |
7742 "/ |
7743 id := self |
7743 id := self |
7744 getFontWithFoundry:'*' |
7744 getFontWithFoundry:'*' |
7745 family:familyString asLowercase |
7745 family:familyString asLowercase |
7746 weight:faceString |
7746 weight:faceString |
7747 slant:xlatedStyle |
7747 slant:xlatedStyle |
7748 spacing:spacing |
7748 spacing:spacing |
7749 pixelSize:nil |
7749 pixelSize:nil |
7750 size:roundedSize |
7750 size:roundedSize |
7751 encoding:encodingMatch asUppercase. |
7751 encoding:encodingMatch asUppercase. |
7752 id isNil ifTrue:[ |
7752 id isNil ifTrue:[ |
7753 id := self |
7753 id := self |
7754 getFontWithFoundry:'*' |
7754 getFontWithFoundry:'*' |
7755 family:familyString asLowercase |
7755 family:familyString asLowercase |
7756 weight:faceString |
7756 weight:faceString |
7757 slant:xlatedStyle |
7757 slant:xlatedStyle |
7758 spacing:spacing |
7758 spacing:spacing |
7759 pixelSize:nil |
7759 pixelSize:nil |
7760 size:roundedSize |
7760 size:roundedSize |
7761 encoding:encodingMatch asLowercase. |
7761 encoding:encodingMatch asLowercase. |
7762 ] |
7762 ] |
7763 ] |
7763 ] |
7764 ]. |
7764 ]. |
7765 ^ id |
7765 ^ id |
7766 |
7766 |
7767 "Modified: 4.7.1996 / 11:38:47 / stefan" |
7767 "Modified: 4.7.1996 / 11:38:47 / stefan" |
7768 "Modified: 10.4.1997 / 19:20:06 / cg" |
7768 "Modified: 10.4.1997 / 19:20:06 / cg" |