Faculty of Information Technology
Software Engineering Group

Opened 9 years ago

Last modified 9 years ago

#21 new todo

Better font rendering on X

Reported by: Jan Vrany Owned by:
Priority: major Milestone:
Component: default Keywords:
Cc: Also affects CVS HEAD (eXept version): no

Description

On X Window, an ancient core X API is used to draw text. The result is bad as it has no support for freetype fonts, antialiasing, hintting and so on.

While the best would be yo use PANGO library, this is quite some work.

As an transitional solution one may use Xft library. The idea here is to
create a special XftFont class and use custom font rendering (simular to BitmapFont?). Later on, the support could be merged right into XWorkstation.

Attachments (1)

XWorkstation-with-xft.st (291.9 KB) - added by Jan Vrany 9 years ago.
An old attemt to use Xft in XWorkstation.st

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by Jan Vrany

Attachment: XWorkstation-with-xft.st added

An old attemt to use Xft in XWorkstation.st

comment:1 Changed 9 years ago by Jan Vrany

Recent CVS contains a new class XftFontDescription (unfinished). To compile stx:libview with Xft support, add following to the end of stx/configurations/myConf:

XDEFS+=-DXFT
XINCLUDE+=$(shell pkg-config --cflags xft)
LIB_XFT=-l:libXft.so.2 -l:libfontconfig.so.1

comment:2 Changed 9 years ago by Jan Vrany

Type: defecttodo

comment:3 Changed 9 years ago by Jan Vrany

As of XftFontDescription 1.10 whole IDE could be switched to Xft fonts usinf following code:

View defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
Label defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
CheckBox defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
CheckLabel defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
Button defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
Toggle defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
SelectionInListView defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
MenuView defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
MenuPanel defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
NoteBookView defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
PullDownMenu defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
TextView defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
EditTextView defaultFont: (XftFontDescription family: 'DejaVu Sans' size: 10).
CodeView defaultFont: (XftFontDescription family: 'DejaVu Sans Mono' size: 10).
Tools::CodeView2::TextView defaultFont: (XftFontDescription family: 'DejaVu Sans Mono' size: 10).

comment:4 Changed 9 years ago by Jan Vrany

A short document describing how to enable Xft rendering on recent jv-branch builds.

comment:5 Changed 9 years ago by Jan Vrany

Next steps:

  • Test current implementation.
  • Code cleanup.
  • Write code to list fonts Xft/fontconfig fonts (meanwhile, use fc-list command.
  • Integrate Xft fonts to Font/XWorkstation and add a preference (one still may want to use core X fonts when running X over slowww line.

It may be handy to keep XftDraw instances per GraphicsContext instead of
keeping it in XftFontDescription and changing underlying Drawable. There are two
ways how to do it:

  1. Add new instvar to GraphicsContext or similar - this would require to increase major version number as compiled class libs will no longer be binary-compatible.
  2. Instead of keeping ExternalAddress pointing to X {{GC}}} in DeviceGraphicsContext.gcId, keep a special object, say XWorkstation:: DeviceGraphicsContextHandle with pointer to X {{GC}} and possibly to XftDraw.

Comment on Cairo: once (if ever) whole rendering is switched to Cairo, whole Xft stuff will be thrown away. However, we will then use slot for XftDraw to keep reference to cairo_t or cairo_surface_t.

Note: See TracTickets for help on using tickets.