Comments (18)
This is still important, but text layout has unfortunately taken precedence due to other interested parties that are making use of the crate. If you want to have a go at it, that sounds great! My plan is to essentially use the HarfBuzz test suite as is, so the first step is to write a parser for the test data to extract the fonts, input text and expected output glyph sequences. I don't recall if the test data contains the associated script. If not, you'd need to detect the dominant script in the input text. Then it's just a matter of loading the font, running the shaper and comparing the results.
I don't have a lot of time to devote to this at the moment, but am happy to provide assistance when I am able.
from swash.
It's only a draft PR, so it may end up being that original 8-10 week estimate to get it merged :P
from swash.
No worries. If you're not done by time it rolls around on my schedule, we'll finish it up together. Then comes the challenge of fixing all the bugs that the tests are sure to reveal. I know HarfBuzz has some per-script special casing for ZWJ/ZWNJ that I haven't accounted for so I'm hoping that pops up in some of the tests. There were also comments about tricky bits with some Arabic ligatures, but my ligature handling code is quite different from what HarfBuzz does so I'm curious to see if it catches the edge cases. We'll see how it fares.
from swash.
Realized I had written this code in an earlier rev, so just copied it over and pushed to master. FontRef
now has a hidden glyph_name
function that takes a GlyphId
and returns Option<&'a str>
. I believe HarfBuzz uses gid<id> for missing names.
from swash.
Progress update: I've begun working out the beginnings of the generate_tests
tool. I hope (fingers crossed) that I will be able to get text-rendering-tests
complete tomorrow.
@dfrg I don't quite understand the output format used in this test, any idea as to what they could mean?: https://github.com/harfbuzz/harfbuzz/blob/main/test/shaping/data/text-rendering-tests/tests/MORX-11.tests
[B|A@650,0|B@1288,0|B@1938,0|A@2588,0|X@3226,0|A@3812,0|B@4450,0]
Edit: Nevermind, I believe I found what it means: https://github.com/RazrFalcon/rustybuzz/blob/8a138b1843dcb967b785510e80dc38c4d6c319cf/src/buffer.rs#L1702
from swash.
Just a note that HarfBuzz seems to be accumulating advances into offsets here. I'm not sure if that is done for all of the tests.
I hacked together a small harness for this and an initial run through the shaper yields:
[B@0,0+650|A@0,0+638|B@0,0+650|B@0,0+650|A@0,0+638|X@0,0+586|A@0,0+638|B@0,0+650]
And if I accumulate advances:
[B|A@650,0|B@1288,0|B@1938,0|A@2588,0|X@3226,0|A@3812,0|B@4450,0]
Which matches the expected output.
The source text here is "BABBAABX" and the resulting glyphs are "BABBAXAB". This is a fairly odd use of the rearrangement mechanism in the AAT extended metamorphosis table that revealed two bugs. Both are "fixed" but might need some more work if there are real fonts that do this sort of thing. Notably, this font probably breaks text selection on macOS. Looks like we're in for a bumpy ride :)
from swash.
Note: rustybuzz is a direct port of harfbuzz. So its not surprising that they could just lift the test suite directly
from swash.
I am actually going to begin investigating this in the next few hours because I believe it is vitally important now that this crate is released. I will leave this issue open and report back here on progress.
from swash.
Small update on this. I've spent some time with the HarfBuzz test suite and developed a plan for moving forward. I won't try to predict a timeframe, but this issue is fairly high priority for everyone that has expressed interest in using this crate for shaping so it will be receiving a high proportion of my attention.
from swash.
Small update on this. I've spent some time with the HarfBuzz test suite and developed a plan for moving forward. I won't try to predict a timeframe, but this issue is fairly high priority for everyone that has expressed interest in using this crate for shaping so it will be receiving a high proportion of my attention.
If you're interested, I could try implementing it if you don't mind giving a rundown on how you planned on doing it.
from swash.
Gotcha, I'll work on it as soon as I'm able.
from swash.
After some poking around with HarfBuzz, RustyBuzz, and Swash, I think I have a good idea on how to proceed from here. Since I know absolutely nothing about shaping, I'll estimate it'll take me 1-2 weeks to get a draft PR submitted (though with anything, prepare to add 1 or 2 weeks to that estimate :-) ). I was keen on learning shaping anyway, so I'm excited to start working on this.
from swash.
Brilliant!
Tackling this was about 8-10 weeks out for me, so no rush at all. As for shaping, enjoy your journey down the rabbit hole. I took the tumble almost two years ago now and haven't hit the bottom yet :)
from swash.
@dfrg I've begun researching what I need to create the tests, and I've hit an obstacle with figuring out how to get the glyph name from a GlyphId
in swash
. Is there a method or function somewhere I missed?
Edit:
The more I look into it, it seems like that's being deferred to a higher-level API? I might have to figure out how to do it then, thankfully Microsoft's documentation is really good.
from swash.
Good catch. I didn't want to provide glyph names as public API because they're not useful in the context of font rendering, but I'll throw together some quick code to parse them from the post
table and expose it under some doc(hidden) function to be used for the tests.
from swash.
Awesome!
from swash.
Hi Kirawi,
I am interested in testing swash, what's about your testing tool? If I can help you anything, please let me know.
Thanks,
from swash.
It was already merged #19, but @dfrg is continuing to work on it I believe.
from swash.
Related Issues (20)
- AAT ligatures HOT 1
- Subpixel Format Rendering? HOT 2
- Extract text analysis code into separate crate HOT 1
- Add support for COLRv1 HOT 1
- Implement a reference rasterizer for COLRv1 outlines HOT 2
- expose the panose subfield for detecting the GenericFamily in fount HOT 1
- Testing swash
- 🤖 and 🪵 are rendered incorrectly it would seem HOT 7
- Some fonts are rasterised very small
- Cannot render `U+1FB87 : RIGHT ONE QUARTER BLOCK` HOT 1
- i is not rendered properly when using JetBrains Mono HOT 1
- Support for CFF seac / enchar
- Rust Nightly 4-1-2023 and forward breaks swash. HOT 2
- Use ttf-parser for font parsing HOT 5
- How is unicode_data.rs generated? HOT 1
- "Panic: misaligned pointer reference" in rustc 1.70.0 HOT 3
- CharMap does not include substitutions
- Expose public C/C++ API
- Documentation: what does "code units" means? HOT 1
- crate-private type `Outlines<'_>` in public interface HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swash.