private Font resolveFontFaceBaseFont(String normalizedFontFamily, float size, IdentValue weight, IdentValue style) { FontFamily<FontDescription> fontFamily = _fontFamilies.get(normalizedFontFamily); if (fontFamily != null) { FontDescription result = fontFamily.match(FontResolverHelper.convertWeightToInt(weight), style); if (result != null) { if (result.realizeFont()) { return result.getBaseFont(); } } } return null; }
private FontDescription resolveFont(SharedContext ctx, String fontFamily, float size, IdentValue weight, IdentValue style, IdentValue variant) { String normalizedFontFamily = normalizeFontFamily(fontFamily); String cacheKey = getHashName(normalizedFontFamily, weight, style); FontDescription result = _fontCache.get(cacheKey); if (result != null) { return result; } FontFamily<FontDescription> family = _fontFamilies.get(normalizedFontFamily); if (family != null) { result = family.match(FontResolverHelper.convertWeightToInt(weight), style); if (result != null) { _fontCache.put(cacheKey, result); return result; } } return null; }
private FontDescription resolveFont(SharedContext ctx, String fontFamily, float size, IdentValue weight, IdentValue style, IdentValue variant) { String normalizedFontFamily = normalizeFontFamily(fontFamily); String cacheKey = getHashName(normalizedFontFamily, weight, style); FontDescription result = _fontCache.get(cacheKey); if (result != null) { return result; } FontFamily<FontDescription> family = _fontFamilies.get(normalizedFontFamily); if (family != null) { result = family.match(FontResolverHelper.convertWeightToInt(weight), style); if (result != null) { _fontCache.put(cacheKey, result); return result; } } return null; }
public T match(int desiredWeight, IdentValue style) { if (_fontDescriptions == null) { throw new RuntimeException("fontDescriptions is null"); } List<T> candidates = new ArrayList<T>(); for (T description : _fontDescriptions) { if (description.getStyle() == style) { candidates.add(description); } } if (candidates.size() == 0) { if (style == IdentValue.ITALIC) { return match(desiredWeight, IdentValue.OBLIQUE); } else if (style == IdentValue.OBLIQUE) { return match(desiredWeight, IdentValue.NORMAL); } else { candidates.addAll(_fontDescriptions); } } T result = findByWeight(candidates, desiredWeight, SM_EXACT); if (result != null) { return result; } else { if (desiredWeight <= 500) { return findByWeight(candidates, desiredWeight, SM_LIGHTER_OR_DARKER); } else { return findByWeight(candidates, desiredWeight, SM_DARKER_OR_LIGHTER); } } }