David PHAM-VAN

Fix TTF font issues

... ... @@ -15,7 +15,7 @@
DART_SRC=$(shell find . -name '*.dart')
CLNG_SRC=$(shell find printing/ios -name '*.java' -o -name '*.m' -o -name '*.h') $(shell find printing/android -name '*.java' -o -name '*.m' -o -name '*.h')
SWFT_SRC=$(shell find . -name '*.swift')
FONTS=pdf/open-sans.ttf pdf/roboto.ttf pdf/noto-sans.ttf
FONTS=pdf/open-sans.ttf pdf/roboto.ttf pdf/noto-sans.ttf pdf/genyomintw.ttf
all: $(FONTS) format
... ... @@ -28,6 +28,9 @@ pdf/roboto.ttf:
pdf/noto-sans.ttf:
curl -L "https://raw.githubusercontent.com/google/fonts/master/ofl/notosans/NotoSans-Regular.ttf" > $@
pdf/genyomintw.ttf:
curl -L "https://github.com/ButTaiwan/genyo-font/raw/master/TW/GenYoMinTW-Heavy.ttf" > $@
format: format-dart format-clang format-swift
format-dart: $(DART_SRC)
... ...
... ... @@ -49,7 +49,7 @@ void main() {
'The Portable Document Format (PDF) is a file format developed by Adobe in the 1990s to present documents, including text formatting and images, in a manner independent of application software, hardware, and operating systems. Based on the PostScript language, each PDF file encapsulates a complete description of a fixed-layout flat document, including the text, fonts, vector graphics, raster images and other information needed to display it. PDF was standardized as an open format, ISO 32000, in 2008, and no longer requires any royalties for its implementation.'),
Paragraph(
text:
'Today, PDF files may contain a variety of content besides flat text and graphics including logical structuring elements, interactive elements such as annotations and form-fields, layers, rich media (including video content) and three dimensional objects using U3D or PRC, and various other data formats.[citation needed] The PDF specification also provides for encryption and digital signatures, file attachments and metadata to enable workflows requiring these features.'),
'Today, PDF files may contain a variety of content besides flat text and graphics including logical structuring elements, interactive elements such as annotations and form-fields, layers, rich media (including video content) and three dimensional objects using U3D or PRC, and various other data formats. The PDF specification also provides for encryption and digital signatures, file attachments and metadata to enable workflows requiring these features.'),
Header(level: 1, text: 'History and standardization'),
Paragraph(
text:
... ...
... ... @@ -67,8 +67,8 @@ class TtfWriter {
continue;
}
final TtfGlyphInfo glyph = ttf.readGlyph(
chars[index] == 0 ? 0 : ttf.charToGlyphIndexMap[chars[index]]);
final TtfGlyphInfo glyph =
ttf.readGlyph(ttf.charToGlyphIndexMap[chars[index]] ?? 0);
for (int g in glyph.compounds) {
compounds[g] = null;
}
... ...
... ... @@ -56,6 +56,7 @@ class Font {
factory Font.timesItalic() => Font.type1(Type1Fonts.timesItalic);
factory Font.symbol() => Font.type1(Type1Fonts.symbol);
factory Font.zapfDingbats() => Font.type1(Type1Fonts.zapfDingbats);
factory Font.ttf(ByteData data) => TtfFont(data);
final Type1Fonts font;
... ...
... ... @@ -70,6 +70,7 @@ void main() {
printTextTtf(g, s, File('open-sans.ttf'), 30.0 + 30.0 * top++);
printTextTtf(g, s, File('roboto.ttf'), 30.0 + 30.0 * top++);
printTextTtf(g, s, File('noto-sans.ttf'), 30.0 + 30.0 * top++);
printTextTtf(g, '你好 檯號 ', File('genyomintw.ttf'), 30.0 + 30.0 * top++);
final File file = File('ttf.pdf');
file.writeAsBytesSync(pdf.save());
... ...