L i^."ddlmZddlmZmZmZmZmZddlmZm Z ddl m Z ddl m Z ddlmZddlmZmZddlmZmZdd lmZdd lmZmZdd lmZdd lmZdd lmZddlmZddlZddgZ GddZ!Gdde!eZ"Gdde!e e Z#y))array)AnyCallableDictOptionalTuple) MAX_F2DOT14floatToFixedToFloat)LogMixin)AbstractPointPenotRound) LoggingPenPenError) TransformPenTransformPointPen) ttProgram) flagOnCurve flagCubic)Glyph)GlyphComponent)GlyphCoordinates)dropImpliedOnCurvePointsN TTGlyphPenTTGlyphPointPenc eZdZ ddeeeefdeddfdZdede e e e e e e ffdZ d Z dd Z dd ede e e e e e e fd eed eddf dZdZ deddededee gefdefdZy)_TTGlyphBasePenglyphSethandleOverflowingTransformsreturnNc@||_||_|jy)a Construct a new pen. Args: glyphSet (Dict[str, Any]): A glyphset object, used to resolve components. handleOverflowingTransforms (bool): See below. If ``handleOverflowingTransforms`` is True, the components' transform values are checked that they don't overflow the limits of a F2Dot14 number: -2.0 <= v < +2.0. If any transform value exceeds these, the composite glyph is decomposed. An exception to this rule is done for values that are very close to +2.0 (both for consistency with the -2.0 case, and for the relative frequency these occur in real fonts). When almost +2.0 values occur (and all other values are within the range -2.0 <= x <= +2.0), they are clamped to the maximum positive value that can still be encoded as an F2Dot14: i.e. 1.99993896484375. If False, no check is done and all components are translated unmodified into the glyf table, followed by an inevitable ``struct.error`` once an attempt is made to compile them. If both contours and components are present in a glyph, the components are decomposed. N)rrinit)selfrrs _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fontTools/pens/ttGlyphPen.py__init__z_TTGlyphBasePen.__init__s>! +F( glyphNametransformationcz|j||}t|j||j|yN) transformPengetattrr drawMethod)r#r'r(tpens r$ _decomposez_TTGlyphBasePen._decompose9s4   ~6: i($//:4@r&ct)z6 Check if the current path is closed. )NotImplementedErrorr#s r$ _isClosedz_TTGlyphBasePen._isClosedAs "!r&c<g|_g|_g|_g|_yr*)pointsendPtstypes componentsr2s r$r"z_TTGlyphBasePen.initGs   r& baseGlyphName identifierkwargsc >|jj||fy)z" Add a sub glyph. N)r8append)r#r9r(r:r;s r$ addComponentz_TTGlyphBasePen.addComponentMs  ~>?r&cn|jrtd|jD}g}|jD]\}}||jvr |jj d|d4|j s|jrr|j||at}||_ d|ddD\|_ |_ td|ddD}|dk7r?|jr$td|Drtd |D}|dd |d df|_ ||_|j||S) Nc3NK|]\}}|ddD]}|dkDxs|dkyw)N).0r'r(ss r$ z3_TTGlyphBasePen._buildComponents..]sF/Y'+ARs#%z skipped non-existing component ''c32K|]}t|ywr*r rEvs r$rGz3_TTGlyphBasePen._buildComponents..ns'Oq 'OsrAc34K|]}t|dyw)N)r rJs r$rGz3_TTGlyphBasePen._buildComponents..qs#/0#Ar*#s)rrrNc3DK|]}t|cxkxrdkncywrBNr rErFs r$rGz3_TTGlyphBasePen._buildComponents..us"<-.K!(q((<s c3PK|]}t|cxkrdkr nntn| ywrPrQrRs r$rGz3_TTGlyphBasePen._buildComponents..ys)+(3Q';!'; B+s$&rB)ranyr8rlogwarningr5r/rr'xytuple transformflagsr=)r#componentFlags overflowingr8r'r( components r$_buildComponentsz _TTGlyphBasePen._buildComponentsYsX  + +37??K  )- ) %I~ -  #CI;a!PQ{{t??K >:&(I"+I 'ON12!";M&N #,IO   i (9 ):r&roundr\dropImpliedOnCurvesrac0|js td|j|}t}t |j |_|j|_td|j|_ |j|r||_ d|_|St|j|_t!j"|_|j$j'd|r t)||j j+||S)a Returns a :py:class:`~._g_l_y_f.Glyph` object representing the glyph. Args: componentFlags: Flags to use for component glyphs. (default: 0x04) dropImpliedOnCurves: Whether to remove implied-oncurve points. (default: False) zDidn't close last contour.Br&r`)r3rr_rrr5 coordinatesr6endPtsOfContoursrr7r[r"r8numberOfContourslenrProgramprogram fromBytecodertoInt)r#r\rbrar8glyphs r$rnz_TTGlyphBasePen.glyphs~~78 8**>: ,T[[9!%C,   *E %'E " &))?)?%@E "%--/EM MM & &s +"(/    # #% # 0 r&)Tr Nr*)rAF)__name__ __module__ __qualname__rrstrrboolr%rfloatr/r3r"r>r_rintrrrnrDr&r$rrs-1!4S>*!&*!  !FAAeUE5%FGA" %) @ @eUE5%FG @SM @  @  @'V#$)& )0 &&"&  % &  &r&rc eZdZdZdZeZ ddeee e fde de ddffd Z d e eefd eddfd Zdd Zde fd Zd e eefddfdZd e eefddfdZddZddZddZddZxZS)ra Pen used for drawing to a TrueType glyph. This pen can be used to construct or modify glyphs in a TrueType format font. After using the pen to draw, use the ``.glyph()`` method to retrieve a :py:class:`~._g_l_y_f.Glyph` object representing the glyph. drawNrroutputImpliedClosingLiner c4t|||||_yr*)superr%ry)r#rrry __class__s r$r%zTTGlyphPen.__init__s #>?(@%r&pttpcp|jj||jj|yr*)r5r=r7)r#r}r~s r$ _addPointzTTGlyphPen._addPoints& 2 "r&cl|jj|jjyr*)r5popr7r2s r$ _popPointzTTGlyphPen._popPoints  r&c|j xs6|jxr(|jdt|jdz k(S)NrerN)r5r6rir2s r$r3zTTGlyphPen._isCloseds<KK KK CDKKOs4;;/?!/CC r&c0|j|tyr*)rrr#r}s r$lineTozTTGlyphPen.lineTos r;'r&cf|js td|j|ty)Nz+"move"-type point must begin a new contour.)r3rrrrs r$moveTozTTGlyphPen.moveTos&~~HI I r;'r&ct|dzdk(sJ|ddD]}|j|t|d|j|ddyy)NrBrNre)rirrr#r5r}s r$curveTozTTGlyphPen.curveTos^6{Q!###"+ *B NN2y ) * ": ! NN6":q ) "r&ct|dk\sJ|ddD]}|j|d|d|j|ddyy)NrNrer)rirrs r$qCurveTozTTGlyphPen.qCurveTosZ6{a"+ "B NN2q ! " ": ! NN6":q ) "r&ct|jdz }|dk(s!|jr&||jddzk(r|jy|jsTd}|jr|jddz}|j||j|k(r|j|dz}|jj |y)NrNrre)rir5r6rryr=)r#endPtstartPts r$ closePathzTTGlyphPen.closePathsDKK 1$ A:$++%4;;r?Q3F*F NN  ,,G{{++b/A-{{7#t{{5'99   5!r&c$|jyr*)rr2s r$endPathzTTGlyphPen.endPaths  r&)NTFro)rprqrr__doc__r-rr+rrrsrrtr%rrurvrrr3rrrrrr __classcell__r|s@r$rrsJL.2,0). A4S>*A&*A#' A  AE%,/ST 4 (ue|,(((ue|,(( **"&r&ceZdZdZdZeZdfd ZdefdZ dde e de ddfd Z dd Z dd eeefd e e d ede e de e de ddfdZxZS)ra Point pen used for drawing to a TrueType glyph. This pen can be used to construct or modify glyphs in a TrueType format font. After using the pen to draw, use the ``.glyph()`` method to retrieve a :py:class:`~._g_l_y_f.Glyph` object representing the glyph. drawPointsr Nc0t|d|_yr*)r{r"_currentContourStartIndex)r#r|s r$r"zTTGlyphPointPen.init s  )-&r&c|jduSr*)rr2s r$r3zTTGlyphPointPen._isCloseds--55r&r:r;c n|js tdt|j|_y)z' Start a new sub path. zDidn't close previous contour.N)r3rrir5r)r#r:r;s r$ beginPathzTTGlyphPointPen.beginPaths+~~;< <),T[[)9&r&c|jr td|jt|jk(rd|_y|j r|j ddznd}|j j t|jdz d|_|j}t|t|D]K}||dk(s |dz }||krt|dz }||dk(rt||<|dz}||dk(rt||<My)z+ End the current sub path. zContour is already closed.NrerNrcurve) r3rrrir5r6r=r7rangerr)r# contourStartr[ijs r$rzTTGlyphPointPen.endPaths >> 78 8  ) )S-= =-1D * .2kkt{{2*q  3t{{+a/0)-& |SZ0 'AQx7"E|#E QAAh!m(E!HFAAh!m'a 'r&r} segmentTypesmoothnamec |jr td||jjdnu|dvr |jjtnQ|dk(r |jjtn,|dk(r|jjdn t ||j j|y)z6 Add a point to the current sub path. z&Can't add a point to a closed contour.Nr)linemoveqcurver)r3rr7r=rAssertionErrorr5)r#r}rrrr:r;s r$addPointzTTGlyphPointPen.addPoint6s >> CD D   JJ  a , , JJ  k * H $ JJ  k * G # JJ  g & - - 2r&ror*)NFNN)rprqrrrr-rr+r"rtr3rrsrrrrrurrrs@r$rrsJ$L.646:HSM:C:D:'>&*"$(  %, c]  sm  SM  r&)$rtypingrrrrrfontTools.misc.fixedToolsr r fontTools.misc.loggingToolsr fontTools.pens.pointPenr fontTools.misc.roundToolsrfontTools.pens.basePenrrfontTools.pens.transformPenrrfontTools.ttLib.tablesrfontTools.ttLib.tables._g_l_y_frrrrrrmath__all__rrrrDr&r$rss77F04-7G,B1:<D  * +SSlQ*QhPox1APr&