question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

non-latin font (Persian fonts) upside-down

See original GitHub issue

I did try register Persian fonts, everything looks fine unless text gets larger than one line. this is my codes:

mock text:

export const data = {
    text_persian: 'لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است. چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است و برای شرایط فعلی تکنولوژی مورد نیاز و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد.',
    text_english: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.',
};

and this is my template:

import React from 'react';
import { data } from './mock';
import { Page, Text, View, Document, StyleSheet } from '@react-pdf/renderer';

const styles = StyleSheet.create({
    page: { fontFamily: "iransans" },
    textRight: { textAlign: 'right' },
});

export function invoicePdfTemplate() {
    return (
        <Document>
            <Page size="A4" style={styles.page}>
                <View>
                    <Text>
                        {data.text_english}
                    </Text>
                    <Text style={styles.textRight}>
                        {data.text_persian}
                    </Text>
                </View>
            </Page>
        </Document>
    )
}

and this is the final result: image

the problem is in Persian font if the text gets larger than a line, it will be rendered upside-down

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
diegomuracommented, Jun 2, 2021

I have some progress made on supporting RTL text using the style direction: rtl although it’s not yet finished. I’m clos to, but need more time unfortunately, which I lack lately 😅 Will post updates as soon as I have them

1reaction
hrkazemicommented, Jul 30, 2020

I should mention that registering font, works fine (both URL and import).

import React from 'react';
import { PDFDownloadLink, Font } from '@react-pdf/renderer';
import { invoicePdfTemplate } from './pdfTemplate';
import font from './IRANSansWeb.ttf'

Font.register({
    family: "iransans",
    format: "truetype",
    // src: `${process.env.PUBLIC_URL}/static/fonts/IRANSansWeb.ttf`
    src: font
});

export class Gholi extends React.Component{
    render() {
        return <PDFDownloadLink document={invoicePdfTemplate()} fileName={`invoice-1.pdf`}>
            {({ blob, url, loading, error }) => {
                return <>{(loading ? 'Loading...' : 'Download now!')}</>;
            }}
        </PDFDownloadLink>
    }
}

the only problem is when the text gets larger than one line

Read more comments on GitHub >

github_iconTop Results From Across the Web

non-latin font (Persian fonts) upside-down - Bountysource
I did try register Persian fonts, everything looks fine unless text gets larger than one line. this is my codes: mock text:
Read more >
Persian fonts looks ugly : r/linuxquestions - Reddit
Hi, I just installed Arch in my machine every thing is good but Persian fonts just looks really ugly. screenshot.
Read more >
Quirkus Upside Down font - Fonts2u
Font family. Quirkus Upside Down. Font subfamily. Regular. Unique subfamily identification. Quirkus Upside Down: 2009. Full font name. Quirkus Upside Down.
Read more >
Upside down, backwards letters and symbols
Upside down font generator. Just type something in and this generator is going to flip and reverse your text characters upside down and...
Read more >
Can I use a font for English text, and another font for Arabic ...
If this is for a web project, you can just put both fonts in your font stack: font-family: EnglishFont, ArabicPersianFont, sans-serif;.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found