• 0 Posts
  • 328 Comments
Joined 2 years ago
cake
Cake day: September 2nd, 2023

help-circle



  • I’ve got all that. I just needed to convert a string of characters into a list of glyph IDs.

    For context, I’m doing a code editor.

    I don’t use harfbuzz for shaping or whatever, since I planned on rendering single lines of mono spaced text. I can do everything except string->glyphs conversion.

    Just trying to implement basic features such as ligatures is incredibly hard, since there’s almost no documentation. Therefore you can’t make assumptions that are necessary to take shortcuts and make optimizations. I don’t know if harfbuzz uses a source of documentation that I haven’t been able to find, or maybe they are just way smarter than me, or if fonts are made in a way that they work with harfbuzz instead of the other way around.

    As someone trying to have as little dependencies as possible, it is a struggle. But at the same time, harfbuzz saved me soo much time.

    EDIT: I don’t do my own glyph rasterization, but that’s because I haven’t gotten to it yet, so I do use a library. I don’t know if it’s going to be harder than string->glyphs, but I doubt so.


  • You can’t shrink the yardstick down to an infinitesimal size.

    Coastlines are not well defined. They change in time with tides and waves. And even if you take a picture and try to measure that, you still have to decide at what point exactly the sea ends and the land starts.

    If the criteria for that is “the line is where it would make a fractal” then sure, by that arbitrary decision, it is infinite. However, a way better way to answer the question “where is the line” is to just decide on a fixed resolution (or variable if you want to get fancy), which makes the distinction between sea and land clearer.

    It is like saying that an electron is everywhere in the universe, because of Heisenberg’s uncertainty principle. While it is very technically true, just pick a resolution of 1mm^3 and you know exactly where the electron is.



  • I’ve read a lot of people saying “oh what a horror, they used unwrap in production, they should NEVER do that”. But I don’t think that’s true at all.

    1. The rust type system is not 100% flawless. For example you have a mathematically proven never-errors algorithm, but inside some steps have provisional Nones. At the end you just unwrap, since there’s no point in changing the return type to an option to handle a non-existent error. You can’t represent “this is None but I promise that it won’t by the end” in rust’s type system.
    2. Sometimes it’s not worth handling the error. For example a simple CLI tool, just throw expects everywhere that shows why it failed, since most CLI tools just close anyway on failure, might as well panic.

    That being said, this was clearly a case where ? should have been used, since the function has a clear error case. And it also is a critical application that can’t afford panicking as an error handling method.

    EDIT: Just to clarify, the way you would do this is by having a type Features that can error on creation/parsing which has a limit of 200 entries. And afterwards you can just use that type knowing that it will always have <= 200 entries. And you gracefully handle that one error case on creation/parsing.

    EDIT2: Another point for why I disagree with “production should never have unwrap”:

    1. Unwrap is basically the same as assert(my_variable.is_some). I don’t know a single person that would say “you should never have asserts in production code”, the only reason I disable some assertions for release builds is for performance. Asserts are statements that should never do anything, by that logic they pose no harm by being there, so no need to remove them, their only effect should be wasting a few CPU cycles. Since asserts are only put when the programmer assures that a certain precondition will always be met. And if it is not, it’s because the code changes and automatic tests should catch that.

  • I cannot comprehend what the fuck harfbuzz does.

    I tried to implement my own because “I don’t need all the features, I’m gonna render self-to-right western text with very few font features”. But holly fuck, the font format documentation is barely non-existent. And when I tried my naive solution it was like 10000x (or more) slower than harfbuzz.





  • It’s not one thing or the other.

    For example I often end up using event loops. Where an event is a tagged union. Some events take up 1 byte, some 400. It’s almost effortless to put the big variants in the heap, and just keep a pointer in the union. So why not do it from the start.

    Sure, optimizing every loop to make it vectorizable is probably not worth it, since that loop you wrote on the 10th commit might not even exist when the software is released. But there are many low hanging fruit.

    Also, some optimizations require a very specific software architecture. Turning all your arrays of structs into structs of arrays may be a pain if you didn’t plan for making that switch.



  • I don’t understand why any user would have to care or even know what GUI toolkit an app uses.

    I don’t know why the burden is put on the user/DE. You shouldn’t have to care about what GUI toolkit your DE uses either.

    DE and themes should be decoupled from eachother. So the user can install whatever “theming system” they want, and GUI toolkits should aim to support as many theming systems as practical.

    GUI toolkits are implementation details, the user doesn’t care about implementation, it cares about what it sees. And what it sees is the colors and icons.