-
Notifications
You must be signed in to change notification settings - Fork 28
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
Misaligned RTL Text #27
Comments
I also note that if I put this in the playground: <div style="direction: rtl; width: 200px;">أية تقنية متقدمة بما فيه الكفاية لا يمكن تمييزها عن السحر.</div> It is laid out visible, but the punctuation is still on the incorrect end: If I put |
Thanks for the debugging info. As you found out by looking at the playground, this is specific to the SVG painter, which I haven't tested as much as the canvas one. I think the The punctuation problem is similar, but for canvas. It needs to set (I hope it wasn't too much trouble to get a dropflow example running. I faced several pain points when reproing that; there's some rough edges to clean up with registering fonts at least.) |
Thanks for your response! Yes, I had some trouble getting DropFlow to load in a browser environment with respect to loading fonts. I discovered I couldn't load the fonts and import DropFlow in the same file, so I had to break it up into a loader, which is called when my app starts up: // loadDropFlow.ts
// LoadBuffer is implemented differently for my Jest/Node-based testing.
import { loadBuffer } from "./resourceUtils";
const dropFlowPrefix = import.meta.env.DEV
? ['node_modules', 'dropflow', 'dist']
: []; // Assumes dropflow is in the dist directory in production
import setBundleLocator from "dropflow/wasm-locator.js";
setBundleLocator(async () => {
console.log('Loading dropflow.wasm');
return await loadBuffer(dropFlowPrefix, 'dropflow.wasm')
.then((buffer) => new Uint8Array(buffer));
}); In my main startup resource loader, I import the above file, then do everything else. // Resources.ts
// This must be imported before the DropFlow API.
import "./loadDropFlow";
import * as flow from 'dropflow';
import { loadCanvasKit } from "./canvasKit";
import { fontsData, loadFontsData } from "./fontsData";
export async function loadResources(): Promise<void> {
await loadFontsData(['fonts']);
await Promise.all(fontsData.map(fontData => flow.registerFont(fontData.buffer, fontData.placeholderUrl)));
const canvasKitPrefix =
import.meta.env.DEV
? ['node_modules', 'canvaskit-wasm', 'bin']
: []; // Assumes canvaskit.wasm is in the dist directory in production
await loadCanvasKit(canvasKitPrefix);
} |
Follow-up: I didn't notice because I mostly test in node-canvas, which auto-detects the
Yeah, sorry about that. Having WASM dependencies is a bit of a pain still, and that's the best way I could find so people could just (mostly) |
going to use `direction` and `textAlign` to address #27
I am experimenting with this example of Arabic text:
Which is outputting the following SVG:
Which renders off the left side of the viewbox:
If I make the viewbox bigger:
I can see the full text, each line is laid out right to left correctly, but clearly the positioning is wrong.
If I remove the
white-space: pre; direction: rtl; unicode-bidi: bidi-override
directives:Then the text is properly right-aligned, but the second line's punctuation is on the wrong end.
Is this a bug or am I doing something wrong?
The text was updated successfully, but these errors were encountered: