-
-
Notifications
You must be signed in to change notification settings - Fork 598
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
RTL and Script Unicode Font (ttf), and ligatures not supported #198
Comments
Sorry, I don't really see what's wrong in the rendering. I don't read Bengali and can't really spot the missing features. |
Similar Problem is mentioned here .. But its for PHP pdf generation lib. https://stackoverflow.com/questions/32421564/bangla-unicode-font-not-rendering-correctly-in-tcpdf |
Ok, I guess it's about GSUB support for OTF fonts: |
I guess so. https://docs.microsoft.com/en-us/typography/script-development/bengali This is the problem I am getting whats left side fo |
@DavBfr i tried the |
No, the arabic-fonts branch uses some specific character replacement for Arabic only. GSUB is not yet implemented. If you're willing to implement it in ttf_parser.dart I'll be happy to help. Try something like this: diff --git a/pdf/lib/src/ttf_parser.dart b/pdf/lib/src/ttf_parser.dart
index 3108a48..fc7cce0 100644
--- a/pdf/lib/src/ttf_parser.dart
+++ b/pdf/lib/src/ttf_parser.dart
@@ -54,6 +54,9 @@ class TtfParser {
_parseCMap();
_parseIndexes();
_parseGlyphs();
+ if (tableOffsets.containsKey(gsub_table)) {
+ _parseGsub();
+ }
}
static const String head_table = 'head';
@@ -64,6 +67,7 @@ class TtfParser {
static const String maxp_table = 'maxp';
static const String loca_table = 'loca';
static const String glyf_table = 'glyf';
+ static const String gsub_table = 'GSUB';
final UnmodifiableByteDataView bytes;
final Map<String, int> tableOffsets = <String, int>{};
@@ -368,4 +372,20 @@ class TtfParser {
components,
);
}
+
+ void _parseGsub() {
+ print(fontName);
+ print(tableOffsets);
+
+ final int basePosition = tableOffsets[gsub_table];
+ print('GSUB Version: ${bytes.getUint32(basePosition).toRadixString(16)}');
+ final int scriptListOffset =
+ bytes.getUint16(basePosition + 4) + basePosition;
+ final int featureListOffset =
+ bytes.getUint16(basePosition + 6) + basePosition;
+ final int lookupListOffset =
+ bytes.getUint16(basePosition + 8) + basePosition;
+ print(
+ 'GSUB Offsets: $scriptListOffset $featureListOffset $lookupListOffset');
+ }
} And see if your font contains any useful information. |
I am ready to implement it. Just tell me what to write ? It would be better if you could show me for just one character as example and where can i find the position to complete the rest then i can complete it. I am totally new to this. |
@DavBfr this is what i found running the code above. Whats next ?
|
Using this site called FontDrop I can see the following... Could it help implement the parser? If so then can you just guide me how to implement it ? |
This site is really useful, thanks! So the first step is to parse this GSUB table to find all the lookups. Then I think when you have this: {
"ligGlyph": 237,
"components": [
102,
86
]
} if we want to draw the glyphs 102 and 86 next to eachother, we replace with 237 |
I think the tables to read for your issue is the Ligature Substitution Subtable: Only one format, that should not be too difficult. |
Thank you for your ans. I am starting to understand how this works but I am totally new to this and have no idea about the variables in the parser. Can you just write a function or a bloc of code just to parse this as an example
maybe after that i can follow that code and implement the rest ? |
If you look at _parseGlyphs() in the same file, it will look the same: In the function The first to parse is the featureList described here: and get all the features with the right tag, maybe https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#blws Then the lookupList will give the right glyphs to replace. |
Is there any chance you can add this feature soon ? I badly need this :( . Since i have no idea on the variable used in the parsing and how it works i think i wont be able to help much. Eagerly waiting for your answer on this. Please, can find some of your spare time to add this feature ? Or Milestone ? |
@DavBfr what functions to use for find and replace the glyphs
I could not find any substitution function in |
how can i help you guys ? |
I think all the needed info is on this ticket. I don't have time to work on this now. Unless some of you are willing to pay for the feature. Then I could take a look at crowdfunding. This also includes Arabic and other languages. |
@DavBfr Hi, I'm able to prepare featureList , what to do next? should I prepare lookup table? |
Yes, the lookup table is next. |
Sure, :), I'm stuck at subtable parsing in lookup table. |
I am also facing same problem while generating PDF. Bangla Unicode Characters are broken. |
https://github.com/anandsubbu007/anand-work/tree/BLOC/tamil_pdf |
@anandsubbu007 - Thanks much Anand. This works nicely.. Really appreciate your response!.. I will do more testing and will share comments if any. |
If possible to introduce the person to me who wrote this will be great, We really need the support for 6 Pashto special characters. |
Use |
Please, check Gujarati font as well, I'm using google gujarati font(Noto Serif Gujarati).. there is the string on-screen is લોગિન and when I print in pdf it becomes લોગનિ |
How will this help me? |
hello @DavBfr DavBfr Any new update to fix this issue ?! and please let us know how can help you to fix it... Thanks |
@AkamBarznji I'm not working on this, I'll let native writers improve on this. I'll not try to fix something I don't understand. |
@DevBfr
We really need a fix for this
If its not possible to be fixed in Text Widget
Please create a new widget and name it something like LocaleText which
shall have support for all languages
Or
Have parameter for unicodes so developers can pass unicode of thier
langiage as parameter
…On Tue, Oct 11, 2022, 12:37 AM David PHAM-VAN ***@***.***> wrote:
@AkamBarznji <https://github.com/AkamBarznji> I'm not working on this,
I'll let native writers improve on this. I'll not try to fix something I
don't understand.
—
Reply to this email directly, view it on GitHub
<#198 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIUFLXGXHDXRY6AOZPXO2N3WCRZRVANCNFSM4KBO5LTQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Seemingly Hebrew has the range \u0590-\u05fe according to this nice JavaScript Unicode Regex generator: So we can use this to find and reverse Hebrew only from any given string. Here is the perfect working example: String reverseHebrew(String text) { |
For printing Bangla font use this method:
final font = await rootBundle.load("fonts/SiyamRupaliANSI.ttf");
pw.Text( "e‡Kqv", style: pw.TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
font: Font.ttf(font),
), |
This will help https://www.youtube.com/watch?v=LLBoRBAQIw0 |
same issue in myanmar unicode font |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
Still same problem available in kurdish language also |
Closing this stale issue because it has no activity. |
And this problem is yet not solved ? |
how could you prepare feature list please, can you give some illustrations .. thanks |
how to use urdu font family |
i have a problem in my code when i use urdu language word then the dependency which is use has give me the whole world seperate this is my code pdfWid.Text( |
i have a problem in my code when i use urdu language word then the dependency which is use has give me the whole world seperate this is my code pdfWid.Text( |
As this issue still not resolved, Please report this issue to flutter so they can develop this. |
Use Vazirmatn font will help you |
hello @DavBfr When this issue will be fixed ? |
@rabadiaanurag I won't be working on RTL and Script support. If someone wants to work on it, they can provide a PR. I'm only working on this package on my free time. |
Describe the bug
Bangla Unicode Fonts gets Broken after generation of the PDF. The Unicode font works well in web. But its got broken when
I made a repository to demonstrate the problem. ( font included ). I have tried with 12 different Bangla Unicode font. Same result for all.
Just run the program and you will see that the String in
Text
widget didnt get rendered properly.https://github.com/sh0umik/flutter_pdf_test.git
Expected behaviour
Expected behaviour is exactly like the test in
Text
widgetScreenshots
Got this (broken)
Expected this
Flutter Doctor
Paste the output of running
flutter doctor -v
here.Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Many thing on my flutter web app depends on this plugin. Need to find a solution ASAP.
Also i am converting the pdf.save() into a Uint8List so that it could be sent through firebase.
Could this be a problem ? List to Uint8List conversation ?
The text was updated successfully, but these errors were encountered: