CSS20FontDatabase.java 25.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.agl.util.ULocale
 */
package com.adobe.fontengine.inlineformatting.css20;

import com.adobe.agl.util.ULocale;
import com.adobe.fontengine.font.Font;
import com.adobe.fontengine.font.FontDescription;
import com.adobe.fontengine.font.FontException;
import com.adobe.fontengine.font.FontLoadingException;
import com.adobe.fontengine.font.InvalidFontException;
import com.adobe.fontengine.font.UnsupportedFontException;
import com.adobe.fontengine.fontmanagement.FontProxy;
import com.adobe.fontengine.fontmanagement.FontResolutionPriority;
import com.adobe.fontengine.fontmanagement.FontSetStack;
import com.adobe.fontengine.fontmanagement.IntelligentResolver;
import com.adobe.fontengine.inlineformatting.FallbackFontSet;
import com.adobe.fontengine.inlineformatting.css20.CSS20Attribute;
import com.adobe.fontengine.inlineformatting.css20.CSS20FontDescription;
import com.adobe.fontengine.inlineformatting.css20.CSS20FontSet;
import com.adobe.fontengine.inlineformatting.css20.CSS20GenericFontFamily;
import com.adobe.fontengine.inlineformatting.css20.FamilyNameNormalizer;
import com.adobe.fontengine.inlineformatting.css20.PassThroughFamilyNameNormalizer;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public final class CSS20FontDatabase
extends FontSetStack
implements CSS20FontSet {
    static final long serialVersionUID = 1;
    private final FamilyNameNormalizer normalizer;
    private final boolean ignoreVariant;
    private HashMap fontsByFamilyName = new HashMap();
    private FontResolutionPriority resolutionPriority = FontResolutionPriority.FIRST;
    private ArrayList serif = new ArrayList();
    private ArrayList sansSerif = new ArrayList();
    private ArrayList monospace = new ArrayList();
    private ArrayList fantasy = new ArrayList();
    private ArrayList cursive = new ArrayList();
    private FallbackFontSet fallbackFontSet = new FallbackFontSet();

    public CSS20FontDatabase() {
        this(new PassThroughFamilyNameNormalizer(), true);
    }

    public CSS20FontDatabase(boolean ignoreVariant) {
        this(new PassThroughFamilyNameNormalizer(), ignoreVariant);
    }

    public CSS20FontDatabase(FamilyNameNormalizer normalizer) {
        this(normalizer, true);
    }

    public CSS20FontDatabase(FamilyNameNormalizer normalizer, boolean ignoreVariant) {
        if (normalizer == null) {
            normalizer = new PassThroughFamilyNameNormalizer();
        }
        this.normalizer = normalizer;
        this.ignoreVariant = ignoreVariant;
    }

    public CSS20FontDatabase(CSS20FontDatabase original) {
        super(original);
        this.normalizer = original.normalizer;
        this.ignoreVariant = original.ignoreVariant;
        this.resolutionPriority = original.resolutionPriority;
        this.serif = (ArrayList)original.serif.clone();
        this.sansSerif = (ArrayList)original.sansSerif.clone();
        this.monospace = (ArrayList)original.monospace.clone();
        this.fantasy = (ArrayList)original.fantasy.clone();
        this.cursive = (ArrayList)original.cursive.clone();
        this.fallbackFontSet = original.fallbackFontSet;
        Set keySet = original.fontsByFamilyName.keySet();
        for (Object key : keySet) {
            CSSFontsWithSameName fontsByName = new CSSFontsWithSameName(this, (CSSFontsWithSameName)original.fontsByFamilyName.get(key));
            this.fontsByFamilyName.put(key, fontsByName);
        }
    }

    public FontResolutionPriority setResolutionPriority(FontResolutionPriority priority) {
        FontResolutionPriority oldPriority = this.resolutionPriority;
        this.resolutionPriority = priority;
        return oldPriority;
    }

    public void addFont(Font font) throws InvalidFontException, UnsupportedFontException, FontLoadingException {
        CSS20FontDescription[] fontDesc = font.getCSS20FontDescription();
        if (fontDesc == null) {
            throw new InvalidFontException("Font has no CSS20FontDescription", font);
        }
        for (int i = 0; i < fontDesc.length; ++i) {
            FontProxy fontProxy = new FontProxy(fontDesc[i], font);
            this.addFontProxy(fontProxy);
        }
    }

    public void addFont(CSS20FontDescription fontDesc, Font font) throws InvalidFontException, UnsupportedFontException, FontLoadingException {
        FontProxy fontProxy = new FontProxy(fontDesc, font);
        this.addFontProxy(fontProxy);
    }

    private boolean addFontProxy(FontProxy fontProxy) throws InvalidFontException, UnsupportedFontException, FontLoadingException {
        boolean added;
        String familyName = this.normalizer.normalize(((CSS20FontDescription)fontProxy.getFontDescription()).getFamilyName());
        CSSFontsWithSameName fontsWithSameName = (CSSFontsWithSameName)this.fontsByFamilyName.get(familyName);
        if (fontsWithSameName == null) {
            fontsWithSameName = new CSSFontsWithSameName(this);
            this.fontsByFamilyName.put(familyName, fontsWithSameName);
        }
        if (added = fontsWithSameName.addFont(fontProxy)) {
            super.fontAdded(fontProxy);
        }
        return added;
    }

    protected void removeFontProxy(FontProxy fontProxy) {
        String familyName = this.normalizer.normalize(((CSS20FontDescription)fontProxy.getFontDescription()).getFamilyName());
        CSSFontsWithSameName fontsWithSameName = (CSSFontsWithSameName)this.fontsByFamilyName.get(familyName);
        if (fontsWithSameName != null) {
            fontsWithSameName.removeFont(fontProxy);
        }
    }

    public boolean isEmpty() {
        return this.fontsByFamilyName.isEmpty();
    }

    public void setGenericFont(CSS20GenericFontFamily genericFamily, String[] replacementFontNames) {
        ArrayList genericFamilyList = null;
        if (genericFamily == CSS20GenericFontFamily.SERIF) {
            genericFamilyList = this.serif;
        } else if (genericFamily == CSS20GenericFontFamily.SANS_SERIF) {
            genericFamilyList = this.sansSerif;
        } else if (genericFamily == CSS20GenericFontFamily.CURSIVE) {
            genericFamilyList = this.cursive;
        } else if (genericFamily == CSS20GenericFontFamily.FANTASY) {
            genericFamilyList = this.fantasy;
        } else if (genericFamily == CSS20GenericFontFamily.MONOSPACE) {
            genericFamilyList = this.monospace;
        } else {
            return;
        }
        genericFamilyList.clear();
        genericFamilyList.ensureCapacity(replacementFontNames.length);
        for (int i = 0; i < replacementFontNames.length; ++i) {
            genericFamilyList.add(i, replacementFontNames[i]);
        }
    }

    public void setFallbackFonts(FallbackFontSet fallbackFontSet) {
        this.fallbackFontSet = fallbackFontSet;
    }

    protected List getGenericFont(CSS20GenericFontFamily genericFamily) {
        if (genericFamily == CSS20GenericFontFamily.SERIF) {
            return this.serif;
        }
        if (genericFamily == CSS20GenericFontFamily.SANS_SERIF) {
            return this.sansSerif;
        }
        if (genericFamily == CSS20GenericFontFamily.CURSIVE) {
            return this.cursive;
        }
        if (genericFamily == CSS20GenericFontFamily.FANTASY) {
            return this.fantasy;
        }
        if (genericFamily == CSS20GenericFontFamily.MONOSPACE) {
            return this.monospace;
        }
        return null;
    }

    protected FallbackFontSet getFallbackFontSet() {
        return this.fallbackFontSet;
    }

    protected boolean replaceGenericFontFamily(List fontFamilyNames) {
        boolean foundGenerics = false;
        for (int i = 0; i < fontFamilyNames.size(); ++i) {
            String fontName = (String)fontFamilyNames.get(i);
            if (fontName.equals("serif")) {
                List serif = this.getGenericFont(CSS20GenericFontFamily.SERIF);
                fontFamilyNames.remove(i);
                if (serif == null) continue;
                fontFamilyNames.addAll(i, serif);
                foundGenerics = true;
                continue;
            }
            if (fontName.equals("sans-serif")) {
                List sansSerif = this.getGenericFont(CSS20GenericFontFamily.SANS_SERIF);
                fontFamilyNames.remove(i);
                if (sansSerif == null) continue;
                fontFamilyNames.addAll(i, sansSerif);
                foundGenerics = true;
                continue;
            }
            if (fontName.equals("cursive")) {
                List cursive = this.getGenericFont(CSS20GenericFontFamily.CURSIVE);
                fontFamilyNames.remove(i);
                if (cursive == null) continue;
                fontFamilyNames.addAll(i, cursive);
                foundGenerics = true;
                continue;
            }
            if (fontName.equals("fantasy")) {
                List fantasy = this.getGenericFont(CSS20GenericFontFamily.FANTASY);
                fontFamilyNames.remove(i);
                if (fantasy == null) continue;
                fontFamilyNames.addAll(i, fantasy);
                foundGenerics = true;
                continue;
            }
            if (!fontName.equals("monospace")) continue;
            List monospace = this.getGenericFont(CSS20GenericFontFamily.MONOSPACE);
            fontFamilyNames.remove(i);
            if (monospace == null) continue;
            fontFamilyNames.addAll(i, monospace);
            foundGenerics = true;
        }
        return foundGenerics;
    }

    protected Font[] findFont(String familyName, CSS20Attribute attributes) {
        Font[] foundFonts = null;
        CSSFontsWithSameName fontsWithSameName = (CSSFontsWithSameName)this.fontsByFamilyName.get(this.normalizer.normalize(familyName));
        if (fontsWithSameName != null) {
            foundFonts = fontsWithSameName.findFont(attributes);
        }
        return foundFonts;
    }

    public Font findFont(CSS20Attribute attributes, ULocale locale) throws FontException {
        List fontFamilyList = attributes.getFamilyNamesList();
        this.replaceGenericFontFamily(fontFamilyList);
        for (int i = 0; i < fontFamilyList.size(); ++i) {
            String familyName = (String)fontFamilyList.get(i);
            Font[] proposedFonts = this.findFont(familyName, attributes);
            if (proposedFonts == null) continue;
            return proposedFonts[0];
        }
        Iterator it = this.getFallbackFontSet().getFallbackFonts(locale);
        if (it.hasNext()) {
            return (Font)it.next();
        }
        return null;
    }

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof CSS20FontDatabase)) {
            return false;
        }
        CSS20FontDatabase o = (CSS20FontDatabase)obj;
        return this.fontsByFamilyName.equals(o.fontsByFamilyName) && this.serif.equals(o.serif) && this.sansSerif.equals(o.sansSerif) && this.monospace.equals(o.monospace) && this.fantasy.equals(o.fantasy) && this.cursive.equals(o.cursive) && this.fallbackFontSet.equals(o.fallbackFontSet);
    }

    public int hashCode() {
        int hashCode = 0;
        int hashCode1 = this.fontsByFamilyName.hashCode();
        int hashCode2 = this.serif.hashCode();
        int hashCode3 = this.sansSerif.hashCode();
        int hashCode4 = this.monospace.hashCode();
        int hashCode5 = this.fantasy.hashCode();
        int hashCode6 = this.cursive.hashCode();
        int hashCode7 = this.fallbackFontSet.hashCode();
        hashCode = hashCode1 ^ hashCode2 ^ hashCode3 ^ hashCode4 ^ hashCode5 ^ hashCode6 ^ hashCode7;
        return hashCode;
    }

    public String toString() {
        TreeSet tempSet = new TreeSet();
        Iterator it = this.fontsByFamilyName.keySet().iterator();
        while (it.hasNext()) {
            tempSet.add(it.next());
        }
        StringBuffer sb = new StringBuffer();
        sb.append("family names:\n");
        for (String k : tempSet) {
            sb.append("  ");
            sb.append(k);
            sb.append(" = ");
            sb.append(this.fontsByFamilyName.get(k).toString());
            sb.append("\n");
        }
        sb.append("generic names:\n");
        this.toString(sb, "serif", this.serif);
        this.toString(sb, "sans", this.sansSerif);
        this.toString(sb, "mono", this.monospace);
        this.toString(sb, "fantasy", this.fantasy);
        this.toString(sb, "cursive", this.cursive);
        sb.append("fallback fonts:\n");
        sb.append(this.fallbackFontSet.toString());
        return sb.toString();
    }

    protected void toString(StringBuffer sb, String key, ArrayList al) {
        TreeMap<String, Integer> tempMap = new TreeMap<String, Integer>();
        for (String name : al) {
            int count = 0;
            if (tempMap.containsKey(name)) {
                count = (Integer)tempMap.get(name);
            }
            tempMap.put(name, new Integer(++count));
        }
        sb.append("  ");
        sb.append(key);
        sb.append(" = {");
        String prefix = "'";
        for (String name2 : tempMap.keySet()) {
            int count = (Integer)tempMap.get(name2);
            while (count-- > 0) {
                sb.append(prefix);
                sb.append("'");
                sb.append(name2);
                sb.append("'");
                prefix = ", ";
            }
        }
        sb.append("}\n");
    }

    final class CSSFontsWithSameName
    implements Serializable {
        static final long serialVersionUID = 1;
        private ArrayList[][] fonts;
        private static final int kVariantNormal = 0;
        private static final int kVariantSmallCaps = 1;
        private static final int kVariantSize = 2;
        private static final int kStyleNormal = 0;
        private static final int kStyleOblique = 1;
        private static final int kStyleItalic = 2;
        private static final int kStyleSize = 3;
        final /* synthetic */ CSS20FontDatabase this$0;

        protected CSSFontsWithSameName(CSS20FontDatabase cSS20FontDatabase) {
            this.this$0 = cSS20FontDatabase;
            this.fonts = new ArrayList[2][3];
        }

        protected CSSFontsWithSameName(CSS20FontDatabase cSS20FontDatabase, CSSFontsWithSameName original) {
            this.this$0 = cSS20FontDatabase;
            this.fonts = new ArrayList[2][3];
            for (int i = 0; i < 2; ++i) {
                for (int j = 0; j < 3; ++j) {
                    if (original.fonts[i][j] == null) continue;
                    this.fonts[i][j] = (ArrayList)original.fonts[i][j].clone();
                }
            }
        }

        protected boolean addFont(FontProxy fontProxy) throws InvalidFontException, UnsupportedFontException, FontLoadingException {
            CSS20FontDescription fontDesc = (CSS20FontDescription)fontProxy.getFontDescription();
            ArrayList fontList = this.pickStyleVariantList(fontDesc.getVariant(), fontDesc.getStyle(), true);
            return this.insertFontInList(fontList, fontProxy);
        }

        protected boolean insertFontInList(ArrayList fontList, FontProxy fontProxy) throws InvalidFontException, UnsupportedFontException, FontLoadingException {
            boolean wasAdded = true;
            if (fontList.size() == 0) {
                fontList.add(fontProxy);
            }
            CSS20FontDescription fontDesc = (CSS20FontDescription)fontProxy.getFontDescription();
            int[] bounds = new int[]{0, fontList.size()};
            this.findWeightRange(fontDesc.getWeight(), fontList, bounds);
            int foundWeight = ((CSS20FontDescription)((FontProxy)fontList.get(bounds[0])).getFontDescription()).getWeight();
            if (fontDesc.getWeight() < foundWeight) {
                fontList.add(bounds[0], fontProxy);
            } else if (fontDesc.getWeight() > foundWeight) {
                fontList.add(bounds[1], fontProxy);
            } else {
                this.findStretchRange(fontDesc.getStretch(), fontList, bounds);
                int foundStretch = ((CSS20FontDescription)((FontProxy)fontList.get(bounds[0])).getFontDescription()).getStretch().getValue();
                if (fontDesc.getStretch().getValue() < foundStretch) {
                    fontList.add(bounds[0], fontProxy);
                } else if (fontDesc.getStretch().getValue() > foundStretch) {
                    fontList.add(bounds[1], fontProxy);
                } else if (this.this$0.resolutionPriority == FontResolutionPriority.LAST) {
                    fontList.add(bounds[0], fontProxy);
                } else if (this.this$0.resolutionPriority == FontResolutionPriority.FIRST) {
                    fontList.add(bounds[1], fontProxy);
                } else {
                    Font fontInList = ((FontProxy)fontList.get(bounds[0])).getFont();
                    Font preferred = IntelligentResolver.choosePreferredFont(fontInList, fontProxy.getFont(), this.this$0.resolutionPriority == FontResolutionPriority.INTELLIGENT_FIRST);
                    if (preferred == fontInList) {
                        fontList.add(bounds[1], fontProxy);
                    } else {
                        fontList.add(bounds[0], fontProxy);
                    }
                }
            }
            return wasAdded;
        }

        protected int findWeightRange(int searchWeight, ArrayList fontList, int[] bounds) {
            int bandWeight = 0;
            int[] bandBounds = new int[]{bounds[0], bounds[0]};
            for (int i = bounds[0]; i < bounds[1]; ++i) {
                FontProxy currentFontProxy = (FontProxy)fontList.get(i);
                CSS20FontDescription currentFontDescription = (CSS20FontDescription)currentFontProxy.getFontDescription();
                int currentWeight = currentFontDescription.getWeight();
                if (currentWeight == bandWeight) {
                    bandBounds[1] = i;
                    continue;
                }
                if (currentWeight <= bandWeight) continue;
                if (currentWeight <= searchWeight) {
                    bandBounds[0] = i;
                    bandBounds[1] = i;
                    bandWeight = currentWeight;
                    continue;
                }
                if (bandWeight == 0) {
                    bandBounds[0] = i;
                    bandBounds[1] = i;
                    bandWeight = currentWeight;
                    continue;
                }
                if (searchWeight <= CSS20Attribute.CSSWeightValue.W500.getValue() || bandWeight >= searchWeight) break;
                bandBounds[0] = i;
                bandBounds[1] = i;
                bandWeight = currentWeight;
            }
            bounds[0] = bandBounds[0];
            bounds[1] = bandBounds[1] + 1;
            return bounds[0];
        }

        protected int findStretchRange(CSS20Attribute.CSSStretchValue stretch, ArrayList fontList, int[] bounds) {
            int bandStretch = 0;
            int[] bandBounds = new int[]{bounds[0], bounds[0]};
            int searchStretch = stretch.getValue();
            for (int i = bounds[0]; i < bounds[1]; ++i) {
                FontProxy currentFontProxy = (FontProxy)fontList.get(i);
                CSS20FontDescription currentFontDescription = (CSS20FontDescription)currentFontProxy.getFontDescription();
                int currentStretch = currentFontDescription.getStretch().getValue();
                if (currentStretch == bandStretch) {
                    bandBounds[1] = i;
                    continue;
                }
                if (currentStretch <= bandStretch) continue;
                if (currentStretch <= searchStretch) {
                    bandBounds[0] = i;
                    bandBounds[1] = i;
                    bandStretch = currentStretch;
                    continue;
                }
                if (bandStretch == 0) {
                    bandBounds[0] = i;
                    bandBounds[1] = i;
                    bandStretch = currentStretch;
                    continue;
                }
                if (searchStretch <= CSS20Attribute.CSSStretchValue.NORMAL.getValue() || bandStretch >= searchStretch) break;
                bandBounds[0] = i;
                bandBounds[1] = i;
                bandStretch = currentStretch;
            }
            bounds[0] = bandBounds[0];
            bounds[1] = bandBounds[1] + 1;
            return bounds[0];
        }

        protected int findOpticalSize(double pointSize, ArrayList fontList, int[] bounds) {
            for (int i = bounds[0]; i < bounds[1]; ++i) {
                FontProxy currentFontProxy = (FontProxy)fontList.get(i);
                CSS20FontDescription currentFontDescription = (CSS20FontDescription)currentFontProxy.getFontDescription();
                double lowPointSize = currentFontDescription.getLowPointSize();
                double highPointSize = currentFontDescription.getHighPointSize();
                if (pointSize < lowPointSize || pointSize >= highPointSize) continue;
                return i;
            }
            return bounds[0];
        }

        protected Font[] findFont(CSS20Attribute attributes) {
            ArrayList fontList = this.pickStyleVariantList(attributes.getVariant(), attributes.getStyle(), false);
            Font[] foundFonts = null;
            if (fontList != null) {
                int foundFontIndex = 0;
                int[] bounds = new int[]{0, fontList.size()};
                this.findWeightRange(attributes.getWeight(), fontList, bounds);
                this.findStretchRange(attributes.getStretch(), fontList, bounds);
                foundFontIndex = this.findOpticalSize(attributes.getOpticalSize(), fontList, bounds);
                foundFonts = new Font[bounds[1] - bounds[0]];
                for (int i = 0; i < foundFonts.length; ++i) {
                    foundFonts[i] = ((FontProxy)fontList.get(foundFontIndex)).getFont();
                    foundFontIndex = ++foundFontIndex == bounds[1] ? bounds[0] : foundFontIndex;
                }
            }
            return foundFonts;
        }

        protected void removeFont(FontProxy fontProxy) {
            CSS20FontDescription fontDesc = (CSS20FontDescription)fontProxy.getFontDescription();
            ArrayList fontList = this.pickStyleVariantList(fontDesc.getVariant(), fontDesc.getStyle(), true);
            Iterator iter = fontList.iterator();
            while (iter.hasNext()) {
                FontProxy currentFontProxy = (FontProxy)iter.next();
                if (fontProxy != currentFontProxy) continue;
                iter.remove();
                break;
            }
        }

        private ArrayList pickStyleVariantList(CSS20Attribute.CSSVariantValue variant, CSS20Attribute.CSSStyleValue style, boolean createIfNull) {
            int variantIndex = variant == CSS20Attribute.CSSVariantValue.NORMAL || this.this$0.ignoreVariant ? 0 : 1;
            int styleIndex = style == CSS20Attribute.CSSStyleValue.NORMAL ? 0 : (style == CSS20Attribute.CSSStyleValue.OBLIQUE ? 1 : 2);
            if (createIfNull && this.fonts[variantIndex][styleIndex] == null) {
                this.fonts[variantIndex][styleIndex] = new ArrayList();
            }
            return this.fonts[variantIndex][styleIndex];
        }

        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof CSSFontsWithSameName)) {
                return false;
            }
            CSSFontsWithSameName o = (CSSFontsWithSameName)obj;
            for (int i = 0; i < 2; ++i) {
                for (int j = 0; j < 3; ++j) {
                    if (!(this.fonts[i][j] != null ? !this.fonts[i][j].equals(o.fonts[i][j]) : o.fonts[i][j] != null)) continue;
                    return false;
                }
            }
            return true;
        }

        public int hashCode() {
            int hashCode = 0;
            for (int i = 0; i < 2; ++i) {
                for (int j = 0; j < 3; ++j) {
                    if (this.fonts[i][j] == null) continue;
                    hashCode ^= this.fonts[i][j].hashCode();
                }
            }
            return hashCode;
        }

        public String toString() {
            TreeMap<String, Integer> tempMap = new TreeMap<String, Integer>();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < this.fonts.length; ++i) {
                for (int j = 0; j < this.fonts[i].length; ++j) {
                    if (this.fonts[i][j] == null) continue;
                    Iterator it = this.fonts[i][j].iterator();
                    while (it.hasNext()) {
                        String name = it.next().toString();
                        int count = 0;
                        if (tempMap.containsKey(name)) {
                            count = (Integer)tempMap.get(name);
                        }
                        tempMap.put(name, new Integer(++count));
                    }
                }
            }
            for (String name : tempMap.keySet()) {
                int count = (Integer)tempMap.get(name);
                while (count-- > 0) {
                    sb.append(name);
                    sb.append("\n");
                }
            }
            return sb.toString();
        }
    }

}