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

Glyph atlas preparations #18

Merged
merged 20 commits into from
Feb 27, 2019
Merged

Glyph atlas preparations #18

merged 20 commits into from
Feb 27, 2019

Conversation

manu-unter
Copy link
Collaborator

@manu-unter manu-unter commented Jan 26, 2019

This PR is required for revery-ui/revery#53

TODO: Fixate minimum reason-glfw version once we know it, i.e. after https://github.com/bryphe/reason-glfw/pull/87 has been merged

  • Migrate glyph rendering to Bigarray.Array2s to allow access to the raw pixels
  • Bring native and JS dummy font rendering closer together

Note: There is currently a big difference between native and JS glyph rendering! The JS bindings will create RGBA glyphs while the native bindings create ALPHA-only bitmaps. I adapted the consuming code in revery's GlyphAtlas to use them accordingly but we should probably align the two versions ASAP. That along with subpixel-rendering and the corresponding shaders.

@@ -37,7 +47,8 @@ let run = () => {
glfwMakeContextCurrent(w);
glViewport(0, 0, 800, 600);

let%lwt font = Fontkit.load("Roboto-Regular.ttf", 24);
let%lwt font =
Fontkit.load(getExecutingDirectory() ++ "Roboto-Regular.ttf", 24);
Copy link
Member

Choose a reason for hiding this comment

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

So nice to be able to use esy x for this too, nice!

FT_Bitmap bitmap = face->glyph->bitmap;
int bitmapDataLength = bitmap.rows * abs(bitmap.pitch);
bitmapBigarray = caml_ba_alloc_dims(CAML_BA_UINT8 | CAML_BA_C_LAYOUT, 2, NULL, bitmap.rows, abs(bitmap.pitch));
memcpy(Caml_ba_data_val(bitmapBigarray), (const char *)bitmap.buffer, bitmapDataLength);
Copy link
Member

Choose a reason for hiding this comment

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

Excellent! That's great that we can copy directly into the Bigarray buffer vs allocated an extra one. Nice find 👍

@@ -1,18 +0,0 @@

extern "C" {
Copy link
Member

Choose a reason for hiding this comment

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

Ah this was duplicated between the projects - nice to see it go away!

* API: Add 'fk_get_metrics' API (#20)

Add 'fk_get_metrics' API

* 2.1.0

* Upgrade reason-glfw -> 3.2.1015 (#21)

* Use hb_blob_create_from_file for mmap file reading (#19)

Not tested locally however.

* 2.2.0

* Add /opt/local/lib to link path (#22)

* 2.2.1

* Update fontkit.cpp

* Bring back iSize

* Debugging

* Get working on Windows

* Add bitmap back
@bryphe
Copy link
Member

bryphe commented Feb 27, 2019

Thanks for your work here, @manuhornung !

@bryphe bryphe merged commit 736964a into master Feb 27, 2019
@bryphe bryphe deleted the glyph-atlas-preparations branch February 27, 2019 01:19
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