Pdf.dart 包实现 fontFallback 打印表情符号

问题描述 投票:0回答:1

我尝试了网上提出的许多解决方案,但没有成功 我正在尝试打印文本(存储在本地数据库中),其中包括表情符号(智能手机起源)和特殊的法语字符(即 Œ ) 嵌入 fontFallback 时我无法解决“Future”的问题...... 我的代码:



import 'package:google_fonts/google_fonts.dart';

static Future emoji() async =\> await PdfGoogleFonts.notoColorEmoji();

static pw.Widget cell(pw.Context context, int index) {
String texte = SQLHelper.listeItemsRepas()\[index\];

    // Text including some emojis
    
    
    // Create a custom TextStyle with fallback fonts
    pw.TextStyle(
      fontFallback: emoji(),
    );
    return pw.Container(
      constraints: const pw.BoxConstraints.tightFor(
          width: double.infinity, height: 22.0),
      padding: const pw.EdgeInsets.all(3),
      child: pw.Text(
        texte,
        style: const pw.TextStyle(
            fontSize: 9),
        textAlign: pw.TextAlign.left,
        softWrap: true,
        maxLines: 6,
    
        //  style: style,
      ),
    );

}

    // Text including some emojis
    

你能给我正确的代码吗?

flutter dart pdf-generation
1个回答
0
投票

颤医生:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.6, on macOS 14.0 23A344 darwin-arm64, locale en-MX)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.82.2)
[✓] Connected device (4 available)
[✓] Network resources

以我的部分代码为例->

pdf.addPage(
pw.MultiPage(
  theme: pw.ThemeData.withFont(
    base: await PdfGoogleFonts.quicksandRegular(),
    bold: await PdfGoogleFonts.quicksandMedium(),
    icons: await PdfGoogleFonts.notoColorEmoji(),
    fontFallback: [await PdfGoogleFonts.notoColorEmoji()],
  ),
  pageFormat: PdfPageFormat.a4,
  build: (pw.Context page_context) => [
© www.soinside.com 2019 - 2024. All rights reserved.