Exemplo n.º 1
0
  public FontFaceRule getFontFaceRule(String family, boolean bold, boolean italic) {
    //	TODO still necessary?
    if ((family != null) && family.startsWith("\"")) {
      family = family.substring(1);
      if (family.endsWith("\"")) {
        family = family.substring(0, family.length() - 1);
      }
    }

    return FontFaceRule.getRule(fontFaceRules, family, bold, italic);
  }
Exemplo n.º 2
0
  public boolean hasFontFamily(String family) {
    //	TODO still necessary?
    if (family.startsWith("\"")) // why why why why??
    {
      family = family.substring(1);
      if (family.endsWith("\"")) {
        family = family.substring(0, family.length() - 1);
      }
    }

    return FontFaceRule.hasFamily(fontFaceRules, family);
  }
Exemplo n.º 3
0
  public void addFontFaceRule(FontFaceRule rule) {
    assert rule != null;

    String family = rule.getFamily();
    boolean bold = rule.isBold();
    boolean italic = rule.isItalic();

    if (getFontFaceRule(family, bold, italic) == null) {
      fontFaceRules.add(rule);

      //    add embed for font
      String propName =
          "_embed__font_"
              + family
              + "_"
              + (bold ? "bold" : "medium")
              + "_"
              + (italic ? "italic" : "normal");
      Map embedParams = rule.getEmbedParams();
      StyleDeclaration styleDeclaration = rule.getStyle();
      String path = styleDeclaration.getPath();

      if (path.indexOf('\\') > -1) {
        embedParams.put(Transcoder.FILE, path.replace('\\', '/'));
        embedParams.put(Transcoder.PATHSEP, "true");
      } else {
        embedParams.put(Transcoder.FILE, path);
      }

      embedParams.put(Transcoder.LINE, Integer.toString(styleDeclaration.getLineNumber()));
      AtEmbed atEmbed =
          AtEmbed.create(propName, rule.getStyle().getLineNumber(), embedParams, false);
      addAtEmbed(atEmbed);
    } else if (Trace.font) {
      Trace.trace(
          "Font face already existed for " + family + " bold? " + bold + " italic? " + italic);
    }
  }