Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004917OCamlOCaml otherlibspublic2009-11-12 18:012013-11-05 16:16
ReporterRichard Jones 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version3.11.1 
Target VersionFixed in Version 
Summary0004917: Make Graphics module use modern X fonts instead of X core fonts
DescriptionX core fonts have been deprecated for many years. Fedora are trying to identify pieces of software which still use X core fonts and could be changed to use modern X fonts (based on Xft and FontConfig). The OCaml Graphics module is one such place.

The attached patch changes the Graphics module to use modern X fonts. The changes are relatively simple - changing calls such as XDrawString to use the Xft equivalent (XftDrawString8).

One immediate advantage is that Graphics users will see anti-aliased fonts.

Another advantage is that Graphics users can specify font names like "Times-12" instead of the massive and incomprehensible XLFD strings ("-*-times-*-r-....")
Tagspatch
Attached Filespatch file icon 0001-Graphics-Use-modern-X-fonts-instead-of-X-core-fonts.patch [^] (9,122 bytes) 2009-11-12 18:01 [Show Content]
patch file icon 0001-Graphics-Use-modern-X-fonts-instead-of-X-core-fonts-2.patch [^] (9,164 bytes) 2009-11-12 18:33 [Show Content]

- Relationships

-  Notes
(0005158)
Richard Jones (reporter)
2009-11-12 18:34

I don't know how to delete files in Mantis.

The first version of the patch contained a memory leak in caml_gr_draw_text. The second version corrects this.
(0005159)
johnwhitington (reporter)
2009-11-12 20:09

One of the reasons against adding anti-aliased primitives without a configuration option is that invalidates invariants like the ability to blank out a primitive after having plotted it by plotting the same primitive in the background colour, and people reading colours at a point from the image and relying on the result.

So if we're going to go down this route without breaking existing programs, there should be a configuration option in the Graphics module to enable the antialiasing.
(0005160)
Richard Jones (reporter)
2009-11-12 21:35
edited on: 2009-11-12 21:37

John is correct that with antialiasing you cannot overwrite a string with the background colour and expect that it will completely disappear (instead you will see that the outline of the font remains).

However with FontConfig it's very easy to select non-antialiased fonts. Just add ":antialias=false" to the end of the font name, as in the example program below:

open Graphics

let () =
  open_graph " 200x150";
  set_font "Liberation-18:antialias=false";
  moveto 20 20;
  set_color red;
  draw_string "Hello, world!";
  moveto 20 20;
  set_color white;
  draw_string "Hello, world!";
  ignore (read_line ())

A full list of FontConfig properties is here:
http://www.fontconfig.org/fontconfig-user.html [^]


- Issue History
Date Modified Username Field Change
2009-11-12 18:01 Richard Jones New Issue
2009-11-12 18:01 Richard Jones File Added: 0001-Graphics-Use-modern-X-fonts-instead-of-X-core-fonts.patch
2009-11-12 18:33 Richard Jones File Added: 0001-Graphics-Use-modern-X-fonts-instead-of-X-core-fonts-2.patch
2009-11-12 18:34 Richard Jones Note Added: 0005158
2009-11-12 20:09 johnwhitington Note Added: 0005159
2009-11-12 21:35 Richard Jones Note Added: 0005160
2009-11-12 21:36 Richard Jones Note Edited: 0005160
2009-11-12 21:37 Richard Jones Note Edited: 0005160
2009-12-08 17:33 doligez Status new => acknowledged
2013-09-04 18:16 doligez Tag Attached: patch
2013-11-05 16:16 lpw25 Category OCaml general => OCaml otherlibs


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker