warning : meta NOT subset; don't know how to subset; dropped

795 Views Asked by At

I am working on python program which get some data from SQL database and arrange it in a pdf file in Arabic language, so I use these libraries;

# -*- coding: utf-8 -*-
from fpdf import FPDF, XPos, YPos
from arabic_reshaper import reshape
from bidi.algorithm import get_display
import types
import mysql.connector

When I call the function create_pdf() method I get the warning;

C:\Users\ASUS\PycharmProjects\pythontelegrambot\venv\Scripts\python.exe C:\Users\ASUS\PycharmProjects\pythontelegrambot\p_... 
meta NOT subset; don't know how to subset; dropped
connected

Code Sample

def create_pdf(data1, data2):
    pdf = FPDF('L', 'mm', 'A4')
    pdf.add_page()

    pdf.add_font('arabic', '', 'C:\\Windows\\Fonts\\msuighur.ttf')
    pdf.set_font('arabic', size=14)
    #print positive
    m = len(data1) - 1
    sump = 0
    for i in range(m, -1, -1): sump += data1[i][1]
    spaces = 0
    #print titles1
    pdf.cell(len('اجمالي المستحق') * 1.7, 10, txt=get_display(reshape('اجمالي المستحق')), border=True, align='C')
    for i in range(m, -1, -1):
        pdf.cell(len(data1[i][0]) * 1.7, 10, txt=get_display(reshape(data1[i][0])), border=True, align='C',
                 new_x=XPos.LMARGIN if i == 0 else XPos.RIGHT, new_y=YPos.NEXT if i == 0 else YPos.TOP)
        spaces += len(data1[i][0]) * 1.7

    # print values 1
    pdf.cell(len('اجمالي المستحق') * 1.7, 10, txt=str(sump), border=True, align='C')
    for i in range(m, -1, -1):
        pdf.cell(len(data1[i][0]) * 1.7, 10, txt=str(data1[i][1]), border=True, align='C',
                 new_x=XPos.LMARGIN if i == 0 else XPos.RIGHT, new_y=YPos.NEXT if i == 0 else YPos.TOP)
    # calculate negatives
    n = len(data2)-1
    
    net = 0
    spaces1 = 0
    spaces2 = 0
    for i in range(math.floor(n / 2), -1, -1): spaces1 += len(data2[i][0])*2
    for i in range(n, math.floor(n/2), -1): spaces2 += len(data2[i][0])*2
    for i in range(n, -1, -1): net += data2[i][1]
    
    pdf.cell(spaces - spaces1+len('اجمالي المستحق') * 1.7, 10, txt=get_display(reshape('')), border=False, align='C')
    for i in range(math.floor(n/2), -1, -1):
        pdf.cell(len(data2[i][0]) * 2, 10, txt=get_display(reshape(data2[i][0])), border=True, align='C',
                 new_x=XPos.LMARGIN if i == 0 else XPos.RIGHT, new_y=YPos.NEXT if i == 0 else YPos.TOP)
    ################################
    #valus
    pdf.cell(spaces - spaces1 + len('اجمالي المستحق') * 1.7, 10, txt=get_display(reshape('')), border=False, align='C')
    for i in range(math.floor(n / 2), -1, -1):
        pdf.cell(len(data2[i][0]) * 2, 10, txt=str(data2[i][1]), border=True, align='C',
                 new_x=XPos.LMARGIN if i == 0 else XPos.RIGHT, new_y=YPos.NEXT if i == 0 else YPos.TOP)
    #####################################
    pdf.cell(spaces - spaces2 + len('اجمالي المستحق') * 1.7, 10, txt=get_display(reshape('')), border=False, align='C')
    for i in range(n, math.floor(n/2), -1):
        pdf.cell(len(data2[i][0]) * 2, 10, txt=get_display(reshape(data2[i][0])), border=True, align='C',
                 new_x=XPos.LMARGIN if i == math.floor(n/2)+1 else XPos.RIGHT, new_y=YPos.NEXT if i == math.floor(n/2)+1 else YPos.TOP)
    ############################valus
    pdf.cell(spaces - spaces2 + len('اجمالي المستحق') * 1.7, 10, txt=get_display(reshape('')), border=False, align='C')
    for i in range(n, math.floor(n / 2), -1):
        pdf.cell(len(data2[i][0]) * 2, 10, txt=str(data2[i][1]), border=True, align='C',
                 new_x=XPos.LMARGIN if i == math.floor(n/2)+1 else XPos.RIGHT, new_y=YPos.NEXT if i == math.floor(n/2)+1 else YPos.TOP)

    # print values2
    pdf.cell(len('الصافي') * 1.7, 10, txt=get_display(reshape("الصافي")), border=True, align='C')
    pdf.cell(len('الصافي') * 1.7, 10, txt=str(sump - net), border=True, align='C')


    pdf.output("hello_world.pdf")

Please help explain what the warning is about.

I tried to search inside libraries I used about that warning but found nothing.

1

There are 1 best solutions below

0
On

This is a warning from fonttools. You can see the specific error emitted in the sources here: https://github.com/fonttools/fonttools/blob/main/Lib/fontTools/subset/init.py#L3459

The warning is also reported by other PyPDF users here: https://github.com/PyFPDF/fpdf2/issues/831

The important question is: is your output being produced properly, or not?

If it is, you can probably ignore this warning.

If not, you need to understand why the font you're using (MS Uighur) has data that fonttools can't subset. From the comment in that issue:

We don't subset the meta table in the font. If you don't care about that table being dropped from the subset, you are fine with the warning. If you want subsetter to just pass it through unmodified, pass --no-subset-tables+=meta to the command line.

We don't subset it because it lists supported languages, and modifying that based on text retained is non-trivial.