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
2019-04-06 14:59:10 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d031f7c61317a334fdfccbbbbe676beb36efd442
d031f7c6
1 parent
320b5b8d
Add Font::toString()
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
18 deletions
pdf/lib/widgets/font.dart
pdf/lib/widgets/font.dart
View file @
d031f7c
...
...
@@ -60,26 +60,27 @@ class Font {
final
Type1Fonts
font
;
static
const
Map
<
Type1Fonts
,
String
>
_type1Map
=
<
Type1Fonts
,
String
>{
Type1Fonts
.
courier
:
'Courier'
,
Type1Fonts
.
courierBold
:
'Courier-Bold'
,
Type1Fonts
.
courierBoldOblique
:
'Courier-BoldOblique'
,
Type1Fonts
.
courierOblique
:
'Courier-Oblique'
,
Type1Fonts
.
helvetica
:
'Helvetica'
,
Type1Fonts
.
helveticaBold
:
'Helvetica-Bold'
,
Type1Fonts
.
helveticaBoldOblique
:
'Helvetica-BoldOblique'
,
Type1Fonts
.
helveticaOblique
:
'Helvetica-Oblique'
,
Type1Fonts
.
times
:
'Times-Roman'
,
Type1Fonts
.
timesBold
:
'Times-Bold'
,
Type1Fonts
.
timesBoldItalic
:
'Times-BoldItalic'
,
Type1Fonts
.
timesItalic
:
'Times-Italic'
,
Type1Fonts
.
symbol
:
'Symbol'
,
Type1Fonts
.
zapfDingbats
:
'ZapfDingbats'
};
String
get
fontName
=>
_type1Map
[
font
];
@protected
PdfFont
buildFont
(
PdfDocument
pdfDocument
)
{
const
Map
<
Type1Fonts
,
String
>
type1Map
=
<
Type1Fonts
,
String
>{
Type1Fonts
.
courier
:
'Courier'
,
Type1Fonts
.
courierBold
:
'Courier-Bold'
,
Type1Fonts
.
courierBoldOblique
:
'Courier-BoldOblique'
,
Type1Fonts
.
courierOblique
:
'Courier-Oblique'
,
Type1Fonts
.
helvetica
:
'Helvetica'
,
Type1Fonts
.
helveticaBold
:
'Helvetica-Bold'
,
Type1Fonts
.
helveticaBoldOblique
:
'Helvetica-BoldOblique'
,
Type1Fonts
.
helveticaOblique
:
'Helvetica-Oblique'
,
Type1Fonts
.
times
:
'Times-Roman'
,
Type1Fonts
.
timesBold
:
'Times-Bold'
,
Type1Fonts
.
timesBoldItalic
:
'Times-BoldItalic'
,
Type1Fonts
.
timesItalic
:
'Times-Italic'
,
Type1Fonts
.
symbol
:
'Symbol'
,
Type1Fonts
.
zapfDingbats
:
'ZapfDingbats'
};
final
String
fontName
=
type1Map
[
font
];
final
PdfFont
existing
=
pdfDocument
.
fonts
.
firstWhere
(
(
PdfFont
font
)
=>
font
.
subtype
==
'/Type1'
&&
font
.
fontName
==
fontName
,
orElse:
()
=>
null
,
...
...
@@ -132,14 +133,24 @@ class Font {
return
_pdfFont
;
}
@override
String
toString
()
=>
'<Type1 Font "
$fontName
">'
;
}
class
TtfFont
extends
Font
{
TtfFont
(
this
.
data
);
final
ByteData
data
;
@override
PdfFont
buildFont
(
PdfDocument
pdfDocument
)
{
return
PdfTtfFont
(
pdfDocument
,
data
);
}
@override
String
toString
()
{
final
TtfParser
font
=
TtfParser
(
data
);
return
'<TrueType Font "
${font.fontName}
">'
;
}
}
...
...
Please
register
or
login
to post a comment