Examples of VectorFontCharacter


Examples of org.mt4j.components.visibleComponents.font.VectorFontCharacter

      }
     
    }
   
    if(qName.equalsIgnoreCase(SVGConstants.SVG_GLYPH_TAG)|| qName.equalsIgnoreCase(SVGConstants.SVG_MISSING_GLYPH_TAG)){
      VectorFontCharacter currentCharacter = null;
     
      for ( int i = 0; i < attributes.getLength(); i++ ){
        String currentAttributeName = attributes.getQName(i);
        String currentAttribueValue = attributes.getValue(i);
       
        if (currentAttributeName.equalsIgnoreCase("d")){
//          ArrayList<SvgFontCharacter> characters = extractPath(currentAttribueValue);
         
          //Parse the Paths's "d" attribute and create a new character
          pathHandler = new CustomPathHandler();
          pathParser.setPathHandler(pathHandler);
          pathParser.parse(currentAttribueValue);
          currentCharacter = this.createCharacter(pathHandler);
         
          //Set unicode/name for missing glyph by hand
          if (qName.equalsIgnoreCase("missing-glyph")){
            currentUnicode = "missing-glyph";
            currentGlyphName = "missing-glyph";
          }
        }else if (currentAttributeName.equalsIgnoreCase("unicode")){
          currentUnicode = currentAttribueValue;
          if (currentUnicode.equalsIgnoreCase(" ")){
            Vertex[] spaceVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(fontDefaultXAdvancing,0,0),new Vertex(fontDefaultXAdvancing,100,0), /*new Vertex(0,100,0)*/};
            ArrayList<Vertex[]> spaceContours = new ArrayList<Vertex[]>();
            spaceContours.add(spaceVerts);
            VectorFontCharacter spaceCharacter = new VectorFontCharacter(spaceContours, pa);
//            VectorFontCharacter spaceCharacter = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(100,0,0),new Vertex(100,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
            spaceCharacter.setPickable(false);
            if (MT4jSettings.getInstance().isOpenGlMode()){
              spaceCharacter.setUseDirectGL(true);
//              spaceCharacter.generateAndUseDisplayLists();
            }
            spaceCharacter.setVisible(false);
            spaceCharacter.setNoFill(true);
            spaceCharacter.setNoStroke(true);
            currentCharacter = spaceCharacter;
          }
        }else if (currentAttributeName.equalsIgnoreCase("glyph-name")){
          currentGlyphName = currentAttribueValue;
          if (currentUnicode.equalsIgnoreCase("space")){
            Vertex[] spaceVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(fontDefaultXAdvancing,0,0),new Vertex(fontDefaultXAdvancing,100,0), /*new Vertex(0,100,0)*/};
            ArrayList<Vertex[]> spaceContours = new ArrayList<Vertex[]>();
            spaceContours.add(spaceVerts);
            VectorFontCharacter spaceCharacter = new VectorFontCharacter(spaceContours, pa);
//            VectorFontCharacter spaceCharacter = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(100,0,0),new Vertex(100,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
            spaceCharacter.setPickable(false);
            if (MT4jSettings.getInstance().isOpenGlMode()){
              spaceCharacter.setUseDirectGL(true);
//              spaceCharacter.generateAndUseDisplayLists();
            }
            spaceCharacter.setVisible(false);
            spaceCharacter.setNoFill(true);
            spaceCharacter.setNoStroke(true);
            currentCharacter = spaceCharacter;
          }
        }else if (currentAttributeName.equalsIgnoreCase("horiz-adv-x")){
          currenthorizontalAdvX = Integer.parseInt(currentAttribueValue);
        }
View Full Code Here

Examples of org.mt4j.components.visibleComponents.font.VectorFontCharacter

//    Vertex.scaleVectorArray(allPathVertices, new Vector3D(0,0,0), (float)(1.0/(float)font_units_per_em));
//    Vertex.scaleVectorArray(allPathVertices, new Vector3D(0,0,0), fontSize);
    Vertex.scaleVectorArray(allPathVertices, new Vector3D(0,0,0), this.scaleFactor);
   
    //TODO nur contours als parameter is intuitiver
    VectorFontCharacter character = new VectorFontCharacter(contours,  pa);
   
    if (MT4jSettings.getInstance().isOpenGlMode())
      character.setUseDirectGL(true);

    //Color
    character.setStrokeColor(new MTColor(strokeColor.getR(), strokeColor.getG(), strokeColor.getB(), strokeColor.getAlpha()));
    character.setFillColor(new MTColor(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha()));
   
    character.setStrokeWeight(0.7f);
    character.setPickable(false);
   
    if (!antiAliased){
      character.setNoStroke(true)
    }else{
      if (MT4jSettings.getInstance().isMultiSampling() && fillColor.equals(strokeColor)){
        character.setNoStroke(true);
      }else{
        character.setNoStroke(false)
      }
    }
 
    if (MT4jSettings.getInstance().isOpenGlMode())
      character.generateAndUseDisplayLists();
   
    return character;
  }
View Full Code Here

Examples of org.mt4j.components.visibleComponents.font.VectorFontCharacter

   
    //Manually add a NEWLINE character to the font
    Vertex[] nlVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),/*new Vertex(0,100,0)*/};
    ArrayList<Vertex[]> nlContours = new ArrayList<Vertex[]>();
    nlContours.add(nlVerts);
    VectorFontCharacter newLine = new VectorFontCharacter(nlContours, pa);
//    VectorFontCharacter newLine = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
    newLine.setPickable(false);                   
    newLine.setVisible(false);
    newLine.setNoFill(true);
    newLine.setNoStroke(true);
    newLine.setHorizontalDist(0);
    newLine.setUnicode("\n");
    newLine.setName("newline");
    characters.add(newLine);
   
    //Manually add a TAB character to the font
    int defaultTabWidth = 200;
    Vertex[] tabVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),/*new Vertex(0,100,0)*/};
    ArrayList<Vertex[]> tabContours = new ArrayList<Vertex[]>();
    tabContours.add(tabVerts);
    VectorFontCharacter tab = new VectorFontCharacter(tabContours, pa);
//    VectorFontCharacter tab = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(defaultTabWidth,0,0),new Vertex(defaultTabWidth,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
    tab.setPickable(false);
    try {
      IFontCharacter space = svgFont.getFontCharacterByUnicode(" ");
      int tabWidth = 4*space.getHorizontalDist();
      tab.setHorizontalDist(tabWidth);
      tab.setVertices(new Vertex[]{new Vertex(0,0,0), new Vertex(tabWidth,0,0),new Vertex(tabWidth,100,0) /*,new Vertex(0,100,0)*/} );
    } catch (Exception e) {
      tab.setHorizontalDist(defaultTabWidth);
    }
    tab.setUnicode("\t");
    tab.setName("tab");
    tab.setVisible(false);
    tab.setNoFill(true);
    tab.setNoStroke(true);
    characters.add(tab);
   
    //Create a new SVG-FONT
//    VectorFont svgFont = new VectorFont(this.getCharacters(), fontDefaultXAdvancing, fontFamily, fontMaxAscent, fontMaxDescent, font_units_per_em, fontSize,
    VectorFont svgFont = new VectorFont((VectorFontCharacter[])characters.toArray(new VectorFontCharacter[characters.size()]), fontDefaultXAdvancing, fontFamily, fontMaxAscent, fontMaxDescent, font_units_per_em, fontSize,
View Full Code Here

Examples of org.mt4j.components.visibleComponents.font.VectorFontCharacter

   
    //Manually add a NEWLINE character to the font
    Vertex[] nlVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),/*new Vertex(0,100,0)*/};
    ArrayList<Vertex[]> nlContours = new ArrayList<Vertex[]>();
    nlContours.add(nlVerts);
    VectorFontCharacter newLine = new VectorFontCharacter(nlContours, pa);
    newLine.setPickable(false);                   
    newLine.setVisible(false);
    newLine.setNoFill(true);
    newLine.setNoStroke(true);
    newLine.setHorizontalDist(0);
    newLine.setUnicode("\n");
    newLine.setName("newline");
    newArray[newArray.length-3] = newLine;
   
    //Manually add a SPACE character to the font
//    int charIndex       = this.getCmapFormat(f).mapCharCode(32);
    int charIndex       = this.getCmapFormat(f).mapCharCode('i');
//    int charIndex       = this.getCmapFormat(f).mapCharCode('-');
    int default_advance_x   = f.getHmtxTable().getAdvanceWidth(charIndex);
    Glyph glyph        = f.getGlyph(charIndex);
    int xadvance = 0;
    if (glyph != null){
//      xadvance = Math.round((default_advance_x * (float)(1.0/(float)this.unitsPerEm)) * fontSize);
      xadvance = Math.round(default_advance_x * this.scaleFactor);
    }else{
//      xadvance = Math.round((fontDefaultXAdvancing * (float)(1.0/(float)this.unitsPerEm)) * fontSize);
      xadvance = Math.round(fontDefaultXAdvancing * this.scaleFactor);
    }
   
    Vertex[] spaceVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(xadvance,0,0),new Vertex(xadvance,100,0), /*new Vertex(0,100,0)*/};
    ArrayList<Vertex[]> spaceContours = new ArrayList<Vertex[]>();
    spaceContours.add(spaceVerts);
    VectorFontCharacter space = new VectorFontCharacter(spaceContours, pa);
    space.setPickable(false);                   
    space.setVisible(false);
    space.setNoFill(true);
    space.setNoStroke(true);
    space.setHorizontalDist(xadvance);
    space.setUnicode(" ");
    space.setName("space");
    newArray[newArray.length-2] = space;

    //Manually add a TAB character to the font
    int defaultTabWidth = fontDefaultXAdvancing*4;
    Vertex[] tabVerts = new Vertex[]{new Vertex(0,0,0), new Vertex(200,0,0),new Vertex(200,100,0),/*new Vertex(0,100,0)*/};
    ArrayList<Vertex[]> tabContours = new ArrayList<Vertex[]>();
    tabContours.add(tabVerts);
    VectorFontCharacter tab = new VectorFontCharacter(tabContours, pa);
    tab.setPickable(false);
    try {
      int tabWidth = 4 * space.getHorizontalDist();
      tab.setHorizontalDist(tabWidth);
      tab.setVertices(new Vertex[]{new Vertex(0,0,0), new Vertex(tabWidth,0,0),new Vertex(tabWidth,100,0),/*new Vertex(0,100,0)*/} );
    } catch (Exception e) {
      tab.setHorizontalDist(defaultTabWidth);
    }
    tab.setUnicode("\t");
    tab.setName("tab");
    tab.setVisible(false);
    tab.setNoFill(true);
    tab.setNoStroke(true);
    newArray[newArray.length-1] = tab;
    ////////

    int fontMaxAscent   = f.getAscent();
    int fontMaxDescent  = f.getDescent();
View Full Code Here

Examples of org.mt4j.components.visibleComponents.font.VectorFontCharacter

      int default_advance_x   = f.getHmtxTable().getAdvanceWidth(glyphIndex);

      if (glyph != null) {
//        glyph.scale(Math.round(scaleFactor)); //Scaling has changed to int!?
        // Add the Glyph to the Shape with an horizontal offset of x
        VectorFontCharacter fontChar = getGlyphAsShape(f, glyph, glyphIndex, x, fillColor, strokeColor);

        if (fontChar != null){
          //Sets characters horizontal advancement and unicode value
          fontChar.setHorizontalDist(default_advance_x);

//          float tmp = fontChar.getHorizontalDist() * (float)(1.0/(float)this.unitsPerEm);
//          fontChar.setHorizontalDist(Math.round(tmp * fontSize));
         
          fontChar.setHorizontalDist(Math.round(fontChar.getHorizontalDist() * scaleFactor)); //FIXME TRIAL
         
          fontChar.setUnicode(Character.toString(text.charAt(i)));
          fontChar.setName(Character.toString(text.charAt(i)));

          characters.add(fontChar);
        }

        x += glyph.getAdvanceWidth();
View Full Code Here

Examples of org.mt4j.components.visibleComponents.font.VectorFontCharacter

//        Vertex.scaleVectorArray(contour, new Vector3D(0,0,0), (float)(1.0/(float)this.unitsPerEm));
//        Vertex.scaleVectorArray(contour, new Vector3D(0,0,0), fontSize);
        Vertex.scaleVectorArray(contour, new Vector3D(0,0,0), this.scaleFactor);
      }
     
      VectorFontCharacter character = new VectorFontCharacter(allContours,  pa);
     
      if (MT4jSettings.getInstance().isOpenGlMode())
        character.setUseDirectGL(true);
     
      character.setStrokeWeight(0.7f);
      character.setPickable(false);
     
//      //FIXME TEST -> dont use a font outline if we use multi-sampling and outlineColor=fillcolor
      if (!this.antiAliasing){
        character.setNoStroke(true)
      }else{
        if (MT4jSettings.getInstance().isMultiSampling() && fillColor.equals(strokeColor)){
          character.setNoStroke(true);
        }else{
          character.setNoStroke(false)
        }
      }

//      for(Vertex[] contour: character.getContours()){
//        Vertex.xRotateVectorArray(contour, new Vector3D((float)(xadv/2.0),0,0), 180);
//        Vertex.scaleVectorArray(contour, new Vector3D(0,0,0), (float)(1.0/(float)this.unitsPerEm));
//        Vertex.scaleVectorArray(contour, new Vector3D(0,0,0), fontSize);
//      }

//      Vertex[] v = character.getGeometryInfo().getVertices();
//      Vertex.xRotateVectorArray(v, new Vector3D((float)(xadv/2.0),0,0), 180);
//      Vertex.scaleVectorArray(v, new Vector3D(0,0,0), (float)(1.0/(float)this.unitsPerEm));
//      Vertex.scaleVectorArray(v, new Vector3D(0,0,0), fontSize);
//      character.setVertices(v);
     
      /*
      character.xRotate(new Vector3D((float)(xadv/2.0),0,0), 180);
      character.scale((float)(1.0/(float)this.unitsPerEm), new Vector3D(0,0,0));
      character.scale(fontSize , new Vector3D(0,0,0));
       */

      character.setStrokeColor(new MTColor(strokeColor));
      character.setFillColor(new MTColor(fillColor));
     
      if (MT4jSettings.getInstance().isOpenGlMode())
        character.generateAndUseDisplayLists();
     
      return character;
    }else{
      return null;
    }
View Full Code Here

Examples of org.mt4j.components.visibleComponents.font.VectorFontCharacter

    int charIndex = cmapFmt.mapCharCode(charCodeMapIndex);
    int default_advance_x   = f.getHmtxTable().getAdvanceWidth(charIndex);
   
    Glyph glyph  = f.getGlyph(charIndex);
    if (glyph != null){
      VectorFontCharacter character = this.getGlyphAsShape(f, glyph, charIndex, 0, new MTColor(0,0,0,255), new MTColor(0,0,0,255));
      if (character != null){
        character.setHorizontalDist(default_advance_x);
        return character;
      }else{
        return null;
      }
    }else{
View Full Code Here

Examples of org.mt4j.components.visibleComponents.font.VectorFontCharacter

    });
    this.addChild(keybCloseSvg);
//    */
   
    //INITIALIZE SPACE-Button "by hand"
    VectorFontCharacter SpaceF = (VectorFontCharacter) keyFont.getFontCharacterByUnicode("k");
//    MTKey space = new MTKey(SpaceF.getGeometryInfo().getVertices(), /*spaceOutlines,*/pa, " ", " ");
    MTKey space = new MTKey(SpaceF.getGeometryInfo(), /*spaceOutlines,*/pa, " ", " ");
    space.setName(SpaceF.getName());
    //Set the contours to draw the outline - do this after settings the geominfo
    //so the outline displaylist will be overridden with the new contours list
    space.setOutlineContours(SpaceF.getContours()); //FIXME do we have to in opengl mode? -> we will use displayLists anyway..
    if (MT4jSettings.getInstance().isOpenGlMode()){
      space.setUseDirectGL(true);
//      System.out.println(SpaceF.getDisplayListIDs()[0] + "  - " + SpaceF.getDisplayListIDs()[1]);
//      space.setDisplayListIDs(SpaceF.getDisplayListIDs()); //Wenn nicht displaylisten, m�ssen wir geometry auch �bernehmen!
      space.getGeometryInfo().setDisplayListIDs(SpaceF.getGeometryInfo().getDisplayListIDs()); //Wenn nicht displaylisten, m�ssen wir geometry auch �bernehmen!
      space.setUseDisplayList(true);
    }
    space.setNoStroke(false);
    space.setDrawSmooth(true);
    space.setPickable(true);
    space.setGestureAllowance(DragProcessor.class, false);
    space.setGestureAllowance(RotateProcessor.class, false);
    space.setGestureAllowance(ScaleProcessor.class, false);
    space.unregisterAllInputProcessors();
//    space.translate(new Vector3D(100, space.getOriginalHeight(), 0)); //Translate to 0,0
//    space.translate(new Vector3D(225, 190,0));
    scaleKey(space, 40);
    space.setPositionRelativeToParent(new Vector3D(350,210,0));
    space.setGestureAllowance(TapProcessor.class, true);
    space.registerInputProcessor(new TapProcessor(pa));
    space.addGestureListener(TapProcessor.class, keyClickAction);
    SpaceF = null;
    keyList.add(space);
    this.addChild(space);

    KeyInfo[] keyInfos = this.getKeysLayout();
   
    //CREATE THE KEYS \\
//    for (int i = 0; i < keyInfos.size(); i++) {
//      KeyInfo keyInfo = keyInfos.get(i);
    for (int i = 0; i < keyInfos.length; i++) {
      KeyInfo keyInfo = keyInfos[i];
     
      VectorFontCharacter fontChar = (VectorFontCharacter) keyFont.getFontCharacterByUnicode(keyInfo.keyfontUnicode);
      //FIXME expensive..
//      MTKey key = new MTKey(fontChar.getGeometryInfo().getVertices(), fontChar.getContours(),pa, keyInfo.charUnicodeToWrite, keyInfo.charUnicodeToWriteShifted);
//      MTKey key = new MTKey(new Vertex[]{new Vertex(0,0,0),new Vertex(10,0,0),new Vertex(0,10,0),}, /*fontChar.getContours(),*/ pa, keyInfo.charUnicodeToWrite, keyInfo.charUnicodeToWriteShifted);
      MTKey key = new MTKey(fontChar.getGeometryInfo(),  pa, keyInfo.charUnicodeToWrite, keyInfo.charUnicodeToWriteShifted);
//      key.setGeometryInfo(fontChar.getGeometryInfo());
      key.setName(fontChar.getName());
      key.setPickable(true);
      key.unregisterAllInputProcessors();
     
      key.setOutlineContours(fontChar.getContours());
      if (MT4jSettings.getInstance().isOpenGlMode()){
        key.setUseDirectGL(true);
        //Use the display lists already created for the font characters of the key-font
        key.getGeometryInfo().setDisplayListIDs(fontChar.getGeometryInfo().getDisplayListIDs());
        key.setUseDisplayList(true);
      }
//      key.setOutlineContours(fontChar.getContours());
     
      //Translate to 0,0
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.