如何在pygame上使用字体系列?

时间:2018-08-27 05:04:32

标签: python python-3.x fonts pygame font-family

我前一段时间安装了“ Raleway”,似乎无法使其适用于pygame。我的程序似乎只能显示该字体的常规版本,而不能显示粗体,斜体等。这是我所拥有的:

public function save_reconciliation(){
    $itemNum = $this->input->post('itemNum');
    $physical_count = $this->input->post('physical_count');
    $ph_id = $this->input->post('ph_id');
    $remarks = $this->input->post('remarks');
    $status = $this->input->post('status');
    $computed = $this->input->post('computed');
    $initial = $this->input->post('initial');
    $unit_price = $this->input->post('unitPrice');
    $ledger = [];
    $product = [];
    $reconciliation = [];
    $count = 0;
    $temp_total = array();
    foreach ($itemNum as $key => $value) {
        $temp_total[$key] = $unit_price[$key] * $physical_count[$key];
        $inventory_in = (filter_var(strip_tags($status[$key]), FILTER_SANITIZE_SPECIAL_CHARS) == 'surplus') ? filter_var(strip_tags($computed[$key]), FILTER_SANITIZE_SPECIAL_CHARS) : '';
        $inventory_out = (filter_var(strip_tags($status[$key]), FILTER_SANITIZE_SPECIAL_CHARS) == 'surplus') ? '' : filter_var(strip_tags($computed[$key]), FILTER_SANITIZE_SPECIAL_CHARS);
        array_push($ledger, [
                                'itemNum' => filter_var(strip_tags($value), FILTER_SANITIZE_SPECIAL_CHARS),
                                'activity' => 'adjustment',
                                'activity_date' => date('Y-m-d H:i:s'),
                                'initial_inventory' => filter_var(strip_tags($initial[$key]), FILTER_SANITIZE_SPECIAL_CHARS),
                                'inventory_in' => $inventory_in,
                                'inventory_out' => $inventory_out,
                                'balance' => filter_var(strip_tags($physical_count[$key]), FILTER_SANITIZE_SPECIAL_CHARS),
                                'ph_id' => filter_var(strip_tags($ph_id[$key]), FILTER_SANITIZE_SPECIAL_CHARS),
                                'business_partner' => ''
                            ]);
        array_push($product, [
                                'itemNum' => filter_var(strip_tags($value), FILTER_SANITIZE_SPECIAL_CHARS),
                                'prodQty' => filter_var(strip_tags($physical_count[$key]), FILTER_SANITIZE_SPECIAL_CHARS)
                            ]);
        array_push($reconciliation, [
                                'recon_date' => date('Y-m-d H:i:s'),
                                'itemNum' => filter_var(strip_tags($value), FILTER_SANITIZE_SPECIAL_CHARS),
                                'logical_count' => filter_var(strip_tags($initial[$key]), FILTER_SANITIZE_SPECIAL_CHARS),
                                'physical_count' => filter_var(strip_tags($physical_count[$key]), FILTER_SANITIZE_SPECIAL_CHARS),
                                'status' => filter_var(strip_tags($status[$key]), FILTER_SANITIZE_SPECIAL_CHARS),
                                'remarks' => filter_var(strip_tags($remarks[$key]), FILTER_SANITIZE_SPECIAL_CHARS),
                                'item_total' => filter_var(strip_tags($temp_total[$key]), FILTER_SANITIZE_SPECIAL_CHARS),
                            ]);
    }


    $this->Csr_Reconciliation_Model->save_reconciliation($ledger, $product, $reconciliation);
    redirect('csrproducts');
}

这是字体家族下可用的字体: Raleway

1 个答案:

答案 0 :(得分:2)

您的字体实际上只是命名为Raleway,并且要加载粗体版本,您必须set the bold flag

myfont = pygame.font.SysFont('Raleway', 72, bold=True, italic=False)