<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>FontInfo.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache PDFBox</a> &gt; <a href="index.source.html" class="el_package">org.apache.pdfbox.pdmodel.font</a> &gt; <span class="el_source">FontInfo.java</span></div><h1>FontInfo.java</h1><pre class="source lang-java linenums">/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the &quot;License&quot;); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.pdfbox.pdmodel.font;

import org.apache.fontbox.FontBoxFont;

/**
 * Information about a font on the system.
 *
 * @author John Hewson
 */
<span class="fc" id="L27">public abstract class FontInfo</span>
{
    /**
     * Returns the PostScript name of the font.
     */
    public abstract String getPostScriptName();

    /**
     * Returns the font's format.
     */
    public abstract FontFormat getFormat();

    /**
     * Returns the CIDSystemInfo associated with the font, if any.
     */
    public abstract CIDSystemInfo getCIDSystemInfo();

    /**
     * Returns a new FontBox font instance for the font. Implementors of this method must not
     * cache the return value of this method unless doing so via the current {@link FontCache}.
     */
    public abstract FontBoxFont getFont();

    /**
     * Returns the sFamilyClass field of the &quot;OS/2&quot; table, or -1.
     */
    public abstract int getFamilyClass();

    /**
     * Returns the usWeightClass field of the &quot;OS/2&quot; table, or -1.
     */
    public abstract int getWeightClass();

    /**
     * Returns the usWeightClass field as a Panose Weight.
     */
    final int getWeightClassAsPanose()
    {
<span class="nc" id="L65">        int usWeightClass = getWeightClass();</span>
<span class="nc bnc" id="L66" title="All 12 branches missed.">        switch (usWeightClass)</span>
        {
<span class="nc" id="L68">            case -1: return 0;</span>
<span class="nc" id="L69">            case 0: return 0;</span>
<span class="nc" id="L70">            case 100: return 2;</span>
<span class="nc" id="L71">            case 200: return 3;</span>
<span class="nc" id="L72">            case 300: return 4;</span>
<span class="nc" id="L73">            case 400: return 5;</span>
<span class="nc" id="L74">            case 500: return 6;</span>
<span class="nc" id="L75">            case 600: return 7;</span>
<span class="nc" id="L76">            case 700: return 8;</span>
<span class="nc" id="L77">            case 800: return 9;</span>
<span class="nc" id="L78">            case 900: return 10;</span>
<span class="nc" id="L79">            default: return 0;</span>
        }
    }

    /**
     * Returns the ulCodePageRange1 field of the &quot;OS/2&quot; table, or 0.
     */
    public abstract int getCodePageRange1();

    /**
     * Returns the ulCodePageRange2 field of the &quot;OS/2&quot; table, or 0.
     */
    public abstract int getCodePageRange2();

    /**
     * Returns the ulCodePageRange1 and ulCodePageRange1 field of the &quot;OS/2&quot; table, or 0.
     */
    final long getCodePageRange()
    {
<span class="nc" id="L98">        long range1 = getCodePageRange1() &amp; 0x00000000ffffffffL;</span>
<span class="nc" id="L99">        long range2 = getCodePageRange2() &amp; 0x00000000ffffffffL;</span>
<span class="nc" id="L100">        return range2 &lt;&lt; 32 | range1;</span>
    }

    /**
     * Returns the macStyle field of the &quot;head&quot; table, or -1.
     */
    public abstract int getMacStyle();

    /**
     * Returns the Panose classification of the font, if any.
     */
    public abstract PDPanoseClassification getPanose();
    
    // todo: 'post' table for Italic. Also: OS/2 fsSelection for italic/bold.
    // todo: ulUnicodeRange too?
    
    @Override
    public String toString()
    {
<span class="nc" id="L119">        return getPostScriptName() + &quot; (&quot; + getFormat() +</span>
<span class="nc" id="L120">                &quot;, mac: 0x&quot; + Integer.toHexString(getMacStyle()) +</span>
<span class="nc" id="L121">                &quot;, os/2: 0x&quot; + Integer.toHexString(getFamilyClass()) +</span>
<span class="nc" id="L122">                &quot;, cid: &quot; + getCIDSystemInfo() + &quot;)&quot;;</span>
    }
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>