gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz ./TODO gfx/demo/gldemo.py gfx/demo/text.py ...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz ./TODO gfx/demo/gldemo.py gfx/demo/text.py ...
Date: Tue, 08 Oct 2002 03:30:12 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/10/08 03:30:12

Modified files:
        .              : TODO 
        gfx/demo       : gldemo.py text.py 
        gfx/libtext    : Text.cxx Text.hxx 
        gzz/vob        : TextVob.java 

Log message:
        Baselined text now works in openGL

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/TODO.diff?tr1=1.254&tr2=1.255&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/gldemo.py.diff?tr1=1.35&tr2=1.36&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/text.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtext/Text.cxx.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtext/Text.hxx.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/TextVob.java.diff?tr1=1.37&tr2=1.38&r1=text&r2=text

Patches:
Index: gzz/TODO
diff -c gzz/TODO:1.254 gzz/TODO:1.255
*** gzz/TODO:1.254      Tue Oct  8 01:30:47 2002
--- gzz/TODO    Tue Oct  8 03:30:12 2002
***************
*** 157,168 ****
          avoid breakage on them from now on.
            - MAKE SURE THAT THESE TESTS CATCH THE LOCALE BUG
        - sane exception if ../mstmpimg isn't found
!       - a really comprehensive web page of screenshots
!         and instructions on how to get them and run.
            - clean up OpenGL demos and views and document, list
              so easy to look at.
        - fix mirror failing test, make more tests and check.
!       - if there are problems with performance, edit libcoords to use
          boost::object_pool for making allocations much faster
        - fix fillet demo last two screens
        - make GLVobCoorder's all coordsys types
--- 157,168 ----
          avoid breakage on them from now on.
            - MAKE SURE THAT THESE TESTS CATCH THE LOCALE BUG
        - sane exception if ../mstmpimg isn't found
!       - a really comprehensive web page of screenshots, animations
!         and instructions on how to get them working.
            - clean up OpenGL demos and views and document, list
              so easy to look at.
        - fix mirror failing test, make more tests and check.
!       + if there are problems with performance, edit libcoords to use
          boost::object_pool for making allocations much faster
        - fix fillet demo last two screens
        - make GLVobCoorder's all coordsys types
Index: gzz/gfx/demo/gldemo.py
diff -c gzz/gfx/demo/gldemo.py:1.35 gzz/gfx/demo/gldemo.py:1.36
*** gzz/gfx/demo/gldemo.py:1.35 Mon Oct  7 12:29:29 2002
--- gzz/gfx/demo/gldemo.py      Tue Oct  8 03:30:12 2002
***************
*** 52,64 ****
        Color %s %s %s
        Begin QUADS
        TexCoord 0 0
!       Vertex -1 -1
        TexCoord 0 1
!       Vertex -1 1
        TexCoord 1 1
        Vertex 1 1
        TexCoord 1 0
!       Vertex 1 -1
        End
        PopAttrib
      """%(rgb))
--- 52,64 ----
        Color %s %s %s
        Begin QUADS
        TexCoord 0 0
!       Vertex 0 0
        TexCoord 0 1
!       Vertex 0 1
        TexCoord 1 1
        Vertex 1 1
        TexCoord 1 0
!       Vertex 1 0
        End
        PopAttrib
      """%(rgb))
Index: gzz/gfx/demo/text.py
diff -c gzz/gfx/demo/text.py:1.2 gzz/gfx/demo/text.py:1.3
*** gzz/gfx/demo/text.py:1.2    Mon Oct  7 13:47:55 2002
--- gzz/gfx/demo/text.py        Tue Oct  8 03:30:12 2002
***************
*** 6,21 ****
  
  textstyle = GLTextStyle.create("sans", 0, 1)
  
  A = [GLRen.createHorizText2(f, "ABCgabcg", 1, 1, 1, 0) for f in fonts]
! B = [TextVob(textstyle, "ABCgabcg") for f in fonts]
  
  class TextScene:
      def __init__(self):
        self.fontind = len(A)-1
        self.offset = [(0,0),(1.5,1.5),(0,1.5),(1.5,0)]
        self.regcomb = 0
      
      def key(self, key):
        if key == "c":
            self.regcomb = not self.regcomb
            AbstractUpdateManager.setNoAnimation()
--- 6,32 ----
  
  textstyle = GLTextStyle.create("sans", 0, 1)
  
+ for f in fonts:
+     print f.getHeight(), f.getYOffs()
+ 
  A = [GLRen.createHorizText2(f, "ABCgabcg", 1, 1, 1, 0) for f in fonts]
! B = TextVob(textstyle, "ABCgabcg", 0) 
! C = TextVob(textstyle, "ABCgabcg", 1) 
! 
! cq = coloredQuad((1,1,1))
  
  class TextScene:
      def __init__(self):
        self.fontind = len(A)-1
        self.offset = [(0,0),(1.5,1.5),(0,1.5),(1.5,0)]
        self.regcomb = 0
+       self.textvobs = [B, C]
      
      def key(self, key):
+       if key == "b":
+           rotatelist(self.textvobs)
+           AbstractUpdateManager.setNoAnimation()
+           AbstractUpdateManager.chg()
        if key == "c":
            self.regcomb = not self.regcomb
            AbstractUpdateManager.setNoAnimation()
***************
*** 37,46 ****
        vs.map.put(background((0.3,0.5,0.6)))
  
        vs.map.put(getDListNocoords("""
            Enable BLEND
            Disable ALPHA_TEST
-           Color 0 0 0
            PushAttrib ENABLE_BIT TEXTURE_BIT
        """))
  
        if self.regcomb:
--- 48,58 ----
        vs.map.put(background((0.3,0.5,0.6)))
  
        vs.map.put(getDListNocoords("""
+           Color 0 0 0
            Enable BLEND
            Disable ALPHA_TEST
            PushAttrib ENABLE_BIT TEXTURE_BIT
+           Disable TEXTURE_2D
        """))
  
        if self.regcomb:
***************
*** 62,67 ****
--- 74,80 ----
  
        y = 20
        sizes = (5, 6, 7, 8, 9, 10, 12, 15, 16, 20, 24, 32, 64, 100, 200)
+ 
        for s in sizes:
            y += s
            for i in (self.fontind,): # range(0,len(A)):
***************
*** 73,83 ****
  
      
        y = 20
-       sizes = (5, 6, 7, 8, 9, 10, 12, 15, 16, 20, 24, 32, 64, 100, 200)
        for s in sizes:
            y += s
!           for i in (self.fontind,): # range(0,len(A)):
!               vs.put(B[i], "B"+str((s,i)), 0, 500 + self.offset[0][0], y + 
self.offset[0][1], s, s)
  
  currentScene = TextScene()
  
--- 86,105 ----
  
      
        y = 20
        for s in sizes:
            y += s
!           cs = vs.coords.coordsys(0, 0, 500 + self.offset[0][0], y + 
self.offset[0][1], s, s)
!           vs.matcher.add(cs, "B"+str(s))
!           vs.map.put(getDListNocoords("""
!               Disable TEXTURE_2D
!           """))
!           vs.map.put(cq, cs)
!           vs.map.put(getDListNocoords("""
!               Color 0 0 0
!               Enable TEXTURE_2D
!           """))
!           vs.map.put(self.textvobs[0], cs)
!           # print "T: ",cs
  
  currentScene = TextScene()
  
Index: gzz/gfx/libtext/Text.cxx
diff -c gzz/gfx/libtext/Text.cxx:1.6 gzz/gfx/libtext/Text.cxx:1.7
*** gzz/gfx/libtext/Text.cxx:1.6        Mon Oct  7 13:47:55 2002
--- gzz/gfx/libtext/Text.cxx    Tue Oct  8 03:30:12 2002
***************
*** 32,37 ****
--- 32,40 ----
                gotError(error);
  
        if((error = FT_Set_Pixel_Sizes(face, 0, pixsize))) gotError(error);
+ 
+       // scale line height to unity
+       this->scale = 1.0 / (face->size->metrics.height >> 6);
      }
  
      FTFont::~FTFont() {
***************
*** 46,58 ****
        FT_GlyphSlot slot = face->glyph;
        FT_Bitmap *bitmap = &(slot->bitmap);
  
!       float ps = this->pixsize;
  
        return Glyph(GlyphInfo(
!                   -slot->bitmap_top / ps, slot->bitmap_left / ps, 
!                           bitmap->width / ps, bitmap->rows / ps,
!                           (slot->advance.x >> 6) / ps,
!                           1/ps,
                            bitmap->width, bitmap->rows
                            ),
                Raster<Mosaic::Format::Alpha>(bitmap->width, bitmap->rows, 
--- 49,61 ----
        FT_GlyphSlot slot = face->glyph;
        FT_Bitmap *bitmap = &(slot->bitmap);
  
!       float ps = this->scale;
  
        return Glyph(GlyphInfo(
!                   -slot->bitmap_top * ps, slot->bitmap_left * ps, 
!                           bitmap->width * ps, bitmap->rows * ps,
!                           (slot->advance.x >> 6) * ps,
!                           scale,
                            bitmap->width, bitmap->rows
                            ),
                Raster<Mosaic::Format::Alpha>(bitmap->width, bitmap->rows, 
***************
*** 62,72 ****
        
      }
  
!     int FTFont::getLineHeight() {
!       return (face->size->metrics.height >> 6) / (float)pixsize;
      }
!     int FTFont::getLineOffset() {
!       return (face->size->metrics.ascender >> 6) / (float)pixsize;
      }
  
  
--- 65,75 ----
        
      }
  
!     float FTFont::getLineHeight() {
!       return (face->size->metrics.height >> 6) * scale;
      }
!     float FTFont::getLineOffset() {
!       return (face->size->metrics.ascender >> 6) * scale;
      }
  
  
Index: gzz/gfx/libtext/Text.hxx
diff -c gzz/gfx/libtext/Text.hxx:1.10 gzz/gfx/libtext/Text.hxx:1.11
*** gzz/gfx/libtext/Text.hxx:1.10       Sun Oct  6 13:37:46 2002
--- gzz/gfx/libtext/Text.hxx    Tue Oct  8 03:30:12 2002
***************
*** 108,118 ****
        /** Get the number of pixels each line should 
         * be below the previous one.
         */
!       virtual int getLineHeight() = 0;
        /** Get the y coordinate where the first line
         * should be rendered.
         */
!       virtual int getLineOffset() = 0;
      };
  
      /** A freetype font.
--- 108,118 ----
        /** Get the number of pixels each line should 
         * be below the previous one.
         */
!       virtual float getLineHeight() = 0;
        /** Get the y coordinate where the first line
         * should be rendered.
         */
!       virtual float getLineOffset() = 0;
      };
  
      /** A freetype font.
***************
*** 120,125 ****
--- 120,126 ----
      class FTFont : public Font {
            FT_Face face;
            int pixsize;
+           float scale; // The scale of all metrics.
        public:
            /** Create from file.
             * @param pixsize The pixel (texel) size to load the font at
***************
*** 127,134 ****
            FTFont(string filename, int pixsize) ;
            ~FTFont();
            virtual Glyph getRaster(int unicode);
!           virtual int getLineHeight();
!           virtual int getLineOffset();
            class Error { } ;
      };
  
--- 128,135 ----
            FTFont(string filename, int pixsize) ;
            ~FTFont();
            virtual Glyph getRaster(int unicode);
!           virtual float getLineHeight();
!           virtual float getLineOffset();
            class Error { } ;
      };
  
***************
*** 152,161 ****
                Glyph g = f->getRaster(unicode);
                return g.withBorder(bwidth);
            }
!           virtual int getLineHeight() {
                return f->getLineHeight();
            }
!           virtual int getLineOffset() {
                return f->getLineOffset();
            }
            
--- 153,162 ----
                Glyph g = f->getRaster(unicode);
                return g.withBorder(bwidth);
            }
!           virtual float getLineHeight() {
                return f->getLineHeight();
            }
!           virtual float getLineOffset() {
                return f->getLineOffset();
            }
            
Index: gzz/gzz/vob/TextVob.java
diff -c gzz/gzz/vob/TextVob.java:1.37 gzz/gzz/vob/TextVob.java:1.38
*** gzz/gzz/vob/TextVob.java:1.37       Mon Oct  7 13:47:55 2002
--- gzz/gzz/vob/TextVob.java    Tue Oct  8 03:30:12 2002
***************
*** 1,7 ****
  /*
  TextVob.java
   *    
!  *    Copyright (c) 2001, Ted Nelson and Tuomas Lukka
   *
   *    You may use and distribute under the terms of either the GNU Lesser
   *    General Public License, either version 2 of the license or,
--- 1,7 ----
  /*
  TextVob.java
   *    
!  *    Copyright (c) 2001-2002, Ted Nelson and Tuomas Lukka
   *
   *    You may use and distribute under the terms of either the GNU Lesser
   *    General Public License, either version 2 of the license or,
***************
*** 31,63 ****
   * from these and use a LineBreaker.
   */
  public class TextVob extends HBox.VobHBox {
! String rcsid = "$Id: TextVob.java,v 1.37 2002/10/07 17:47:55 tjl Exp $";
      public static boolean dbg = false;
      private static void pa(String s) { System.err.println(s); }
  
      protected final TextStyle style;
      protected final String text;
!     /** The scale this Vob's TextStyle should be used.
!      * XXX Performance?
!      */
!     protected float scale;
!     
      protected Object key;
  
!     public TextVob(TextStyle style, String text) {
        super();
        this.style = style;
        this.text = text;
-         this.scale = 1;
-     }
- 
-     public TextVob(TextStyle style, float scale, String text) {
-         this(style, text);
-         this.scale = scale;
      }
  
!     public TextVob(TextStyle style, float scale, String text, Object key) {
!         this(style, scale, text);
        this.key = key;
      }
  
--- 31,55 ----
   * from these and use a LineBreaker.
   */
  public class TextVob extends HBox.VobHBox {
! String rcsid = "$Id: TextVob.java,v 1.38 2002/10/08 07:30:12 tjl Exp $";
      public static boolean dbg = false;
      private static void pa(String s) { System.err.println(s); }
  
      protected final TextStyle style;
      protected final String text;
!     protected final boolean baselined;
! 
      protected Object key;
  
!     public TextVob(TextStyle style, String text, boolean baselined) {
        super();
        this.style = style;
+       this.baselined = baselined;
        this.text = text;
      }
  
!     public TextVob(TextStyle style, String text, boolean baselined, Object 
key) {
!         this(style, text, baselined);
        this.key = key;
      }
  
***************
*** 78,83 ****
--- 70,76 ----
                       boolean fast,
                       RenderInfo info1,
                       RenderInfo info2) {
+       // XXX Needs adjusting to baselined!
          g.setColor(info1.getMixedFgColor());
        //info1.getClipRect(rect);
  
***************
*** 91,99 ****
                        rect.width,
                      rect.height + 3);*/
  
!       float scale = this.scale;
!       if(scale < 0)
!           scale = style.getScaleByHeight(h-3);
          if(dbg) pa("Render @ scale " + scale + ": '"+text+"' "+x+" "+y+" 
"+w+" "+h);
  
        float fasc = style.getAscent(scale);
--- 84,90 ----
                        rect.width,
                      rect.height + 3);*/
  
!       float scale = style.getScaleByHeight(h-3);
          if(dbg) pa("Render @ scale " + scale + ": '"+text+"' "+x+" "+y+" 
"+w+" "+h);
  
        float fasc = style.getAscent(scale);
***************
*** 140,156 ****
  
      /** The OpenGL renderable for this TextVob.
       */
!     private GLRen.HorizText2 ht;
      public int addToListGL(GraphicsAPI.Window win,
                        int[] list, int curs, int coordsys1,
                                int coordsys2) {
        if(dbg) pa("Addtolistgl text "+text);
        if(ht == null) {
            GLTextStyle gls = (GLTextStyle)style;
!           ht = GLRen.createHorizText2(
                    gls.theFont,
!                   text, gls.theFont.getHeight(), gls.theFont.getYOffs(),
!                   scale * gls.fontScale, 0);
        }
        curs = getStartCode().addToListGL(win, list, curs, 0, 0);
        curs = ht.addToListGL(win, list, curs, coordsys1, coordsys2);
--- 131,150 ----
  
      /** The OpenGL renderable for this TextVob.
       */
!     private Vob ht;
      public int addToListGL(GraphicsAPI.Window win,
                        int[] list, int curs, int coordsys1,
                                int coordsys2) {
        if(dbg) pa("Addtolistgl text "+text);
        if(ht == null) {
            GLTextStyle gls = (GLTextStyle)style;
!           ht = GLRen.createHorizText(
                    gls.theFont,
!                   text, 
!                   0,
!                   (baselined ? 1 : gls.theFont.getYOffs()),
!                   0,
!                   1, 1);
        }
        curs = getStartCode().addToListGL(win, list, curs, 0, 0);
        curs = ht.addToListGL(win, list, curs, coordsys1, coordsys2);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]