Retrieve column font details from a block of property data.

@param data property data
@param offset offset into property data
@param fontBases map of font bases
@return ColumnFontStyle instance
510292
protected TableFontStyle getColumnFontStyle(byte[] data, int offset, Map<Integer, FontBase> fontBases)
   {
      int uniqueID = MPPUtility.getInt(data, offset);
      FieldType fieldType = MPPTaskField.getInstance(MPPUtility.getShort(data, offset + 4));
      Integer index = Integer.valueOf(MPPUtility.getByte(data, offset + 8));
      int style = MPPUtility.getByte(data, offset + 9);
      ColorType color = ColorType.getInstance(MPPUtility.getByte(data, offset + 10));
      int change = MPPUtility.getByte(data, offset + 12);

      FontBase fontBase = fontBases.get(index);

      boolean bold = ((style & 0x01) != 0);
      boolean italic = ((style & 0x02) != 0);
      boolean underline = ((style & 0x04) != 0);

      boolean boldChanged = ((change & 0x01) != 0);
      boolean underlineChanged = ((change & 0x02) != 0);
      boolean italicChanged = ((change & 0x04) != 0);
      boolean colorChanged = ((change & 0x08) != 0);
      boolean fontChanged = ((change & 0x10) != 0);
      boolean backgroundColorChanged = (uniqueID == -1);
      boolean backgroundPatternChanged = (uniqueID == -1);

      return (new TableFontStyle(uniqueID, fieldType, fontBase, italic, bold, underline, false, color.getColor(), Color.BLACK, BackgroundPattern.TRANSPARENT, italicChanged, boldChanged, underlineChanged, false, colorChanged, fontChanged, backgroundColorChanged, backgroundPatternChanged));
   }
1167666
public void setTextStyle(byte[] fields, int style) {
        for (byte field : fields) {
            getFieldInfos(field).m_fontStyle = style;
        }
		notifyListeners();
	}
520482
public function do_text(
        $text,
        $offsetX = 0,
        $offsetY = 0,
        $opacity = 1.0,
        $color = 0x000000,
        $size = 12,
        $font_file = null
    ) {
        $textColor = imagecolorallocatealpha($this->_image, ($color >> 16) & 0xFF, ($color >> 8) & 0xFF,
            $color & 0xFF, abs(1 - $opacity) * 127);
        if ($font_file) {
            imagettftext($this->_image, $size, 0, $offsetX, $offsetY, $textColor, $this->alias->resolve($font_file), $text);
        } else {
            imagestring($this->_image, $size, $offsetX, $offsetY, $text, $textColor);
        }

        return $this;
    }
659786
public Font getTextFont(byte field) {
		FieldInfos fi = getFieldInfos(field);
		Vector v = new Vector(m_defaultTextFontFamilyNames.length+fi.m_fontFamilyNames.length);
        Collections.addAll(v, fi.m_fontFamilyNames);
        Collections.addAll(v, m_defaultTextFontFamilyNames);
		Iterator it = v.iterator();
		Font font = null;
		String s = "";
		int style = getTextStyle(field);
		int size = (int) getTextSize(field);
		while (it.hasNext()) {
			String fontName = (String) it.next();
			if (s.length() > 0)
				s += ", ";
			s += fontName;
			if (isFontAvailable(fontName)) {
				font = new Font(fontName, style, size);
				break;
			}
		}
		if (font == null) {
			System.err.println("None of these fonts are available: " + s);
			font = new Font("Dialog", style, size);
		}
		if (fi.m_textAttributes != null) {
			font = font.deriveFont(fi.m_textAttributes);
		}
		return font;
	}
348243
protected void updateStyle(BoxStyle bstyle, TextPosition text)
    {
        String font = text.getFont().getName();
        String family = null;
        String weight = null;
        String fstyle = null;

        bstyle.setFontSize(text.getFontSizeInPt());
        bstyle.setLineHeight(text.getHeight());

        if (font != null)
        {
        	//font style and weight
            for (int i = 0; i < pdFontType.length; i++)
            {
                if (font.toLowerCase().lastIndexOf(pdFontType[i]) >= 0)
                {
                    weight = cssFontWeight[i];
                    fstyle = cssFontStyle[i];
                    break;
                }
            }
            if (weight != null)
            	bstyle.setFontWeight(weight);
            else
            	bstyle.setFontWeight(cssFontWeight[0]);
            if (fstyle != null)
            	bstyle.setFontStyle(fstyle);
            else
            	bstyle.setFontStyle(cssFontStyle[0]);

            //font family
            //If it's a known common font don't embed in html output to save space
            String knownFontFamily = findKnownFontFamily(font);
            if (!knownFontFamily.equals(""))
                family = knownFontFamily;
            else
            {
                family = fontTable.getUsedName(text.getFont());
                if (family == null)
                    family = font;
            }

            if (family != null)
            	bstyle.setFontFamily(family);
        }

        updateStyleForRenderingMode();
    }
545179
function guessFontStyle(basename) {
  return basename
    .split('-')
    .slice(1)
    .map(item => item.toLowerCase())
    .reduce((prev, item) => {
      if (fontStyleKeywords.indexOf(item) >= 0) {
        return `font-style:${item};`
      }

      return prev
    }, '')
}
1041391
private int getOffsetY(int rowStartOffset, FontMetrics fontMetrics)
    throws BadLocationException {
    // Get the bounding rectangle of the row

    Rectangle r = component.modelToView(rowStartOffset);
    int lineHeight = fontMetrics.getHeight();
    int y = r.y + r.height;
    int descent = 0;

    // The text needs to be positioned above the bottom of the bounding
    // rectangle based on the descent of the font(s) contained on the row.

    if (r.height == lineHeight) // default font is being used
    {
      descent = fontMetrics.getDescent();
    } else // We need to check all the attributes for font changes
    {
      if (fonts == null)
        fonts = new HashMap<>();

      Element root = component.getDocument().getDefaultRootElement();
      int index = root.getElementIndex(rowStartOffset);
      Element line = root.getElement(index);

      for (int i = 0; i < line.getElementCount(); i++) {
        Element child = line.getElement(i);
        AttributeSet as = child.getAttributes();
        String fontFamily = (String) as.getAttribute(StyleConstants.FontFamily);
        Integer fontSize = (Integer) as.getAttribute(StyleConstants.FontSize);
        String key = fontFamily + fontSize;

        FontMetrics fm = fonts.get(key);

        if (fm == null) {
          Font font = new Font(fontFamily, Font.PLAIN, fontSize);
          fm = component.getFontMetrics(font);
          fonts.put(key, fm);
        }

        descent = Math.max(descent, fm.getDescent());
      }
    }

    return y - descent;
  }
519728
function toFontString(font) {
	if (!font || helpers.isNullOrUndef(font.size) || helpers.isNullOrUndef(font.family)) {
		return null;
	}

	return (font.style ? font.style + ' ' : '')
		+ (font.weight ? font.weight + ' ' : '')
		+ font.size + 'px '
		+ font.family;
}
49670
public static PDFont chooseMatchingCourier(Font font) {
		if ((font.getStyle() & (Font.ITALIC | Font.BOLD)) == (Font.ITALIC | Font.BOLD))
			return PDType1Font.COURIER_BOLD_OBLIQUE;
		if ((font.getStyle() & Font.ITALIC) == Font.ITALIC)
			return PDType1Font.COURIER_OBLIQUE;
		if ((font.getStyle() & Font.BOLD) == Font.BOLD)
			return PDType1Font.COURIER_BOLD;
		return PDType1Font.COURIER;
	}
1193514
public void addFont(Font font) {
        if (font.getBaseFont() != null) {
            fonts.add(font);
            return;
        }
        BaseFont bf = font.getCalculatedBaseFont(true);
        Font f2 = new Font(bf, font.getSize(), font.getCalculatedStyle(), font.getColor());
        fonts.add(f2);
    }
488732
public void updateForGraphics(NodeData style, Graphics2D g)
    {
        if (style != null) update(style);
        updateGraphics(g);
        fm = g.getFontMetrics();
        
        //update the width units
        //em has been updated in update()
        
        FontRenderContext frc = new FontRenderContext(null, false, false);
        TextLayout layout = new TextLayout("x", font, frc);
        ex = layout.getBounds().getHeight();
        
        ch = fm.charWidth('0');
    }
591036
public StyleSet setFont(Font font, boolean ignoreHead) {
		if(false == ignoreHead) {
			this.headCellStyle.setFont(font);
		}
		this.cellStyle.setFont(font);
		this.cellStyleForNumber.setFont(font);
		this.cellStyleForDate.setFont(font);
		return this;
	}
800158
public static TextStyleContainer findIcons(Spanned spannable, HashMap<String, ITypeface> fonts) {
        LinkedList<StyleContainer> styleContainers = new LinkedList<>();
        LinkedList<StyleContainer> existingSpans = new LinkedList<>();

        // remember the previous style spans
        for (ParcelableSpan span : spannable.getSpans(0, spannable.length(), ParcelableSpan.class)) {
            existingSpans.add(new StyleContainer(spannable.getSpanStart(span), spannable.getSpanEnd(span), span, spannable.getSpanFlags(span)));
        }
        for (CharacterStyle span : spannable.getSpans(0, spannable.length(), CharacterStyle.class)) {
            existingSpans.add(new StyleContainer(spannable.getSpanStart(span), spannable.getSpanEnd(span), span, spannable.getSpanFlags(span)));
        }

        //the new string built with the replaced icons
        SpannableStringBuilder spannedString = new SpannableStringBuilder();
        SpannableStringBuilder tempIconString = new SpannableStringBuilder();

        int removedChars = 0;
        for (int i = 0; i < spannable.length(); i++) {
            Character c = spannable.charAt(i);
            if (c == ICON_START) {
                //if something started with { but was no icon replacement
                spannedString.append(tempIconString);
                //start to remember the tempIconString again
                tempIconString = new SpannableStringBuilder();
                tempIconString.append(c);
            } else if (c == ICON_END) {
                tempIconString.append(c);
                //make sure there was a { before and enough chars for the font key
                if (tempIconString.length() > 5) {
                    StyleContainer styleContainer = placeFontIcon(spannedString, tempIconString, fonts);
                    if (styleContainer != null) {
                        styleContainers.add(styleContainer);

                        //adjust existing spans to new position
                        for (StyleContainer existingStyleContainer : existingSpans) {
                            if (existingStyleContainer.startIndex > i - removedChars) {
                                existingStyleContainer.startIndex = existingStyleContainer.startIndex - tempIconString.length() + 1;
                            }
                            if (existingStyleContainer.endIndex > i - removedChars) {
                                existingStyleContainer.endIndex = existingStyleContainer.endIndex - tempIconString.length() + 1;
                            }
                        }
                        removedChars += tempIconString.length() - 1;
                    }
                } else {
                    spannedString.append(tempIconString);
                }
                tempIconString = new SpannableStringBuilder();
            } else {
                if (tempIconString.length() == 0) {
                    spannedString.append(c);
                } else {
                    tempIconString.append(c);
                }
            }
        }

        //make sure to add the last characters which create no complete icon
        spannedString.append(tempIconString);

        //add the existing spans
        styleContainers.addAll(existingSpans);

        return new TextStyleContainer(spannedString, styleContainers);
    }
1177288
public void setFont(Font font) {
		if (comboBox != null) {
			comboBox.setFont(font);
		}
		super.setFont(font);
	}
225932
public static Font getFont(Properties attributes) {
        fontImp.defaultEmbedding = defaultEmbedding;
        fontImp.defaultEncoding = defaultEncoding;
        return fontImp.getFont(attributes);
    }
320750
public function writeText($text, $point, $size, $angle, $font, $maxwidth = 0, $rgbAr = null, $textAlignment = 1)
    {
        if (!is_readable($font)) {
            throw new ImageUtilException('Error: The specified font not found');
        }

        if (!is_array($rgbAr)) {
            $rgbAr = [0, 0, 0];
        }

        $color = imagecolorallocate($this->image, $rgbAr[0], $rgbAr[1], $rgbAr[2]);

        // Determine the line break if required.
        if (($maxwidth > 0) && ($angle == 0)) {
            $words = explode(' ', $text);
            $lines = [$words[0]];
            $currentLine = 0;

            $numberOfWords = count($words);
            for ($i = 1; $i < $numberOfWords; $i++) {
                $lineSize = imagettfbbox($size, 0, $font, $lines[$currentLine] . ' ' . $words[$i]);
                if ($lineSize[2] - $lineSize[0] < $maxwidth) {
                    $lines[$currentLine] .= ' ' . $words[$i];
                } else {
                    $currentLine++;
                    $lines[$currentLine] = $words[$i];
                }
            }
        } else {
            $lines = [$text];
        }

        $curX = $point[0];
        $curY = $point[1];

        foreach ($lines as $text) {
            $bbox = imagettfbbox($size, $angle, $font, $text);

            switch ($textAlignment) {
                case TextAlignment::RIGHT:
                    $curX = $point[0] - abs($bbox[2] - $bbox[0]);
                    break;

                case TextAlignment::CENTER:
                    $curX = $point[0] - (abs($bbox[2] - $bbox[0]) / 2);
                    break;
            }

            imagettftext($this->image, $size, $angle, $curX, $curY, $color, $font, $text);

            $curY += ($size * 1.35);
        }
    }
119089
public NonStandardFontFamily get(String fontFamily) {

        NonStandardFontFamily f = standardUnicodeFontFamilySet
                .getFontFamilyByName(fontFamily);
        if (f != null)
            return f;

        f = standardNonUnicodeFontFamilySet.getFontFamilyByName(fontFamily);
        if (f != null)
            return f;

        f = nonStandardFontFamilySet.getFontFamilyByName(fontFamily);
        if (f != null)
            return f;

        return null;
    }