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

Use modern X fonts instead of X core fonts #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nchataing
Copy link

This is an actualization of the patch proposed in #3 (first issued at ocaml/ocaml#4917), so all credit goes to the original author of the patch (Richard Jones).

I've adapted the machinery to link against the xft library in discover.ml, though I have no clue if this is the right way to do it (there may be some other things to tweak for the darwin target).

Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks nice so it should not sink into oblivion. I had a quick look and spotted a few oddities.

Comment on lines +17 to +27
| Some pc ->
let packages = [("x11","-lX11"); ("xft", "-lXft")] in
let cflags, libs =
packages
|> List.map (fun (package, fallback) ->
match C.Pkg_config.query pc ~package with
| None -> [], [fallback]
| Some { cflags; libs } -> cflags, libs)
|> List.split
in
List.concat cflags, List.concat libs
Copy link
Contributor

@xavierleroy xavierleroy Dec 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. pkg-config handles multiple package names just fine, e.g. pkg-config --libs xft x11 gives -lXft -lX11, no need for multiple invocations. But of cours Dune configurator doesn't support this.

The whole discover.ml file is an embarrassment. It would be 3 times shorter as a shell script.

Also: it would be prudent to link -lXft before -lX11, as the former certainly uses symbols from the latter.

XftDrawString8 (d, &xftcol, caml_gr_font,
caml_gr_x, Bcvt(caml_gr_y) - caml_gr_font->descent + 1,
(const FcChar8 *) txt, len);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing XftDrawDestroy(d); here?

visual, caml_gr_colormap);
XftDrawString8 (d, &xftcol, caml_gr_font,
caml_gr_x, Wcvt(caml_gr_y) - caml_gr_font->descent + 1,
(const FcChar8 *) txt, len);
Copy link
Contributor

@xavierleroy xavierleroy Dec 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing XftDrawDestroy(d); here?

XFlush(caml_gr_display);
}
caml_gr_x += XTextWidth(caml_gr_font, txt, len);

if (d) XftDrawDestroy (d);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This destroys one XftDraw object but two may have been created. Also, d is not initialized, if I'm not mistaken, so the if (d) test is weird.

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

Successfully merging this pull request may close these issues.

2 participants