Esempio n. 1
0
        protected static int addRealText(BlockArea ba, FontState fontState,
                                         float red, float green, float blue,
                                         WrapOption wrapOption, LinkSet ls,
                                         int whiteSpaceCollapse, char[] data,
                                         int start, int end, TextState textState,
                                         VerticalAlign vAlign)
        {
            int ts, te;

            char[] ca;

            ts = start;
            te = end;
            ca = data;

            LineArea la = ba.getCurrentLineArea();

            if (la == null)
            {
                return(start);
            }

            la.changeFont(fontState);
            la.changeColor(red, green, blue);
            la.changeWrapOption(wrapOption);
            la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
            la.changeVerticalAlign(vAlign);
            ba.setupLinkSet(ls);

            ts = la.addText(ca, ts, te, ls, textState);

            while (ts != -1)
            {
                la = ba.createNextLineArea();
                if (la == null)
                {
                    return(ts);
                }
                la.changeFont(fontState);
                la.changeColor(red, green, blue);
                la.changeWrapOption(wrapOption);
                la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
                ba.setupLinkSet(ls);

                ts = la.addText(ca, ts, te, ls, textState);
            }
            return(-1);
        }
Esempio n. 2
0
        /// <summary>
        /// Reloads the OpenGl Texture from the Surface.
        /// </summary>
        /// <param name="surface">The surface to load from.</param>
        /// <param name="isFlipped">States if the surface should be flipped when moved into the OpenGl Texture.</param>
        /// <param name="minifyingFilter">"The openGl filter used for minifying"</param>
        /// <param name="magnificationFilter">"The openGl filter used for magnification"</param>
        /// <param name="wrapS">The wrap parameter for texture coordinate S</param>
        /// <param name="wrapT">The wrap parameter for texture coordinate T</param>
        public void Refresh(Surface surface, bool isFlipped, MinifyingOption minifyingFilter, MagnificationOption magnificationFilter, WrapOption wrapS, WrapOption wrapT)
        {
            if (surface == null)
            {
                throw new ArgumentNullException("surface");
            }
            this.surface = surface;
            this.Delete();
            using (Surface textureSurface = TransformSurface(isFlipped))
            {
                int[] textures = new int[1];
                glGenTextures(1, textures);
                this.textureId = textures[0];

                this.textureWidth        = textureSurface.Width;
                this.textureHeight       = textureSurface.Height;
                this.isFlipped           = isFlipped;
                this.minifyingFilter     = minifyingFilter;
                this.magnificationFilter = magnificationFilter;
                this.wrapS       = wrapS;
                this.wrapT       = wrapT;
                this.widthRatio  = (float)surface.Width / textureWidth;
                this.heightRatio = (float)surface.Height / textureHeight;

                glBindTexture(GL_TEXTURE_2D, textureId);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (int)minifyingFilter);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (int)magnificationFilter);

                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (int)wrapS);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (int)wrapT);



                if (minifyingFilter == MinifyingOption.Linear || minifyingFilter == MinifyingOption.Nearest)
                {
                    glTexImage2D(GL_TEXTURE_2D, 0, textureSurface.BytesPerPixel, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSurface.Pixels);
                }
                else
                {
                    NativeMethods.gluBuild2DMipmaps(GL_TEXTURE_2D, textureSurface.BytesPerPixel, textureWidth, textureHeight, GL_RGBA, GL_UNSIGNED_BYTE, textureSurface.Pixels);
                }

                needRefresh    = false;
                needSetOptions = false;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Creates a new Instance of SurfaceGl.
 /// </summary>
 /// <param name="surface">The surface to be copied into a OpenGl Texture.</param>
 /// <param name="isFlipped">States if the surface should be flipped when copied into a OpenGl Texture.</param>
 public SurfaceGl(Surface surface, bool isFlipped)
 {
     if (surface == null)
     {
         throw new ArgumentNullException("surface");
     }
     this.surface             = surface;
     this.isFlipped           = isFlipped;
     this.textureId           = -1;
     this.textureWidth        = -1;
     this.textureHeight       = -1;
     this.widthRatio          = -1;
     this.heightRatio         = -1;
     this.minifyingFilter     = MinifyingOption.Linear;
     this.magnificationFilter = MagnificationOption.Linear;
     this.wrapS = WrapOption.Repeat;
     this.wrapT = WrapOption.Repeat;
 }
Esempio n. 4
0
        public override Status Layout(Area area)
        {
            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetWarning(
                    "Page-number outside block area");
                return(new Status(Status.OK));
            }
            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                ColorType c = this.properties.GetProperty("color").GetColorType();
                this.red   = c.Red;
                this.green = c.Green;
                this.blue  = c.Blue;

                this.wrapOption         = (WrapOption)this.properties.GetProperty("wrap-option").GetEnum();
                this.whiteSpaceCollapse =
                    this.properties.GetProperty("white-space-collapse").GetEnum();
                ts          = new TextState();
                this.marker = 0;


                area.GetMyRefs().InitializeID(this.properties.GetId(), area);
            }

            string p = area.getPage().getFormattedNumber();

            this.marker = FOText.addText((BlockArea)area,
                                         propMgr.GetFontState(area.getFontInfo()),
                                         red, green, blue, wrapOption, null,
                                         whiteSpaceCollapse, p.ToCharArray(), 0,
                                         p.Length, ts, VerticalAlign.BASELINE);
            return(new Status(Status.OK));
        }
Esempio n. 5
0
        public override Status Layout(Area area)
        {
            BlockArea blockArea;

            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetWarning(
                    "Currently Character can only be in a BlockArea");
                return(new Status(Status.OK));
            }
            blockArea = (BlockArea)area;
            bool textDecoration;

            AuralProps            mAurProps  = propMgr.GetAuralProps();
            BorderAndPadding      bap        = propMgr.GetBorderAndPadding();
            BackgroundProps       bProps     = propMgr.GetBackgroundProps();
            HyphenationProps      mHyphProps = propMgr.GetHyphenationProps();
            MarginInlineProps     mProps     = propMgr.GetMarginInlineProps();
            RelativePositionProps mRelProps  = propMgr.GetRelativePositionProps();
            ColorType             c          = properties.GetColorType();
            float red   = c.Red;
            float green = c.Green;
            float blue  = c.Blue;

            int        whiteSpaceCollapse = properties.GetWhiteSpaceCollapse();
            WrapOption wrapOption         = this.parent.properties.GetWrapOption();

            TextDecoration tmp = properties.GetTextDecoration();

            if (tmp == TextDecoration.UNDERLINE)
            {
                textDecoration = true;
            }
            else
            {
                textDecoration = false;
            }

            char   characterValue = this.properties.GetChar();
            string id             = this.properties.GetId();

            blockArea.GetMyRefs().InitializeID(id, blockArea);

            LineArea la = blockArea.getCurrentLineArea();

            if (la == null)
            {
                return(new Status(Status.AREA_FULL_NONE));
            }
            la.changeFont(propMgr.GetFontState(area.getFontInfo()));
            la.changeColor(red, green, blue);
            la.changeWrapOption(wrapOption);
            la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
            blockArea.setupLinkSet(this.GetLinkSet());
            int result = la.addCharacter(characterValue, this.GetLinkSet(),
                                         textDecoration);

            if (result == Character.DOESNOT_FIT)
            {
                la = blockArea.createNextLineArea();
                if (la == null)
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }
                la.changeFont(propMgr.GetFontState(area.getFontInfo()));
                la.changeColor(red, green, blue);
                la.changeWrapOption(wrapOption);
                la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
                blockArea.setupLinkSet(this.GetLinkSet());
                la.addCharacter(characterValue, this.GetLinkSet(),
                                textDecoration);
            }
            return(new Status(Status.OK));
        }
Esempio n. 6
0
        public override Status Layout(Area area)
        {
            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetError(
                    "Text outside block area" + new String(ca, start, length));
                return(new Status(Status.OK));
            }
            if (this.marker == MarkerStart)
            {
                string fontFamily =
                    this.parent.properties.GetProperty("font-family").GetString();
                string fontStyle =
                    this.parent.properties.GetProperty("font-style").GetString();
                string fontWeight =
                    this.parent.properties.GetProperty("font-weight").GetString();
                int fontSize =
                    this.parent.properties.GetProperty("font-size").GetLength().MValue();
                int fontVariant =
                    this.parent.properties.GetProperty("font-variant").GetEnum();

                int letterSpacing =
                    this.parent.properties.GetProperty("letter-spacing").GetLength().MValue();
                this.fs = new FontState(area.getFontInfo(), fontFamily,
                                        fontStyle, fontWeight, fontSize,
                                        fontVariant, letterSpacing);

                ColorType c = this.parent.properties.GetProperty("color").GetColorType();
                this.red   = c.Red;
                this.green = c.Green;
                this.blue  = c.Blue;

                this.verticalAlign =
                    this.parent.properties.GetVerticalAlign();

                this.wrapOption =
                    (WrapOption)this.parent.properties.GetProperty("wrap-option").GetEnum();
                this.whiteSpaceCollapse =
                    this.parent.properties.GetProperty("white-space-collapse").GetEnum();
                this.ts = new TextState();
                ts.setUnderlined(underlined);
                ts.setOverlined(overlined);
                ts.setLineThrough(lineThrough);

                this.marker = this.start;
            }
            int orig_start = this.marker;

            this.marker = addText((BlockArea)area, fs, red, green, blue,
                                  wrapOption, this.GetLinkSet(),
                                  whiteSpaceCollapse, ca, this.marker, length,
                                  ts, verticalAlign);
            if (this.marker == -1)
            {
                return(new Status(Status.OK));
            }
            else if (this.marker != orig_start)
            {
                return(new Status(Status.AREA_FULL_SOME));
            }
            else
            {
                return(new Status(Status.AREA_FULL_NONE));
            }
        }
Esempio n. 7
0
        public static int addText(BlockArea ba, FontState fontState, float red,
                                  float green, float blue, WrapOption wrapOption,
                                  LinkSet ls, int whiteSpaceCollapse,
                                  char[] data, int start, int end,
                                  TextState textState, VerticalAlign vAlign)
        {
            if (fontState.FontVariant == FontVariant.SMALL_CAPS)
            {
                FontState smallCapsFontState;
                try
                {
                    int smallCapsFontHeight =
                        (int)(((double)fontState.FontSize) * 0.8d);
                    smallCapsFontState = new FontState(fontState.FontInfo,
                                                       fontState.FontFamily,
                                                       fontState.FontStyle,
                                                       fontState.FontWeight,
                                                       smallCapsFontHeight,
                                                       FontVariant.NORMAL);
                }
                catch (FonetException ex)
                {
                    smallCapsFontState = fontState;
                    FonetDriver.ActiveDriver.FireFonetError(
                        "Error creating small-caps FontState: " + ex.Message);
                }

                char      c;
                bool      isLowerCase;
                int       caseStart;
                FontState fontStateToUse;
                for (int i = start; i < end;)
                {
                    caseStart   = i;
                    c           = data[i];
                    isLowerCase = (Char.IsLetter(c) && Char.IsLower(c));
                    while (isLowerCase == (Char.IsLetter(c) && Char.IsLower(c)))
                    {
                        if (isLowerCase)
                        {
                            data[i] = Char.ToUpper(c);
                        }
                        i++;
                        if (i == end)
                        {
                            break;
                        }
                        c = data[i];
                    }
                    if (isLowerCase)
                    {
                        fontStateToUse = smallCapsFontState;
                    }
                    else
                    {
                        fontStateToUse = fontState;
                    }
                    int index = addRealText(ba, fontStateToUse, red, green, blue,
                                            wrapOption, ls, whiteSpaceCollapse,
                                            data, caseStart, i, textState,
                                            vAlign);
                    if (index != -1)
                    {
                        return(index);
                    }
                }

                return(-1);
            }

            return(addRealText(ba, fontState, red, green, blue, wrapOption, ls,
                               whiteSpaceCollapse, data, start, end, textState,
                               vAlign));
        }
Esempio n. 8
0
        /// <summary>
        /// Reloads the OpenGl Texture from the Surface.
        /// </summary>
        /// <param name="surface">The surface to load from.</param>
        /// <param name="isFlipped">States if the surface should be flipped when moved into the OpenGl Texture.</param>
        /// <param name="minifyingFilter">"The openGl filter used for minifying"</param>
        /// <param name="magnificationFilter">"The openGl filter used for magnification"</param>
        /// <param name="wrapS">The wrap parameter for texture coordinate S</param>
        /// <param name="wrapT">The wrap parameter for texture coordinate T</param>
        public void Refresh(Surface surface, bool isFlipped, MinifyingOption minifyingFilter, MagnificationOption magnificationFilter, WrapOption wrapS, WrapOption wrapT)
        {
            if (surface == null) { throw new ArgumentNullException("surface"); }
            this.surface = surface;
            this.Delete();
            using (Surface textureSurface = TransformSurface(isFlipped))
            {
                int[] textures = new int[1];
                glGenTextures(1, textures);
                this.textureId = textures[0];

                this.textureWidth = textureSurface.Width;
                this.textureHeight = textureSurface.Height;
                this.isFlipped = isFlipped;
                this.minifyingFilter = minifyingFilter;
                this.magnificationFilter = magnificationFilter;
                this.wrapS = wrapS;
                this.wrapT = wrapT;
                this.widthRatio = (float)surface.Width / textureWidth;
                this.heightRatio = (float)surface.Height / textureHeight;

                glBindTexture(GL_TEXTURE_2D, textureId);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (int)minifyingFilter);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (int)magnificationFilter);

                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (int)wrapS);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (int)wrapT);



                if (minifyingFilter == MinifyingOption.Linear || minifyingFilter == MinifyingOption.Nearest)
                {
                    glTexImage2D(GL_TEXTURE_2D, 0, textureSurface.BytesPerPixel, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureSurface.Pixels);
                }
                else
                {
                    NativeMethods.gluBuild2DMipmaps(GL_TEXTURE_2D, textureSurface.BytesPerPixel, textureWidth, textureHeight, GL_RGBA, GL_UNSIGNED_BYTE, textureSurface.Pixels);
                }

                needRefresh = false;
                needSetOptions = false;
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Creates a new Instance of SurfaceGl.
 /// </summary>
 /// <param name="surface">The surface to be copied into a OpenGl Texture.</param>
 /// <param name="isFlipped">States if the surface should be flipped when copied into a OpenGl Texture.</param>
 public SurfaceGl(Surface surface, bool isFlipped)
 {
     if (surface == null)
     {
         throw new ArgumentNullException("surface");
     }
     this.surface = surface;
     this.isFlipped = isFlipped;
     this.textureId = -1;
     this.textureWidth = -1;
     this.textureHeight = -1;
     this.widthRatio = -1;
     this.heightRatio = -1;
     this.minifyingFilter = MinifyingOption.Linear;
     this.magnificationFilter = MagnificationOption.Linear;
     this.wrapS = WrapOption.Repeat;
     this.wrapT = WrapOption.Repeat;
 }
Esempio n. 10
0
        public override Status Layout(Area area)
        {
            if (!(area is BlockArea))
            {
                FonetDriver.ActiveDriver.FireFonetWarning(
                    "Page-number-citation outside block area");
                return(new Status(Status.OK));
            }

            MyIDRefs idReferences = area.GetMyRefs();

            this.area = area;
            if (this.marker == MarkerStart)
            {
                AccessibilityProps    mAccProps = propMgr.GetAccessibilityProps();
                AuralProps            mAurProps = propMgr.GetAuralProps();
                BorderAndPadding      bap       = propMgr.GetBorderAndPadding();
                BackgroundProps       bProps    = propMgr.GetBackgroundProps();
                MarginInlineProps     mProps    = propMgr.GetMarginInlineProps();
                RelativePositionProps mRelProps = propMgr.GetRelativePositionProps();

                ColorType c = this.properties.GetProperty("color").GetColorType();
                this.red   = c.Red;
                this.green = c.Green;
                this.blue  = c.Blue;

                this.wrapOption         = (WrapOption)this.properties.GetProperty("wrap-option").GetEnum();
                this.whiteSpaceCollapse =
                    this.properties.GetProperty("white-space-collapse").GetEnum();

                this.refId = this.properties.GetProperty("ref-id").GetString();

                if (this.refId.Equals(""))
                {
                    throw new FonetException("page-number-citation must contain \"ref-id\"");
                }

                this.id = this.properties.GetProperty("id").GetString();
                idReferences.CreateID(id);
                ts = new TextState();

                this.marker = 0;
            }

            if (marker == 0)
            {
                idReferences.ConfigureID(id, area);
            }


            pageNumber = idReferences.getPageNumber(refId);

            if (pageNumber != null)
            {
                this.marker =
                    FOText.addText((BlockArea)area,
                                   propMgr.GetFontState(area.getFontInfo()), red,
                                   green, blue, wrapOption, null,
                                   whiteSpaceCollapse, pageNumber.ToCharArray(),
                                   0, pageNumber.Length, ts,
                                   VerticalAlign.BASELINE);
            }
            else
            {
                BlockArea blockArea = (BlockArea)area;
                LineArea  la        = blockArea.getCurrentLineArea();
                if (la == null)
                {
                    return(new Status(Status.AREA_FULL_NONE));
                }
                la.changeFont(propMgr.GetFontState(area.getFontInfo()));
                la.changeColor(red, green, blue);
                la.changeWrapOption(wrapOption);
                la.changeWhiteSpaceCollapse(whiteSpaceCollapse);
                la.addPageNumberCitation(refId, null);
                this.marker = -1;
            }

            if (this.marker == -1)
            {
                return(new Status(Status.OK));
            }
            else
            {
                return(new Status(Status.AREA_FULL_NONE));
            }
        }
Esempio n. 11
0
 public void changeWrapOption(WrapOption wrapOption)
 {
     this.wrapOption = wrapOption;
 }