Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2020-08-16 19:52:53 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
79e7405ba017b06135314e0e943618c899fefc79
79e7405b
1 parent
5a760232
Add Directionality Widget
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
5 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/text.dart
pdf/lib/widgets/text_style.dart
pdf/pubspec.yaml
pdf/test/widget_table_test.dart
pdf/CHANGELOG.md
View file @
79e7405
# Changelog
## 1.1
0.2
## 1.1
1.0
-
Fix mixing Arabic with English
[
Anas Altair
]
-
Support Dagger alif in Arabic
[
Anas Altair
]
-
Support ARABIC TATWEEL
[
Anas Altair
]
-
Update Arabic tests
[
Anas Altair
]
-
Add Directionality Widget
## 1.10.1
...
...
pdf/lib/widgets/text.dart
View file @
79e7405
...
...
@@ -445,14 +445,13 @@ class RichText extends Widget {
RichText
(
{
@required
this
.
text
,
TextAlign
textAlign
,
TextDirection
textDirection
,
this
.
textDirection
,
bool
softWrap
,
this
.
tightBounds
=
false
,
this
.
textScaleFactor
=
1.0
,
int
maxLines
})
:
assert
(
text
!=
null
),
_textAlign
=
textAlign
,
textDirection
=
textDirection
??
TextDirection
.
ltr
,
_softWrap
=
softWrap
,
_maxLines
=
maxLines
;
...
...
@@ -486,6 +485,7 @@ class RichText extends Widget {
double
wordsWidth
,
bool
last
,
double
baseline
,
TextDirection
textDirection
,
)
{
double
delta
=
0
;
switch
(
textAlign
)
{
...
...
@@ -553,6 +553,8 @@ class RichText extends Widget {
_softWrap
??=
theme
.
softWrap
;
_maxLines
??=
theme
.
maxLines
;
_textAlign
??=
theme
.
textAlign
;
final
TextDirection
_textDirection
=
textDirection
??
Directionality
.
of
(
context
);
final
double
constraintWidth
=
constraints
.
hasBoundedWidth
?
constraints
.
maxWidth
...
...
@@ -583,7 +585,7 @@ class RichText extends Widget {
final
PdfFontMetrics
space
=
font
.
stringMetrics
(
' '
)
*
(
style
.
fontSize
*
textScaleFactor
);
final
List
<
String
>
spanLines
=
(
textDirection
==
TextDirection
.
rtl
final
List
<
String
>
spanLines
=
(
_
textDirection
==
TextDirection
.
rtl
?
PdfArabic
.
convert
(
span
.
text
)
:
span
.
text
)
.
split
(
'
\n
'
);
...
...
@@ -613,6 +615,7 @@ class RichText extends Widget {
style
.
letterSpacing
,
false
,
bottom
,
_textDirection
,
));
spanStart
+=
spanCount
;
...
...
@@ -676,6 +679,7 @@ class RichText extends Widget {
style
.
letterSpacing
,
true
,
bottom
,
_textDirection
,
));
spanStart
+=
spanCount
;
...
...
@@ -725,6 +729,7 @@ class RichText extends Widget {
offsetX
,
false
,
bottom
,
_textDirection
,
));
spanStart
+=
spanCount
;
...
...
@@ -782,6 +787,7 @@ class RichText extends Widget {
offsetX
,
true
,
bottom
,
_textDirection
,
));
bottom
??=
0.0
;
...
...
pdf/lib/widgets/text_style.dart
View file @
79e7405
...
...
@@ -380,3 +380,45 @@ class TextStyle {
String
toString
()
=>
'TextStyle(color:
$color
font:
$font
size:
$fontSize
weight:
$fontWeight
style:
$fontStyle
letterSpacing:
$letterSpacing
wordSpacing:
$wordSpacing
lineSpacing:
$lineSpacing
height:
$height
background:
$background
decoration:
$decoration
decorationColor:
$decorationColor
decorationStyle:
$decorationStyle
decorationThickness:
$decorationThickness
, renderingMode:
$renderingMode
)'
;
}
class
Directionality
extends
StatelessWidget
implements
Inherited
{
/// Creates a widget that determines the directionality of text and
/// text-direction-sensitive render objects.
///
/// The [textDirection] and [child] arguments must not be null.
Directionality
({
@required
this
.
textDirection
,
@required
this
.
child
,
})
:
assert
(
textDirection
!=
null
),
assert
(
child
!=
null
);
/// The subtree
final
Widget
child
;
/// The text direction for this subtree.
final
TextDirection
textDirection
;
/// The text direction from the closest instance of this class that encloses
/// the given context.
///
/// If there is no [Directionality] ancestor widget in the tree at the given
/// context, then this will return TextDirection.ltr.
///
/// Typical usage is as follows:
///
/// ```dart
/// TextDirection textDirection = Directionality.of(context);
/// ```
static
TextDirection
of
(
Context
context
)
{
final
Directionality
widget
=
context
.
inherited
[
Directionality
];
return
widget
?.
textDirection
??
TextDirection
.
ltr
;
}
@override
Widget
build
(
Context
context
)
{
return
InheritedWidget
(
build:
(
context
)
=>
child
,
inherited:
this
,
);
}
}
...
...
pdf/pubspec.yaml
View file @
79e7405
...
...
@@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
1.1
0.2
version
:
1.1
1.0
environment
:
sdk
:
"
>=2.3.0
<3.0.0"
...
...
pdf/test/widget_table_test.dart
View file @
79e7405
...
...
@@ -24,6 +24,8 @@ import 'package:test/test.dart';
import
'package:pdf/pdf.dart'
;
import
'package:pdf/widgets.dart'
;
import
'utils.dart'
;
Document
pdf
;
List
<
TableRow
>
buildTable
(
...
...
@@ -232,6 +234,25 @@ void main() {
));
});
test
(
'Table fromTextArray with directionality'
,
()
{
pdf
.
addPage
(
Page
(
theme:
ThemeData
.
withFont
(
base:
loadFont
(
'hacen-tunisia.ttf'
),
),
build:
(
Context
context
)
=>
Directionality
(
textDirection:
TextDirection
.
rtl
,
child:
Table
.
fromTextArray
(
headers:
<
dynamic
>[
'ثلاثة'
,
'اثنان'
,
'واحد'
],
cellAlignment:
Alignment
.
centerRight
,
data:
<
List
<
dynamic
>>[
<
dynamic
>[
'الكلب'
,
'قط'
,
'ذئب'
],
<
dynamic
>[
'فأر'
,
'بقرة'
,
'طائر'
],
],
),
),
));
});
tearDownAll
(()
{
final
File
file
=
File
(
'widgets-table.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
...
...
Please
register
or
login
to post a comment