Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Graphics module use modern X fonts instead of X core fonts #4917

Closed
vicuna opened this issue Nov 12, 2009 · 4 comments
Closed

Make Graphics module use modern X fonts instead of X core fonts #4917

vicuna opened this issue Nov 12, 2009 · 4 comments

Comments

@vicuna
Copy link

vicuna commented Nov 12, 2009

Original bug ID: 4917
Reporter: Richard Jones
Status: acknowledged (set by @damiendoligez on 2009-12-08T16:33:11Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.11.1
Category: otherlibs
Tags: patch
Monitored by: mehdi @glondu @hcarty @Chris00

Bug description

X 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-....")

File attachments

@vicuna
Copy link
Author

vicuna commented Nov 12, 2009

Comment author: Richard Jones

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.

@vicuna
Copy link
Author

vicuna commented Nov 12, 2009

Comment author: @johnwhitington

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.

@vicuna
Copy link
Author

vicuna commented Nov 12, 2009

Comment author: Richard Jones

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

@nojb
Copy link
Contributor

nojb commented Mar 15, 2019

The graphics library has been split off the compiler codebase: https://github.com/ocaml/graphics
This issue has been re-submitted there: ocaml/graphics#3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants