Exemplo n.º 1
0
def ttt_segments(text):
    wr = ttt.SEG_Writer()
    wr.arc = False  # approximate arcs with lines
    wr.conic = False  # approximate conic with arc/line
    wr.cubic = False  # approximate cubic with arc/line
    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = 50  # =10 increasesn nr of points to 366, = 5 gives 729 pts
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    wr.scale = 1

    wr.setFont(3)
    # 0  freeserif
    # 1  freeserif bold
    # 2  freeserif italic
    # 3  freeserif bold italic
    # 4  "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf" );
    # 5  "/usr/share/fonts/truetype/freefont/FreeMonoBoldOblique.ttf" );
    # 6  "/usr/share/fonts/truetype/freefont/FreeMonoOblique.ttf" )
    # 7  "/usr/share/fonts/truetype/freefont/FreeSans.ttf" );
    # 8  "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf" );
    # 9  "/usr/share/fonts/truetype/freefont/FreeSansBoldOblique.ttf" );
    # 10 "/usr/share/fonts/truetype/freefont/FreeSansOblique.ttf" );

    ttt.ttt(text, wr)
    segs = wr.get_segments()
    ext = wr.extents
    return [ext, segs]
def ttt_segments(text, scale):
    wr = ttt.SEG_Writer()

    # wr.scale = 3
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = 25  # this increases nr of points
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    wr.scale = float(1) / float(scale)
    wr.set_font(3)
    # 0 OK   freeserif
    # 1 OK   freeserif bold
    # 2 err  freeserif italic   (has "VX" overlap!)
    # 3 OK   freeserif bold italic
    # 4  OK  fonts.push_back( "/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf" );
    # 5  err fonts.push_back( "/usr/share/fonts/truetype/freefont/FreeMonoBoldOblique.ttf" );  PPPSolver error?
    # 6  err fonts.push_back( "/usr/share/fonts/truetype/freefont/FreeMonoOblique.ttf" ) error?
    # 7  OK  fonts.push_back( "/usr/share/fonts/truetype/freefont/FreeSans.ttf" );
    # 8  err fonts.push_back( "/usr/share/fonts/truetype/freefont/FreeSansBold.ttf" );
    # 9  err fonts.push_back( "/usr/share/fonts/truetype/freefont/FreeSansBoldOblique.ttf" );
    # 10 err fonts.push_back( "/usr/share/fonts/truetype/freefont/FreeSansOblique.ttf" );
    s3 = ttt.ttt(text, wr)
    segs = wr.get_segments()
    return segs
def ttt_segments(text, scale, subdivision=100):
    """ get geometry from truetypetracer
    """
    wr = ttt.SEG_Writer()

    # wr.scale = 3
    # wr.arc = False
    # wr.conic = False
    # wr.cubic = False
    wr.scale = scale  # float(1)/float(scale)
    # "L" has 36 points by default
    # wr.conic_biarc_subdivision = 10 # this has no effect?
    wr.conic_line_subdivision = subdivision  # =10 increases nr of points to 366, = 5 gives 729 pts

    # "C"  subd  points
    #       50   248
    #       40   311
    #       30   416
    #       20   627

    # wr.cubic_biarc_subdivision = 10 # no effect?
    # wr.cubic_line_subdivision = 10 # no effect?
    # wr.setFont(0)
    # wr.setFontbyPath("/usr/share/fonts/truetype/freefont/FreeSerif.ttf")
    s3 = ttt.ttt(text, wr)
    exts = wr.extents
    # print exts
    segs = wr.get_segments()
    return (segs, exts)
Exemplo n.º 4
0
def draw_ttt(myscreen, text, x, y, scale):
    wr = ttt.SEG_Writer()
    # wr.arc = False
    wr.arc = True
    # wr.conic = False
    # wr.cubic = False
    wr.scale = float(1) / float(scale)
    # "L" has 36 points by default
    wr.conic_biarc_subdivision = 200
    wr.conic_line_subdivision = 50  # this increasesn nr of points to 366
    # wr.cubic_biarc_subdivision = 10 # no effect?
    # wr.cubic_line_subdivision = 10 # no effect?
    wr.setFont(0)
    s3 = ttt.ttt(text, wr)
    ext = wr.extents
    dx = ext.maxx - ext.minx

    segs = wr.get_segments()
    segs = translate(segs, x, y)
    print "number of polygons: ", len(segs)
    np = 0
    sum_pts = 0

    segs = modify_segments(segs)
    for s in segs:
        sum_pts += len(s)
        print " polygon ", np, " has ", len(s), " points"
        np = np + 1
    print "total points: ", sum_pts
    drawLoops(myscreen, segs, ovdvtk.yellow)
def ttt_segments(text, scale, subdivision=100):
    wr = ttt.SEG_Writer()

    # wr.scale = 3
    #wr.arc = False
    #wr.conic = False
    #wr.cubic = False
    wr.scale = scale  #float(1)/float(scale)
    # "L" has 36 points by default
    #wr.conic_biarc_subdivision = 10 # this has no effect?
    wr.conic_line_subdivision = subdivision  # =10 increasesn nr of points to 366, = 5 gives 729 pts

    # "C"  subd  points
    #       50   248
    #       40   311
    #       30   416
    #       20   627

    #wr.cubic_biarc_subdivision = 10 # no effect?
    #wr.cubic_line_subdivision = 10 # no effect?
    #wr.setFont(0)
    s3 = ttt.ttt(text, wr)
    exts = wr.extents
    #print exts
    segs = wr.get_segments()
    return (segs, exts)
Exemplo n.º 6
0
def draw_ttt(myscreen, text, x, y, scale):
    wr = ttt.SEG_Writer()
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.scale = float(1) / float(scale)
    # "L" has 36 points by default
    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = 10  # this increasesn nr of points to 366
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    wr.set_font(2)
    s3 = ttt.ttt(text, wr)
    ext = wr.extents
    dx = ext.maxx - ext.minx

    segs = wr.get_segments()
    segs = translate(segs, x, y)
    print("number of polygons: %s" % len(segs))
    np = 0
    for s in segs:
        print(" polygon %s has %s points" % (np, len(s)))
        np = np + 1
    segs = modify_segments(segs)
    drawLoops(myscreen, segs, ovdvtk.yellow)
Exemplo n.º 7
0
def ttt_segments(text, scale):
    wr = ttt.SEG_Writer()
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.scale = float(1) / float(scale)
    ttt.ttt(text, wr)
    segs = wr.get_segments()
    return segs
Exemplo n.º 8
0
def ttt_segments(text, scale):
    wr = ttt.SEG_Writer()
    wr.arc = False
    wr.conic = False
    wr.cubic = False

    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = 50  # this increases nr of points
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    wr.setFont(3)

    wr.scale = float(1) / float(scale)
    ttt.ttt(text, wr)
    segs = wr.get_segments()
    return segs
Exemplo n.º 9
0
def ttt_segments(text, scale):
    wr = ttt.SEG_Writer()

    # wr.scale = 3
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    wr.scale = float(1) / float(scale)
    # "L" has 36 points by default
    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = 50  # =10 increasesn nr of points to 366, = 5 gives 729 pts
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    s3 = ttt.ttt(text, wr)
    segs = wr.get_segments()
    return segs
Exemplo n.º 10
0
def test_seg_writer():
    #wr = ttt.NGC_Writer()
    wr = ttt.SEG_Writer()

    # wr.scale = 1
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    s3 = ttt.ttt("LT", wr)
    print(s3)
    s = wr.get_segments()
    print(s)
    e = wr.extents
    print("number of segments %s" % len(s))
    print(e)
    print("extents max x %s" % e.maxx)
    print("extents min x %s" % e.minx)
    print("extents max y %s" % e.maxy)
    print("extents min y %s" % e.miny)
Exemplo n.º 11
0
def test_basic():
    t = ttt.ngc("a")
    print(t)

    s = ttt.dxf()
    print(s)
    s2 = ttt.dxf("a")
    f = open('test.dxf', 'w')
    f.write(s2)

    wr = ttt.NGC_Writer()
    s3 = ttt.ttt("a", wr)
    print(s3)

    wr = ttt.SEG_Writer()

    # wr.scale = 1
    wr.arc = False
    wr.conic = False
    wr.cubic = False
    s3 = ttt.ttt("LT", wr)
    print(s3)
Exemplo n.º 12
0
def ttt_geometry(text_string="TEST", text_scale=1, subdiv=10):
    """ get geometry from truetypetracer
    """
    wr = ttt.SEG_Writer()
    wr.scale = text_scale
    wr.arc = False
    wr.conic = False
    wr.cubic = False

    wr.conic_biarc_subdivision = 10  # this has no effect?
    wr.conic_line_subdivision = subdiv  # this increasesn nr of points to 366
    wr.cubic_biarc_subdivision = 10  # no effect?
    wr.cubic_line_subdivision = 10  # no effect?
    #wr.setFont(2)

    s3 = ttt.ttt(text_string, wr)
    print(s3)
    segments = wr.get_segments()
    # format is
    # (x, y, r, cw(bool), cx, cy)
    #e = wr.extents
    print("number of loops %s" % len(segments))
    return segments
Exemplo n.º 13
0
import truetypetracer as ttt

t = ttt.ngc("a")
print t

s = ttt.dxf()
print s
s2 = ttt.dxf("a")
f = open('test.dxf', 'w')
f.write(s2)

wr = ttt.NGC_Writer()
s3 = ttt.ttt("a",wr)
print s3


wr = ttt.SEG_Writer()

# wr.scale = 1
wr.arc = False
wr.conic = False
wr.cubic = False
s3 = ttt.ttt("LT",wr)
print s3