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
2023-04-07 07:32:52 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fdf7e2ca07c748377ef67b8c257e3d259e41dc63
fdf7e2ca
1 parent
007c9939
Fix Type1 font widths
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
23 deletions
pdf/CHANGELOG.md
pdf/lib/src/pdf/obj/font.dart
pdf/lib/src/pdf/obj/type1_font.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
fdf7e2c
# Changelog
## 3.10.2
-
Fix Type1 font widths
## 3.10.1
-
Fix web debug build
...
...
pdf/lib/src/pdf/obj/font.dart
View file @
fdf7e2c
...
...
@@ -47,7 +47,6 @@ abstract class PdfFont extends PdfObjectDict {
stdHW:
84
,
stdVW:
106
,
isFixedPitch:
true
,
missingWidth:
600
,
);
}
...
...
@@ -63,7 +62,6 @@ abstract class PdfFont extends PdfObjectDict {
stdHW:
51
,
stdVW:
51
,
isFixedPitch:
true
,
missingWidth:
600
,
);
}
...
...
@@ -80,7 +78,6 @@ abstract class PdfFont extends PdfObjectDict {
isFixedPitch:
true
,
stdHW:
84
,
stdVW:
106
,
missingWidth:
600
,
);
}
...
...
@@ -97,7 +94,6 @@ abstract class PdfFont extends PdfObjectDict {
italicAngle:
-
12
,
stdHW:
51
,
stdVW:
51
,
missingWidth:
600
,
);
}
...
...
@@ -280,9 +276,6 @@ See https://github.com/DavBfr/dart_pdf/wiki/Fonts-Management
/// Spans the distance between the baseline and the lowest descending glyph
double
get
descent
;
/// Default width of a glyph
static
const
double
defaultGlyphWidth
=
0.600
;
/// Internal units per
int
get
unitsPerEm
;
...
...
pdf/lib/src/pdf/obj/type1_font.dart
View file @
fdf7e2c
...
...
@@ -42,7 +42,7 @@ class PdfType1Font extends PdfFont {
required
int
stdHW
,
required
int
stdVW
,
bool
isFixedPitch
=
false
,
int
?
missingWidth
,
this
.
missingWidth
=
0.600
,
this
.
widths
=
const
<
double
>[]})
:
assert
(()
{
// ignore: avoid_print
...
...
@@ -54,22 +54,26 @@ class PdfType1Font extends PdfFont {
params
[
'/BaseFont'
]
=
PdfName
(
'/
$fontName
'
);
if
(
settings
.
version
.
index
>=
PdfVersion
.
pdf_1_5
.
index
)
{
params
[
'/FirstChar'
]
=
const
PdfNum
(
0
);
params
[
'/LastChar'
]
=
const
PdfNum
(
256
);
params
[
'/Widths'
]
=
PdfArray
.
fromNum
(
widths
.
map
((
e
)
=>
e
*
1000
));
params
[
'/LastChar'
]
=
const
PdfNum
(
255
);
if
(
widths
.
isNotEmpty
)
{
params
[
'/Widths'
]
=
PdfArray
.
fromNum
(
widths
.
map
((
e
)
=>
(
e
*
unitsPerEm
).
toInt
()));
}
else
{
params
[
'/Widths'
]
=
PdfArray
.
fromNum
(
List
<
int
>.
filled
(
256
,
(
missingWidth
*
unitsPerEm
).
toInt
()));
}
final
fontDescriptor
=
PdfObjectDict
(
pdfDocument
,
type:
'/FontDescriptor'
)
..
params
[
'/FontName'
]
=
PdfName
(
'/
$fontName
'
)
..
params
[
'/Flags'
]
=
PdfNum
(
32
+
(
isFixedPitch
?
1
:
0
))
..
params
[
'/FontBBox'
]
=
PdfArray
.
fromNum
(
fontBBox
)
..
params
[
'/Ascent'
]
=
PdfNum
((
ascent
*
1000
).
toInt
())
..
params
[
'/Descent'
]
=
PdfNum
((
descent
*
1000
).
toInt
())
..
params
[
'/Ascent'
]
=
PdfNum
((
ascent
*
unitsPerEm
).
toInt
())
..
params
[
'/Descent'
]
=
PdfNum
((
descent
*
unitsPerEm
).
toInt
())
..
params
[
'/ItalicAngle'
]
=
PdfNum
(
italicAngle
)
..
params
[
'/CapHeight'
]
=
PdfNum
(
capHeight
)
..
params
[
'/StemV'
]
=
PdfNum
(
stdVW
)
..
params
[
'/StemH'
]
=
PdfNum
(
stdHW
);
if
(
missingWidth
!=
null
)
{
fontDescriptor
.
params
[
'/MissingWidth'
]
=
PdfNum
(
missingWidth
);
}
..
params
[
'/StemH'
]
=
PdfNum
(
stdHW
)
..
params
[
'/MissingWidth'
]
=
PdfNum
((
missingWidth
*
unitsPerEm
).
toInt
());
params
[
'/FontDescriptor'
]
=
fontDescriptor
.
ref
();
}
...
...
@@ -90,6 +94,9 @@ class PdfType1Font extends PdfFont {
/// Width of each glyph
final
List
<
double
>
widths
;
/// Default width of a glyph
final
double
missingWidth
;
@override
PdfFontMetrics
glyphMetrics
(
int
charCode
)
{
if
(!
isRuneSupported
(
charCode
))
{
...
...
@@ -98,12 +105,11 @@ class PdfType1Font extends PdfFont {
}
return
PdfFontMetrics
(
left:
0
,
top:
descent
,
right:
charCode
<
widths
.
length
?
widths
[
charCode
]
:
PdfFont
.
defaultGlyphWidth
,
bottom:
ascent
);
left:
0
,
top:
descent
,
right:
charCode
<
widths
.
length
?
widths
[
charCode
]
:
missingWidth
,
bottom:
ascent
,
);
}
@override
...
...
pdf/pubspec.yaml
View file @
fdf7e2c
...
...
@@ -6,7 +6,7 @@ issue_tracker: https://github.com/DavBfr/dart_pdf/issues
screenshots
:
-
description
:
'
Example
of
a
generated
document'
path
:
example.jpg
version
:
3.10.
1
version
:
3.10.
2
environment
:
sdk
:
"
>=2.18.0
<3.0.0"
...
...
Please
register
or
login
to post a comment