Hacker News new | ask | show | jobs
by vidarh 952 days ago
I really should just reproduce that output in its entirety for direct comparison.

If it does not produce pixel for pixel identical output it's a bug. But here is the first pass of code that uses the same approach to integrate it with X and use Xrender to output the rendered glyphs:

https://github.com/vidarh/skrift-x11

(EDIT: Fixed the issue below) Note that the example contains a hard coded visual. I need to push a fix for that - it was last updated before I added support to the X11 client to look up the visual. In it's current form it probably won't work for you. Will see if I can push a fix for that today.

1 comments

nice! probably magenta on a red background is undesirable, though; maybe switch to colors with better contrasts, or add a border or drop shadow, or just postprocess with a zero-phase high-pass filter

i hate x11 visuals and in https://gitlab.com/kragen/bubbleos/blob/master/yeso/yeso-xli... i just assume that everything is 32-bit bgra. i need to get around to fixing that at some point

what do you think an idiomatic ruby binding for yeso would look like? so far i only have lua, c, and python bindings, which are described in https://gitlab.com/kragen/bubbleos/blob/master/yeso/README.m.... my ruby experience is both limited (only a few thousand lines of code) and over a decade ago

Yeah, the colour choices were pretty random, I need to clean it up.

X11 visuals are severely annoying. I get they made sense in the 80's and 90's - I spent time in computer labs where the machines ranged from monochrome to SGI Indy's, with 8-bit palette, and 15 and 16 bit direct color displays in between, but I'm all for just assuming 32-bit bgra is available these days.

Any server supporting XRender needs to support it anyway as it's one of the standard formats for XRender. (I don't know if you've looked at the XRender library code, though, but one of the things that made me facepalm was that even though it requires a handful of standard visuals, the new Xrender call that returns the visuals for Xrender does not just return a list of the handful of standard formats as part of the response - you need to filter the full list of visuals and match them to depths and bit masks... Not that it's a lot of code, but it just so aggravatingly pointless)

> what do you think an idiomatic ruby binding for yeso would look like?

I think a bit of a mix between the Python and Lua would get you pretty close. Don't look at "my" X11 client for idiomatic Ruby :) It was "inherited" from an older client, and it's very closely following the protocol more so than idiomatic Ruby, and I'll eventually try to massage it into something nicer.

To take your examples, we'd probably want to use blocks. E.g. I could see the munching squares example looking something like this in Ruby:

    def munch(t, fb)
      fb.each_row do |y|
         fb.each_col do |x|
            fb[x,y] = ...
         end 
      end
    end
You could also use the approach you use more directly, and I'm sure nobody would think that was weird either:

    def much (t,fb)
      fb.each_row do |y, p|
         fb.each_col do |x|
            p[x] = ...
         end
      end
  end
For the main bit, "new" will always directly return the window, but it's not unreasonable to then either `yield self if block_given?` in the constructor to allow similar code to your Python version:

    Yeso::Window.new(...) do |w| .. and so on; end
or wrap that in a class method:

     Yeso::Window.create(...) do |w|
        (0..).each {|t| w.frame {|fb| much(t,fb) } }
     end
(Endless infinite range is "new" since 2.6)

The class method vs. constructor only really buys you that you can make it slightly harder to accidentally keep the object around since you can prevent it from being directly returned. I think overall that's probably the most common approach even when the constructor supports taking a block directly.

this is motherfucking gold, thank you so much