#displayString: in CairoGraphicsContext revamped
Introduced a CairoScaledFont, a kind of FontDescription for Cairo fonts
(Cairo::ScaledFont / cairo_scaled_font_t). CairoScaledFont provides a bridge
between Smalltalk/X font API and Cairo the same way CairoGraphicsContext
provides a bridge bewtween Smalltalk/X drawing API and Cairo.
Don't use Cairo's "toy" text API to select font. Under X11, use FontConfig
to select a proper font. However, for actual text rendering and measurements,
Cairo's "toy" API is still used - it seems to be good enough, certainly as good
as Core X11 / Xft text rendering for Latin-based left-to-right languages.
At this point a TextEditView can be rendered using Cairo.
"{ Package: 'stx:goodies/libcairo' }"
"{ NameSpace: Cairo }"
CObject subclass:#FontFace
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Cairo-Objects'
!
!FontFace class methodsFor:'instance creation'!
fromFontDescription: aFontDescription
Screen current platformName == #X11 ifTrue:[
| pattern |
pattern := FcPattern fromFontDescription: aFontDescription.
^ CPrimitives cairo_ft_font_face_create_for_pattern: pattern.
].
self error: 'Noy yet implemented'.
"
Cairo::FontFace fromFontDescription: CodeView defaultFont
"
"Created: / 17-02-2016 / 20:01:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!FontFace class methodsFor:'accessing'!
dllPath
OperatingSystem isMSWINDOWSlike ifTrue:[
^ #( 'C:\Windows' 'C:\Windows\System32' "Wild guess, should not harm" )
].
OperatingSystem isUNIXlike ifTrue:[
OperatingSystem getSystemType == #linux ifTrue:[
| path |
path := #( '/lib' '/usr/lib' '/usr/local/lib' ).
(OperatingSystem getSystemInfo at:#machine) = 'x86_64' ifTrue:[
"If the machine is 64bit, prepend standard path for 32bit libs.
Leave standard paths at the end, as the system might be completely
32bit but running on 64bit-capable CPU.
CAVEAT: This is bit dangerous, as on 64bit OS, if ia32 libs are
not installed byt 64bit sqlite libs are, then 64bit libs are found
and when a function is called, segfault will occur!!
Q: Is there a way how to figure out if the OS itself is 32bit,
regardles on CPU?"
path := #( '/lib32' '/usr/lib32' '/usr/local/lib32' ) , path.
].
^path
].
].
self error:'Unsupported operating system'
"
SqliteLibrary dllPath
"
"Created: / 31-08-2011 / 18:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
sizeof
"Returns size of undelaying structure in bytes"
^0
! !
!FontFace methodsFor:'accessing'!
referenceCount
"Return value or reference counter"
^ CPrimitives cairo_font_face_get_reference_count: self
"Modified: / 17-02-2016 / 19:54:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
type
"This function returns the type of the backend used to create a font face.
See FontType for available types."
^ CPrimitives cairo_font_face_get_type: self
"Created: / 17-02-2016 / 19:54:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!FontFace methodsFor:'private'!
destroy
"Tell Cairo library to destroy the corresponding C object.
Remember that object is physically destroyed only if internal
refcounter goes to zero. However, after calling destroy,
this instance should be treated as invalid."
^ CPrimitives cairo_font_face_destroy: self
"Modified: / 17-02-2016 / 19:54:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!FontFace class methodsFor:'documentation'!
version
^'$Id$'
!
version_HG
^ '$Changeset: <not expanded> $'
! !